From 2e78f23e692246f94ae7d6943d6cb1e3d760a15d Mon Sep 17 00:00:00 2001 From: ThierryA Date: Wed, 12 Oct 2016 09:15:20 +0200 Subject: [PATCH 001/800] Fixed PHPDoc incorrect external link to UIkit website. --- lib/api/uikit/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index e0bd6dda..34709f87 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -16,7 +16,7 @@ * Enqueue UIkit components. * * Enqueued components will be compiled into a single file. Refer to - * {@link http://http://getuikit.com/ UIkit} to learn more about the available components. + * {@link http://getuikit.com/ UIkit} to learn more about the available components. * * When development mode is enabled, files changes will automatically be detected. This makes it very easy * to style UIkit themes using LESS. @@ -60,7 +60,7 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload * Dequeue UIkit components. * * Dequeued components are removed from the UIkit compiler. Refer to - * {@link http://http://getuikit.com/ UIkit} to learn more about the available components. + * {@link http://getuikit.com/ UIkit} to learn more about the available components. * * When development mode is enabled, files changes will automatically be detected. This makes it very easy * to style UIkit themes using LESS. From 9fe9f8271404e566d0b5250080714538423a0cb7 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Fri, 14 Oct 2016 15:09:58 +0200 Subject: [PATCH 002/800] Fixed `beans_get_post_meta()` PHPDoc incorrect argument name. --- lib/api/post-meta/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index 94844374..992be0dd 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -12,7 +12,7 @@ * * @param string $field_id The post meta id searched. * @param mixed $default Optional. The default value to return of the post meta value doesn't exist. - * @param int $term_id Optional. Overwrite the current post id. + * @param int $post_id Optional. Overwrite the current post id. * * @return mixed Saved data if exist, otherwise default value set. */ From ea1ad46bb3b47568225239fd893380e6b76bf929 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Wed, 23 Nov 2016 08:16:09 +0100 Subject: [PATCH 003/800] Improved code indentation. --- lib/admin/wp-customize.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index c4f8ef97..998d1afb 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -27,9 +27,9 @@ function beans_do_register_wp_customize_options() { $fields = array( array( - 'id' => 'beans_logo_image', - 'label' => __( 'Logo Image', 'tm-beans' ), - 'type' => 'WP_Customize_Image_Control', + 'id' => 'beans_logo_image', + 'label' => __( 'Logo Image', 'tm-beans' ), + 'type' => 'WP_Customize_Image_Control', ), ); From 1efe68b6246f906dc4d75cb00d103f8842164ef1 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Thu, 1 Dec 2016 07:46:24 +0200 Subject: [PATCH 004/800] Added GPL license file. --- license.txt | 703 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 703 insertions(+) create mode 100644 license.txt diff --git a/license.txt b/license.txt new file mode 100644 index 00000000..08f48fa6 --- /dev/null +++ b/license.txt @@ -0,0 +1,703 @@ +Beans - Theme Framework for WordPress + +Copyright 2016 by the contributors + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +This program incorporates work covered by the following copyright and +permission notices: + + Beans - Theme Framework for WordPress + + Beans is Copyright (c) 2016 BeansPress + + Beans is released under the GPL + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright © 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright © + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright © + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file From 1c2771df9ab55fea3a6490899fe1af92028bab72 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Mon, 2 Jan 2017 14:14:18 +0100 Subject: [PATCH 005/800] Fixed PHP 7 warning due to dynamic global access. --- lib/api/compiler/class-page-compiler.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/api/compiler/class-page-compiler.php b/lib/api/compiler/class-page-compiler.php index f0bec5b7..dcda160e 100644 --- a/lib/api/compiler/class-page-compiler.php +++ b/lib/api/compiler/class-page-compiler.php @@ -65,17 +65,16 @@ public function compile_page_scripts() { */ private function compile_enqueued( $type, $depedencies = false ) { - $set_global = 'wp_' . $type . 's'; - $set_dequeued_global = 'beans_dequeue_' . $type . 's'; - - global $$set_global; + if ( ! $assets = beans_get( "wp_{$type}s", $GLOBALS ) ) { + return array(); + } if ( 'script' == $type ) { add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 ); } if ( ! $depedencies ) { - $depedencies = $$set_global->queue; + $depedencies = $assets->queue; } $fragments = array(); @@ -87,7 +86,7 @@ private function compile_enqueued( $type, $depedencies = false ) { continue; } - if ( ! $args = beans_get( $id, $$set_global->registered ) ) { + if ( ! $args = beans_get( $id, $assets->registered ) ) { continue; } @@ -108,7 +107,7 @@ private function compile_enqueued( $type, $depedencies = false ) { $args->src = add_query_arg( array( 'beans_compiler_media_query' => $args->args ), $args->src ); } - $$set_global->done[] = $id; + $assets->done[] = $id; } elseif ( 'script' == $type ) { From fc9b074651b1904fd1e74c192bcda718f360f076 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Fri, 13 Jan 2017 09:12:10 +0100 Subject: [PATCH 006/800] Updated UIkit reference to UIkit 2 --- lib/api/uikit/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index 34709f87..888c7da0 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -1,6 +1,6 @@ Date: Thu, 26 Jan 2017 07:27:14 +0100 Subject: [PATCH 007/800] Fixed trailing characters leftover. --- lib/api/term-meta/class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/term-meta/class.php b/lib/api/term-meta/class.php index 5a4ac86e..88c62575 100644 --- a/lib/api/term-meta/class.php +++ b/lib/api/term-meta/class.php @@ -69,7 +69,7 @@ public function fields( $tag ) { foreach ( beans_get_fields( 'term_meta', $this->section ) as $field ) { ?> - '; + From 113be501ee2ffe3e175a10ff42752f82e7b22e53 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Thu, 2 Mar 2017 10:37:48 +0100 Subject: [PATCH 008/800] Fixed legacy <5.3 PHP fatal error. --- lib/api/html/functions.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 723803d4..cc53e94f 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -62,7 +62,9 @@ function beans_output( $id, $output ) { */ function beans_output_e( $id, $output ) { - echo call_user_func_array( 'beans_output', func_get_args() ); + $args = func_get_args(); + + echo call_user_func_array( 'beans_output', $args ); } @@ -185,7 +187,9 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { */ function beans_open_markup_e( $id, $tag, $attributes = array() ) { - echo call_user_func_array( 'beans_open_markup', func_get_args() ); + $args = func_get_args(); + + echo call_user_func_array( 'beans_open_markup', $args ); } @@ -244,7 +248,9 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { */ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { - echo call_user_func_array( 'beans_selfclose_markup', func_get_args() ); + $args = func_get_args(); + + echo call_user_func_array( 'beans_selfclose_markup', $args ); } @@ -307,7 +313,9 @@ function beans_close_markup( $id, $tag ) { */ function beans_close_markup_e( $id, $tag ) { - echo call_user_func_array( 'beans_close_markup', func_get_args() ); + $args = func_get_args(); + + echo call_user_func_array( 'beans_close_markup', $args ); } From 127fd580013015d81e863bc05bc1b1584f3c15b4 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Thu, 18 May 2017 09:40:09 +0200 Subject: [PATCH 009/800] Fixed previous link "rel" attribute typography mistake. --- lib/templates/fragments/post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 7b6ff5f5..02cbf5d4 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -385,7 +385,7 @@ function beans_previous_post_link( $output, $format, $link, $post ) { $output = beans_open_markup( 'beans_previous_link[_post_navigation]', 'a', array( 'href' => get_permalink( $post ), // Automatically escaped. - 'ref' => 'previous', + 'rel' => 'previous', 'title' => $post->post_title, // Automatically escaped. ) ); From 2b315558dc4a63302f39e5ae39ddbdf7f1c5ca5c Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sun, 12 Nov 2017 16:59:52 -0700 Subject: [PATCH 010/800] Initial PHPCS setup (#58) * Add composer.json * Add initial PHPCS config * Requested PR amendments --- .gitignore | 2 + composer.json | 32 +++ composer.lock | 518 +++++++++++++++++++++++++++++++++++++++++++++++++ phpcs.xml.dist | 61 ++++++ 4 files changed, 613 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 phpcs.xml.dist diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1733a33c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/node_modules/ +/vendor/ diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..fd965c8e --- /dev/null +++ b/composer.json @@ -0,0 +1,32 @@ +{ + "name": "beans/beans", + "description": "The most innovative theme for WordPress. The real magic is under the hood.", + "type": "wordpress-theme", + "license": "GPL-2.0+", + "homepage": "http://www.getbeans.io/", + "support": { + "issues": "https://github.com/GetBeans/Beans/issues", + "source": "https://github.com/GetBeans/Beans" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": "^5.2|^7", + "composer/installers": "^1.4", + "roave/security-advisories": "dev-master" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4", + "sirbrillig/phpcs-variable-analysis": "^2.0", + "wimg/php-compatibility": "^8.0", + "wp-coding-standards/wpcs": "^0.14.0" + }, + "config": { + "sort-order": true + }, + "scripts": { + "install-codestandards": [ + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run" + ] + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..32b4d017 --- /dev/null +++ b/composer.lock @@ -0,0 +1,518 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "f7cf443a0f40789221cf4cdd8e2672ea", + "packages": [ + { + "name": "composer/installers", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b", + "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "replace": { + "roundcube/plugin-installer": "*", + "shama/baton": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "4.1.*" + }, + "type": "composer-plugin", + "extra": { + "class": "Composer\\Installers\\Plugin", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Installers\\": "src/Composer/Installers" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "https://composer.github.io/installers/", + "keywords": [ + "Craft", + "Dolibarr", + "Eliasis", + "Hurad", + "ImageCMS", + "Kanboard", + "Lan Management System", + "MODX Evo", + "Mautic", + "Maya", + "OXID", + "Plentymarkets", + "Porto", + "RadPHP", + "SMF", + "Thelia", + "WolfCMS", + "agl", + "aimeos", + "annotatecms", + "attogram", + "bitrix", + "cakephp", + "chef", + "cockpit", + "codeigniter", + "concrete5", + "croogo", + "dokuwiki", + "drupal", + "eZ Platform", + "elgg", + "expressionengine", + "fuelphp", + "grav", + "installer", + "itop", + "joomla", + "kohana", + "laravel", + "lavalite", + "lithium", + "magento", + "mako", + "mediawiki", + "modulework", + "moodle", + "osclass", + "phpbb", + "piwik", + "ppi", + "puppet", + "reindex", + "roundcube", + "shopware", + "silverstripe", + "sydes", + "symfony", + "typo3", + "wordpress", + "yawik", + "zend", + "zikula" + ], + "time": "2017-08-09T07:53:48+00:00" + }, + { + "name": "roave/security-advisories", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/Roave/SecurityAdvisories.git", + "reference": "43f7f8243b81e3fd843b150a30a6d0a91167d4f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/43f7f8243b81e3fd843b150a30a6d0a91167d4f5", + "reference": "43f7f8243b81e3fd843b150a30a6d0a91167d4f5", + "shasum": "" + }, + "conflict": { + "adodb/adodb-php": "<5.20.6", + "amphp/artax": ">=2,<2.0.6|<1.0.6", + "aws/aws-sdk-php": ">=3,<3.2.1", + "bugsnag/bugsnag-laravel": ">=2,<2.0.2", + "cakephp/cakephp": ">=2,<2.4.99|>=1.3,<1.3.18|>=3,<3.0.15|>=2.5,<2.5.99|>=2.6,<2.6.12|>=2.7,<2.7.6|>=3.1,<3.1.4", + "cart2quote/module-quotation": ">=4.1.6,<=4.4.5|>=5,<5.4.4", + "cartalyst/sentry": "<2.1", + "codeigniter/framework": "<=3.0.6", + "composer/composer": "<=1.0.0-alpha11", + "contao-components/mediaelement": ">=2.14.2,<2.21.1", + "contao/core": ">=2,<3.5.28", + "contao/core-bundle": ">=4,<4.4.1", + "doctrine/annotations": ">=1,<1.2.7", + "doctrine/cache": ">=1,<1.3.2|>=1.4,<1.4.2", + "doctrine/common": ">=2,<2.4.3|>=2.5,<2.5.1", + "doctrine/dbal": ">=2,<2.0.8|>=2.1,<2.1.2", + "doctrine/doctrine-bundle": "<1.5.2", + "doctrine/doctrine-module": "<=0.7.1", + "doctrine/mongodb-odm": ">=1,<1.0.2", + "doctrine/mongodb-odm-bundle": ">=2,<3.0.1", + "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1", + "dompdf/dompdf": ">=0.6,<0.6.2", + "drupal/core": ">=8,<8.3.7", + "drupal/drupal": ">=8,<8.3.7", + "ezsystems/ezpublish-legacy": ">=2017.8,<2017.8.1.1|>=5.4,<5.4.10.1|>=5.3,<5.3.12.2", + "firebase/php-jwt": "<2", + "friendsofsymfony/rest-bundle": ">=1.2,<1.2.2", + "friendsofsymfony/user-bundle": ">=1.2,<1.3.5", + "gregwar/rst": "<1.0.3", + "guzzlehttp/guzzle": ">=6,<6.2.1|>=4.0.0-rc2,<4.2.4|>=5,<5.3.1", + "illuminate/auth": ">=4,<4.0.99|>=4.1,<4.1.26", + "illuminate/database": ">=4,<4.0.99|>=4.1,<4.1.29", + "joomla/session": "<1.3.1", + "laravel/framework": ">=4,<4.0.99|>=4.1,<4.1.29", + "laravel/socialite": ">=1,<1.0.99|>=2,<2.0.10", + "magento/magento1ce": ">=1.5.0.1,<1.9.3.2", + "magento/magento1ee": ">=1.9,<1.14.3.2", + "magento/magento2ce": ">=2,<2.2", + "monolog/monolog": ">=1.8,<1.12", + "namshi/jose": "<2.2", + "onelogin/php-saml": "<2.10.4", + "oro/crm": ">=1.7,<1.7.4", + "oro/platform": ">=1.7,<1.7.4", + "phpmailer/phpmailer": ">=5,<5.2.24", + "phpxmlrpc/extras": "<6.0.1", + "pusher/pusher-php-server": "<2.2.1", + "sabre/dav": ">=1.6,<1.6.99|>=1.7,<1.7.11|>=1.8,<1.8.9", + "shopware/shopware": "<5.2.25", + "silverstripe/cms": ">=3.1,<3.1.11|>=3,<=3.0.11", + "silverstripe/forum": "<=0.6.1|>=0.7,<=0.7.3", + "silverstripe/framework": ">=3,<3.3", + "silverstripe/userforms": "<3", + "simplesamlphp/saml2": "<1.8.1|>=1.9,<1.9.1|>=1.10,<1.10.3|>=2,<2.3.3", + "simplesamlphp/simplesamlphp": "<1.14.16", + "simplesamlphp/simplesamlphp-module-infocard": "<1.0.1", + "socalnick/scn-social-auth": "<1.15.2", + "squizlabs/php_codesniffer": ">=1,<2.8.1", + "swiftmailer/swiftmailer": ">=4,<5.4.5", + "symfony/dependency-injection": ">=2,<2.0.17", + "symfony/form": ">=2.3,<2.3.35|>=2.4,<2.6.12|>=2.7,<2.7.7", + "symfony/framework-bundle": ">=2,<2.3.18|>=2.4,<2.4.8|>=2.5,<2.5.2", + "symfony/http-foundation": ">=2,<2.3.27|>=2.4,<2.5.11|>=2.6,<2.6.6", + "symfony/http-kernel": ">=2,<2.3.29|>=2.4,<2.5.12|>=2.6,<2.6.8", + "symfony/routing": ">=2,<2.0.19", + "symfony/security": ">=2.3,<2.3.37|>=2.4,<2.6.13|>=2.7,<2.7.9|>=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2,<2.0.25|>=2.1,<2.1.13|>=2.2,<2.2.9", + "symfony/security-core": ">=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2.8,<2.8.6|>=3,<3.0.6|>=2.4,<2.6.13|>=2.7,<2.7.9", + "symfony/security-http": ">=2.4,<2.7.13|>=2.3,<2.3.41|>=2.8,<2.8.6|>=3,<3.0.6", + "symfony/serializer": ">=2,<2.0.11", + "symfony/symfony": ">=2,<2.3.41|>=2.4,<2.7.13|>=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2.8,<2.8.6|>=3,<3.0.6", + "symfony/translation": ">=2,<2.0.17", + "symfony/validator": ">=2,<2.0.24|>=2.1,<2.1.12|>=2.2,<2.2.5|>=2.3,<2.3.3", + "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", + "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7", + "thelia/backoffice-default-template": ">=2.1,<2.1.2", + "thelia/thelia": ">=2.1.0-beta1,<2.1.3|>=2.1,<2.1.2", + "twig/twig": "<1.20", + "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.22|>=8,<8.7.5", + "typo3/flow": ">=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5|>=1.1,<1.1.1|>=2,<2.0.1|>=1,<1.0.4", + "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4", + "willdurand/js-translation-bundle": "<2.1.1", + "yiisoft/yii": ">=1.1.14,<1.1.15", + "yiisoft/yii2": "<2.0.5", + "yiisoft/yii2-bootstrap": "<2.0.4", + "yiisoft/yii2-dev": "<2.0.4", + "yiisoft/yii2-gii": "<2.0.4", + "yiisoft/yii2-jui": "<2.0.4", + "zendframework/zend-cache": ">=2.4,<2.4.8|>=2.5,<2.5.3", + "zendframework/zend-captcha": ">=2,<2.4.9|>=2.5,<2.5.2", + "zendframework/zend-crypt": ">=2,<2.4.9|>=2.5,<2.5.2", + "zendframework/zend-db": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.10|>=2.3,<2.3.5", + "zendframework/zend-diactoros": ">=1,<1.0.4", + "zendframework/zend-form": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-http": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.3,<2.3.8|>=2.4,<2.4.1", + "zendframework/zend-json": ">=2.1,<2.1.6|>=2.2,<2.2.6", + "zendframework/zend-ldap": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.8|>=2.3,<2.3.3", + "zendframework/zend-mail": ">=2,<2.4.11|>=2.5,<2.7.2", + "zendframework/zend-navigation": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-session": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.9|>=2.3,<2.3.4", + "zendframework/zend-validator": ">=2.3,<2.3.6", + "zendframework/zend-view": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-xmlrpc": ">=2.1,<2.1.6|>=2.2,<2.2.6", + "zendframework/zendframework": ">=2,<2.4.11|>=2.5,<2.5.1", + "zendframework/zendframework1": "<1.12.20", + "zendframework/zendopenid": ">=2,<2.0.2", + "zendframework/zendxml": ">=1,<1.0.1", + "zf-commons/zfc-user": "<1.2.2", + "zfcampus/zf-apigility-doctrine": ">=1,<1.0.3", + "zfr/zfr-oauth2-server-module": "<0.1.2" + }, + "type": "metapackage", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "role": "maintainer" + } + ], + "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", + "time": "2017-10-31T23:55:04+00:00" + } + ], + "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.4.3", + "source": { + "type": "git", + "url": "https://github.com/DealerDirect/phpcodesniffer-composer-installer.git", + "reference": "63c0ec0ac286d31651d3c70e5bf76ad87db3ba23" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/DealerDirect/phpcodesniffer-composer-installer/zipball/63c0ec0ac286d31651d3c70e5bf76ad87db3ba23", + "reference": "63c0ec0ac286d31651d3c70e5bf76ad87db3ba23", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": "^5.3|^7", + "squizlabs/php_codesniffer": "*" + }, + "require-dev": { + "composer/composer": "*", + "wimg/php-compatibility": "^8.0" + }, + "suggest": { + "dealerdirect/qa-tools": "All the PHP QA tools you'll need" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "f.nijhof@dealerdirect.nl", + "homepage": "http://workingatdealerdirect.eu", + "role": "Developer" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://workingatdealerdirect.eu", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "time": "2017-09-18T07:49:36+00:00" + }, + { + "name": "sirbrillig/phpcs-variable-analysis", + "version": "v2.0", + "source": { + "type": "git", + "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", + "reference": "ab7460330bc261499bb9a9b56f2d8f5d2c8ef64a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/ab7460330bc261499bb9a9b56f2d8f5d2c8ef64a", + "reference": "ab7460330bc261499bb9a9b56f2d8f5d2c8ef64a", + "shasum": "" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "authors": [ + { + "name": "Payton Swick", + "email": "payton@foolord.com" + } + ], + "description": "A PHPCS sniff to detect problems with variables.", + "time": "2017-11-03T18:09:07+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d667e245d5dcd4d7bf80f26f2c947d476b66213e", + "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2017-10-16T22:40:25+00:00" + }, + { + "name": "wimg/php-compatibility", + "version": "8.0.1", + "source": { + "type": "git", + "url": "https://github.com/wimg/PHPCompatibility.git", + "reference": "4c4385fb891dff0501009670f988d4fe36785249" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/4c4385fb891dff0501009670f988d4fe36785249", + "reference": "4c4385fb891dff0501009670f988d4fe36785249", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.2 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "PHPCompatibility\\": "PHPCompatibility/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "time": "2017-08-07T19:39:05+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "0.14.0", + "source": { + "type": "git", + "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", + "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/8cadf48fa1c70b2381988e0a79e029e011a8f41c", + "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "wordpress" + ], + "time": "2017-11-01T15:10:46+00:00" + } + ], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": { + "roave/security-advisories": 20 + }, + "prefer-stable": true, + "prefer-lowest": false, + "platform": { + "php": "^5.2|^7" + }, + "platform-dev": [] +} diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 00000000..3d536995 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,61 @@ + + + The code standard for Beans. + + . + + + dist/* + node_modules/* + vendor/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From dae4deb6054093ef4ef53ad48815ff37e74eb2af Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Wed, 22 Nov 2017 16:04:29 -0600 Subject: [PATCH 011/800] Made API Utilities WPCS Compliant (#67) * Made API Utilities WPCS Compliant 1. WPCS compliant see #46 2. Unit tests see #47 3. Fixes #63 4. Fixes #64 5. Fixes #65 6. Fixes #66 7. Closes #68 - deprecated the function. 8. Adds composer scripts. 9. Adds PHPUnit development suite setup. --- .gitignore | 2 + README.md | 10 +- composer.json | 79 +- composer.lock | 1698 ++++++++++++++++- lib/api/init.php | 15 +- lib/api/utilities/deprecated.php | 45 +- lib/api/utilities/functions.php | 339 ++-- lib/api/utilities/polyfills.php | 53 + phpcs.xml.dist | 18 +- phpunit.xml.dist | 39 + tests/phpunit/bootstrap.php | 30 + tests/phpunit/class-bootstrap.php | 34 + tests/phpunit/integration-tests/bootstrap.php | 62 + .../integration-tests/integrationSample.php | 38 + .../integration-tests/integrationSetup.php | 30 + .../unit-tests/api/utilities/beansGet.php | 64 + .../utilities/beansMultiArrayKeyExists.php | 120 ++ .../api/utilities/beansPathToUrl.php | 340 ++++ .../api/utilities/beansRemoveDir.php | 118 ++ .../api/utilities/beansRenderFunction.php | 80 + .../utilities/beansRenderFunctionArray.php | 91 + .../api/utilities/beansSanitizePath.php | 49 + .../api/utilities/beansUrlToPath.php | 367 ++++ tests/phpunit/unit-tests/class-test-case.php | 53 + 24 files changed, 3469 insertions(+), 305 deletions(-) create mode 100644 lib/api/utilities/polyfills.php create mode 100644 phpunit.xml.dist create mode 100644 tests/phpunit/bootstrap.php create mode 100644 tests/phpunit/class-bootstrap.php create mode 100644 tests/phpunit/integration-tests/bootstrap.php create mode 100644 tests/phpunit/integration-tests/integrationSample.php create mode 100644 tests/phpunit/integration-tests/integrationSetup.php create mode 100644 tests/phpunit/unit-tests/api/utilities/beansGet.php create mode 100644 tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php create mode 100644 tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php create mode 100644 tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php create mode 100644 tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php create mode 100644 tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php create mode 100644 tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php create mode 100644 tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php create mode 100644 tests/phpunit/unit-tests/class-test-case.php diff --git a/.gitignore b/.gitignore index 1733a33c..e53db368 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /node_modules/ /vendor/ +/logs/ +/reports/ diff --git a/README.md b/README.md index c02843b9..fe7aba0f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # Beans WordPress theme framework + +[![Build Status](https://travis-ci.org/Getbeans/Beans.svg?branch=development)](https://travis-ci.org/Getbeans/Beans) + [Beans](http://www.getbeans.io/) is an incredibly powerful and flexible WordPress theme, yet light weight and unbelievably fast. Whether you are a pro or a beginner, you will enjoy the simplicity of it. The magic is under the hood! # Documentation Whether you are looking how to get started or how to use Beans API, you will find your answers in the [documentation](http://www.getbeans.io/documentation/). If your don't find what your are looking for, don't hesitate to [contact us](http://getbeans.io/contact/). @@ -18,11 +21,6 @@ Beans community is growing rapidly and a lot of people are asking how they can c * Build extensions * Contribute to Beans core -If you are a Beans superstar and you want to contribute to Beans core, here are a few house rules: - -* Commits must start with a **capital** letter and end with a **dot** (unless it ends with a version number). -* Commits must start with one of the following key words **Added**, **Fixed**, **Updated**, **Improved**, **Modified** or **Removed**. -* Commits must be split into specific tasks and kept small so that other developers can easily see what it's about. -* Code format must be strictly similar to the rest of the theme framework. +If you are a Beans superstar and you want to contribute to Beans core, please see the [Beans Contributor's Wiki](wiki). Thanks for making Beans such a great theme which is loved and used by truly passionate people. diff --git a/composer.json b/composer.json index fd965c8e..dac32da4 100644 --- a/composer.json +++ b/composer.json @@ -1,32 +1,53 @@ { - "name": "beans/beans", - "description": "The most innovative theme for WordPress. The real magic is under the hood.", - "type": "wordpress-theme", - "license": "GPL-2.0+", - "homepage": "http://www.getbeans.io/", - "support": { - "issues": "https://github.com/GetBeans/Beans/issues", - "source": "https://github.com/GetBeans/Beans" - }, - "minimum-stability": "dev", - "prefer-stable": true, - "require": { - "php": "^5.2|^7", - "composer/installers": "^1.4", - "roave/security-advisories": "dev-master" - }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4", - "sirbrillig/phpcs-variable-analysis": "^2.0", - "wimg/php-compatibility": "^8.0", - "wp-coding-standards/wpcs": "^0.14.0" - }, - "config": { - "sort-order": true - }, - "scripts": { - "install-codestandards": [ - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run" - ] + "name": "beans/beans", + "description": "The most innovative theme for WordPress. The real magic is under the hood.", + "type": "wordpress-theme", + "license": "GPL-2.0+", + "homepage": "http://www.getbeans.io/", + "support": { + "issues": "https://github.com/GetBeans/Beans/issues", + "source": "https://github.com/GetBeans/Beans" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "exclude-from-classmap": [ + "/tests/" + ] + }, + "autoload-dev": { + "psr-4": { + "Beans\\Framework\\Tests\\": "tests/" } + }, + "require": { + "php": "^5.2|^7", + "composer/installers": "^1.4", + "roave/security-advisories": "dev-master" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3", + "sirbrillig/phpcs-variable-analysis": "^2.0", + "wimg/php-compatibility": "^8.0", + "wp-coding-standards/wpcs": "^0.14.0", + "phpunit/phpunit": "~5.7.9", + "brain/monkey": "^2.0", + "mikey179/vfsStream": "^1.6" + }, + "config": { + "sort-order": true + }, + "scripts": { + "install-codestandards": [ + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run" + ], + "phpcs-src": "vendor/bin/phpcs", + "phpcs-tests": "vendor/bin/phpcs --runtime-set testVersion 5.6 tests/phpunit/", + "phpcs": [ + "@phpcs-src", + "@phpcs-tests" + ], + "test-unit": "vendor/bin/phpunit --testsuite unit", + "test-integration": "vendor/bin/phpunit --testsuite integration" + } } diff --git a/composer.lock b/composer.lock index 32b4d017..0f80efe9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "f7cf443a0f40789221cf4cdd8e2672ea", + "hash": "fd519171be3f04b2ed6bca41c0676f48", + "content-hash": "8eedeb84b37d0361c9be0190fe2c7d00", "packages": [ { "name": "composer/installers", @@ -121,7 +122,7 @@ "zend", "zikula" ], - "time": "2017-08-09T07:53:48+00:00" + "time": "2017-08-09 07:53:48" }, { "name": "roave/security-advisories", @@ -129,12 +130,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "43f7f8243b81e3fd843b150a30a6d0a91167d4f5" + "reference": "bf2267389f86ae9a168fd0166be59d36ffc07827" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/43f7f8243b81e3fd843b150a30a6d0a91167d4f5", - "reference": "43f7f8243b81e3fd843b150a30a6d0a91167d4f5", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/bf2267389f86ae9a168fd0166be59d36ffc07827", + "reference": "bf2267389f86ae9a168fd0166be59d36ffc07827", "shasum": "" }, "conflict": { @@ -142,14 +143,15 @@ "amphp/artax": ">=2,<2.0.6|<1.0.6", "aws/aws-sdk-php": ">=3,<3.2.1", "bugsnag/bugsnag-laravel": ">=2,<2.0.2", - "cakephp/cakephp": ">=2,<2.4.99|>=1.3,<1.3.18|>=3,<3.0.15|>=2.5,<2.5.99|>=2.6,<2.6.12|>=2.7,<2.7.6|>=3.1,<3.1.4", + "cakephp/cakephp": ">=2,<2.4.99|>=2.5,<2.5.99|>=2.6,<2.6.12|>=2.7,<2.7.6|>=3,<3.0.15|>=3.1,<3.1.4|>=1.3,<1.3.18", "cart2quote/module-quotation": ">=4.1.6,<=4.4.5|>=5,<5.4.4", "cartalyst/sentry": "<2.1", "codeigniter/framework": "<=3.0.6", "composer/composer": "<=1.0.0-alpha11", "contao-components/mediaelement": ">=2.14.2,<2.21.1", - "contao/core": ">=2,<3.5.28", - "contao/core-bundle": ">=4,<4.4.1", + "contao/core": ">=2,<3.5.31", + "contao/core-bundle": ">=4,<4.4.8", + "contao/listing-bundle": ">=4,<4.4.8", "doctrine/annotations": ">=1,<1.2.7", "doctrine/cache": ">=1,<1.3.2|>=1.4,<1.4.2", "doctrine/common": ">=2,<2.4.3|>=2.5,<2.5.1", @@ -182,11 +184,12 @@ "oro/crm": ">=1.7,<1.7.4", "oro/platform": ">=1.7,<1.7.4", "phpmailer/phpmailer": ">=5,<5.2.24", + "phpunit/phpunit": ">=5.0.10,<5.6.3|>=4.8.19,<4.8.28", "phpxmlrpc/extras": "<6.0.1", "pusher/pusher-php-server": "<2.2.1", "sabre/dav": ">=1.6,<1.6.99|>=1.7,<1.7.11|>=1.8,<1.8.9", "shopware/shopware": "<5.2.25", - "silverstripe/cms": ">=3.1,<3.1.11|>=3,<=3.0.11", + "silverstripe/cms": ">=3,<=3.0.11|>=3.1,<3.1.11", "silverstripe/forum": "<=0.6.1|>=0.7,<=0.7.3", "silverstripe/framework": ">=3,<3.3", "silverstripe/userforms": "<3", @@ -197,26 +200,28 @@ "squizlabs/php_codesniffer": ">=1,<2.8.1", "swiftmailer/swiftmailer": ">=4,<5.4.5", "symfony/dependency-injection": ">=2,<2.0.17", - "symfony/form": ">=2.3,<2.3.35|>=2.4,<2.6.12|>=2.7,<2.7.7", + "symfony/form": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13|>=2.3,<2.3.35|>=2.4,<2.6.12", "symfony/framework-bundle": ">=2,<2.3.18|>=2.4,<2.4.8|>=2.5,<2.5.2", "symfony/http-foundation": ">=2,<2.3.27|>=2.4,<2.5.11|>=2.6,<2.6.6", "symfony/http-kernel": ">=2,<2.3.29|>=2.4,<2.5.12|>=2.6,<2.6.8", + "symfony/intl": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", "symfony/routing": ">=2,<2.0.19", - "symfony/security": ">=2.3,<2.3.37|>=2.4,<2.6.13|>=2.7,<2.7.9|>=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2,<2.0.25|>=2.1,<2.1.13|>=2.2,<2.2.9", - "symfony/security-core": ">=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2.8,<2.8.6|>=3,<3.0.6|>=2.4,<2.6.13|>=2.7,<2.7.9", - "symfony/security-http": ">=2.4,<2.7.13|>=2.3,<2.3.41|>=2.8,<2.8.6|>=3,<3.0.6", + "symfony/security": ">=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2.3,<2.3.37|>=2.4,<2.6.13|>=2.7,<2.7.9|>=2,<2.0.25|>=2.1,<2.1.13|>=2.2,<2.2.9", + "symfony/security-core": ">=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2.4,<2.6.13|>=2.7,<2.7.9|>=2.8,<2.8.6|>=3,<3.0.6", + "symfony/security-csrf": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", + "symfony/security-http": ">=2.4,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13|>=2.3,<2.3.41", "symfony/serializer": ">=2,<2.0.11", - "symfony/symfony": ">=2,<2.3.41|>=2.4,<2.7.13|>=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2.8,<2.8.6|>=3,<3.0.6", + "symfony/symfony": ">=2,<2.3.41|>=2.4,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", "symfony/translation": ">=2,<2.0.17", "symfony/validator": ">=2,<2.0.24|>=2.1,<2.1.12|>=2.2,<2.2.5|>=2.3,<2.3.3", "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7", "thelia/backoffice-default-template": ">=2.1,<2.1.2", - "thelia/thelia": ">=2.1.0-beta1,<2.1.3|>=2.1,<2.1.2", + "thelia/thelia": ">=2.1,<2.1.2|>=2.1.0-beta1,<2.1.3", "twig/twig": "<1.20", "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.22|>=8,<8.7.5", - "typo3/flow": ">=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5|>=1.1,<1.1.1|>=2,<2.0.1|>=1,<1.0.4", - "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4", + "typo3/flow": ">=1,<1.0.4|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5|>=1.1,<1.1.1|>=2,<2.0.1", + "typo3/neos": ">=1.2,<1.2.13|>=2,<2.0.4|>=1.1,<1.1.3", "willdurand/js-translation-bundle": "<2.1.1", "yiisoft/yii": ">=1.1.14,<1.1.15", "yiisoft/yii2": "<2.0.5", @@ -243,6 +248,7 @@ "zendframework/zendframework1": "<1.12.20", "zendframework/zendopenid": ">=2,<2.0.2", "zendframework/zendxml": ">=1,<1.0.1", + "zetacomponents/mail": "<1.8.2", "zf-commons/zfc-user": "<1.2.2", "zfcampus/zf-apigility-doctrine": ">=1,<1.0.3", "zfr/zfr-oauth2-server-module": "<0.1.2" @@ -260,10 +266,115 @@ } ], "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", - "time": "2017-10-31T23:55:04+00:00" + "time": "2017-11-17 12:15:33" } ], "packages-dev": [ + { + "name": "antecedent/patchwork", + "version": "2.1.6", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "91608c0c0b3b0d6b04e5bd11406ae0d5d5f7c26e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/91608c0c0b3b0d6b04e5bd11406ae0d5d5f7c26e", + "reference": "91608c0c0b3b0d6b04e5bd11406ae0d5d5f7c26e", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "homepage": "http://patchwork2.org/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ], + "time": "2017-11-05 10:37:19" + }, + { + "name": "brain/monkey", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/Brain-WP/BrainMonkey.git", + "reference": "98fd6de9f094b189d430a1d27cb35f86b00ec115" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/98fd6de9f094b189d430a1d27cb35f86b00ec115", + "reference": "98fd6de9f094b189d430a1d27cb35f86b00ec115", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.0", + "mockery/mockery": "~0.9.0", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-version/1": "1.x-dev", + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Brain\\Monkey\\": "src/" + }, + "files": [ + "inc/api.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Giuseppe Mazzapica", + "email": "giuseppe.mazzapica@gmail.com", + "homepage": "https://gmazzap.me", + "role": "Developer" + } + ], + "description": "Mocking utility for PHP functions and WordPress plugin API", + "keywords": [ + "Monkey Patching", + "interception", + "mock", + "mock functions", + "mockery", + "patchwork", + "redefinition", + "runkit", + "test", + "testing" + ], + "time": "2017-09-28 18:57:07" + }, { "name": "dealerdirect/phpcodesniffer-composer-installer", "version": "v0.4.3", @@ -330,67 +441,136 @@ "stylecheck", "tests" ], - "time": "2017-09-18T07:49:36+00:00" + "time": "2017-09-18 07:49:36" }, { - "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.0", + "name": "doctrine/instantiator", + "version": "1.1.0", "source": { "type": "git", - "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "ab7460330bc261499bb9a9b56f2d8f5d2c8ef64a" + "url": "https://github.com/doctrine/instantiator.git", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/ab7460330bc261499bb9a9b56f2d8f5d2c8ef64a", - "reference": "ab7460330bc261499bb9a9b56f2d8f5d2c8ef64a", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "shasum": "" }, - "type": "phpcodesniffer-standard", + "require": { + "php": "^7.1" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD" + "MIT" ], "authors": [ { - "name": "Payton Swick", - "email": "payton@foolord.com" + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" } ], - "description": "A PHPCS sniff to detect problems with variables.", - "time": "2017-11-03T18:09:07+00:00" + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2017-07-22 11:58:36" }, { - "name": "squizlabs/php_codesniffer", - "version": "3.1.1", + "name": "hamcrest/hamcrest-php", + "version": "v1.2.2", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e" + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d667e245d5dcd4d7bf80f26f2c947d476b66213e", - "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c", + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c", "shasum": "" }, "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" + "php": ">=5.3.2" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0" + "phpunit/php-file-iterator": "1.3.3", + "satooshi/php-coveralls": "dev-master" }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" + "type": "library", + "autoload": { + "classmap": [ + "hamcrest" + ], + "files": [ + "hamcrest/Hamcrest.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" ], + "time": "2015-05-11 14:41:42" + }, + { + "name": "mikey179/vfsStream", + "version": "v1.6.5", + "source": { + "type": "git", + "url": "https://github.com/mikey179/vfsStream.git", + "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", + "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.5" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "org\\bovigo\\vfs\\": "src/main/php" } }, "notification-url": "https://packagist.org/downloads/", @@ -399,17 +579,1425 @@ ], "authors": [ { - "name": "Greg Sherwood", - "role": "lead" + "name": "Frank Kleine", + "homepage": "http://frankkleine.de/", + "role": "Developer" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", + "description": "Virtual file system to mock the real file system in unit tests.", + "homepage": "http://vfs.bovigo.org/", + "time": "2017-08-01 08:02:14" + }, + { + "name": "mockery/mockery", + "version": "0.9.9", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "6fdb61243844dc924071d3404bb23994ea0b6856" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/6fdb61243844dc924071d3404bb23994ea0b6856", + "reference": "6fdb61243844dc924071d3404bb23994ea0b6856", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "~1.1", + "lib-pcre": ">=7.0", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", + "homepage": "http://github.com/padraic/mockery", "keywords": [ - "phpcs", - "standards" + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "time": "2017-02-28 12:52:32" + }, + { + "name": "myclabs/deep-copy", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2017-10-19 19:58:43" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2017-09-11 18:02:19" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "4.1.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2d3d238c433cf69caeb4842e97a3223a116f94b2", + "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2", + "shasum": "" + }, + "require": { + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0@dev", + "phpdocumentor/type-resolver": "^0.4.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2017-08-30 18:51:59" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2017-07-14 14:27:02" + }, + { + "name": "phpspec/prophecy", + "version": "v1.7.2", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", + "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8 || ^5.6.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2017-09-04 11:05:03" + }, + { + "name": "phpunit/php-code-coverage", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^5.6 || ^7.0", + "phpunit/php-file-iterator": "^1.3", + "phpunit/php-text-template": "^1.2", + "phpunit/php-token-stream": "^1.4.2 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0", + "sebastian/environment": "^1.3.2 || ^2.0", + "sebastian/version": "^1.0 || ^2.0" + }, + "require-dev": { + "ext-xdebug": "^2.1.4", + "phpunit/phpunit": "^5.7" + }, + "suggest": { + "ext-xdebug": "^2.5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2017-04-02 07:44:40" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2016-10-03 07:40:28" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21 13:50:34" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2017-02-26 11:10:40" + }, + { + "name": "phpunit/php-token-stream", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0", + "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2017-08-20 05:47:52" + }, + { + "name": "phpunit/phpunit", + "version": "5.7.25", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4b1c822a68ae6577df38a59eb49b046712ec0f6a", + "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "~1.3", + "php": "^5.6 || ^7.0", + "phpspec/prophecy": "^1.6.2", + "phpunit/php-code-coverage": "^4.0.4", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "^1.0.6", + "phpunit/phpunit-mock-objects": "^3.2", + "sebastian/comparator": "^1.2.4", + "sebastian/diff": "^1.4.3", + "sebastian/environment": "^1.3.4 || ^2.0", + "sebastian/exporter": "~2.0", + "sebastian/global-state": "^1.1", + "sebastian/object-enumerator": "~2.0", + "sebastian/resource-operations": "~1.0", + "sebastian/version": "~1.0.3|~2.0", + "symfony/yaml": "~2.1|~3.0|~4.0" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "3.0.2" + }, + "require-dev": { + "ext-pdo": "*" + }, + "suggest": { + "ext-xdebug": "*", + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2017-11-14 14:50:51" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.6 || ^7.0", + "phpunit/php-text-template": "^1.2", + "sebastian/exporter": "^1.2 || ^2.0" + }, + "conflict": { + "phpunit/phpunit": "<5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2017-06-30 09:13:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04 06:30:41" + }, + { + "name": "sebastian/comparator", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2 || ~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2017-01-29 09:50:25" + }, + { + "name": "sebastian/diff", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2017-05-22 07:24:03" + }, + { + "name": "sebastian/environment", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2016-11-26 07:53:53" + }, + { + "name": "sebastian/exporter", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2016-11-19 08:54:04" + }, + { + "name": "sebastian/global-state", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2015-10-12 03:26:01" + }, + { + "name": "sebastian/object-enumerator", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-02-18 15:18:39" + }, + { + "name": "sebastian/recursion-context", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2016-11-19 07:33:16" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28 20:34:47" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03 07:35:21" + }, + { + "name": "sirbrillig/phpcs-variable-analysis", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", + "reference": "e586fe27f519e8c7b8ba54d4ffd48da84ff1482b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/e586fe27f519e8c7b8ba54d4ffd48da84ff1482b", + "reference": "e586fe27f519e8c7b8ba54d4ffd48da84ff1482b", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "roave/security-advisories": "dev-master", + "squizlabs/php_codesniffer": "^3.0.2" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Payton Swick", + "email": "payton@foolord.com" + } + ], + "description": "A PHPCS sniff to detect problems with variables.", + "time": "2017-11-12 19:56:56" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d667e245d5dcd4d7bf80f26f2c947d476b66213e", + "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2017-10-16 22:40:25" + }, + { + "name": "symfony/yaml", + "version": "v3.3.13", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "0938408c4faa518d95230deabb5f595bf0de31b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/0938408c4faa518d95230deabb5f595bf0de31b9", + "reference": "0938408c4faa518d95230deabb5f595bf0de31b9", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "require-dev": { + "symfony/console": "~2.8|~3.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2017-11-10 18:26:04" + }, + { + "name": "webmozart/assert", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" ], - "time": "2017-10-16T22:40:25+00:00" + "time": "2016-11-23 20:04:58" }, { "name": "wimg/php-compatibility", @@ -461,7 +2049,7 @@ "phpcs", "standards" ], - "time": "2017-08-07T19:39:05+00:00" + "time": "2017-08-07 19:39:05" }, { "name": "wp-coding-standards/wpcs", @@ -501,7 +2089,7 @@ "standards", "wordpress" ], - "time": "2017-11-01T15:10:46+00:00" + "time": "2017-11-01 15:10:46" } ], "aliases": [], diff --git a/lib/api/init.php b/lib/api/init.php index 4c0e26a4..7b50286f 100644 --- a/lib/api/init.php +++ b/lib/api/init.php @@ -1,11 +1,11 @@ $item ) { - $path = $dir_path . '/' . $item; - if ( 'dir' === filetype( $dir_path . '/' . $item ) ) { + if ( is_dir( $path ) ) { beans_remove_dir( $path ); } else { - @unlink( $path ); + @unlink( $path ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. } - - unset( $items[ $needle ] ); - } - @rmdir( $dir_path ); - - return true; - + return @rmdir( $dir_path ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. } /** @@ -105,18 +98,18 @@ function beans_remove_dir( $dir_path ) { * * This function must only be used with internal paths. * - * @since 1.0.0 + * @since 1.5.0 * - * @param string $path Path to be converted. Accepts absolute and relative internal paths. + * @param string $path Path to be converted. Accepts absolute and relative internal paths. + * @param bool $force_rebuild Optional. Forces the rebuild of the root url and path. * * @return string Url. */ -function beans_path_to_url( $path ) { - - static $root, $host; +function beans_path_to_url( $path, $force_rebuild = false ) { + static $root_path, $root_url; // Stop here if it is already a url or data format. - if ( true == preg_match( '#^(http|https|\/\/|data)#', $path ) ) { + if ( preg_match( '#^(http|https|\/\/|data)#', $path ) ) { return $path; } @@ -124,43 +117,46 @@ function beans_path_to_url( $path ) { $path = wp_normalize_path( $path ); // Set root and host if it isn't cached. - if ( ! $root ) { + if ( ! $root_path || true === $force_rebuild ) { // Standardize backslashes set host. - $root = wp_normalize_path( untrailingslashit( ABSPATH ) ); - $host = untrailingslashit( site_url() ); + $root_path = wp_normalize_path( untrailingslashit( ABSPATH ) ); + $root_url = untrailingslashit( site_url() ); // Remove subfolder if necessary. - if ( '' !== ( $subfolder = parse_url( $host, PHP_URL_PATH ) ) ) { + $subfolder = parse_url( $root_url, PHP_URL_PATH ); + + if ( $subfolder && '/' !== $subfolder ) { + $pattern = '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#'; + $root_path = preg_replace( $pattern, '', $root_path ); + $root_url = preg_replace( $pattern, '', $root_url ); + } - $root = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root ); - $host = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $host ); + // If it's a multisite and not the main site, then add the site's path. + if ( ! is_main_site() ) { + $blogdetails = get_blog_details( get_current_blog_id() ); - // Add the blog path for multsites. - if ( ! is_main_site() && ( $blogdetails = get_blog_details( get_current_blog_id() ) ) ) { - if ( ! ( defined( 'WP_SITEURL' ) ) || ( defined( 'WP_SITEURL' ) && WP_SITEURL == site_url() ) ) { - $host = untrailingslashit( $host ) . $blogdetails->path; - } + if ( $blogdetails && ( ! defined( 'WP_SITEURL' ) || ( defined( 'WP_SITEURL' ) && WP_SITEURL === site_url() ) ) ) { + $root_url = untrailingslashit( $root_url ) . $blogdetails->path; } } - $explode = beans_get( 0, explode( '/' , trailingslashit( ltrim( $subfolder, '/' ) ) ) ); - // Maybe re-add tilde from host. - if ( false !== stripos( $explode, '~' ) ) { - $host = trailingslashit( $host ) . $explode; + $maybe_tilde = beans_get( 0, explode( '/', trailingslashit( ltrim( $subfolder, '/' ) ) ) ); + + if ( false !== stripos( $maybe_tilde, '~' ) ) { + $root_url = trailingslashit( $root_url ) . $maybe_tilde; } } // Remove root if necessary. - if ( false !== stripos( $path, $root ) ) { - $path = str_replace( $root, '', $path ); + if ( false !== stripos( $path, $root_path ) ) { + $path = str_replace( $root_path, '', $path ); } elseif ( false !== stripos( $path, beans_get( 'DOCUMENT_ROOT', $_SERVER ) ) ) { $path = str_replace( beans_get( 'DOCUMENT_ROOT', $_SERVER ), '', $path ); } - return trailingslashit( $host ) . ltrim( $path, '/' ); - + return trailingslashit( $root_url ) . ltrim( $path, '/' ); } /** @@ -168,85 +164,98 @@ function beans_path_to_url( $path ) { * * This function must only be used with internal urls. * - * @since 1.0.0 + * @since 1.5.0 * - * @param string $url Url to be converted. Accepts only internal urls. + * @param string $url Url to be converted. Accepts only internal urls. + * @param bool $force_rebuild Optional. Forces the rebuild of the root url and path. * * @return string Absolute path. */ -function beans_url_to_path( $url ) { +function beans_url_to_path( $url, $force_rebuild = false ) { + static $root_path, $blogdetails; + $site_url = site_url(); - static $root, $blogdetails; + if ( true === $force_rebuild ) { + $root_path = ''; + $blogdetails = ''; + } - // Stop here if it is not an internal url. - if ( false === stripos( $url, parse_url( site_url(), PHP_URL_HOST ) ) ) { - return beans_sanitize_path( $url ); + // Fix protocol. It isn't needed to set SSL as it is only used to parse the URL. + if ( ! parse_url( $url, PHP_URL_SCHEME ) ) { + $original_url = $url; + $url = 'http://' . ltrim( $url, '/' ); } - // Fix protocole. It isn't needed to set SSL as it is only used to parse the URL. - if ( preg_match( '#^(\/\/)#', $url ) ) { - $url = 'http:' . $url; + // It's not an internal URL. Bail out. + if ( false === stripos( parse_url( $url, PHP_URL_HOST ), parse_url( $site_url, PHP_URL_HOST ) ) ) { + return isset( $original_url ) ? $original_url : $url; } // Parse url and standardize backslashes. - $url = parse_url( $url, PHP_URL_PATH ); + $url = parse_url( $url, PHP_URL_PATH ); $path = wp_normalize_path( $url ); - $explode = beans_get( 0, explode( '/' , trailingslashit( ltrim( $path, '/' ) ) ) ); // Maybe remove tilde from path. - if ( false !== stripos( $explode, '~' ) ) { - $path = preg_replace( '#\~[^/]*\/#', '', $path ); + $trimmed_path = trailingslashit( ltrim( $path, '/' ) ); + $maybe_tilde = beans_get( 0, explode( '/', $trimmed_path ) ); + + if ( false !== stripos( $maybe_tilde, '~' ) ) { + $ends_with_slash = substr( $path, - 1 ) === '/'; + $path = preg_replace( '#\~[^/]*\/#', '', $trimmed_path ); + + if ( $path && ! $ends_with_slash ) { + $path = rtrim( $path, '/' ); + } } // Set root if it isn't cached yet. - if ( ! $root ) { - + if ( ! $root_path ) { // Standardize backslashes and remove windows drive for local installs. - $root = wp_normalize_path( untrailingslashit( ABSPATH ) ); - $set_root = true; - + $root_path = wp_normalize_path( untrailingslashit( ABSPATH ) ); + $set_root = true; } - // Remove subfolder if necessary. - if ( '' !== ( $subfolder = parse_url( site_url(), PHP_URL_PATH ) ) ) { + /* + * If the subfolder exists for the root URL, then strip it off of the root path. + * Why? We don't want a double subfolder in the final path. + */ + $subfolder = parse_url( $site_url, PHP_URL_PATH ); - // Set root if it isn't cached. - if ( isset( $set_root ) ) { + if ( isset( $set_root ) && $subfolder && '/' !== $subfolder ) { + $root_path = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root_path ); - // Remove subfolder. - $root = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root ); + // Add an extra step which is only used for extremely rare case. + if ( defined( 'WP_SITEURL' ) ) { + $subfolder = parse_url( WP_SITEURL, PHP_URL_PATH ); - // Add an extra step which is only used for extremely rare case. - if ( defined( 'WP_SITEURL' ) && '' !== ( $subfolder = parse_url( WP_SITEURL, PHP_URL_PATH ) ) ) { - $root = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root ); + if ( '' !== $subfolder ) { + $root_path = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root_path ); } } + } - // Remove the blog path for multsites. - if ( ! is_main_site() ) { - - // Set blogdetails if it isn't cached. - if ( ! $blogdetails ) { - $blogdetails = get_blog_details( get_current_blog_id() ); - } - - $path = preg_replace( '#^(\/?)' . trailingslashit( preg_quote( ltrim( $blogdetails->path, '/' ) ) ) . '#', '', $path ); + // Remove the blog path for multisites. + if ( ! is_main_site() ) { + // Set blogdetails if it isn't cached. + if ( ! $blogdetails ) { + $blogdetails = get_blog_details( get_current_blog_id() ); } + + $path = preg_replace( '#^(\/?)' . trailingslashit( preg_quote( ltrim( $blogdetails->path, '/' ) ) ) . '#', '', $path ); } // Remove Windows drive for local installs if the root isn't cached yet. if ( isset( $set_root ) ) { - $root = beans_sanitize_path( $root ); + $root_path = beans_sanitize_path( $root_path ); } // Add root of it doesn't exist. - if ( false === strpos( $path, $root ) ) { - $path = trailingslashit( $root ) . ltrim( $path, '/' ); + if ( false === strpos( $path, $root_path ) ) { + $path = trailingslashit( $root_path ) . ltrim( $path, '/' ); } return beans_sanitize_path( $path ); - } /** @@ -269,7 +278,6 @@ function beans_sanitize_path( $path ) { $path = preg_replace( '#^[A-Z]\:#i', '', $path ); return wp_normalize_path( $path ); - } /** @@ -278,15 +286,15 @@ function beans_sanitize_path( $path ) { * @since 1.0.0 * * @param string $needle Name of the searched key. - * @param string $haystack Optional. Associative array. If false, $_GET is set to be the $haystack. - * @param mixed $default Optional. Value returned if the searched key isn't found. + * @param mixed $haystack Optional. The target to search. If false, $_GET is set to be the $haystack. + * @param mixed $default Optional. Value to return if the needle isn't found. * - * @return string Value if found, $default otherwise. + * @return string Returns the value if found; else $default is returned. */ function beans_get( $needle, $haystack = false, $default = null ) { if ( false === $haystack ) { - $haystack = $_GET; + $haystack = $_GET; // @codingStandardsIgnoreLine - WordPress.CSRF.NonceVerification.NoNonceVerification as the nonce verification check should be at the form processing level. } $haystack = (array) $haystack; @@ -296,7 +304,6 @@ function beans_get( $needle, $haystack = false, $default = null ) { } return $default; - } /** @@ -305,14 +312,12 @@ function beans_get( $needle, $haystack = false, $default = null ) { * @since 1.0.0 * * @param string $needle Name of the searched key. - * @param mixed $default Optional. Value returned if the searched key isn't found. + * @param mixed $default Optional. Value to return if the needle isn't found. * - * @return string Value if found, $default otherwise. + * @return string Returns the value if found; else $default is returned. */ function beans_post( $needle, $default = null ) { - - return beans_get( $needle, $_POST, $default ); - + return beans_get( $needle, $_POST, $default ); // @codingStandardsIgnoreLine - WordPress.CSRF.NonceVerification.NoNonceVerification as the nonce verification check should be at the form processing level. } /** @@ -321,66 +326,24 @@ function beans_post( $needle, $default = null ) { * @since 1.0.0 * * @param string $needle Name of the searched key. - * @param mixed $default Optional. Value returned if the searched key isn't found. + * @param mixed $default Optional. Value to return if the needle isn't found. * - * @return string Value if found, $default otherwise. + * @return string Returns the value if found; else $default is returned. */ function beans_get_or_post( $needle, $default = null ) { + $get = beans_get( $needle ); - if ( $get = beans_get( $needle ) ) { + if ( $get ) { return $get; } - if ( $post = beans_post( $needle ) ) { + $post = beans_post( $needle ); + + if ( $post ) { return $post; } return $default; - -} - -/** - * Count recursive array. - * - * This function is able to count a recursive array. The depth can be defined as well as if the parent should be - * counted. For instance, if $depth is defined and $count_parent is set to false, only the level of the - * defined depth will be counted. - * - * @since 1.0.0 - * - * @param string $array The array. - * @param int|bool $depth Optional. Depth until which the entries should be counted. - * @param bool $count_parent Optional. Whether the parent should be counted or not. - * - * @return int Number of entries found. - */ -function beans_count_recursive( $array, $depth = false, $count_parent = true ) { - - if ( ! is_array( $array ) ) { - return 0; - } - - if ( 1 === $depth ) { - return count( $array ); - } - - if ( ! is_numeric( $depth ) ) { - return count( $array, COUNT_RECURSIVE ); - } - - $count = $count_parent ? count( $array ) : 0; - - foreach ( $array as $_array ) { - - if ( is_array( $_array ) ) { - $count += beans_count_recursive( $_array, $depth - 1, $count_parent ); - } else { - $count += 1; - } - } - - return $count; - } /** @@ -393,48 +356,48 @@ function beans_count_recursive( $array, $depth = false, $count_parent = true ) { * @param bool $strict If the third parameter strict is set to true, the beans_in_multi_array() * function will also check the types of the needle in the haystack. * - * @return bool True if needle is found in the array, false otherwise. + * @return bool Returns true if needle is found in the array; else, false is returned. */ function beans_in_multi_array( $needle, $haystack, $strict = false ) { - if ( in_array( $needle, $haystack, $strict ) ) { + if ( in_array( $needle, $haystack, $strict ) ) { // @codingStandardsIgnoreLine - WordPress.PHP.StrictInArray.MissingTrueStrict requires 3rd argument to be true or false and not a variable. return true; } foreach ( (array) $haystack as $value ) { - if ( is_array( $value ) && beans_in_multi_array( $needle , $value ) ) { + + if ( is_array( $value ) && beans_in_multi_array( $needle, $value ) ) { return true; } } return false; - } /** * Checks if a key or index exists in a multi-dimensional array. * - * @since 1.0.0 + * @since 1.5.0 * - * @param string $needle The searched value. - * @param array $haystack The multi-dimensional array. + * @param string $needle The key to search for within the haystack. + * @param array $haystack The array to be searched. * - * @return bool True if needle is found in the array, False otherwise. + * @return bool Returns true if needle is found in the array; else, false is returned. */ -function beans_multi_array_key_exists( $needle, $haystack ) { +function beans_multi_array_key_exists( $needle, array $haystack ) { if ( array_key_exists( $needle, $haystack ) ) { return true; } foreach ( $haystack as $value ) { - if ( is_array( $value ) && beans_multi_array_key_exists( $needle , $value ) ) { + + if ( is_array( $value ) && beans_multi_array_key_exists( $needle, $value ) ) { return true; } } return false; - } /** @@ -444,10 +407,10 @@ function beans_multi_array_key_exists( $needle, $haystack ) { * * @since 1.0.0 * - * @param string $content Content containing the shortcode(s) delimited with curly brackets (e.g. {key}). + * @param string $content Content containing the shortcode(s) delimited with curly brackets (e.g. {key}). * Shortcode(s) correspond to the searched array key and will be replaced by the array * value if found. - * @param array $haystack The associative array used to replace shortcode(s). + * @param array $haystack The associative array used to replace shortcode(s). * * @return string Content with shortcodes filtered out. */ @@ -456,15 +419,12 @@ function beans_array_shortcodes( $content, $haystack ) { if ( preg_match_all( '#{(.*?)}#', $content, $matches ) ) { foreach ( $matches[1] as $needle ) { - $sub_keys = explode( '.', $needle ); - $value = false; + $value = false; foreach ( $sub_keys as $sub_key ) { - $search = $value ? $value : $haystack; - $value = beans_get( $sub_key, $search ); - + $value = beans_get( $sub_key, $search ); } if ( $value ) { @@ -474,7 +434,6 @@ function beans_array_shortcodes( $content, $haystack ) { } return $content; - } /** @@ -484,12 +443,13 @@ function beans_array_shortcodes( $content, $haystack ) { * * @since 1.0.0 * + * @global $menu + * * @param int $position The desired position. * - * @return bool Valid postition. + * @return bool Valid position. */ function beans_admin_menu_position( $position ) { - global $menu; if ( ! is_array( $position ) ) { @@ -501,7 +461,6 @@ function beans_admin_menu_position( $position ) { } return $position; - } /** @@ -537,46 +496,20 @@ function beans_esc_attributes( $attributes ) { foreach ( (array) $attributes as $attribute => $value ) { - if ( null !== $value ) { - - if ( $method = beans_get( $attribute, $methods ) ) { - $value = call_user_func( $method, $value ); - } else { - $value = esc_attr( $value ); - } - - $string .= $attribute . '="' . $value . '" '; - + if ( null === $value ) { + continue; } - } - - return trim( $string ); -} - -if ( ! function_exists( 'array_replace_recursive' ) ) { + $method = beans_get( $attribute, $methods ); - /** - * PHP 5.2 fallback. - * - * @ignore - */ - function array_replace_recursive( $base, $replacements ) { - - if ( ! is_array( $base ) || ! is_array( $replacements ) ) { - return $base; - } - - foreach ( $replacements as $key => $value ) { - - if ( is_array( $value ) && is_array( $from_base = beans_get( $key, $base ) ) ) { - $base[ $key ] = array_replace_recursive( $from_base, $value ); - } else { - $base[ $key ] = $value; - } + if ( $method ) { + $value = call_user_func( $method, $value ); + } else { + $value = esc_attr( $value ); } - return $base; - + $string .= $attribute . '="' . $value . '" '; } + + return trim( $string ); } diff --git a/lib/api/utilities/polyfills.php b/lib/api/utilities/polyfills.php new file mode 100644 index 00000000..8d1c3069 --- /dev/null +++ b/lib/api/utilities/polyfills.php @@ -0,0 +1,53 @@ + $value ) { + $from_base = beans_get( $key, $array1 ); + + if ( is_array( $value ) && is_array( $from_base ) ) { + $array1[ $key ] = array_replace_recursive( $from_base, $value ); // @codingStandardsIgnoreLine - PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound) - Sniffer is not picking up the polyfill. + } else { + $array1[ $key ] = $value; + } + } + + return $array1; + } +} diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 3d536995..fb049156 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -5,26 +5,35 @@ . - dist/* + */dist/* node_modules/* - vendor/* + */vendor/* + */vendors/* + - + + + */tests/* + + + + + @@ -45,6 +54,9 @@ + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 00000000..c27daaf3 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,39 @@ + + + + + + + + + + + ./tests/phpunit/unit-tests/ + + + ./tests/phpunit/integration-tests/ + + + + + + . + + + + + + + diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php new file mode 100644 index 00000000..3415e6a2 --- /dev/null +++ b/tests/phpunit/bootstrap.php @@ -0,0 +1,30 @@ +getName() ) { + require_once __DIR__ . '/integration-tests/bootstrap.php'; + } + } +} diff --git a/tests/phpunit/integration-tests/bootstrap.php b/tests/phpunit/integration-tests/bootstrap.php new file mode 100644 index 00000000..56fb38f5 --- /dev/null +++ b/tests/phpunit/integration-tests/bootstrap.php @@ -0,0 +1,62 @@ +get_stylesheet(); +} + +/** + * Callback for changing the active template during tests. + * + * @param string $template Existing template name. + * + * @return string Amended template name. + */ +function beans_testing_override_template( $template ) { + return wp_get_theme( BEANS_THEME_DIR )->get_template(); +} + +tests_add_filter( 'setup_theme', 'beans_testing_manually_load_theme' ); + +// Start up the WP testing environment. +require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php'; + +require __DIR__ . '/class-test-case.php'; diff --git a/tests/phpunit/integration-tests/integrationSample.php b/tests/phpunit/integration-tests/integrationSample.php new file mode 100644 index 00000000..88146a03 --- /dev/null +++ b/tests/phpunit/integration-tests/integrationSample.php @@ -0,0 +1,38 @@ +assertTrue( true ); + } +} diff --git a/tests/phpunit/integration-tests/integrationSetup.php b/tests/phpunit/integration-tests/integrationSetup.php new file mode 100644 index 00000000..11a78d9b --- /dev/null +++ b/tests/phpunit/integration-tests/integrationSetup.php @@ -0,0 +1,30 @@ +assertTrue( true ); + } +} diff --git a/tests/phpunit/unit-tests/api/utilities/beansGet.php b/tests/phpunit/unit-tests/api/utilities/beansGet.php new file mode 100644 index 00000000..94c3991f --- /dev/null +++ b/tests/phpunit/unit-tests/api/utilities/beansGet.php @@ -0,0 +1,64 @@ +assertEquals( 10, beans_get( 'foo', 'bar', 10 ) ); + $this->assertNull( beans_get( 'foo', array( 'oof' => 'found me' ) ) ); + $this->assertNull( beans_get( 'foo', array( 10, 'bar', 'baz' ) ) ); + $this->assertFalse( beans_get( 'foo', (object) array( 'bar', 'baz' ), false ) ); + } + + /** + * Test beans_get() should find the needle. + */ + public function test_should_find_needle() { + $this->assertEquals( 'bar', beans_get( 0, 'bar', 10 ) ); + + $data = array( + 'foo' => 'found me', + ); + $this->assertEquals( 'found me', beans_get( 'foo', $data, 10 ) ); + $this->assertEquals( 'found me', beans_get( 'foo', (object) $data, 10 ) ); + + $data = array( + 'baz' => 'zab', + 'rab' => 'bar', + 'red', + ); + $this->assertEquals( 'red', beans_get( 0, $data ) ); + $this->assertEquals( 'zab', beans_get( 'baz', $data ) ); + $this->assertEquals( 'red', beans_get( 0, (object) $data ) ); + $this->assertEquals( 'zab', beans_get( 'baz', (object) $data ) ); + } +} diff --git a/tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php b/tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php new file mode 100644 index 00000000..a021c216 --- /dev/null +++ b/tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php @@ -0,0 +1,120 @@ +expectException( \TypeError::class ); + $this->assertFalse( beans_multi_array_key_exists( 0, 'bar' ) ); + $this->assertFalse( beans_multi_array_key_exists( 'foo', 10 ) ); + $this->assertFalse( beans_multi_array_key_exists( 'bar', new \stdClass() ) ); + } + + /** + * Test beans_multi_array_key_exists() should return true when key does exist. + */ + public function test_should_return_true_when_key_exists() { + $data = array( + 'oof' => 'found me', + ); + $this->assertTrue( beans_multi_array_key_exists( 'oof', $data ) ); + $this->assertTrue( beans_multi_array_key_exists( 1, array( 10, 'bar', 'baz' ) ) ); + $data = array( + 'green' => 'grass', + 'blue' => 'sky', + ); + $this->assertTrue( beans_multi_array_key_exists( 'blue', $data ) ); + } + + /** + * Test beans_multi_array_key_exists() should return false when key does not exist. + */ + public function test_should_return_false_when_key_does_not_exist() { + $data = array( + 'oof' => 'found me', + ); + $this->assertFalse( beans_multi_array_key_exists( 'foo', $data ) ); + $this->assertFalse( beans_multi_array_key_exists( 'bar', array( 10, 'bar', 'baz' ) ) ); + $data = array( + 'green' => 'grass', + 'blue' => 'sky', + ); + $this->assertFalse( beans_multi_array_key_exists( 'red', $data ) ); + } + + /** + * Test beans_multi_array_key_exists() should return true when key exists within a multi-dimensional array. + */ + public function test_should_return_true_when_key_exists_multidimensional() { + $data = array( + 'bar', + array( + 'zab' => 'foo', + ), + ); + $this->assertTrue( beans_multi_array_key_exists( 'zab', $data ) ); + + $data = array( + 'bar', + 'skill' => array( + 'javascript' => true, + 'php' => true, + 'sql' => true, + 'beans' => 'rocks', + ), + ); + $this->assertTrue( beans_multi_array_key_exists( 'beans', $data ) ); + } + + /** + * Test beans_multi_array_key_exists() should return true when key exists within a multi-dimensional array. + */ + public function test_should_return_false_when_key_does_not_exist_multidimensional() { + $data = array( + 'bar', + array( + 'zab' => 'foo', + ), + ); + $this->assertFalse( beans_multi_array_key_exists( 'foo', $data ) ); + $data = array( + 'bar', + 'skill' => array( + 'javascript' => true, + 'php' => true, + 'sql' => true, + 'beans' => 'rocks', + ), + ); + $this->assertFalse( beans_multi_array_key_exists( 'rocks', $data ) ); + } +} diff --git a/tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php b/tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php new file mode 100644 index 00000000..c6b55233 --- /dev/null +++ b/tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php @@ -0,0 +1,340 @@ +assertSame( 'http://getbeans.io', beans_path_to_url( 'http://getbeans.io' ) ); + $this->assertSame( 'http://www.getbeans.io', beans_path_to_url( 'http://www.getbeans.io' ) ); + $this->assertSame( 'https://getbeans.io', beans_path_to_url( 'https://getbeans.io' ) ); + $this->assertSame( 'https://www.getbeans.io', beans_path_to_url( 'https://www.getbeans.io' ) ); + } + + /** + * Test beans_path_to_url() should bail out when relative URL. + */ + public function test_should_bail_out_when_relative_url() { + $this->assertSame( '//getbeans.io', beans_path_to_url( '//getbeans.io' ) ); + $this->assertSame( '//www.getbeans.io', beans_path_to_url( '//www.getbeans.io' ) ); + } + + /** + * Test beans_path_to_url() should bail out when Data URI. + */ + public function test_should_bail_out_when_data_url() { + $this->assertSame( 'data:,Hello%2C%20World!', beans_path_to_url( 'data:,Hello%2C%20World!' ) ); + $this->assertSame( + 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D', + beans_path_to_url( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) + ); + } + + /** + * Test beans_path_to_url() should bail out when IP Address. + */ + public function test_should_bail_out_when_ip() { + $this->assertSame( 'http://8.8.8.8', beans_path_to_url( 'http://8.8.8.8' ) ); + $this->assertSame( 'http://8000:8.8.8.8', beans_path_to_url( 'http://8000:8.8.8.8' ) ); + } + + /** + * Test beans_path_to_url() converts path. + */ + public function test_should_convert_absolute_path() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + $url = 'https://getbeans.io'; + Functions\expect( 'site_url' )->andReturn( $url ); + + $this->assertSame( "{$url}/api/utilities/beansPathToUrl.php", beans_path_to_url( __FILE__, true ) ); + $this->assertSame( "{$url}/api/utilities", beans_path_to_url( __DIR__, true ) ); + } + + /** + * Test beans_path_to_url() converts path. + */ + public function test_should_convert_relative_path() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + $url = 'https://getbeans.io'; + Functions\expect( 'site_url' )->andReturn( $url ); + + $path = '/wp-content/themes'; + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + + $path = 'wp-content/themes/tm-beans/'; + $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + } + + /** + * Test beans_path_to_url() should convert to IP Address when absolute path. + */ + public function test_should_convert_to_ip_when_absolute_path() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + $url = 'https://8.8.8.8'; + Functions\expect( 'site_url' )->andReturn( $url ); + + $this->assertSame( "{$url}/api/utilities/beansPathToUrl.php", beans_path_to_url( __FILE__, true ) ); + $this->assertSame( "{$url}/api/utilities", beans_path_to_url( __DIR__, true ) ); + } + + /** + * Test beans_path_to_url() should convert to IP Address when relative path. + */ + public function test_should_convert_to_ip_when_relative_path() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + $url = 'https://8.8.8.8'; + Functions\expect( 'site_url' )->andReturn( $url ); + + $path = '/wp-content/themes'; + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + + $path = 'wp-content/themes/tm-beans/'; + $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + } + + /** + * Test beans_path_to_url() should convert absolute path when domain has a trailing slash. + */ + public function test_should_convert_absolute_path_when_trailingslash_domain() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + $url = 'https://getbeans.io'; + Functions\expect( 'site_url' )->andReturn( $url . '/' ); + + $this->assertSame( "{$url}/api/utilities/beansPathToUrl.php", beans_path_to_url( __FILE__, true ) ); + $this->assertSame( "{$url}/api/utilities", beans_path_to_url( __DIR__, true ) ); + } + + /** + * Test beans_path_to_url() should convert relative path when domain has a trailing slash. + */ + public function test_should_convert_relative_path_when_trailingslash_domain() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + $url = 'https://getbeans.io'; + Functions\expect( 'site_url' )->andReturn( $url . '/' ); + $path = 'wp-content/themes'; + $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + + $path = '/wp-content/themes/tm-beans/'; + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + } + + /** + * Test beans_path_to_url() should convert absolute path when IP address has a trailing slash. + */ + public function test_should_convert_absolute_path_when_ip_trailingslash() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + $url = 'https://8000:10.127.47.355'; + Functions\expect( 'site_url' )->andReturn( $url . '/' ); + + $this->assertSame( "{$url}/api/utilities/beansPathToUrl.php", beans_path_to_url( __FILE__, true ) ); + $this->assertSame( "{$url}/api/utilities", beans_path_to_url( __DIR__, true ) ); + } + + /** + * Test beans_path_to_url() should convert relative path when IP address has a trailing slash. + */ + public function test_should_convert_relative_path_when_ip_trailingslash() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + $url = 'https://9000:10.127.47.355'; + Functions\expect( 'site_url' )->andReturn( $url . '/' ); + + $path = 'wp-content/themes'; + $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + + $path = '/wp-content/themes/tm-beans/'; + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + } + + /** + * Test beans_path_to_url() should remove the domain URL's subfolder. + */ + public function test_should_remove_domain_subfolder() { + $path = '/wp-content/themes'; + Functions\expect( 'is_main_site' )->andReturn( true ); + + $url = 'http://example.com'; + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo' ); + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo/' ); + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo/bar' ); + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo/bar/' ); + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + } + + /** + * Test beans_path_to_url() should remove the IP Address' subfolder. + */ + public function test_should_remove_ip_subfolder() { + Functions\expect( 'is_main_site' )->andReturn( true ); + $url = 'http://8.8.8.8'; + $path = '/wp-content/themes'; + + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo' ); + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo/' ); + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo/bar' ); + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo/bar/' ); + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); + } + + /** + * Test beans_path_to_url() should re-add the domain URL's tilde upon conversion. + */ + public function test_should_re_add_domain_tilde() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://getbeans.io' ); + $this->assertSame( 'https://getbeans.io/api/utilities/beansPathToUrl.php', beans_path_to_url( __FILE__, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://example.com/~subdomain' ); + $this->assertSame( 'https://example.com/~subdomain/foo', beans_path_to_url( 'foo', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://example.com/~subdomain/baz' ); + $this->assertSame( 'https://example.com/~subdomain/foo/bar', beans_path_to_url( 'foo/bar', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://example.com/~subdomain/baz/' ); + $this->assertSame( 'https://example.com/~subdomain/foo/bar/', beans_path_to_url( '/foo/bar/', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://example.com/~subdomain/baz/foobar' ); + $this->assertSame( 'https://example.com/~subdomain/foo/bar', beans_path_to_url( '/foo/bar', true ) ); + } + + /** + * Test beans_path_to_url() should re-add the domain URL's tilde upon conversion. + */ + public function test_should_re_add_ip_tilde() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://8.8.8.8' ); + $this->assertSame( 'https://8.8.8.8/api/utilities/beansPathToUrl.php', beans_path_to_url( __FILE__, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://17.17.17.17/~subdomain' ); + $this->assertSame( 'https://17.17.17.17/~subdomain/foo', beans_path_to_url( 'foo', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://20.20.20.20/~subdomain/baz' ); + $this->assertSame( 'https://20.20.20.20/~subdomain/foo/bar', beans_path_to_url( 'foo/bar', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://8.8.8.8/~subdomain/baz/' ); + $this->assertSame( 'https://8.8.8.8/~subdomain/foo/bar/', beans_path_to_url( '/foo/bar/', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'https://10.10.10.10/~subdomain/baz/foobar' ); + $this->assertSame( 'https://10.10.10.10/~subdomain/foo/bar', beans_path_to_url( '/foo/bar', true ) ); + } + + /** + * Test beans_path_to_url() should convert for domain URL's subdirectory multisite. + */ + public function test_should_convert_for_domain_subdirectory_multisite() { + $path = 'wp-content/themes'; + Functions\expect( 'is_main_site' )->andReturn( false ); + Functions\expect( 'get_current_blog_id' )->andReturn( 10 ); + + $url = 'http://example.com'; + Functions\expect( 'get_blog_details' )->once()->andReturn( (object) array( 'path' => '/shop/' ) ); + Functions\expect( 'site_url' )->once()->andReturn( $url . '/' ); + $this->assertSame( "{$url}/shop/{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'get_blog_details' )->once()->andReturn( (object) array( 'path' => '/shop/' ) ); + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo' ); + $this->assertSame( "{$url}/shop/{$path}", beans_path_to_url( $path, true ) ); + } + + /** + * Test beans_path_to_url() should convert for IP Address's subdirectory multisite. + */ + public function test_should_convert_for_ip_subdirectory_multisite() { + $path = 'wp-content/themes'; + Functions\expect( 'is_main_site' )->andReturn( false ); + Functions\expect( 'get_current_blog_id' )->andReturn( 15 ); + + $url = 'http://8.8.8.8'; + Functions\expect( 'get_blog_details' )->once()->andReturn( (object) array( 'path' => '/support/' ) ); + Functions\expect( 'site_url' )->once()->andReturn( $url . '/' ); + $this->assertSame( "{$url}/support/{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'get_blog_details' )->once()->andReturn( (object) array( 'path' => '/support/' ) ); + Functions\expect( 'site_url' )->once()->andReturn( $url . '/ip-address' ); + $this->assertSame( "{$url}/support/{$path}", beans_path_to_url( $path, true ) ); + } + + /** + * Test beans_path_to_url() should convert for domain URL's subdomain multisite. + */ + public function test_should_convert_for_domain_subdomain_multisite() { + $path = 'wp-content/themes'; + Functions\expect( 'is_main_site' )->andReturn( false ); + Functions\expect( 'get_current_blog_id' )->andReturn( 10 ); + + $url = 'http://shop.example.com'; + Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); + Functions\expect( 'site_url' )->once()->andReturn( $url ); + $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo' ); + $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + } + + /** + * Test beans_path_to_url() should convert for domain URL's subdomain multisite. + */ + public function test_should_convert_for_ip_subdomain_multisite() { + $path = 'wp-content/themes'; + Functions\expect( 'is_main_site' )->andReturn( false ); + Functions\expect( 'get_current_blog_id' )->andReturn( 10 ); + + $url = 'http://shop.8.8.8.8'; + Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); + Functions\expect( 'site_url' )->once()->andReturn( $url ); + $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo' ); + $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + } +} diff --git a/tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php b/tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php new file mode 100644 index 00000000..ae1c964e --- /dev/null +++ b/tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php @@ -0,0 +1,118 @@ +assertFalse( beans_remove_dir( $dir . 'this-dir-does-not-exist' ) ); + $this->assertFalse( beans_remove_dir( $dir . 'foo' ) ); + $this->assertFalse( beans_remove_dir( __FILE__ ) ); + } + + /** + * Test beans_remove_dir() should remove a directory without files. + */ + public function test_should_remove_dir_with_no_files() { + vfsStream::setup( 'remove-dir' ); + $dir = vfsStream::url( 'remove-dir' ); + + $this->directoryExists( $dir ); + $this->assertTrue( beans_remove_dir( $dir ) ); + $this->assertDirectoryNotExists( $dir ); + + vfsStream::setup( 'remove-dir', 0644 ); + $this->directoryExists( $dir ); + $this->assertTrue( beans_remove_dir( $dir ) ); + $this->assertDirectoryNotExists( $dir ); + } + + /** + * Test beans_remove_dir() should remove a directory with files. + */ + public function test_should_remove_dir_with_files() { + vfsStream::setup( 'remove-dir', 0644, [ + 'foo.txt' => 'Testing Beans for foo.txt', + 'bar.txt' => 'Testing Beans for bar.txt', + ] ); + $dir = vfsStream::url( 'remove-dir' ); + + $this->directoryExists( $dir ); + $this->assertFileExists( $dir . '/foo.txt' ); + $this->assertFileExists( $dir . '/bar.txt' ); + $this->assertTrue( beans_remove_dir( $dir ) ); + $this->assertDirectoryNotExists( $dir ); + $this->assertFileNotExists( $dir . '/foo.txt' ); + $this->assertFileNotExists( $dir . '/bar.txt' ); + } + + /** + * Test beans_remove_dir() should remove a deeply nested directory. + */ + public function test_should_remove_deeply_nested_dir() { + vfsStream::setup( 'remove-dir', 0644, [ + 'foo.txt' => 'Testing Beans for foo.txt', + 'sub-dir' => [ + 'bar.txt' => 'Testing Beans for bar.txt', + 'sub-sub-dir' => [ + 'baz.log' => 'Baz logger', + 'foobar.log' => 'Foobar logger', + ], + ], + ] ); + $dir = vfsStream::url( 'remove-dir' ); + + $this->directoryExists( $dir ); + $this->assertFileExists( $dir . '/foo.txt' ); + + $this->directoryExists( $dir . '/sub-dir' ); + $this->assertFileExists( $dir . '/sub-dir/bar.txt' ); + + $this->directoryExists( $dir . '/sub-dir/sub-sub-dir' ); + $this->assertFileExists( $dir . '/sub-dir/sub-sub-dir/baz.log' ); + $this->assertFileExists( $dir . '/sub-dir/sub-sub-dir/foobar.log' ); + + $this->assertTrue( beans_remove_dir( $dir ) ); + + $this->assertDirectoryNotExists( $dir ); + $this->assertFileNotExists( $dir . '/foo.txt' ); + + $this->assertDirectoryNotExists( $dir . '/sub-dir' ); + $this->assertFileNotExists( $dir . '/sub-dir/bar.txt' ); + + $this->assertDirectoryNotExists( $dir . '/sub-dir/sub-sub-dir' ); + $this->assertFileNotExists( $dir . '/sub-dir/sub-sub-dir/baz.log' ); + $this->assertFileNotExists( $dir . '/sub-dir/sub-sub-dir/foobar.log' ); + } +} diff --git a/tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php b/tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php new file mode 100644 index 00000000..c8538ac0 --- /dev/null +++ b/tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php @@ -0,0 +1,80 @@ +assertNull( beans_render_function( 'this-callback-does-not-exist' ) ); + } + + /** + * Test beans_render_function() should work when there no arguments. + */ + public function test_should_work_when_no_arguments() { + $this->assertEquals( 'You called me!', beans_render_function( function () { + echo 'You called me!'; + } ) ); + } + + /** + * Test beans_render_function() should work with arguments. + */ + public function test_should_work_with_arguments() { + + Functions\when( 'callback_for_render_function' ) + ->justEcho( 'foo' ); + $this->assertSame( 'foo', beans_render_function( 'callback_for_render_function', 'foo' ) ); + + $callback = function ( $foo, $bar, $baz ) { + echo "{$foo} {$bar} {$baz}"; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + }; + $this->assertSame( 'foo bar baz', beans_render_function( $callback, 'foo', 'bar', 'baz' ) ); + + $callback = function ( $array, $baz ) { + echo join( ' ', $array ) . ' ' . $baz; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + }; + $this->assertSame( + 'foo bar baz', + beans_render_function( $callback, array( 'foo', 'bar' ), 'baz' ) + ); + + $callback = function ( $object ) { + $this->assertObjectHasAttribute( 'foo', $object ); + echo $object->foo; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + }; + $this->assertSame( + 'beans', + beans_render_function( $callback, (object) array( 'foo' => 'beans' ) ) + ); + } +} diff --git a/tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php b/tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php new file mode 100644 index 00000000..dfdfb425 --- /dev/null +++ b/tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php @@ -0,0 +1,91 @@ +assertEmpty( beans_render_function_array( 'this-callback-does-not-exist' ) ); + } + + /** + * Test beans_render_function_array() should work when there no arguments. + */ + public function test_should_work_when_no_arguments() { + $this->assertEquals( 'You called me!', beans_render_function_array( function () { + echo 'You called me!'; + } ) ); + } + + /** + * Test beans_render_function_array() should work with arguments. + */ + public function test_should_work_with_arguments() { + + $callback = function ( $foo, $bar, $baz ) { + echo "{$foo} {$bar} {$baz}"; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + }; + $this->assertSame( + 'foo bar baz', + beans_render_function_array( $callback, array( 'foo', 'bar', 'baz' ) ) + ); + + $callback = function ( $array, $baz ) { + $this->assertCount( 2, $array ); + echo join( ' ', $array ) . ' ' . $baz; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + }; + $this->assertSame( + 'foo bar baz', + beans_render_function_array( $callback, array( array( 'foo', 'bar' ), 'baz' ) ) + ); + + $callback = function ( $array1, $array2 ) { + $this->assertCount( 2, $array1 ); + $this->assertArrayHasKey( 'bar', $array1 ); + $this->assertCount( 1, $array2 ); + $this->assertArrayHasKey( 'baz', $array2 ); + echo $array1['foo']; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + }; + $this->assertSame( + 'oof', + beans_render_function_array( + $callback, + array( + array( + 'foo' => 'oof', + 'bar' => 'rab', + ), + array( 'baz' => 'zab' ), + ) + ) + ); + } +} diff --git a/tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php b/tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php new file mode 100644 index 00000000..512d35c6 --- /dev/null +++ b/tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php @@ -0,0 +1,49 @@ +assertSame( BEANS_TESTS_DIR, beans_sanitize_path( BEANS_TESTS_DIR ) ); + $this->assertSame( __DIR__, beans_sanitize_path( __DIR__ ) ); + $this->assertSame( BEANS_TESTS_DIR, beans_sanitize_path( __DIR__ . '/../../../' ) ); + $this->assertSame( BEANS_TESTS_DIR . '/bootstrap.php', beans_sanitize_path( __DIR__ . '/../../../bootstrap.php' ) ); + } + + /** + * Test beans_sanitize_path() should remove Windows drive. + */ + public function test_should_remove_windows_drive() { + $this->assertSame( '/Program Files/tmp/', beans_sanitize_path( 'C:\Program Files\tmp\\' ) ); + $this->assertSame( '/Foo/bar/baz/index.txt', beans_sanitize_path( 'D:\Foo\bar\baz\index.txt' ) ); + } +} diff --git a/tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php b/tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php new file mode 100644 index 00000000..fe30999e --- /dev/null +++ b/tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php @@ -0,0 +1,367 @@ +andReturn( 'http://getbeans.io' ); + $this->assertSame( + 'http://www.example.com/image.png', + beans_url_to_path( 'http://www.example.com/image.png' ) + ); + $this->assertSame( 'http://www.getbeans.com', beans_url_to_path( 'http://www.getbeans.com' ) ); + $this->assertSame( 'ftp://foo.com', beans_url_to_path( 'ftp://foo.com' ) ); + $this->assertSame( + 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D', + beans_url_to_path( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) + ); + + $this->assertSame( 'http://8.8.8.8', beans_url_to_path( 'http://8.8.8.8' ) ); + $this->assertSame( 'http://8000:8.8.8.8', beans_url_to_path( 'http://8000:8.8.8.8' ) ); + } + + /** + * Test beans_url_to_path() bails out for an external URL that has an internal path, i.e. + * meaning the site's URL is within the URL's path. + * + * @ticket 65 + */ + public function test_should_bail_out_when_external_url_with_internal_path() { + Functions\expect( 'site_url' )->twice()->andReturn( 'http://getbeans.io' ); + $this->assertSame( + 'http://example.com/cool-stuff-at-getbeans.io', + beans_url_to_path( 'http://example.com/cool-stuff-at-getbeans.io' ) + ); + $this->assertSame( + 'http://8.8.8.8/cool-stuff-at-shop.getbeans.io', + beans_url_to_path( 'http://8.8.8.8/cool-stuff-at-shop.getbeans.io' ) + ); + + Functions\expect( 'site_url' )->twice()->andReturn( 'https://www.getbeans.io' ); + $this->assertSame( + 'http://example.com/cool-stuff-at-www.getbeans.io', + beans_url_to_path( 'http://example.com/cool-stuff-at-www.getbeans.io' ) + ); + $this->assertSame( + 'http://8.8.8.8/cool-stuff-at-shop.getbeans.io', + beans_url_to_path( 'http://8.8.8.8/cool-stuff-at-shop.getbeans.io' ) + ); + + Functions\expect( 'site_url' )->twice()->andReturn( 'http://shop.getbeans.io' ); + $this->assertSame( + 'http://example.com/cool-stuff-at-shop.getbeans.io', + beans_url_to_path( 'http://example.com/cool-stuff-at-shop.getbeans.io' ) + ); + $this->assertSame( + 'http://8.8.8.8/cool-stuff-at-shop.getbeans.io', + beans_url_to_path( 'http://8.8.8.8/cool-stuff-at-shop.getbeans.io' ) + ); + } + + /** + * Test beans_url_to_path() converts the URL. + */ + public function test_should_convert_domain_url() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + Functions\expect( 'site_url' )->twice()->andReturn( 'https://example.com' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://example.com', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://example.com/', true ) ); + + Functions\expect( 'site_url' )->twice()->andReturn( 'http://foo.com/' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://foo.com', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://foo.com/', true ) ); + + Functions\expect( 'site_url' )->times( 3 )->andReturn( 'https://example.com' ); + $this->assertSame( + ABSPATH . 'foo/bar/index.php', + beans_url_to_path( 'https://example.com/foo/bar/index.php', true ) + ); + $this->assertSame( + ABSPATH . 'foo/bar/', + beans_url_to_path( 'https://example.com/foo/bar/', true ) + ); + $this->assertSame( + ABSPATH . 'foo/bar/baz/', + beans_url_to_path( 'https://example.com/foo/bar/baz/', true ) + ); + } + + /** + * Test beans_url_to_path() should converts IP addresses. + */ + public function test_should_convert_ip_address() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + Functions\expect( 'site_url' )->twice()->andReturn( 'https://8.8.8.8' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://8.8.8.8', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://8.8.8.8/', true ) ); + + Functions\expect( 'site_url' )->twice()->andReturn( 'https://8.8.8.8/' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://8.8.8.8', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://8.8.8.8/', true ) ); + + Functions\expect( 'site_url' )->andReturn( 'https://8.8.8.8' ); + $this->assertSame( + ABSPATH . 'foo/bar/index.php', + beans_url_to_path( 'https://8.8.8.8/foo/bar/index.php', true ) + ); + $this->assertSame( + ABSPATH . 'foo/bar/', + beans_url_to_path( 'https://8.8.8.8/foo/bar/', true ) + ); + $this->assertSame( + ABSPATH . 'foo/bar/baz/', + beans_url_to_path( 'https://8.8.8.8/foo/bar/baz/', true ) + ); + } + + /** + * Test beans_url_to_path() converts for domain and removes the subfolder. + */ + public function test_should_convert_domain_and_removes_subfolder() { + Functions\expect( 'is_main_site' )->andReturn( true ); + Functions\expect( 'site_url' )->times( 3 )->andReturn( 'https://example.com/blog/' ); + + $this->assertSame( + ABSPATH . 'blog/', + beans_url_to_path( 'https://example.com/blog/', true ) + ); + + $this->assertSame( + ABSPATH . 'blog/foo/bar/', + beans_url_to_path( 'https://example.com/blog/foo/bar/', true ) + ); + + $this->assertSame( + ABSPATH . 'blog/foo/bar/baz/', + beans_url_to_path( 'https://example.com/blog/foo/bar/baz/', true ) + ); + } + + /** + * Test beans_url_to_path() converts for IP address and removes the subfolder. + */ + public function test_should_convert_ip_and_removes_subfolder() { + Functions\expect( 'is_main_site' )->andReturn( true ); + Functions\expect( 'site_url' )->andReturn( 'https://8.8.8.8/blog/' ); + + $this->assertSame( + ABSPATH . 'blog/', + beans_url_to_path( 'https://8.8.8.8/blog/', true ) + ); + + $this->assertSame( + ABSPATH . 'blog/foo/bar/', + beans_url_to_path( 'https://8.8.8.8/blog/foo/bar/', true ) + ); + + $this->assertSame( + ABSPATH . 'blog/foo/bar/baz/', + beans_url_to_path( 'https://8.8.8.8/blog/foo/bar/baz/', true ) + ); + } + + /** + * Test beans_url_to_path() converts for domain and removes all subfolders. + */ + public function test_should_convert_domain_and_removes_subfolders() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + Functions\expect( 'site_url' )->times( 3 )->andReturn( 'https://example.com/blog/' ); + + $this->assertSame( + ABSPATH . 'blog/', + beans_url_to_path( 'https://example.com/blog/', true ) + ); + + $this->assertSame( + ABSPATH . 'blog/foo/bar/', + beans_url_to_path( 'https://example.com/blog/foo/bar/', true ) + ); + + $this->assertSame( + ABSPATH . 'blog/foo/bar/baz/', + beans_url_to_path( 'https://example.com/blog/foo/bar/baz/', true ) + ); + } + + /** + * Test beans_url_to_path() converts for domain and removes all subfolders. + */ + public function test_should_convert_ip_and_removes_subfolders() { + Functions\expect( 'is_main_site' )->andReturn( true ); + Functions\expect( 'site_url' )->andReturn( 'https://8.8.8.8/blog/foo' ); + + $this->assertSame( + ABSPATH . 'blog/', + beans_url_to_path( 'https://8.8.8.8/blog/', true ) + ); + + $this->assertSame( + ABSPATH . 'blog/foo/bar/', + beans_url_to_path( 'https://8.8.8.8/blog/foo/bar/', true ) + ); + + $this->assertSame( + ABSPATH . 'blog/foo/bar/baz/', + beans_url_to_path( 'https://8.8.8.8/blog/foo/bar/baz/', true ) + ); + } + + /** + * Test beans_url_to_path() converts a relative URL. + * + * @ticket 63 + */ + public function test_should_convert_relative_urls() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + Functions\expect( 'site_url' )->times( 6 )->andReturn( 'https://example.com' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( '//example.com', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'example.com', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'example.com/', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'www.example.com/', true ) ); + $this->assertSame( ABSPATH . 'foo', beans_url_to_path( 'example.com/foo', true ) ); + $this->assertSame( ABSPATH . 'foo/', beans_url_to_path( 'example.com/foo/', true ) ); + } + + + /** + * Test beans_url_to_path() converts a relative URL. + * + * @ticket 63 + */ + public function test_should_convert_relative_ip_address() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + Functions\expect( 'site_url' )->times( 6 )->andReturn( 'https://8.8.8.8' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( '//8.8.8.8', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( '8.8.8.8', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( '8.8.8.8/', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'www.8.8.8.8/', true ) ); + $this->assertSame( ABSPATH . 'foo', beans_url_to_path( '8.8.8.8/foo', true ) ); + $this->assertSame( ABSPATH . 'foo/', beans_url_to_path( '8.8.8.8/foo/', true ) ); + } + + /** + * Test beans_url_to_path() converts the domain URL and removes the tilde. + */ + public function test_should_convert_url_and_remove_tilde() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + Functions\expect( 'site_url' )->andReturn( 'https://foo.com' ); + + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://foo.com/~subdomain', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://foo.com/~subdomain/', true ) ); + $this->assertSame( ABSPATH . 'foo', beans_url_to_path( 'https://foo.com/~subdomain/foo', true ) ); + $this->assertSame( ABSPATH . 'foo/', beans_url_to_path( 'https://foo.com/~subdomain/foo/', true ) ); + $this->assertSame( ABSPATH . 'bar/~subdomain/foo/', beans_url_to_path( 'https://foo.com/bar/~subdomain/foo/', true ) ); + } + + /** + * Test beans_url_to_path() converts the IP address and removes the tilde. + */ + public function test_should_convert_ip_and_remove_tilde() { + Functions\expect( 'is_main_site' )->andReturn( true ); + + Functions\expect( 'site_url' )->andReturn( 'https://255.255.255.255' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://255.255.255.255/~subdomain', true ) ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://255.255.255.255/~subdomain/', true ) ); + $this->assertSame( ABSPATH . 'foo', beans_url_to_path( 'https://255.255.255.255/~subdomain/foo', true ) ); + $this->assertSame( ABSPATH . 'foo/', beans_url_to_path( 'https://255.255.255.255/~subdomain/foo/', true ) ); + $this->assertSame( ABSPATH . 'bar/~subdomain/foo/', beans_url_to_path( 'https://255.255.255.255/bar/~subdomain/foo/', true ) ); + } + + /** + * Test beans_url_to_path() converts domain for subdirectory multisite. + */ + public function test_converts_domain_for_subdirectory_multisite() { + Functions\expect( 'is_main_site' )->andReturn( false ); + Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); + + Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/shop/' ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'http://example.com/shop/' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://example.com/shop/', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'http://example.com/shop/image.png' ); + $this->assertSame( ABSPATH . 'image.png', beans_url_to_path( 'http://example.com/shop/image.png', true ) ); + } + + /** + * Test beans_url_to_path() converts IP address for subdirectory multisite. + */ + public function test_converts_ip_for_subdirectory_multisite() { + Functions\expect( 'is_main_site' )->andReturn( false ); + Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); + + Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/shop/' ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'http://8.8.8.8/shop/' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://8.8.8.8/shop/', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'http://50.50.50.50/shop/image.png' ); + $this->assertSame( ABSPATH . 'image.png', beans_url_to_path( 'http://50.50.50.50/shop/image.png', true ) ); + } + + /** + * Test beans_url_to_path() converts domain for subdomain multisite. + */ + public function test_converts_domain_for_subdomain_multisite() { + Functions\expect( 'is_main_site' )->andReturn( false ); + Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); + + Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); + Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.example.com' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://shop.example.com', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.example.com/image.jpg/foo' ); + $this->assertSame( ABSPATH . 'image.jpg', beans_url_to_path( 'http://shop.example.com/image.jpg', true ) ); + } + + /** + * Test beans_url_to_path() converts IP Address for subdomain multisite. + */ + public function test_converts_ip_for_subdomain_multisite() { + Functions\expect( 'is_main_site' )->andReturn( false ); + Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); + + Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); + Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.255.147.55.10' ); + $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://shop.255.147.55.10', true ) ); + + Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.1.2.3.4/image.jpg/foo' ); + $this->assertSame( ABSPATH . 'image.jpg', beans_url_to_path( 'http://shop.1.2.3.4/image.jpg', true ) ); + } +} diff --git a/tests/phpunit/unit-tests/class-test-case.php b/tests/phpunit/unit-tests/class-test-case.php new file mode 100644 index 00000000..b68e2814 --- /dev/null +++ b/tests/phpunit/unit-tests/class-test-case.php @@ -0,0 +1,53 @@ +alias( function ( $path ) { + $path = str_replace( '\\', '/', $path ); + $path = preg_replace( '|(?<=.)/+|', '/', $path ); + + if ( ':' === substr( $path, 1, 1 ) ) { + $path = ucfirst( $path ); + } + + return $path; + } ); + } + + /** + * Cleans up the test environment after each test. + */ + protected function tearDown() { + Monkey\tearDown(); + parent::tearDown(); + } +} From 63829ea193a219ddb9d2c5f9c4690bf039ed1850 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Fri, 24 Nov 2017 01:59:27 -0600 Subject: [PATCH 012/800] Fixed extra forwardslash in loading api utility file (#73) Existed in setup of each utility unit test. --- tests/phpunit/bootstrap.php | 1 - tests/phpunit/unit-tests/api/utilities/beansGet.php | 2 +- .../unit-tests/api/utilities/beansMultiArrayKeyExists.php | 2 +- tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php | 2 +- tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php | 2 +- tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php | 2 +- .../unit-tests/api/utilities/beansRenderFunctionArray.php | 2 +- tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php | 2 +- tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php | 2 +- 9 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index 3415e6a2..54f2b538 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -13,7 +13,6 @@ } define( 'BEANS_TESTS_DIR', __DIR__ ); - define( 'BEANS_TESTS_LIB_DIR', dirname( dirname( __DIR__ ) ) . '/lib/' ); /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansGet.php b/tests/phpunit/unit-tests/api/utilities/beansGet.php index 94c3991f..bcde0a4b 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansGet.php +++ b/tests/phpunit/unit-tests/api/utilities/beansGet.php @@ -26,7 +26,7 @@ class Tests_BeansGet extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . '/api/utilities/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php b/tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php index a021c216..73c58cad 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php +++ b/tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php @@ -26,7 +26,7 @@ class Tests_BeansMultiArrayKeyExists extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . '/api/utilities/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php b/tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php index c6b55233..e0b5428b 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php +++ b/tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php @@ -27,7 +27,7 @@ class Tests_BeansPathToUrl extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . '/api/utilities/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php b/tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php index ae1c964e..86974e06 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php +++ b/tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php @@ -27,7 +27,7 @@ class Tests_BeansRemoveDir extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . '/api/utilities/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php b/tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php index c8538ac0..cec790da 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php +++ b/tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php @@ -27,7 +27,7 @@ class Tests_BeansRenderFunction extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . '/api/utilities/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php b/tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php index dfdfb425..3dc5e24f 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php +++ b/tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php @@ -26,7 +26,7 @@ class Tests_BeansRenderFunctionArray extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . '/api/utilities/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php b/tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php index 512d35c6..aa0493dc 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php +++ b/tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php @@ -26,7 +26,7 @@ class Tests_BeansSanitizePath extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . '/api/utilities/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php b/tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php index fe30999e..0cc273f2 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php +++ b/tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php @@ -27,7 +27,7 @@ class Tests_BeansUrlToPath extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . '/api/utilities/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } /** From d01ebaa446fa8057e6f0a9effd36b02a3513e644 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Tue, 5 Dec 2017 01:25:15 -0600 Subject: [PATCH 013/800] WP Dev Lib setup with Travis and architecture refactoring (#81) --- .dev-lib | 11 + .gitignore | 2 + .travis.yml | 24 + bin/install-pre-commit-hook.sh | 46 + bin/pre-commit | 17 + bin/travis.sh | 27 + composer.json | 19 +- composer.lock | 2106 ----------------- phpunit.xml.dist | 16 +- tests/phpunit/class-bootstrap.php | 34 - tests/phpunit/integration-tests/bootstrap.php | 62 - .../integration-tests/integrationSetup.php | 30 - tests/phpunit/integration/bootstrap.php | 52 + .../integrationSample.php | 14 +- tests/phpunit/integration/phpunit.xml.dist | 21 + .../api/utilities/beansGet.php | 8 +- .../utilities/beansMultiArrayKeyExists.php | 30 +- .../api/utilities/beansPathToUrl.php | 8 +- .../api/utilities/beansRemoveDir.php | 8 +- .../api/utilities/beansRenderFunction.php | 8 +- .../utilities/beansRenderFunctionArray.php | 6 +- .../api/utilities/beansSanitizePath.php | 12 +- .../api/utilities/beansUrlToPath.php | 8 +- tests/phpunit/{ => unit}/bootstrap.php | 14 +- .../{unit-tests => unit}/class-test-case.php | 14 +- 25 files changed, 286 insertions(+), 2311 deletions(-) create mode 100644 .dev-lib create mode 100644 .travis.yml create mode 100755 bin/install-pre-commit-hook.sh create mode 100755 bin/pre-commit create mode 100644 bin/travis.sh delete mode 100644 composer.lock delete mode 100644 tests/phpunit/class-bootstrap.php delete mode 100644 tests/phpunit/integration-tests/bootstrap.php delete mode 100644 tests/phpunit/integration-tests/integrationSetup.php create mode 100644 tests/phpunit/integration/bootstrap.php rename tests/phpunit/{integration-tests => integration}/integrationSample.php (56%) create mode 100644 tests/phpunit/integration/phpunit.xml.dist rename tests/phpunit/{unit-tests => unit}/api/utilities/beansGet.php (86%) rename tests/phpunit/{unit-tests => unit}/api/utilities/beansMultiArrayKeyExists.php (83%) rename tests/phpunit/{unit-tests => unit}/api/utilities/beansPathToUrl.php (98%) rename tests/phpunit/{unit-tests => unit}/api/utilities/beansRemoveDir.php (93%) rename tests/phpunit/{unit-tests => unit}/api/utilities/beansRenderFunction.php (90%) rename tests/phpunit/{unit-tests => unit}/api/utilities/beansRenderFunctionArray.php (93%) rename tests/phpunit/{unit-tests => unit}/api/utilities/beansSanitizePath.php (78%) rename tests/phpunit/{unit-tests => unit}/api/utilities/beansUrlToPath.php (98%) rename tests/phpunit/{ => unit}/bootstrap.php (62%) rename tests/phpunit/{unit-tests => unit}/class-test-case.php (72%) diff --git a/.dev-lib b/.dev-lib new file mode 100644 index 00000000..8c2a7803 --- /dev/null +++ b/.dev-lib @@ -0,0 +1,11 @@ +PROJECT_TYPE=theme +CHECK_SCOPE=changed-files +WPCS_STANDARD=phpcs.xml.dist +PATH_EXCLUDES_PATTERN='^(.*/)?(vendors|vendor|node_modules)/.*' +DEV_LIB_SKIP=yuicompressor,codeception,grunt,jshint + +# Run integration tests when the DEV_LIB_ONLY is set to phpunit +# This is the only flag we can use to change the config file +if [ 'phpunit' == "$DEV_LIB_ONLY" ]; then + PHPUNIT_CONFIG=tests/phpunit/integration/phpunit.xml.dist +fi diff --git a/.gitignore b/.gitignore index e53db368..b7e87e2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.DS_Store +composer.lock /node_modules/ /vendor/ /logs/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..1bd4fbe8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: php +sudo: false + +cache: + directories: + node_modules + vendor + +matrix: + include: + - php: '5.6' + - php: '7.0' + - php: '7.1' + - php: '7.2' + +install: + - export DEV_LIB_PATH=vendor/xwp/wp-dev-lib + - source $DEV_LIB_PATH/travis.install.sh + +script: + - source bin/travis.sh + +after_script: + - source $DEV_LIB_PATH/travis.after_script.sh diff --git a/bin/install-pre-commit-hook.sh b/bin/install-pre-commit-hook.sh new file mode 100755 index 00000000..d517cb30 --- /dev/null +++ b/bin/install-pre-commit-hook.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Link pre-commit hook for a repo in the directory supplied as an argument, or the parent repo of this file. +# +# USAGES: +# $ /path/to/install-pre-commit-hook.sh +# $ /path/to/install-pre-commit-hook.sh wp-content/themes/my-theme + +set -e + +# Check if Perl is installed +command -v perl >/dev/null 2>&1 || { echo >&2 "Perl is not installed, and is required by this script. See how to install it on http://learn.perl.org/installing"; exit 1; } + +# Store the initial directory to return back to it later +OLDPWD=$(pwd) + +# Navigate to the script directory +cd "$(dirname $0)" + +# Get full path of the script directory +BINDIR=$(pwd) + +# Get back to the calling directory +cd - &> /dev/null + +# If passed a destination, switch to it to get the full path and then .git/hooks directory +if [ ! -z "$1" ]; then + cd $1 + DEST=$(pwd) +fi + +# Get the hooks directory of the current git repo +cd "$(git rev-parse --git-dir)/hooks" + +# Get relative path to the original file from within the hooks directory +RELPATH=$( perl -e 'use File::Spec; print File::Spec->abs2rel(@ARGV)' "$BINDIR/pre-commit" "$(pwd)" ) + +if [ -z "$RELPATH" ]; then + echo 'Could not determine the relative path, Sorry. Try symlinking the file manually.' + exit 1 +fi + +echo "## Placing pre-commit file in $(pwd) from $RELPATH" +ln -s "$RELPATH" . + +# Return back to the calling directory +cd "$OLDPWD" &> /dev/null diff --git a/bin/pre-commit b/bin/pre-commit new file mode 100755 index 00000000..0c7be46e --- /dev/null +++ b/bin/pre-commit @@ -0,0 +1,17 @@ +#!/bin/bash +DEV_LIB_HOOK_PATH='./vendor/xwp/wp-dev-lib/pre-commit' + +# Exit if the dev lib isn't installed +if [ ! -f $DEV_LIB_HOOK_PATH ]; then + echo "Oops, the Dev Library is not install, please run composer install!" +else + # Run sniffers and unit tests. + export PATH="./vendor/bin:$PATH" + export WP_TESTS_DIR='exclude' + $DEV_LIB_HOOK_PATH + + # Run integration tests. + export WP_TESTS_DIR='' + export DEV_LIB_ONLY=phpunit + $DEV_LIB_HOOK_PATH +fi diff --git a/bin/travis.sh b/bin/travis.sh new file mode 100644 index 00000000..b7346ada --- /dev/null +++ b/bin/travis.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +export PATH="./vendor/bin:$PATH" + +# Exit if the dev lib isn't installed +if [ ! -f $DEV_LIB_TRAVIS_PATH ]; then + echo "Oops, the Dev Library is not install, please run composer install!" +else + echo "## Checking files, scope $CHECK_SCOPE:" + if [[ $CHECK_SCOPE != "all" ]]; then + cat "$TEMP_DIRECTORY/paths-scope" + fi + + # Run sniffers. + lint_js_files + lint_php_files + + # Run unit tests. + echo '## Running unit tests:' + phpunit --testsuite unit + + # Run integration tests. + echo '## Running integration tests:' + export PHPUNIT_CONFIG=tests/phpunit/integration/phpunit.xml.dist + run_phpunit_travisci +fi diff --git a/composer.json b/composer.json index dac32da4..ef236a0f 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,20 @@ "Beans\\Framework\\Tests\\": "tests/" } }, + "repositories": [ + { + "type": "package", + "package": { + "name": "xwp/wp-dev-lib", + "version": "1.0.1", + "source": { + "url": "https://github.com/xwp/wp-dev-lib.git", + "type": "git", + "reference": "master" + } + } + } + ], "require": { "php": "^5.2|^7", "composer/installers": "^1.4", @@ -32,7 +46,8 @@ "wp-coding-standards/wpcs": "^0.14.0", "phpunit/phpunit": "~5.7.9", "brain/monkey": "^2.0", - "mikey179/vfsStream": "^1.6" + "mikey179/vfsStream": "^1.6", + "xwp/wp-dev-lib": "^1.0.1" }, "config": { "sort-order": true @@ -48,6 +63,6 @@ "@phpcs-tests" ], "test-unit": "vendor/bin/phpunit --testsuite unit", - "test-integration": "vendor/bin/phpunit --testsuite integration" + "test-integration": "vendor/bin/phpunit --testsuite integration --configuration tests/phpunit/integration/phpunit.xml.dist" } } diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 0f80efe9..00000000 --- a/composer.lock +++ /dev/null @@ -1,2106 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "fd519171be3f04b2ed6bca41c0676f48", - "content-hash": "8eedeb84b37d0361c9be0190fe2c7d00", - "packages": [ - { - "name": "composer/installers", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/composer/installers.git", - "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b", - "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0" - }, - "replace": { - "roundcube/plugin-installer": "*", - "shama/baton": "*" - }, - "require-dev": { - "composer/composer": "1.0.*@dev", - "phpunit/phpunit": "4.1.*" - }, - "type": "composer-plugin", - "extra": { - "class": "Composer\\Installers\\Plugin", - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Installers\\": "src/Composer/Installers" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kyle Robinson Young", - "email": "kyle@dontkry.com", - "homepage": "https://github.com/shama" - } - ], - "description": "A multi-framework Composer library installer", - "homepage": "https://composer.github.io/installers/", - "keywords": [ - "Craft", - "Dolibarr", - "Eliasis", - "Hurad", - "ImageCMS", - "Kanboard", - "Lan Management System", - "MODX Evo", - "Mautic", - "Maya", - "OXID", - "Plentymarkets", - "Porto", - "RadPHP", - "SMF", - "Thelia", - "WolfCMS", - "agl", - "aimeos", - "annotatecms", - "attogram", - "bitrix", - "cakephp", - "chef", - "cockpit", - "codeigniter", - "concrete5", - "croogo", - "dokuwiki", - "drupal", - "eZ Platform", - "elgg", - "expressionengine", - "fuelphp", - "grav", - "installer", - "itop", - "joomla", - "kohana", - "laravel", - "lavalite", - "lithium", - "magento", - "mako", - "mediawiki", - "modulework", - "moodle", - "osclass", - "phpbb", - "piwik", - "ppi", - "puppet", - "reindex", - "roundcube", - "shopware", - "silverstripe", - "sydes", - "symfony", - "typo3", - "wordpress", - "yawik", - "zend", - "zikula" - ], - "time": "2017-08-09 07:53:48" - }, - { - "name": "roave/security-advisories", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "bf2267389f86ae9a168fd0166be59d36ffc07827" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/bf2267389f86ae9a168fd0166be59d36ffc07827", - "reference": "bf2267389f86ae9a168fd0166be59d36ffc07827", - "shasum": "" - }, - "conflict": { - "adodb/adodb-php": "<5.20.6", - "amphp/artax": ">=2,<2.0.6|<1.0.6", - "aws/aws-sdk-php": ">=3,<3.2.1", - "bugsnag/bugsnag-laravel": ">=2,<2.0.2", - "cakephp/cakephp": ">=2,<2.4.99|>=2.5,<2.5.99|>=2.6,<2.6.12|>=2.7,<2.7.6|>=3,<3.0.15|>=3.1,<3.1.4|>=1.3,<1.3.18", - "cart2quote/module-quotation": ">=4.1.6,<=4.4.5|>=5,<5.4.4", - "cartalyst/sentry": "<2.1", - "codeigniter/framework": "<=3.0.6", - "composer/composer": "<=1.0.0-alpha11", - "contao-components/mediaelement": ">=2.14.2,<2.21.1", - "contao/core": ">=2,<3.5.31", - "contao/core-bundle": ">=4,<4.4.8", - "contao/listing-bundle": ">=4,<4.4.8", - "doctrine/annotations": ">=1,<1.2.7", - "doctrine/cache": ">=1,<1.3.2|>=1.4,<1.4.2", - "doctrine/common": ">=2,<2.4.3|>=2.5,<2.5.1", - "doctrine/dbal": ">=2,<2.0.8|>=2.1,<2.1.2", - "doctrine/doctrine-bundle": "<1.5.2", - "doctrine/doctrine-module": "<=0.7.1", - "doctrine/mongodb-odm": ">=1,<1.0.2", - "doctrine/mongodb-odm-bundle": ">=2,<3.0.1", - "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1", - "dompdf/dompdf": ">=0.6,<0.6.2", - "drupal/core": ">=8,<8.3.7", - "drupal/drupal": ">=8,<8.3.7", - "ezsystems/ezpublish-legacy": ">=2017.8,<2017.8.1.1|>=5.4,<5.4.10.1|>=5.3,<5.3.12.2", - "firebase/php-jwt": "<2", - "friendsofsymfony/rest-bundle": ">=1.2,<1.2.2", - "friendsofsymfony/user-bundle": ">=1.2,<1.3.5", - "gregwar/rst": "<1.0.3", - "guzzlehttp/guzzle": ">=6,<6.2.1|>=4.0.0-rc2,<4.2.4|>=5,<5.3.1", - "illuminate/auth": ">=4,<4.0.99|>=4.1,<4.1.26", - "illuminate/database": ">=4,<4.0.99|>=4.1,<4.1.29", - "joomla/session": "<1.3.1", - "laravel/framework": ">=4,<4.0.99|>=4.1,<4.1.29", - "laravel/socialite": ">=1,<1.0.99|>=2,<2.0.10", - "magento/magento1ce": ">=1.5.0.1,<1.9.3.2", - "magento/magento1ee": ">=1.9,<1.14.3.2", - "magento/magento2ce": ">=2,<2.2", - "monolog/monolog": ">=1.8,<1.12", - "namshi/jose": "<2.2", - "onelogin/php-saml": "<2.10.4", - "oro/crm": ">=1.7,<1.7.4", - "oro/platform": ">=1.7,<1.7.4", - "phpmailer/phpmailer": ">=5,<5.2.24", - "phpunit/phpunit": ">=5.0.10,<5.6.3|>=4.8.19,<4.8.28", - "phpxmlrpc/extras": "<6.0.1", - "pusher/pusher-php-server": "<2.2.1", - "sabre/dav": ">=1.6,<1.6.99|>=1.7,<1.7.11|>=1.8,<1.8.9", - "shopware/shopware": "<5.2.25", - "silverstripe/cms": ">=3,<=3.0.11|>=3.1,<3.1.11", - "silverstripe/forum": "<=0.6.1|>=0.7,<=0.7.3", - "silverstripe/framework": ">=3,<3.3", - "silverstripe/userforms": "<3", - "simplesamlphp/saml2": "<1.8.1|>=1.9,<1.9.1|>=1.10,<1.10.3|>=2,<2.3.3", - "simplesamlphp/simplesamlphp": "<1.14.16", - "simplesamlphp/simplesamlphp-module-infocard": "<1.0.1", - "socalnick/scn-social-auth": "<1.15.2", - "squizlabs/php_codesniffer": ">=1,<2.8.1", - "swiftmailer/swiftmailer": ">=4,<5.4.5", - "symfony/dependency-injection": ">=2,<2.0.17", - "symfony/form": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13|>=2.3,<2.3.35|>=2.4,<2.6.12", - "symfony/framework-bundle": ">=2,<2.3.18|>=2.4,<2.4.8|>=2.5,<2.5.2", - "symfony/http-foundation": ">=2,<2.3.27|>=2.4,<2.5.11|>=2.6,<2.6.6", - "symfony/http-kernel": ">=2,<2.3.29|>=2.4,<2.5.12|>=2.6,<2.6.8", - "symfony/intl": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", - "symfony/routing": ">=2,<2.0.19", - "symfony/security": ">=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2.3,<2.3.37|>=2.4,<2.6.13|>=2.7,<2.7.9|>=2,<2.0.25|>=2.1,<2.1.13|>=2.2,<2.2.9", - "symfony/security-core": ">=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5|>=2.4,<2.6.13|>=2.7,<2.7.9|>=2.8,<2.8.6|>=3,<3.0.6", - "symfony/security-csrf": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", - "symfony/security-http": ">=2.4,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13|>=2.3,<2.3.41", - "symfony/serializer": ">=2,<2.0.11", - "symfony/symfony": ">=2,<2.3.41|>=2.4,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", - "symfony/translation": ">=2,<2.0.17", - "symfony/validator": ">=2,<2.0.24|>=2.1,<2.1.12|>=2.2,<2.2.5|>=2.3,<2.3.3", - "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", - "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7", - "thelia/backoffice-default-template": ">=2.1,<2.1.2", - "thelia/thelia": ">=2.1,<2.1.2|>=2.1.0-beta1,<2.1.3", - "twig/twig": "<1.20", - "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.22|>=8,<8.7.5", - "typo3/flow": ">=1,<1.0.4|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5|>=1.1,<1.1.1|>=2,<2.0.1", - "typo3/neos": ">=1.2,<1.2.13|>=2,<2.0.4|>=1.1,<1.1.3", - "willdurand/js-translation-bundle": "<2.1.1", - "yiisoft/yii": ">=1.1.14,<1.1.15", - "yiisoft/yii2": "<2.0.5", - "yiisoft/yii2-bootstrap": "<2.0.4", - "yiisoft/yii2-dev": "<2.0.4", - "yiisoft/yii2-gii": "<2.0.4", - "yiisoft/yii2-jui": "<2.0.4", - "zendframework/zend-cache": ">=2.4,<2.4.8|>=2.5,<2.5.3", - "zendframework/zend-captcha": ">=2,<2.4.9|>=2.5,<2.5.2", - "zendframework/zend-crypt": ">=2,<2.4.9|>=2.5,<2.5.2", - "zendframework/zend-db": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.10|>=2.3,<2.3.5", - "zendframework/zend-diactoros": ">=1,<1.0.4", - "zendframework/zend-form": ">=2,<2.2.7|>=2.3,<2.3.1", - "zendframework/zend-http": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.3,<2.3.8|>=2.4,<2.4.1", - "zendframework/zend-json": ">=2.1,<2.1.6|>=2.2,<2.2.6", - "zendframework/zend-ldap": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.8|>=2.3,<2.3.3", - "zendframework/zend-mail": ">=2,<2.4.11|>=2.5,<2.7.2", - "zendframework/zend-navigation": ">=2,<2.2.7|>=2.3,<2.3.1", - "zendframework/zend-session": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.9|>=2.3,<2.3.4", - "zendframework/zend-validator": ">=2.3,<2.3.6", - "zendframework/zend-view": ">=2,<2.2.7|>=2.3,<2.3.1", - "zendframework/zend-xmlrpc": ">=2.1,<2.1.6|>=2.2,<2.2.6", - "zendframework/zendframework": ">=2,<2.4.11|>=2.5,<2.5.1", - "zendframework/zendframework1": "<1.12.20", - "zendframework/zendopenid": ">=2,<2.0.2", - "zendframework/zendxml": ">=1,<1.0.1", - "zetacomponents/mail": "<1.8.2", - "zf-commons/zfc-user": "<1.2.2", - "zfcampus/zf-apigility-doctrine": ">=1,<1.0.3", - "zfr/zfr-oauth2-server-module": "<0.1.2" - }, - "type": "metapackage", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "role": "maintainer" - } - ], - "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", - "time": "2017-11-17 12:15:33" - } - ], - "packages-dev": [ - { - "name": "antecedent/patchwork", - "version": "2.1.6", - "source": { - "type": "git", - "url": "https://github.com/antecedent/patchwork.git", - "reference": "91608c0c0b3b0d6b04e5bd11406ae0d5d5f7c26e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/antecedent/patchwork/zipball/91608c0c0b3b0d6b04e5bd11406ae0d5d5f7c26e", - "reference": "91608c0c0b3b0d6b04e5bd11406ae0d5d5f7c26e", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignas Rudaitis", - "email": "ignas.rudaitis@gmail.com" - } - ], - "description": "Method redefinition (monkey-patching) functionality for PHP.", - "homepage": "http://patchwork2.org/", - "keywords": [ - "aop", - "aspect", - "interception", - "monkeypatching", - "redefinition", - "runkit", - "testing" - ], - "time": "2017-11-05 10:37:19" - }, - { - "name": "brain/monkey", - "version": "2.1.0", - "source": { - "type": "git", - "url": "https://github.com/Brain-WP/BrainMonkey.git", - "reference": "98fd6de9f094b189d430a1d27cb35f86b00ec115" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/98fd6de9f094b189d430a1d27cb35f86b00ec115", - "reference": "98fd6de9f094b189d430a1d27cb35f86b00ec115", - "shasum": "" - }, - "require": { - "antecedent/patchwork": "^2.0", - "mockery/mockery": "~0.9.0", - "php": ">=5.6.0" - }, - "require-dev": { - "phpunit/phpunit": "~5.7.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-version/1": "1.x-dev", - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Brain\\Monkey\\": "src/" - }, - "files": [ - "inc/api.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Giuseppe Mazzapica", - "email": "giuseppe.mazzapica@gmail.com", - "homepage": "https://gmazzap.me", - "role": "Developer" - } - ], - "description": "Mocking utility for PHP functions and WordPress plugin API", - "keywords": [ - "Monkey Patching", - "interception", - "mock", - "mock functions", - "mockery", - "patchwork", - "redefinition", - "runkit", - "test", - "testing" - ], - "time": "2017-09-28 18:57:07" - }, - { - "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.4.3", - "source": { - "type": "git", - "url": "https://github.com/DealerDirect/phpcodesniffer-composer-installer.git", - "reference": "63c0ec0ac286d31651d3c70e5bf76ad87db3ba23" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/DealerDirect/phpcodesniffer-composer-installer/zipball/63c0ec0ac286d31651d3c70e5bf76ad87db3ba23", - "reference": "63c0ec0ac286d31651d3c70e5bf76ad87db3ba23", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0", - "php": "^5.3|^7", - "squizlabs/php_codesniffer": "*" - }, - "require-dev": { - "composer/composer": "*", - "wimg/php-compatibility": "^8.0" - }, - "suggest": { - "dealerdirect/qa-tools": "All the PHP QA tools you'll need" - }, - "type": "composer-plugin", - "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" - }, - "autoload": { - "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Franck Nijhof", - "email": "f.nijhof@dealerdirect.nl", - "homepage": "http://workingatdealerdirect.eu", - "role": "Developer" - } - ], - "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://workingatdealerdirect.eu", - "keywords": [ - "PHPCodeSniffer", - "PHP_CodeSniffer", - "code quality", - "codesniffer", - "composer", - "installer", - "phpcs", - "plugin", - "qa", - "quality", - "standard", - "standards", - "style guide", - "stylecheck", - "tests" - ], - "time": "2017-09-18 07:49:36" - }, - { - "name": "doctrine/instantiator", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2017-07-22 11:58:36" - }, - { - "name": "hamcrest/hamcrest-php", - "version": "v1.2.2", - "source": { - "type": "git", - "url": "https://github.com/hamcrest/hamcrest-php.git", - "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c", - "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "replace": { - "cordoval/hamcrest-php": "*", - "davedevelopment/hamcrest-php": "*", - "kodova/hamcrest-php": "*" - }, - "require-dev": { - "phpunit/php-file-iterator": "1.3.3", - "satooshi/php-coveralls": "dev-master" - }, - "type": "library", - "autoload": { - "classmap": [ - "hamcrest" - ], - "files": [ - "hamcrest/Hamcrest.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD" - ], - "description": "This is the PHP port of Hamcrest Matchers", - "keywords": [ - "test" - ], - "time": "2015-05-11 14:41:42" - }, - { - "name": "mikey179/vfsStream", - "version": "v1.6.5", - "source": { - "type": "git", - "url": "https://github.com/mikey179/vfsStream.git", - "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", - "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6.x-dev" - } - }, - "autoload": { - "psr-0": { - "org\\bovigo\\vfs\\": "src/main/php" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Frank Kleine", - "homepage": "http://frankkleine.de/", - "role": "Developer" - } - ], - "description": "Virtual file system to mock the real file system in unit tests.", - "homepage": "http://vfs.bovigo.org/", - "time": "2017-08-01 08:02:14" - }, - { - "name": "mockery/mockery", - "version": "0.9.9", - "source": { - "type": "git", - "url": "https://github.com/mockery/mockery.git", - "reference": "6fdb61243844dc924071d3404bb23994ea0b6856" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/6fdb61243844dc924071d3404bb23994ea0b6856", - "reference": "6fdb61243844dc924071d3404bb23994ea0b6856", - "shasum": "" - }, - "require": { - "hamcrest/hamcrest-php": "~1.1", - "lib-pcre": ">=7.0", - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.9.x-dev" - } - }, - "autoload": { - "psr-0": { - "Mockery": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Pádraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - }, - { - "name": "Dave Marshall", - "email": "dave.marshall@atstsolutions.co.uk", - "homepage": "http://davedevelopment.co.uk" - } - ], - "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", - "homepage": "http://github.com/padraic/mockery", - "keywords": [ - "BDD", - "TDD", - "library", - "mock", - "mock objects", - "mockery", - "stub", - "test", - "test double", - "testing" - ], - "time": "2017-02-28 12:52:32" - }, - { - "name": "myclabs/deep-copy", - "version": "1.7.0", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^4.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2017-10-19 19:58:43" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "time": "2017-09-11 18:02:19" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "4.1.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2d3d238c433cf69caeb4842e97a3223a116f94b2", - "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2", - "shasum": "" - }, - "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.4.0", - "webmozart/assert": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-08-30 18:51:59" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "0.4.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", - "shasum": "" - }, - "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "time": "2017-07-14 14:27:02" - }, - { - "name": "phpspec/prophecy", - "version": "v1.7.2", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.7.x-dev" - } - }, - "autoload": { - "psr-0": { - "Prophecy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2017-09-04 11:05:03" - }, - { - "name": "phpunit/php-code-coverage", - "version": "4.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^5.6 || ^7.0", - "phpunit/php-file-iterator": "^1.3", - "phpunit/php-text-template": "^1.2", - "phpunit/php-token-stream": "^1.4.2 || ^2.0", - "sebastian/code-unit-reverse-lookup": "^1.0", - "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "^1.0 || ^2.0" - }, - "require-dev": { - "ext-xdebug": "^2.1.4", - "phpunit/phpunit": "^5.7" - }, - "suggest": { - "ext-xdebug": "^2.5.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2017-04-02 07:44:40" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2016-10-03 07:40:28" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21 13:50:34" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.9", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2017-02-26 11:10:40" - }, - { - "name": "phpunit/php-token-stream", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.2.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2017-08-20 05:47:52" - }, - { - "name": "phpunit/phpunit", - "version": "5.7.25", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4b1c822a68ae6577df38a59eb49b046712ec0f6a", - "reference": "4b1c822a68ae6577df38a59eb49b046712ec0f6a", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.0", - "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^4.0.4", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "^1.2.4", - "sebastian/diff": "^1.4.3", - "sebastian/environment": "^1.3.4 || ^2.0", - "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.1", - "sebastian/object-enumerator": "~2.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", - "symfony/yaml": "~2.1|~3.0|~4.0" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2" - }, - "require-dev": { - "ext-pdo": "*" - }, - "suggest": { - "ext-xdebug": "*", - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.7.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2017-11-14 14:50:51" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "3.4.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.6 || ^7.0", - "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^1.2 || ^2.0" - }, - "conflict": { - "phpunit/phpunit": "<5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2017-06-30 09:13:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04 06:30:41" - }, - { - "name": "sebastian/comparator", - "version": "1.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2017-01-29 09:50:25" - }, - { - "name": "sebastian/diff", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2017-05-22 07:24:03" - }, - { - "name": "sebastian/environment", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2016-11-26 07:53:53" - }, - { - "name": "sebastian/exporter", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~2.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2016-11-19 08:54:04" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2015-10-12 03:26:01" - }, - { - "name": "sebastian/object-enumerator", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", - "shasum": "" - }, - "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-02-18 15:18:39" - }, - { - "name": "sebastian/recursion-context", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-11-19 07:33:16" - }, - { - "name": "sebastian/resource-operations", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "shasum": "" - }, - "require": { - "php": ">=5.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28 20:34:47" - }, - { - "name": "sebastian/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03 07:35:21" - }, - { - "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "e586fe27f519e8c7b8ba54d4ffd48da84ff1482b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/e586fe27f519e8c7b8ba54d4ffd48da84ff1482b", - "reference": "e586fe27f519e8c7b8ba54d4ffd48da84ff1482b", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "roave/security-advisories": "dev-master", - "squizlabs/php_codesniffer": "^3.0.2" - }, - "type": "phpcodesniffer-standard", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Payton Swick", - "email": "payton@foolord.com" - } - ], - "description": "A PHPCS sniff to detect problems with variables.", - "time": "2017-11-12 19:56:56" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d667e245d5dcd4d7bf80f26f2c947d476b66213e", - "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0" - }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2017-10-16 22:40:25" - }, - { - "name": "symfony/yaml", - "version": "v3.3.13", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "0938408c4faa518d95230deabb5f595bf0de31b9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/0938408c4faa518d95230deabb5f595bf0de31b9", - "reference": "0938408c4faa518d95230deabb5f595bf0de31b9", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "require-dev": { - "symfony/console": "~2.8|~3.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2017-11-10 18:26:04" - }, - { - "name": "webmozart/assert", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "time": "2016-11-23 20:04:58" - }, - { - "name": "wimg/php-compatibility", - "version": "8.0.1", - "source": { - "type": "git", - "url": "https://github.com/wimg/PHPCompatibility.git", - "reference": "4c4385fb891dff0501009670f988d4fe36785249" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/4c4385fb891dff0501009670f988d4fe36785249", - "reference": "4c4385fb891dff0501009670f988d4fe36785249", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.2 || ^3.0.2" - }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1" - }, - "type": "phpcodesniffer-standard", - "autoload": { - "psr-4": { - "PHPCompatibility\\": "PHPCompatibility/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0" - ], - "authors": [ - { - "name": "Wim Godden", - "role": "lead" - } - ], - "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", - "keywords": [ - "compatibility", - "phpcs", - "standards" - ], - "time": "2017-08-07 19:39:05" - }, - { - "name": "wp-coding-standards/wpcs", - "version": "0.14.0", - "source": { - "type": "git", - "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", - "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/8cadf48fa1c70b2381988e0a79e029e011a8f41c", - "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" - }, - "type": "phpcodesniffer-standard", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Contributors", - "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors" - } - ], - "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", - "keywords": [ - "phpcs", - "standards", - "wordpress" - ], - "time": "2017-11-01 15:10:46" - } - ], - "aliases": [], - "minimum-stability": "dev", - "stability-flags": { - "roave/security-advisories": 20 - }, - "prefer-stable": true, - "prefer-lowest": false, - "platform": { - "php": "^5.2|^7" - }, - "platform-dev": [] -} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c27daaf3..30a69a2e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ - - - - - - ./tests/phpunit/unit-tests/ - - - ./tests/phpunit/integration-tests/ + ./tests/phpunit/unit/ @@ -32,8 +24,4 @@ . - - - - diff --git a/tests/phpunit/class-bootstrap.php b/tests/phpunit/class-bootstrap.php deleted file mode 100644 index 23ffb75f..00000000 --- a/tests/phpunit/class-bootstrap.php +++ /dev/null @@ -1,34 +0,0 @@ -getName() ) { - require_once __DIR__ . '/integration-tests/bootstrap.php'; - } - } -} diff --git a/tests/phpunit/integration-tests/bootstrap.php b/tests/phpunit/integration-tests/bootstrap.php deleted file mode 100644 index 56fb38f5..00000000 --- a/tests/phpunit/integration-tests/bootstrap.php +++ /dev/null @@ -1,62 +0,0 @@ -get_stylesheet(); -} - -/** - * Callback for changing the active template during tests. - * - * @param string $template Existing template name. - * - * @return string Amended template name. - */ -function beans_testing_override_template( $template ) { - return wp_get_theme( BEANS_THEME_DIR )->get_template(); -} - -tests_add_filter( 'setup_theme', 'beans_testing_manually_load_theme' ); - -// Start up the WP testing environment. -require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php'; - -require __DIR__ . '/class-test-case.php'; diff --git a/tests/phpunit/integration-tests/integrationSetup.php b/tests/phpunit/integration-tests/integrationSetup.php deleted file mode 100644 index 11a78d9b..00000000 --- a/tests/phpunit/integration-tests/integrationSetup.php +++ /dev/null @@ -1,30 +0,0 @@ -assertTrue( true ); - } -} diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php new file mode 100644 index 00000000..b842cdd3 --- /dev/null +++ b/tests/phpunit/integration/bootstrap.php @@ -0,0 +1,52 @@ + + + + + + . + + + diff --git a/tests/phpunit/unit-tests/api/utilities/beansGet.php b/tests/phpunit/unit/api/utilities/beansGet.php similarity index 86% rename from tests/phpunit/unit-tests/api/utilities/beansGet.php rename to tests/phpunit/unit/api/utilities/beansGet.php index bcde0a4b..5c2025d4 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansGet.php +++ b/tests/phpunit/unit/api/utilities/beansGet.php @@ -2,19 +2,19 @@ /** * Tests for beans_get() * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * * @since 1.5.0 */ -namespace Beans\Framework\Tests\UnitTests\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Utilities; -use Beans\Framework\Tests\UnitTests\Test_Case; +use Beans\Framework\Tests\Unit\Test_Case; /** * Class Tests_BeansGet * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * @group unit-tests * @group api */ diff --git a/tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php similarity index 83% rename from tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php rename to tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php index 73c58cad..9e4d4d88 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansMultiArrayKeyExists.php +++ b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php @@ -2,19 +2,19 @@ /** * Tests for beans_multi_array_key_exists() * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * * @since 1.5.0 */ -namespace Beans\Framework\Tests\UnitTests\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Utilities; -use Beans\Framework\Tests\UnitTests\Test_Case; +use Beans\Framework\Tests\Unit\Test_Case; /** * Class Tests_BeansMultiArrayKeyExists * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * @group unit-tests * @group api */ @@ -33,10 +33,24 @@ protected function setUp() { * Test beans_multi_array_key_exists() should throw an error for non-array data type. */ public function test_should_throws_error_for_non_array() { - $this->expectException( \TypeError::class ); - $this->assertFalse( beans_multi_array_key_exists( 0, 'bar' ) ); - $this->assertFalse( beans_multi_array_key_exists( 'foo', 10 ) ); - $this->assertFalse( beans_multi_array_key_exists( 'bar', new \stdClass() ) ); + $args = array( + 0 => 'bar', + 'foo' => 10, + 'bar' => new \stdClass(), + ); + + foreach ( $args as $arg1 => $arg2 ) { + try { + beans_multi_array_key_exists( $arg1, $arg2 ); + } catch ( \Throwable $t ) { + $catch = $t; + } catch ( \Exception $e ) { + $catch = $e; + } + + $this->assertNotEmpty( $catch ); + unset( $catch ); + } } /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php b/tests/phpunit/unit/api/utilities/beansPathToUrl.php similarity index 98% rename from tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php rename to tests/phpunit/unit/api/utilities/beansPathToUrl.php index e0b5428b..6960112d 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansPathToUrl.php +++ b/tests/phpunit/unit/api/utilities/beansPathToUrl.php @@ -2,20 +2,20 @@ /** * Tests for beans_path_to_url() * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * * @since 1.5.0 */ -namespace Beans\Framework\Tests\UnitTests\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Utilities; -use Beans\Framework\Tests\UnitTests\Test_Case; +use Beans\Framework\Tests\Unit\Test_Case; use Brain\Monkey\Functions; /** * Class Tests_BeansPathToUrl * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * @group unit-tests * @group api */ diff --git a/tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php b/tests/phpunit/unit/api/utilities/beansRemoveDir.php similarity index 93% rename from tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php rename to tests/phpunit/unit/api/utilities/beansRemoveDir.php index 86974e06..6fe61c3a 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansRemoveDir.php +++ b/tests/phpunit/unit/api/utilities/beansRemoveDir.php @@ -2,20 +2,20 @@ /** * Tests for beans_remove_dir() * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * * @since 1.5.0 */ -namespace Beans\Framework\Tests\UnitTests\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Utilities; -use Beans\Framework\Tests\UnitTests\Test_Case; +use Beans\Framework\Tests\Unit\Test_Case; use org\bovigo\vfs\vfsStream; /** * Class Tests_BeansRemoveDir * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * @group unit-tests * @group api */ diff --git a/tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php b/tests/phpunit/unit/api/utilities/beansRenderFunction.php similarity index 90% rename from tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php rename to tests/phpunit/unit/api/utilities/beansRenderFunction.php index cec790da..f8cd5ffa 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansRenderFunction.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunction.php @@ -2,20 +2,20 @@ /** * Tests for beans_render_function() * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * * @since 1.5.0 */ -namespace Beans\Framework\Tests\UnitTests\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Utilities; -use Beans\Framework\Tests\UnitTests\Test_Case; +use Beans\Framework\Tests\Unit\Test_Case; use Brain\Monkey\Functions; /** * Class Tests_BeansRenderFunction * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * @group unit-tests * @group api */ diff --git a/tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php similarity index 93% rename from tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php rename to tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php index 3dc5e24f..2eac05d8 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansRenderFunctionArray.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php @@ -2,14 +2,14 @@ /** * Tests for beans_render_function_array() * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * * @since 1.5.0 */ -namespace Beans\Framework\Tests\UnitTests\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Utilities; -use Beans\Framework\Tests\UnitTests\Test_Case; +use Beans\Framework\Tests\Unit\Test_Case; /** * Class Tests_BeansRenderFunctionArray diff --git a/tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php b/tests/phpunit/unit/api/utilities/beansSanitizePath.php similarity index 78% rename from tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php rename to tests/phpunit/unit/api/utilities/beansSanitizePath.php index aa0493dc..27e96fec 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansSanitizePath.php +++ b/tests/phpunit/unit/api/utilities/beansSanitizePath.php @@ -2,19 +2,19 @@ /** * Tests for beans_sanitize_path() * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * * @since 1.5.0 */ -namespace Beans\Framework\Tests\UnitTests\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Utilities; -use Beans\Framework\Tests\UnitTests\Test_Case; +use Beans\Framework\Tests\Unit\Test_Case; /** * Class Tests_BeansSanitizePath * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * @group unit-tests * @group api */ @@ -35,8 +35,8 @@ protected function setUp() { public function test_should_sanitize_for_filesystem() { $this->assertSame( BEANS_TESTS_DIR, beans_sanitize_path( BEANS_TESTS_DIR ) ); $this->assertSame( __DIR__, beans_sanitize_path( __DIR__ ) ); - $this->assertSame( BEANS_TESTS_DIR, beans_sanitize_path( __DIR__ . '/../../../' ) ); - $this->assertSame( BEANS_TESTS_DIR . '/bootstrap.php', beans_sanitize_path( __DIR__ . '/../../../bootstrap.php' ) ); + $this->assertSame( BEANS_TESTS_DIR, beans_sanitize_path( __DIR__ . '/../../' ) ); + $this->assertSame( BEANS_TESTS_DIR . '/bootstrap.php', beans_sanitize_path( __DIR__ . '/../../bootstrap.php' ) ); } /** diff --git a/tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php b/tests/phpunit/unit/api/utilities/beansUrlToPath.php similarity index 98% rename from tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php rename to tests/phpunit/unit/api/utilities/beansUrlToPath.php index 0cc273f2..39a456f5 100644 --- a/tests/phpunit/unit-tests/api/utilities/beansUrlToPath.php +++ b/tests/phpunit/unit/api/utilities/beansUrlToPath.php @@ -2,20 +2,20 @@ /** * Tests for beans_url_to_path() * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * * @since 1.5.0 */ -namespace Beans\Framework\Tests\UnitTests\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Utilities; -use Beans\Framework\Tests\UnitTests\Test_Case; +use Beans\Framework\Tests\Unit\Test_Case; use Brain\Monkey\Functions; /** * Class Tests_BeansUrlToPath * - * @package Beans\Framework\Tests\UnitTests\API\Utilities + * @package Beans\Framework\Tests\Unit\API\Utilities * @group unit-tests * @group api */ diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/unit/bootstrap.php similarity index 62% rename from tests/phpunit/bootstrap.php rename to tests/phpunit/unit/bootstrap.php index 54f2b538..cf0dbbdb 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -1,8 +1,8 @@ alias( function ( $path ) { $path = str_replace( '\\', '/', $path ); $path = preg_replace( '|(?<=.)/+|', '/', $path ); @@ -41,6 +37,10 @@ protected function setUp() { return $path; } ); + + if ( ! defined( 'ABSPATH' ) ) { + define( 'ABSPATH', wp_normalize_path( dirname( __FILE__ ) . '/' ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - ABSPATH is required. + } } /** From cd6fcc7a17ebbb2252afe8f6e7008014927ed207 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Tue, 5 Dec 2017 09:06:44 +0100 Subject: [PATCH 014/800] Fix Travis composer --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1bd4fbe8..a8079701 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ matrix: - php: '7.2' install: + - composer install - export DEV_LIB_PATH=vendor/xwp/wp-dev-lib - source $DEV_LIB_PATH/travis.install.sh From aef4886d74b7ff50938fce61e811711e4d3edd22 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Wed, 6 Dec 2017 08:57:46 -0600 Subject: [PATCH 015/800] Fixed tests, dev env, and composer scripts for Windows (#75) - Adds Windows-friendly filesystem paths for composer scripts - Adds .editorconfig - Changes directory constants to use DIRECTOR_SEPARATOR - Fixes API Utilities tests for Windows filesystem - Tested on OSX and Windows 10 - Closes #71 - Loads either PHPUnit 4.8 or 5.7 --- .editorconfig | 21 +++ .gitignore | 1 + composer.json | 10 +- .../unit/api/utilities/beansPathToUrl.php | 51 ++++++-- .../unit/api/utilities/beansSanitizePath.php | 77 +++++++++-- .../unit/api/utilities/beansUrlToPath.php | 122 ++++++++++-------- tests/phpunit/unit/bootstrap.php | 10 +- tests/phpunit/unit/class-test-case.php | 4 - 8 files changed, 213 insertions(+), 83 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..c951f002 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# https://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab + +[{.jshintrc,*.json,*.yml}] +indent_style = space +indent_size = 2 + +[{*.txt,wp-config-sample.php}] +end_of_line = crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore index b7e87e2d..641e724d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ composer.lock /vendor/ /logs/ /reports/ +composer.lock \ No newline at end of file diff --git a/composer.json b/composer.json index ef236a0f..a2a96abb 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "sirbrillig/phpcs-variable-analysis": "^2.0", "wimg/php-compatibility": "^8.0", "wp-coding-standards/wpcs": "^0.14.0", - "phpunit/phpunit": "~5.7.9", + "phpunit/phpunit": "~4.8 || ~5.7.9", "brain/monkey": "^2.0", "mikey179/vfsStream": "^1.6", "xwp/wp-dev-lib": "^1.0.1" @@ -56,13 +56,13 @@ "install-codestandards": [ "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run" ], - "phpcs-src": "vendor/bin/phpcs", - "phpcs-tests": "vendor/bin/phpcs --runtime-set testVersion 5.6 tests/phpunit/", + "phpcs-src": "\"vendor/bin/phpcs\"", + "phpcs-tests": "\"vendor/bin/phpcs\" --runtime-set testVersion 5.6 tests/phpunit/", "phpcs": [ "@phpcs-src", "@phpcs-tests" ], - "test-unit": "vendor/bin/phpunit --testsuite unit", - "test-integration": "vendor/bin/phpunit --testsuite integration --configuration tests/phpunit/integration/phpunit.xml.dist" + "test-unit": "\"vendor/bin/phpunit\" --testsuite unit", + "test-integration": "\"vendor/bin/phpunit\" --testsuite integration --configuration tests/phpunit/integration/phpunit.xml.dist" } } diff --git a/tests/phpunit/unit/api/utilities/beansPathToUrl.php b/tests/phpunit/unit/api/utilities/beansPathToUrl.php index 6960112d..40bc4741 100644 --- a/tests/phpunit/unit/api/utilities/beansPathToUrl.php +++ b/tests/phpunit/unit/api/utilities/beansPathToUrl.php @@ -21,6 +21,20 @@ */ class Tests_BeansPathToUrl extends Test_Case { + /** + * Relative path to the Beans directory starting from `wp-content`. + * + * @var string + */ + protected $beans_relative_path; + + /** + * Relative path to the Unit Tests directory starting from `wp-content`. + * + * @var string + */ + protected $beans_tests_relative_path; + /** * Setup test fixture. */ @@ -28,6 +42,16 @@ protected function setUp() { parent::setUp(); require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; + + if ( ! $this->beans_relative_path ) { + $abspath = rtrim( ABSPATH, '/' ); + $this->beans_relative_path = wp_normalize_path( + rtrim( str_replace( $abspath, '', BEANS_ROOT_DIR ), DIRECTORY_SEPARATOR ) + ); + $this->beans_tests_relative_path = wp_normalize_path( + str_replace( $abspath, '', BEANS_TESTS_DIR ) + ); + } } /** @@ -75,6 +99,7 @@ public function test_should_convert_absolute_path() { $url = 'https://getbeans.io'; Functions\expect( 'site_url' )->andReturn( $url ); + $url .= $this->beans_tests_relative_path; $this->assertSame( "{$url}/api/utilities/beansPathToUrl.php", beans_path_to_url( __FILE__, true ) ); $this->assertSame( "{$url}/api/utilities", beans_path_to_url( __DIR__, true ) ); @@ -92,8 +117,8 @@ public function test_should_convert_relative_path() { $path = '/wp-content/themes'; $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); - $path = 'wp-content/themes/tm-beans/'; - $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + $path = $this->beans_relative_path; + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); } /** @@ -104,6 +129,7 @@ public function test_should_convert_to_ip_when_absolute_path() { $url = 'https://8.8.8.8'; Functions\expect( 'site_url' )->andReturn( $url ); + $url .= $this->beans_tests_relative_path; $this->assertSame( "{$url}/api/utilities/beansPathToUrl.php", beans_path_to_url( __FILE__, true ) ); $this->assertSame( "{$url}/api/utilities", beans_path_to_url( __DIR__, true ) ); @@ -121,8 +147,8 @@ public function test_should_convert_to_ip_when_relative_path() { $path = '/wp-content/themes'; $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); - $path = 'wp-content/themes/tm-beans/'; - $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); + $path = $this->beans_relative_path; + $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); } /** @@ -133,6 +159,7 @@ public function test_should_convert_absolute_path_when_trailingslash_domain() { $url = 'https://getbeans.io'; Functions\expect( 'site_url' )->andReturn( $url . '/' ); + $url .= $this->beans_tests_relative_path; $this->assertSame( "{$url}/api/utilities/beansPathToUrl.php", beans_path_to_url( __FILE__, true ) ); $this->assertSame( "{$url}/api/utilities", beans_path_to_url( __DIR__, true ) ); @@ -146,10 +173,11 @@ public function test_should_convert_relative_path_when_trailingslash_domain() { $url = 'https://getbeans.io'; Functions\expect( 'site_url' )->andReturn( $url . '/' ); + $path = 'wp-content/themes'; $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); - $path = '/wp-content/themes/tm-beans/'; + $path = $this->beans_relative_path; $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); } @@ -161,6 +189,7 @@ public function test_should_convert_absolute_path_when_ip_trailingslash() { $url = 'https://8000:10.127.47.355'; Functions\expect( 'site_url' )->andReturn( $url . '/' ); + $url .= $this->beans_tests_relative_path; $this->assertSame( "{$url}/api/utilities/beansPathToUrl.php", beans_path_to_url( __FILE__, true ) ); $this->assertSame( "{$url}/api/utilities", beans_path_to_url( __DIR__, true ) ); @@ -178,7 +207,7 @@ public function test_should_convert_relative_path_when_ip_trailingslash() { $path = 'wp-content/themes'; $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); - $path = '/wp-content/themes/tm-beans/'; + $path = $this->beans_relative_path; $this->assertSame( "{$url}{$path}", beans_path_to_url( $path, true ) ); } @@ -231,7 +260,10 @@ public function test_should_re_add_domain_tilde() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->once()->andReturn( 'https://getbeans.io' ); - $this->assertSame( 'https://getbeans.io/api/utilities/beansPathToUrl.php', beans_path_to_url( __FILE__, true ) ); + $this->assertSame( + 'https://getbeans.io' . $this->beans_tests_relative_path . '/api/utilities/beansPathToUrl.php', + beans_path_to_url( __FILE__, true ) + ); Functions\expect( 'site_url' )->once()->andReturn( 'https://example.com/~subdomain' ); $this->assertSame( 'https://example.com/~subdomain/foo', beans_path_to_url( 'foo', true ) ); @@ -253,7 +285,10 @@ public function test_should_re_add_ip_tilde() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->once()->andReturn( 'https://8.8.8.8' ); - $this->assertSame( 'https://8.8.8.8/api/utilities/beansPathToUrl.php', beans_path_to_url( __FILE__, true ) ); + $this->assertSame( + 'https://8.8.8.8' . $this->beans_tests_relative_path . '/api/utilities/beansPathToUrl.php', + beans_path_to_url( __FILE__, true ) + ); Functions\expect( 'site_url' )->once()->andReturn( 'https://17.17.17.17/~subdomain' ); $this->assertSame( 'https://17.17.17.17/~subdomain/foo', beans_path_to_url( 'foo', true ) ); diff --git a/tests/phpunit/unit/api/utilities/beansSanitizePath.php b/tests/phpunit/unit/api/utilities/beansSanitizePath.php index 27e96fec..ba68bc3d 100644 --- a/tests/phpunit/unit/api/utilities/beansSanitizePath.php +++ b/tests/phpunit/unit/api/utilities/beansSanitizePath.php @@ -29,21 +29,82 @@ protected function setUp() { require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } + /** + * Test beans_sanitize_path() should remove Windows drive. + */ + public function test_should_remove_windows_drive() { + $this->assertSame( '/Program Files/tmp/', beans_sanitize_path( 'C:\Program Files\tmp\\' ) ); + $this->assertSame( '/Foo/bar/baz/index.txt', beans_sanitize_path( 'D:\Foo\bar\baz\index.txt' ) ); + } + /** * Test beans_sanitize_path() should sanitize for filesystem. */ public function test_should_sanitize_for_filesystem() { - $this->assertSame( BEANS_TESTS_DIR, beans_sanitize_path( BEANS_TESTS_DIR ) ); - $this->assertSame( __DIR__, beans_sanitize_path( __DIR__ ) ); - $this->assertSame( BEANS_TESTS_DIR, beans_sanitize_path( __DIR__ . '/../../' ) ); - $this->assertSame( BEANS_TESTS_DIR . '/bootstrap.php', beans_sanitize_path( __DIR__ . '/../../bootstrap.php' ) ); + $this->assertSame( $this->prepare_path( BEANS_TESTS_DIR ), beans_sanitize_path( BEANS_TESTS_DIR ) ); + $this->assertSame( $this->prepare_path( __DIR__ ), beans_sanitize_path( __DIR__ ) ); + + // test phpunit's path. + $this->assertSame( + $this->prepare_path( BEANS_TESTS_DIR ) . '/bootstrap.php', + beans_sanitize_path( BEANS_TESTS_DIR . DIRECTORY_SEPARATOR . 'bootstrap.php' ) + ); + $this->assertSame( $this->prepare_path( __FILE__ ), beans_sanitize_path( __FILE__ ) ); + + // test beans' theme root path. + $this->assertSame( + $this->prepare_path( rtrim( BEANS_ROOT_DIR, DIRECTORY_SEPARATOR ) ), + beans_sanitize_path( BEANS_ROOT_DIR ) + ); + $directory_separator = '\\' === DIRECTORY_SEPARATOR ? '/' : ''; + $this->assertSame( + $this->prepare_path( BEANS_ROOT_DIR ) . $directory_separator . 'functions.php', + beans_sanitize_path( BEANS_ROOT_DIR . 'functions.php' ) + ); } /** - * Test beans_sanitize_path() should remove Windows drive. + * Test beans_sanitize_path() should sanitize for filesystem symbolic links. */ - public function test_should_remove_windows_drive() { - $this->assertSame( '/Program Files/tmp/', beans_sanitize_path( 'C:\Program Files\tmp\\' ) ); - $this->assertSame( '/Foo/bar/baz/index.txt', beans_sanitize_path( 'D:\Foo\bar\baz\index.txt' ) ); + public function test_should_sanitize_for_filesystem_symbolic_links() { + // Test in the ./tests/phpunit/unit/api directory. + $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; + $this->assertSame( + $this->prepare_path( BEANS_TESTS_DIR ) . '/api', + beans_sanitize_path( $path ) + ); + + // Test in the ./tests/phpunit/unit directory. + $path .= '..' . DIRECTORY_SEPARATOR; + $this->assertSame( + $this->prepare_path( BEANS_TESTS_DIR ), + beans_sanitize_path( $path ) + ); + $this->assertSame( + $this->prepare_path( BEANS_TESTS_DIR ) . '/bootstrap.php', + beans_sanitize_path( $path . 'bootstrap.php' ) + ); + } + + /** + * Prepare the path for different OS environments. + * + * @since 1.5.0 + * + * @param string $path Filesystem path to prepare. + * + * @return string + */ + protected function prepare_path( $path ) { + + // It's not a Windows path. Just return. + if ( '\\' !== DIRECTORY_SEPARATOR ) { + return $path; + } + + $path = wp_normalize_path( realpath( $path ) ); + + // Strips off the Windows drive letter. + return mb_substr( $path, 2 ); } } diff --git a/tests/phpunit/unit/api/utilities/beansUrlToPath.php b/tests/phpunit/unit/api/utilities/beansUrlToPath.php index 39a456f5..e9b23c64 100644 --- a/tests/phpunit/unit/api/utilities/beansUrlToPath.php +++ b/tests/phpunit/unit/api/utilities/beansUrlToPath.php @@ -21,6 +21,13 @@ */ class Tests_BeansUrlToPath extends Test_Case { + /** + * Sanitized ABSPATH - to ensure it works on both OSX and Windows. + * + * @var string + */ + protected $abspath; + /** * Setup test fixture. */ @@ -28,6 +35,9 @@ protected function setUp() { parent::setUp(); require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; + if ( is_null( $this->abspath ) ) { + $this->abspath = beans_sanitize_path( ABSPATH ) . '/'; + } } /** @@ -95,24 +105,24 @@ public function test_should_convert_domain_url() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->twice()->andReturn( 'https://example.com' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://example.com', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://example.com/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://example.com', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://example.com/', true ) ); Functions\expect( 'site_url' )->twice()->andReturn( 'http://foo.com/' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://foo.com', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://foo.com/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://foo.com', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://foo.com/', true ) ); Functions\expect( 'site_url' )->times( 3 )->andReturn( 'https://example.com' ); $this->assertSame( - ABSPATH . 'foo/bar/index.php', + $this->abspath . 'foo/bar/index.php', beans_url_to_path( 'https://example.com/foo/bar/index.php', true ) ); $this->assertSame( - ABSPATH . 'foo/bar/', + $this->abspath . 'foo/bar/', beans_url_to_path( 'https://example.com/foo/bar/', true ) ); $this->assertSame( - ABSPATH . 'foo/bar/baz/', + $this->abspath . 'foo/bar/baz/', beans_url_to_path( 'https://example.com/foo/bar/baz/', true ) ); } @@ -124,24 +134,24 @@ public function test_should_convert_ip_address() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->twice()->andReturn( 'https://8.8.8.8' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://8.8.8.8', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://8.8.8.8/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://8.8.8.8', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://8.8.8.8/', true ) ); Functions\expect( 'site_url' )->twice()->andReturn( 'https://8.8.8.8/' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://8.8.8.8', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://8.8.8.8/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://8.8.8.8', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://8.8.8.8/', true ) ); Functions\expect( 'site_url' )->andReturn( 'https://8.8.8.8' ); $this->assertSame( - ABSPATH . 'foo/bar/index.php', + $this->abspath . 'foo/bar/index.php', beans_url_to_path( 'https://8.8.8.8/foo/bar/index.php', true ) ); $this->assertSame( - ABSPATH . 'foo/bar/', + $this->abspath . 'foo/bar/', beans_url_to_path( 'https://8.8.8.8/foo/bar/', true ) ); $this->assertSame( - ABSPATH . 'foo/bar/baz/', + $this->abspath . 'foo/bar/baz/', beans_url_to_path( 'https://8.8.8.8/foo/bar/baz/', true ) ); } @@ -154,17 +164,17 @@ public function test_should_convert_domain_and_removes_subfolder() { Functions\expect( 'site_url' )->times( 3 )->andReturn( 'https://example.com/blog/' ); $this->assertSame( - ABSPATH . 'blog/', + $this->abspath . 'blog/', beans_url_to_path( 'https://example.com/blog/', true ) ); $this->assertSame( - ABSPATH . 'blog/foo/bar/', + $this->abspath . 'blog/foo/bar/', beans_url_to_path( 'https://example.com/blog/foo/bar/', true ) ); $this->assertSame( - ABSPATH . 'blog/foo/bar/baz/', + $this->abspath . 'blog/foo/bar/baz/', beans_url_to_path( 'https://example.com/blog/foo/bar/baz/', true ) ); } @@ -177,17 +187,17 @@ public function test_should_convert_ip_and_removes_subfolder() { Functions\expect( 'site_url' )->andReturn( 'https://8.8.8.8/blog/' ); $this->assertSame( - ABSPATH . 'blog/', + $this->abspath . 'blog/', beans_url_to_path( 'https://8.8.8.8/blog/', true ) ); $this->assertSame( - ABSPATH . 'blog/foo/bar/', + $this->abspath . 'blog/foo/bar/', beans_url_to_path( 'https://8.8.8.8/blog/foo/bar/', true ) ); $this->assertSame( - ABSPATH . 'blog/foo/bar/baz/', + $this->abspath . 'blog/foo/bar/baz/', beans_url_to_path( 'https://8.8.8.8/blog/foo/bar/baz/', true ) ); } @@ -201,17 +211,17 @@ public function test_should_convert_domain_and_removes_subfolders() { Functions\expect( 'site_url' )->times( 3 )->andReturn( 'https://example.com/blog/' ); $this->assertSame( - ABSPATH . 'blog/', + $this->abspath . 'blog/', beans_url_to_path( 'https://example.com/blog/', true ) ); $this->assertSame( - ABSPATH . 'blog/foo/bar/', + $this->abspath . 'blog/foo/bar/', beans_url_to_path( 'https://example.com/blog/foo/bar/', true ) ); $this->assertSame( - ABSPATH . 'blog/foo/bar/baz/', + $this->abspath . 'blog/foo/bar/baz/', beans_url_to_path( 'https://example.com/blog/foo/bar/baz/', true ) ); } @@ -224,17 +234,17 @@ public function test_should_convert_ip_and_removes_subfolders() { Functions\expect( 'site_url' )->andReturn( 'https://8.8.8.8/blog/foo' ); $this->assertSame( - ABSPATH . 'blog/', + $this->abspath . 'blog/', beans_url_to_path( 'https://8.8.8.8/blog/', true ) ); $this->assertSame( - ABSPATH . 'blog/foo/bar/', + $this->abspath . 'blog/foo/bar/', beans_url_to_path( 'https://8.8.8.8/blog/foo/bar/', true ) ); $this->assertSame( - ABSPATH . 'blog/foo/bar/baz/', + $this->abspath . 'blog/foo/bar/baz/', beans_url_to_path( 'https://8.8.8.8/blog/foo/bar/baz/', true ) ); } @@ -248,12 +258,12 @@ public function test_should_convert_relative_urls() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->times( 6 )->andReturn( 'https://example.com' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( '//example.com', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'example.com', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'example.com/', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'www.example.com/', true ) ); - $this->assertSame( ABSPATH . 'foo', beans_url_to_path( 'example.com/foo', true ) ); - $this->assertSame( ABSPATH . 'foo/', beans_url_to_path( 'example.com/foo/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( '//example.com', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'example.com', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'example.com/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'www.example.com/', true ) ); + $this->assertSame( $this->abspath . 'foo', beans_url_to_path( 'example.com/foo', true ) ); + $this->assertSame( $this->abspath . 'foo/', beans_url_to_path( 'example.com/foo/', true ) ); } @@ -266,12 +276,12 @@ public function test_should_convert_relative_ip_address() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->times( 6 )->andReturn( 'https://8.8.8.8' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( '//8.8.8.8', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( '8.8.8.8', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( '8.8.8.8/', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'www.8.8.8.8/', true ) ); - $this->assertSame( ABSPATH . 'foo', beans_url_to_path( '8.8.8.8/foo', true ) ); - $this->assertSame( ABSPATH . 'foo/', beans_url_to_path( '8.8.8.8/foo/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( '//8.8.8.8', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( '8.8.8.8', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( '8.8.8.8/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'www.8.8.8.8/', true ) ); + $this->assertSame( $this->abspath . 'foo', beans_url_to_path( '8.8.8.8/foo', true ) ); + $this->assertSame( $this->abspath . 'foo/', beans_url_to_path( '8.8.8.8/foo/', true ) ); } /** @@ -282,11 +292,11 @@ public function test_should_convert_url_and_remove_tilde() { Functions\expect( 'site_url' )->andReturn( 'https://foo.com' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://foo.com/~subdomain', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://foo.com/~subdomain/', true ) ); - $this->assertSame( ABSPATH . 'foo', beans_url_to_path( 'https://foo.com/~subdomain/foo', true ) ); - $this->assertSame( ABSPATH . 'foo/', beans_url_to_path( 'https://foo.com/~subdomain/foo/', true ) ); - $this->assertSame( ABSPATH . 'bar/~subdomain/foo/', beans_url_to_path( 'https://foo.com/bar/~subdomain/foo/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://foo.com/~subdomain', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://foo.com/~subdomain/', true ) ); + $this->assertSame( $this->abspath . 'foo', beans_url_to_path( 'https://foo.com/~subdomain/foo', true ) ); + $this->assertSame( $this->abspath . 'foo/', beans_url_to_path( 'https://foo.com/~subdomain/foo/', true ) ); + $this->assertSame( $this->abspath . 'bar/~subdomain/foo/', beans_url_to_path( 'https://foo.com/bar/~subdomain/foo/', true ) ); } /** @@ -296,11 +306,11 @@ public function test_should_convert_ip_and_remove_tilde() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->andReturn( 'https://255.255.255.255' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://255.255.255.255/~subdomain', true ) ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'https://255.255.255.255/~subdomain/', true ) ); - $this->assertSame( ABSPATH . 'foo', beans_url_to_path( 'https://255.255.255.255/~subdomain/foo', true ) ); - $this->assertSame( ABSPATH . 'foo/', beans_url_to_path( 'https://255.255.255.255/~subdomain/foo/', true ) ); - $this->assertSame( ABSPATH . 'bar/~subdomain/foo/', beans_url_to_path( 'https://255.255.255.255/bar/~subdomain/foo/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://255.255.255.255/~subdomain', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'https://255.255.255.255/~subdomain/', true ) ); + $this->assertSame( $this->abspath . 'foo', beans_url_to_path( 'https://255.255.255.255/~subdomain/foo', true ) ); + $this->assertSame( $this->abspath . 'foo/', beans_url_to_path( 'https://255.255.255.255/~subdomain/foo/', true ) ); + $this->assertSame( $this->abspath . 'bar/~subdomain/foo/', beans_url_to_path( 'https://255.255.255.255/bar/~subdomain/foo/', true ) ); } /** @@ -313,10 +323,10 @@ public function test_converts_domain_for_subdirectory_multisite() { Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/shop/' ) ); Functions\expect( 'site_url' )->once()->andReturn( 'http://example.com/shop/' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://example.com/shop/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://example.com/shop/', true ) ); Functions\expect( 'site_url' )->once()->andReturn( 'http://example.com/shop/image.png' ); - $this->assertSame( ABSPATH . 'image.png', beans_url_to_path( 'http://example.com/shop/image.png', true ) ); + $this->assertSame( $this->abspath . 'image.png', beans_url_to_path( 'http://example.com/shop/image.png', true ) ); } /** @@ -329,10 +339,10 @@ public function test_converts_ip_for_subdirectory_multisite() { Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/shop/' ) ); Functions\expect( 'site_url' )->once()->andReturn( 'http://8.8.8.8/shop/' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://8.8.8.8/shop/', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://8.8.8.8/shop/', true ) ); Functions\expect( 'site_url' )->once()->andReturn( 'http://50.50.50.50/shop/image.png' ); - $this->assertSame( ABSPATH . 'image.png', beans_url_to_path( 'http://50.50.50.50/shop/image.png', true ) ); + $this->assertSame( $this->abspath . 'image.png', beans_url_to_path( 'http://50.50.50.50/shop/image.png', true ) ); } /** @@ -344,10 +354,10 @@ public function test_converts_domain_for_subdomain_multisite() { Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.example.com' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://shop.example.com', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://shop.example.com', true ) ); Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.example.com/image.jpg/foo' ); - $this->assertSame( ABSPATH . 'image.jpg', beans_url_to_path( 'http://shop.example.com/image.jpg', true ) ); + $this->assertSame( $this->abspath . 'image.jpg', beans_url_to_path( 'http://shop.example.com/image.jpg', true ) ); } /** @@ -359,9 +369,9 @@ public function test_converts_ip_for_subdomain_multisite() { Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.255.147.55.10' ); - $this->assertSame( rtrim( ABSPATH, '/' ), beans_url_to_path( 'http://shop.255.147.55.10', true ) ); + $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://shop.255.147.55.10', true ) ); Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.1.2.3.4/image.jpg/foo' ); - $this->assertSame( ABSPATH . 'image.jpg', beans_url_to_path( 'http://shop.1.2.3.4/image.jpg', true ) ); + $this->assertSame( $this->abspath . 'image.jpg', beans_url_to_path( 'http://shop.1.2.3.4/image.jpg', true ) ); } } diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index cf0dbbdb..7ccef788 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -13,10 +13,16 @@ } define( 'BEANS_TESTS_DIR', __DIR__ ); -define( 'BEANS_TESTS_LIB_DIR', dirname( dirname( dirname( __DIR__ ) ) ) . '/lib/' ); +define( 'BEANS_ROOT_DIR', dirname( dirname( dirname( __DIR__ ) ) ) . DIRECTORY_SEPARATOR ); +define( 'BEANS_TESTS_LIB_DIR', BEANS_ROOT_DIR . 'lib' . DIRECTORY_SEPARATOR ); + +// Let's define ABSPATH as it is in WordPress, i.e. relative to the filesystem's WordPress root path. +if ( ! defined( 'ABSPATH' ) ) { + define( 'ABSPATH', dirname( dirname( dirname( BEANS_ROOT_DIR ) ) ) . '/' ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - ABSPATH is required. +} // Time to load Composer's autoloader. -$beans_autoload_path = dirname( dirname( dirname( __DIR__ ) ) ) . '/vendor/'; +$beans_autoload_path = BEANS_ROOT_DIR . 'vendor/'; if ( ! file_exists( $beans_autoload_path . 'autoload.php' ) ) { die( 'Whoops, we need Composer before we start running tests. Please type: `composer install`. When done, try running `phpunit` again.' ); diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 974cb677..b6756c83 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -37,10 +37,6 @@ protected function setUp() { return $path; } ); - - if ( ! defined( 'ABSPATH' ) ) { - define( 'ABSPATH', wp_normalize_path( dirname( __FILE__ ) . '/' ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - ABSPATH is required. - } } /** From 5129eba19b74d504424568e66b55091991cf57ef Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 6 Dec 2017 13:55:43 -0500 Subject: [PATCH 016/800] Fixed #74 - Inconsistencies and typos in tests. --- tests/phpunit/unit/api/utilities/beansGet.php | 2 +- .../utilities/beansMultiArrayKeyExists.php | 4 +- .../unit/api/utilities/beansPathToUrl.php | 12 ++--- .../unit/api/utilities/beansRemoveDir.php | 2 +- .../api/utilities/beansRenderFunction.php | 2 +- .../utilities/beansRenderFunctionArray.php | 2 +- .../unit/api/utilities/beansSanitizePath.php | 4 +- .../unit/api/utilities/beansUrlToPath.php | 50 +++++++++---------- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/tests/phpunit/unit/api/utilities/beansGet.php b/tests/phpunit/unit/api/utilities/beansGet.php index 5c2025d4..5e35574c 100644 --- a/tests/phpunit/unit/api/utilities/beansGet.php +++ b/tests/phpunit/unit/api/utilities/beansGet.php @@ -30,7 +30,7 @@ protected function setUp() { } /** - * Test beans_get() returns the default value. + * Test beans_get() should return the default value. */ public function test_should_return_default() { $this->assertEquals( 10, beans_get( 'foo', 'bar', 10 ) ); diff --git a/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php index 9e4d4d88..137d3809 100644 --- a/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php +++ b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php @@ -32,7 +32,7 @@ protected function setUp() { /** * Test beans_multi_array_key_exists() should throw an error for non-array data type. */ - public function test_should_throws_error_for_non_array() { + public function test_should_throw_error_for_non_array() { $args = array( 0 => 'bar', 'foo' => 10, @@ -110,7 +110,7 @@ public function test_should_return_true_when_key_exists_multidimensional() { } /** - * Test beans_multi_array_key_exists() should return true when key exists within a multi-dimensional array. + * Test beans_multi_array_key_exists() should return false when key does not exist within a multi-dimensional array. */ public function test_should_return_false_when_key_does_not_exist_multidimensional() { $data = array( diff --git a/tests/phpunit/unit/api/utilities/beansPathToUrl.php b/tests/phpunit/unit/api/utilities/beansPathToUrl.php index 40bc4741..0563f8b5 100644 --- a/tests/phpunit/unit/api/utilities/beansPathToUrl.php +++ b/tests/phpunit/unit/api/utilities/beansPathToUrl.php @@ -92,7 +92,7 @@ public function test_should_bail_out_when_ip() { } /** - * Test beans_path_to_url() converts path. + * Test beans_path_to_url() should convert absolute path. */ public function test_should_convert_absolute_path() { Functions\expect( 'is_main_site' )->andReturn( true ); @@ -106,7 +106,7 @@ public function test_should_convert_absolute_path() { } /** - * Test beans_path_to_url() converts path. + * Test beans_path_to_url() should convert relative path. */ public function test_should_convert_relative_path() { Functions\expect( 'is_main_site' )->andReturn( true ); @@ -233,7 +233,7 @@ public function test_should_remove_domain_subfolder() { } /** - * Test beans_path_to_url() should remove the IP Address' subfolder. + * Test beans_path_to_url() should remove the IP address' subfolder. */ public function test_should_remove_ip_subfolder() { Functions\expect( 'is_main_site' )->andReturn( true ); @@ -279,7 +279,7 @@ public function test_should_re_add_domain_tilde() { } /** - * Test beans_path_to_url() should re-add the domain URL's tilde upon conversion. + * Test beans_path_to_url() should re-add the IP address' tilde upon conversion. */ public function test_should_re_add_ip_tilde() { Functions\expect( 'is_main_site' )->andReturn( true ); @@ -322,7 +322,7 @@ public function test_should_convert_for_domain_subdirectory_multisite() { } /** - * Test beans_path_to_url() should convert for IP Address's subdirectory multisite. + * Test beans_path_to_url() should convert for IP address' subdirectory multisite. */ public function test_should_convert_for_ip_subdirectory_multisite() { $path = 'wp-content/themes'; @@ -357,7 +357,7 @@ public function test_should_convert_for_domain_subdomain_multisite() { } /** - * Test beans_path_to_url() should convert for domain URL's subdomain multisite. + * Test beans_path_to_url() should convert for IP address' subdomain multisite. */ public function test_should_convert_for_ip_subdomain_multisite() { $path = 'wp-content/themes'; diff --git a/tests/phpunit/unit/api/utilities/beansRemoveDir.php b/tests/phpunit/unit/api/utilities/beansRemoveDir.php index 6fe61c3a..96560de4 100644 --- a/tests/phpunit/unit/api/utilities/beansRemoveDir.php +++ b/tests/phpunit/unit/api/utilities/beansRemoveDir.php @@ -31,7 +31,7 @@ protected function setUp() { } /** - * Test beans_remove_dir() bails out for a non-directory. + * Test beans_remove_dir() should bail out for a non-directory. */ public function test_should_bail_for_non_dir() { $dir = __DIR__ . '/'; diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunction.php b/tests/phpunit/unit/api/utilities/beansRenderFunction.php index f8cd5ffa..85e92ea3 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunction.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunction.php @@ -38,7 +38,7 @@ public function test_should_bail_when_noncallable() { } /** - * Test beans_render_function() should work when there no arguments. + * Test beans_render_function() should work when there are no arguments. */ public function test_should_work_when_no_arguments() { $this->assertEquals( 'You called me!', beans_render_function( function () { diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php index 2eac05d8..f87be529 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php @@ -37,7 +37,7 @@ public function test_should_bail_when_noncallable() { } /** - * Test beans_render_function_array() should work when there no arguments. + * Test beans_render_function_array() should work when there are no arguments. */ public function test_should_work_when_no_arguments() { $this->assertEquals( 'You called me!', beans_render_function_array( function () { diff --git a/tests/phpunit/unit/api/utilities/beansSanitizePath.php b/tests/phpunit/unit/api/utilities/beansSanitizePath.php index ba68bc3d..05a139b0 100644 --- a/tests/phpunit/unit/api/utilities/beansSanitizePath.php +++ b/tests/phpunit/unit/api/utilities/beansSanitizePath.php @@ -44,14 +44,14 @@ public function test_should_sanitize_for_filesystem() { $this->assertSame( $this->prepare_path( BEANS_TESTS_DIR ), beans_sanitize_path( BEANS_TESTS_DIR ) ); $this->assertSame( $this->prepare_path( __DIR__ ), beans_sanitize_path( __DIR__ ) ); - // test phpunit's path. + // Test phpunit's path. $this->assertSame( $this->prepare_path( BEANS_TESTS_DIR ) . '/bootstrap.php', beans_sanitize_path( BEANS_TESTS_DIR . DIRECTORY_SEPARATOR . 'bootstrap.php' ) ); $this->assertSame( $this->prepare_path( __FILE__ ), beans_sanitize_path( __FILE__ ) ); - // test beans' theme root path. + // Test Beans' theme root path. $this->assertSame( $this->prepare_path( rtrim( BEANS_ROOT_DIR, DIRECTORY_SEPARATOR ) ), beans_sanitize_path( BEANS_ROOT_DIR ) diff --git a/tests/phpunit/unit/api/utilities/beansUrlToPath.php b/tests/phpunit/unit/api/utilities/beansUrlToPath.php index e9b23c64..b4a7bcb9 100644 --- a/tests/phpunit/unit/api/utilities/beansUrlToPath.php +++ b/tests/phpunit/unit/api/utilities/beansUrlToPath.php @@ -41,7 +41,7 @@ protected function setUp() { } /** - * Test beans_url_to_path() bails out for an external URL. + * Test beans_url_to_path() should bail out for an external URL. */ public function test_should_bail_out_when_external_url() { Functions\expect( 'site_url' )->andReturn( 'http://getbeans.io' ); @@ -61,7 +61,7 @@ public function test_should_bail_out_when_external_url() { } /** - * Test beans_url_to_path() bails out for an external URL that has an internal path, i.e. + * Test beans_url_to_path() should bail out for an external URL that has an internal path, i.e. * meaning the site's URL is within the URL's path. * * @ticket 65 @@ -99,7 +99,7 @@ public function test_should_bail_out_when_external_url_with_internal_path() { } /** - * Test beans_url_to_path() converts the URL. + * Test beans_url_to_path() should convert the domain URL. */ public function test_should_convert_domain_url() { Functions\expect( 'is_main_site' )->andReturn( true ); @@ -128,7 +128,7 @@ public function test_should_convert_domain_url() { } /** - * Test beans_url_to_path() should converts IP addresses. + * Test beans_url_to_path() should convert the IP address. */ public function test_should_convert_ip_address() { Functions\expect( 'is_main_site' )->andReturn( true ); @@ -157,9 +157,9 @@ public function test_should_convert_ip_address() { } /** - * Test beans_url_to_path() converts for domain and removes the subfolder. + * Test beans_url_to_path() should convert for domain URL and remove the subfolder. */ - public function test_should_convert_domain_and_removes_subfolder() { + public function test_should_convert_domain_and_remove_subfolder() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->times( 3 )->andReturn( 'https://example.com/blog/' ); @@ -180,9 +180,9 @@ public function test_should_convert_domain_and_removes_subfolder() { } /** - * Test beans_url_to_path() converts for IP address and removes the subfolder. + * Test beans_url_to_path() should convert for IP address and remove the subfolder. */ - public function test_should_convert_ip_and_removes_subfolder() { + public function test_should_convert_ip_and_remove_subfolder() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->andReturn( 'https://8.8.8.8/blog/' ); @@ -203,9 +203,9 @@ public function test_should_convert_ip_and_removes_subfolder() { } /** - * Test beans_url_to_path() converts for domain and removes all subfolders. + * Test beans_url_to_path() should convert for domain URL and remove all subfolders. */ - public function test_should_convert_domain_and_removes_subfolders() { + public function test_should_convert_domain_and_remove_subfolders() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->times( 3 )->andReturn( 'https://example.com/blog/' ); @@ -227,9 +227,9 @@ public function test_should_convert_domain_and_removes_subfolders() { } /** - * Test beans_url_to_path() converts for domain and removes all subfolders. + * Test beans_url_to_path() should convert for IP address and remove all subfolders. */ - public function test_should_convert_ip_and_removes_subfolders() { + public function test_should_convert_ip_and_remove_subfolders() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->andReturn( 'https://8.8.8.8/blog/foo' ); @@ -250,11 +250,11 @@ public function test_should_convert_ip_and_removes_subfolders() { } /** - * Test beans_url_to_path() converts a relative URL. + * Test beans_url_to_path() should convert a relative URL. * * @ticket 63 */ - public function test_should_convert_relative_urls() { + public function test_should_convert_relative_url() { Functions\expect( 'is_main_site' )->andReturn( true ); Functions\expect( 'site_url' )->times( 6 )->andReturn( 'https://example.com' ); @@ -268,7 +268,7 @@ public function test_should_convert_relative_urls() { /** - * Test beans_url_to_path() converts a relative URL. + * Test beans_url_to_path() should convert a relative IP address. * * @ticket 63 */ @@ -285,7 +285,7 @@ public function test_should_convert_relative_ip_address() { } /** - * Test beans_url_to_path() converts the domain URL and removes the tilde. + * Test beans_url_to_path() should convert the domain URL and remove the tilde. */ public function test_should_convert_url_and_remove_tilde() { Functions\expect( 'is_main_site' )->andReturn( true ); @@ -300,7 +300,7 @@ public function test_should_convert_url_and_remove_tilde() { } /** - * Test beans_url_to_path() converts the IP address and removes the tilde. + * Test beans_url_to_path() should convert the IP address and remove the tilde. */ public function test_should_convert_ip_and_remove_tilde() { Functions\expect( 'is_main_site' )->andReturn( true ); @@ -314,9 +314,9 @@ public function test_should_convert_ip_and_remove_tilde() { } /** - * Test beans_url_to_path() converts domain for subdirectory multisite. + * Test beans_url_to_path() should convert domain URL for subdirectory multisite. */ - public function test_converts_domain_for_subdirectory_multisite() { + public function test_should_convert_domain_for_subdirectory_multisite() { Functions\expect( 'is_main_site' )->andReturn( false ); Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); @@ -330,9 +330,9 @@ public function test_converts_domain_for_subdirectory_multisite() { } /** - * Test beans_url_to_path() converts IP address for subdirectory multisite. + * Test beans_url_to_path() should convert IP address for subdirectory multisite. */ - public function test_converts_ip_for_subdirectory_multisite() { + public function test_should_convert_ip_for_subdirectory_multisite() { Functions\expect( 'is_main_site' )->andReturn( false ); Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); @@ -346,9 +346,9 @@ public function test_converts_ip_for_subdirectory_multisite() { } /** - * Test beans_url_to_path() converts domain for subdomain multisite. + * Test beans_url_to_path() should convert domain URL for subdomain multisite. */ - public function test_converts_domain_for_subdomain_multisite() { + public function test_should_convert_domain_for_subdomain_multisite() { Functions\expect( 'is_main_site' )->andReturn( false ); Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); @@ -361,9 +361,9 @@ public function test_converts_domain_for_subdomain_multisite() { } /** - * Test beans_url_to_path() converts IP Address for subdomain multisite. + * Test beans_url_to_path() should convert IP address for subdomain multisite. */ - public function test_converts_ip_for_subdomain_multisite() { + public function test_should_convert_ip_for_subdomain_multisite() { Functions\expect( 'is_main_site' )->andReturn( false ); Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); From 27ba2d2026ed90abf131894404816035e958ce49 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 7 Dec 2017 06:12:50 -0600 Subject: [PATCH 017/800] Made `_beans_render_action` and `_beans_unique_action_id` compliant --- .dev-lib | 1 - lib/api/actions/functions.php | 133 ++++++----- .../unit/api/actions/beansRenderAction.php | 219 ++++++++++++++++++ .../unit/api/actions/beansUniqueActionId.php | 116 ++++++++++ .../api/actions/stubs/class-action-stub.php | 41 ++++ 5 files changed, 453 insertions(+), 57 deletions(-) create mode 100644 tests/phpunit/unit/api/actions/beansRenderAction.php create mode 100644 tests/phpunit/unit/api/actions/beansUniqueActionId.php create mode 100644 tests/phpunit/unit/api/actions/stubs/class-action-stub.php diff --git a/.dev-lib b/.dev-lib index 8c2a7803..6ab05421 100644 --- a/.dev-lib +++ b/.dev-lib @@ -1,5 +1,4 @@ PROJECT_TYPE=theme -CHECK_SCOPE=changed-files WPCS_STANDARD=phpcs.xml.dist PATH_EXCLUDES_PATTERN='^(.*/)?(vendors|vendor|node_modules)/.*' DEV_LIB_SKIP=yuicompressor,codeception,grunt,jshint diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index f66840ec..851e0b6a 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -5,7 +5,9 @@ * While WordPress requires two or three arguments to remove an action, Beans * actions can be modified, replaced, removed or reset using only the ID as a reference. * - * @package API\Actions + * @package Beans\Framework\API\Actions + * + * @since 1.5.0 */ /** @@ -98,14 +100,14 @@ function beans_add_smart_action( $hook, $callback, $priority = 10, $args = 1 ) { * * @since 1.0.0 * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. + * @param string $id The action ID. + * @param string $hook Optional. The name of the new action to which the $callback is hooked. * Use NULL to keep the original value. * @param callback $callback Optional. The name of the new function you wish to be called. * Use NULL to keep the original value. - * @param int $priority Optional. The new priority. + * @param int $priority Optional. The new priority. * Use NULL to keep the original value. - * @param int $args Optional. The new number of arguments the function accept. + * @param int $args Optional. The new number of arguments the function accept. * Use NULL to keep the original value. * * @return bool Will always return true. @@ -185,14 +187,14 @@ function beans_modify_action_callback( $id, $callback ) { * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $priority Optional. The new priority. Use NULL to keep the original value. + * @param string $id The action ID. + * @param int $priority Optional. The new priority. Use NULL to keep the original value. * * @return bool Will always return true. */ -function beans_modify_action_priority( $id, $callback ) { +function beans_modify_action_priority( $id, $priority ) { - return beans_modify_action( $id, null, null, $callback ); + return beans_modify_action( $id, null, null, $priority ); } @@ -203,9 +205,9 @@ function beans_modify_action_priority( $id, $callback ) { * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $args Optional. The new number of arguments the function accepts. Use NULL to keep the - * original value. + * @param string $id The action ID. + * @param int $args Optional. The new number of arguments the function accepts. Use NULL to keep the + * original value. * * @return bool Will always return true. */ @@ -228,14 +230,14 @@ function beans_modify_action_arguments( $id, $args ) { * * @since 1.0.0 * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. + * @param string $id The action ID. + * @param string $hook Optional. The name of the new action to which the $callback is hooked. * Use NULL to keep the original value. * @param callback $callback Optional. The name of the new function you wish to be called. * Use NULL to keep the original value. - * @param int $priority Optional. The new priority. + * @param int $priority Optional. The new priority. * Use NULL to keep the original value. - * @param int $args Optional. The new number of arguments the function accepts. + * @param int $args Optional. The new number of arguments the function accepts. * Use NULL to keep the original value. * * @return bool Will always return true. @@ -304,12 +306,12 @@ function beans_replace_action_callback( $id, $callback ) { * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $priority Optional. The new priority. Use NULL to keep the original value. + * @param string $id The action ID. + * @param int $priority Optional. The new priority. Use NULL to keep the original value. * * @return bool Will always return true. */ -function beans_replace_action_priority( $id, $callback ) { +function beans_replace_action_priority( $id, $priority ) { return beans_replace_action( $id, null, null, $priority ); @@ -322,9 +324,9 @@ function beans_replace_action_priority( $id, $callback ) { * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $args Optional. The new number of arguments the function accepts. Use NULL to keep the original - * value. + * @param string $id The action ID. + * @param int $args Optional. The new number of arguments the function accepts. Use NULL to keep the original + * value. * * @return bool Will always return true. */ @@ -539,73 +541,93 @@ function _beans_add_anonymous_action( $hook, $callback, $priority = 10, $args = /** * Render action which can therefore be stored in a variable. * + * @since 1.5.0 * @ignore + * @access private + * + * @param mixed $hook Hook and possibly sub-hooks to be rendered. + * + * @return bool|null|string */ function _beans_render_action( $hook ) { - $args = func_get_args(); - // Return simple action if no sub-hook is set. - if ( ! preg_match_all( '#\[(.*?)\]#', $args[0], $matches ) ) { - - if ( has_filter( $args[0] ) ) { - return call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); - } else { - return false; - } + // Return simple action if no sub-hook(s) is(are) set. + if ( ! preg_match_all( '#\[(.*?)\]#', $args[0], $sub_hooks ) ) { + return _beans_when_has_action_do_render( $args ); } - $output = null; - $prefix = current( explode( '[', $args[0] ) ); + $output = null; + $prefix = current( explode( '[', $args[0] ) ); $variable_prefix = $prefix; - $suffix = preg_replace( '/^.*\]\s*/', '', $args[0] ); + $suffix = preg_replace( '/^.*\]\s*/', '', $args[0] ); // Base hook. $args[0] = $prefix . $suffix; - if ( has_filter( $args[0] ) ) { - $output .= call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); - } + // If the base hook is registered, render it. + _beans_when_has_action_do_render( $args, $output ); - foreach ( $matches[0] as $i => $subhook ) { + foreach ( (array) $sub_hooks[0] as $index => $sub_hook ) { + $variable_prefix .= $sub_hook; - $variable_prefix = $variable_prefix . $subhook; - $levels = array( $prefix . $subhook . $suffix ); + $levels = array( $prefix . $sub_hook . $suffix ); // Cascade sub-hooks. - if ( $i > 0 ) { - - $levels[] = str_replace( $subhook, '', $hook ); + if ( $index > 0 ) { $levels[] = $variable_prefix . $suffix; - } // Apply sub-hooks. foreach ( $levels as $level ) { - $args[0] = $level; - if ( has_filter( $args[0] ) ) { - $output .= call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); - } + // If the level is registered, render it. + _beans_when_has_action_do_render( $args, $output ); - // Apply filter whithout square brackets for backwards compatibility. + // Apply filter without square brackets for backwards compatibility. $args[0] = preg_replace( '#(\[|\])#', '', $args[0] ); - if ( has_filter( $args[0] ) ) { - $output .= call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); - } + // If the backwards compatible $args[0] is registered, render it. + _beans_when_has_action_do_render( $args, $output ); } } return $output; +} +/** + * Calls beans_render_function when the hook is registered. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @param array $args Array of arguments. + * @param string $output The output to be updated. + * + * @return string|bool + */ +function _beans_when_has_action_do_render( array $args, &$output = '' ) { + + if ( has_action( $args[0] ) ) { + $output .= call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); + return $output; + } + + return false; } /** * Make sure the action ID is unique. * + * @since 1.5.0 * @ignore + * @access private + * + * @param mixed $callback Callback to convert into a unique ID. + * + * @return array|string */ function _beans_unique_action_id( $callback ) { @@ -627,13 +649,12 @@ function _beans_unique_action_id( $callback ) { } return get_class( $callback[0] ) . $callback[1]; + } - } elseif ( is_string( $callback[0] ) ) { // Treat static method. - + // Treat static method. + if ( is_string( $callback[0] ) ) { return $callback[0] . '::' . $callback[1]; - } return md5( $callback ); - } diff --git a/tests/phpunit/unit/api/actions/beansRenderAction.php b/tests/phpunit/unit/api/actions/beansRenderAction.php new file mode 100644 index 00000000..ef5ed2c6 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansRenderAction.php @@ -0,0 +1,219 @@ +assertFalse( _beans_render_action( 'foo' ) ); + $this->assertFalse( _beans_render_action( 'foo', 'bar' ) ); + $this->assertFalse( _beans_render_action( 'foo', 'bar', array( 'baz' => 'zab' ) ) ); + $this->assertFalse( _beans_render_action( 'foo_bar' ) ); + $this->assertFalse( _beans_render_action( 'foo.bar' ) ); + $this->assertFalse( _beans_render_action( 'beans_footer_before_markup' ) ); + $this->assertFalse( _beans_render_action( 'beans_footer_after_markup' ) ); + } + + /** + * Test _beans_render_action() should return after calling the hook with no sub-hook. + */ + public function test_should_return_after_calling_hook_no_subhook() { + // Testing with a closure. + $expected_args = array( + array( 'foo' ), + array( 'foo', 'bar' ), + array( 'foo', 'bar', 'baz' ), + ); + $callback = function() use ( $expected_args ) { + $args = func_get_args(); + $this->assertTrue( doing_action( 'beans_stub' ) ); + $this->assertEquals( $expected_args[ $args[0] ], $args[1] ); + + // Let's echo out to ensure this callback will was called. + echo $args[1][0]; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + }; + add_action( 'beans_stub', $callback ); + $this->assertTrue( has_action( 'beans_stub' ) ); + Actions\expectDone( 'beans_stub' )->whenHappen( $callback ); + foreach ( $expected_args as $index => $args ) { + $this->assertEquals( $args[0], _beans_render_action( 'beans_stub', $index, $args ) ); + } + + // Testing with a stubbed method. + $stub = new Actions_Stub(); + $message = 'Beans rocks!'; + add_action( 'beans_stub_with_object', array( $stub, 'echo_static' ) ); + $this->assertTrue( has_action( 'beans_stub_with_object' ) ); + Actions\expectDone( 'beans_stub_with_object' )->whenHappen( array( $stub, 'echo_static' ) ); + $this->assertEquals( $message, _beans_render_action( 'beans_stub_with_object', $message ) ); + + // Testing with a stubbed static method. + $stub = Actions_Stub::class; + add_action( 'beans_stub_with_static_method', array( $stub, 'echo_static' ) ); + $this->assertTrue( has_action( 'beans_stub_with_static_method' ) ); + Actions\expectDone( 'beans_stub_with_static_method' )->times( 3 )->whenHappen( array( $stub, 'echo_static' ) ); + + $message = 'Calling the static method...and Beans rocks!'; + $this->assertEquals( $message, _beans_render_action( 'beans_stub_with_static_method', $message ) ); + $message = 'Yippee, it worked again!'; + $this->assertEquals( $message, _beans_render_action( 'beans_stub_with_static_method', $message ) ); + $this->assertEquals( 5, _beans_render_action( 'beans_stub_with_static_method', 5 ) ); + } + + /** + * Test _beans_render_action() should return null for a sub-hook(s) when no callback is registered. + */ + public function test_should_return_null_for_subhook_when_no_callback_registered() { + $this->assertNull( _beans_render_action( 'beans_stub[beans_subhook_stub]' ) ); + $this->assertNull( _beans_render_action( 'beans_stub[subhook][subhook]' ) ); + $this->assertNull( _beans_render_action( 'beans_stub[beans_subhook_stub]_after_test' ) ); + } + + /** + * Test _beans_render_action() should render the base hook and not the sub-hooks. + * Why? No callbacks are registered to the sub-hooks. + */ + public function test_should_render_base_hook() { + $stub = Actions_Stub::class; + + // Test with a single sub-hook. + add_action( 'foo', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo' )->whenHappen( array( $stub, 'echo_static' ) ); + Actions\expectDone( 'bar' )->never(); + $this->assertEquals( 'Called foo.', _beans_render_action( 'foo[bar]', 'Called foo.' ) ); + + // Test with a suffix. + add_action( 'foo_bar', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo_bar' )->whenHappen( array( $stub, 'echo_static' ) ); + Actions\expectDone( 'baz_bar' )->never(); + $this->assertEquals( 'Called foo_bar.', _beans_render_action( 'foo[baz]_bar', 'Called foo_bar.' ) ); + + // Test with multiple sub-hooks. + add_action( 'beans_stub', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'beans_stub' )->whenHappen( array( $stub, 'echo_static' ) ); + Actions\expectDone( 'beans_stub[_pre]' )->never(); + Actions\expectDone( 'beans_stub[_before]' )->never(); + Actions\expectDone( 'beans_stub[_pre][_before]' )->never(); + $this->assertEquals( 'Beans rocks!', _beans_render_action( 'beans_stub[_pre][_before]', 'Beans rocks!' ) ); + + // Test with multiple sub-hooks. + add_action( 'beans_stub_after', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'beans_stub_after' )->whenHappen( array( $stub, 'echo_static' ) ); + Actions\expectDone( 'beans_stub[_pre]_after' )->never(); + Actions\expectDone( 'beans_stub[_before]_after' )->never(); + Actions\expectDone( 'beans_stub[_pre][_before]_after' )->never(); + $this->assertEquals( 'Beans rocks!', _beans_render_action( 'beans_stub[_subhook][_subsubhook]_after', 'Beans rocks!' ) ); + } + + /** + * Test _beans_render_action() should render one level of sub-hooks. + */ + public function test_should_render_one_level_of_sub_hooks() { + $stub = Actions_Stub::class; + $hook = 'foo[bar]'; + $message = 'Called me. '; + + // The root hook renders. + add_action( 'foo', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + $expected = $message; + + // The 1st sub-hook renders. + add_action( 'foo[bar]', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo[bar]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + $expected .= $message; + + // Run the test. + $this->assertEquals( $expected, _beans_render_action( $hook, $message ) ); + } + + /** + * Test _beans_render_action() should render two levels of sub-hooks, but not the original. + * Why? A callback is not registered to the original hook. + */ + public function test_should_render_two_levels_of_sub_hooks_but_not_original() { + $stub = Actions_Stub::class; + $hook = 'foo[bar][baz]'; + $message = 'Called me. '; + + // The root hook renders. + add_action( 'foo', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + $expected = $message; + + // The 1st sub-hook renders. + add_action( 'foo[bar]', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo[bar]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + $expected .= $message; + + // These hooks will not render as they are not registered. + Actions\expectDone( 'foo[baz]' )->never(); + Actions\expectDone( 'foo[bar][baz]' )->never(); + + // Run the test. + $this->assertEquals( $expected, _beans_render_action( $hook, $message ) ); + } + + /** + * Test _beans_render_action() should render the base hook and all sub-hooks. + */ + public function test_should_render_hook_and_all_subhooks() { + $stub = Actions_Stub::class; + $hook = 'foo[bar][baz]'; + $message = 'Called me. '; + + // The root hook renders. + add_action( 'foo', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + $expected = $message; + + // The 1st sub-hook renders. + add_action( 'foo[bar]', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo[bar]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + $expected .= $message; + + // The 2nd sub-hook renders. + add_action( 'foo[baz]', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo[baz]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + $expected .= $message; + + // The original hook renders. + add_action( 'foo[bar][baz]', array( $stub, 'echo_static' ) ); + Actions\expectDone( 'foo[bar][baz]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + $expected .= $message; + + // Run the test. + $this->assertEquals( $expected, _beans_render_action( $hook, $message ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansUniqueActionId.php b/tests/phpunit/unit/api/actions/beansUniqueActionId.php new file mode 100644 index 00000000..c8a61d11 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansUniqueActionId.php @@ -0,0 +1,116 @@ +assertEquals( "I'm a string", _beans_unique_action_id( "I'm a string" ) ); + $this->assertEquals( 'I\'m a string', _beans_unique_action_id( 'I\'m a string' ) ); + $this->assertEquals( 'foo', _beans_unique_action_id( 'foo' ) ); + $this->assertEquals( 'trim', _beans_unique_action_id( 'trim' ) ); + $this->assertEquals( '__return_false', _beans_unique_action_id( '__return_false' ) ); + $this->assertEquals( __NAMESPACE__ . '\foo', _beans_unique_action_id( __NAMESPACE__ . '\foo' ) ); + $this->assertEquals( + 'Tests_BeansUniqueActionId::test_should_return_when_string', + _beans_unique_action_id( 'Tests_BeansUniqueActionId::test_should_return_when_string' ) + ); + } + + /** + * Test _beans_unique_action_id() should convert static method. + */ + public function test_should_convert_static_method() { + $this->assertEquals( + 'Foo::bar', + _beans_unique_action_id( array( 'Foo', 'bar' ) ) + ); + $this->assertEquals( + 'Tests_BeansUniqueActionId::test_should_return_when_string', + _beans_unique_action_id( array( 'Tests_BeansUniqueActionId', 'test_should_return_when_string' ) ) + ); + + $stub_classname = __NAMESPACE__ . '\Actions_Stub'; + $this->assertEquals( + $stub_classname . '::dummy_static_method', + _beans_unique_action_id( array( $stub_classname, 'dummy_static_method' ) ) + ); + $this->assertEquals( + $stub_classname . '::dummy_static_method', + _beans_unique_action_id( $stub_classname . '::dummy_static_method' ) + ); + + $stub = new Actions_Stub(); + $this->assertNotEquals( + $stub_classname . '::dummy_static_method', + _beans_unique_action_id( array( $stub, 'dummy_static_method' ) ) + ); + $this->assertStringEndsWith( + 'dummy_static_method', + _beans_unique_action_id( array( $stub, 'dummy_static_method' ) ) + ); + $this->assertEquals( + spl_object_hash( $stub ) . 'dummy_static_method', + _beans_unique_action_id( array( $stub, 'dummy_static_method' ) ) + ); + } + + /** + * Test _beans_unique_action_id() should convert object. + */ + public function test_should_convert_object() { + // 2 different objects should have unique IDs. + $this->assertNotEquals( new \stdClass(), _beans_unique_action_id( new \stdClass() ) ); + $this->assertNotEquals( new Actions_Stub(), _beans_unique_action_id( new Actions_Stub() ) ); + + $stub = new Actions_Stub(); + $this->assertEquals( spl_object_hash( $stub ), _beans_unique_action_id( $stub ) ); + $this->assertEquals( + spl_object_hash( $stub ) . 'dummy_method', + _beans_unique_action_id( array( $stub, 'dummy_method' ) ) + ); + } + + /** + * Test _beans_unique_action_id() should convert closure. + */ + public function test_should_convert_closure() { + $closure = function( $dummy_arg ) { + return $dummy_arg; + }; + + $this->assertEquals( spl_object_hash( $closure ), _beans_unique_action_id( $closure ) ); + $this->assertNotEquals( spl_object_hash( function() { + // Nothing here. + } ), _beans_unique_action_id( $closure ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/stubs/class-action-stub.php b/tests/phpunit/unit/api/actions/stubs/class-action-stub.php new file mode 100644 index 00000000..b44b4c80 --- /dev/null +++ b/tests/phpunit/unit/api/actions/stubs/class-action-stub.php @@ -0,0 +1,41 @@ + Date: Mon, 11 Dec 2017 08:12:41 -0600 Subject: [PATCH 018/800] Made __beans_add_anonymous_action compliant --- .../actions/class-beans-anonymous-action.php | 56 ++++++++++++++++ lib/api/actions/class.php | 49 -------------- lib/api/actions/functions.php | 27 +++++--- .../api/actions/beansAddAnonymousAction.php | 46 +++++++++++++ .../api/actions/beansAddAnonymousAction.php | 65 +++++++++++++++++++ 5 files changed, 186 insertions(+), 57 deletions(-) create mode 100644 lib/api/actions/class-beans-anonymous-action.php delete mode 100644 lib/api/actions/class.php create mode 100644 tests/phpunit/integration/api/actions/beansAddAnonymousAction.php create mode 100644 tests/phpunit/unit/api/actions/beansAddAnonymousAction.php diff --git a/lib/api/actions/class-beans-anonymous-action.php b/lib/api/actions/class-beans-anonymous-action.php new file mode 100644 index 00000000..5c435042 --- /dev/null +++ b/lib/api/actions/class-beans-anonymous-action.php @@ -0,0 +1,56 @@ +callback = $callback; + + add_action( $hook, array( $this, 'callback' ), $priority, $number_args ); + } + + /** + * Get action content and set it as the callback. + * + * @since 1.5.0 + * + * @return void + */ + public function callback() { + echo call_user_func_array( $this->callback[0], $this->callback[1] ); // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: the callback should escape the output. + } +} diff --git a/lib/api/actions/class.php b/lib/api/actions/class.php deleted file mode 100644 index 4cab2c38..00000000 --- a/lib/api/actions/class.php +++ /dev/null @@ -1,49 +0,0 @@ -callback = $callback; - - add_action( $hook, array( $this, 'callback' ), $priority, $args ); - - } - - /** - * Get action content and set it as the callback. - */ - public function callback() { - - echo call_user_func_array( $this->callback[0], $this->callback[1] ); - - } -} diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 851e0b6a..375af2a9 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -528,20 +528,31 @@ function _beans_get_current_action( $id ) { /** * Add anonymous callback using a class since php 5.2 is still supported. * + * @since 1.5.0 * @ignore + * @access private + * + * @param string $hook The name of the action to which the $callback is hooked. + * @param array $callback The callback to register to the given $hook and arguments to pass. + * @param int $priority Optional. Used to specify the order in which the functions + * associated with a particular action are executed. Default 10. + * Lower numbers correspond with earlier execution, + * and functions with the same priority are executed + * in the order in which they were added to the action. + * @param int $number_args Optional. The number of arguments the function accepts. Default 1. + * + * @return _Beans_Anonymous_Actions */ -function _beans_add_anonymous_action( $hook, $callback, $priority = 10, $args = 1 ) { - - require_once( BEANS_API_PATH . 'actions/class.php' ); - - new _Beans_Anonymous_Actions( $hook, $callback, $priority, $args ); +function _beans_add_anonymous_action( $hook, array $callback, $priority = 10, $number_args = 1 ) { + require_once BEANS_API_PATH . 'actions/class-beans-anonymous-action.php'; + return new _Beans_Anonymous_Actions( $hook, $callback, $priority, $number_args ); } /** * Render action which can therefore be stored in a variable. * - * @since 1.5.0 + * @since 1.5.0 * @ignore * @access private * @@ -599,7 +610,7 @@ function _beans_render_action( $hook ) { /** * Calls beans_render_function when the hook is registered. * - * @since 1.5.0 + * @since 1.5.0 * @ignore * @access private * @@ -621,7 +632,7 @@ function _beans_when_has_action_do_render( array $args, &$output = '' ) { /** * Make sure the action ID is unique. * - * @since 1.5.0 + * @since 1.5.0 * @ignore * @access private * diff --git a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php new file mode 100644 index 00000000..f3506364 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php @@ -0,0 +1,46 @@ +assertTrue( has_action( 'do_foo' ) ); + } + + /** + * Test _beans_add_anonymous_action() should call callback on the given hook. + */ + public function test_should_call_callback() { + _beans_add_anonymous_action( 'beans_test_do_foo', array( 'foo_test_callback', array( 'foo' ) ) ); + + Functions\when( 'foo_test_callback' ) + ->justReturn( 'foo' ); + + ob_start(); + do_action( 'beans_test_do_foo' ); + $this->assertEquals( 'foo', ob_get_clean() ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php b/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php new file mode 100644 index 00000000..e67b6edd --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php @@ -0,0 +1,65 @@ +assertTrue( has_action( 'do_foo' ) ); + } + + /** + * Test _beans_add_anonymous_action() should call callback on the given hook. + */ + public function test_should_call_callback() { + $object = _beans_add_anonymous_action( 'beans_test_do_foo', array( 'foo_test_callback', array( 'foo' ) ) ); + + Functions\when( 'foo_test_callback' ) + ->justReturn( 'foo' ); + + Actions\expectDone( 'beans_test_do_foo' ) + ->once() + ->whenHappen( function() use ( $object ) { + ob_start(); + $object->callback(); + $this->assertEquals( 'foo', ob_get_clean() ); + } ); + + do_action( 'beans_test_do_foo' ); + } +} From f82b4c791d6a5d266768fc314dd0140016351394 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Tue, 2 Jan 2018 22:11:18 +0100 Subject: [PATCH 019/800] Issue 91: fix next icons closing markup ids --- lib/templates/fragments/comments.php | 2 +- lib/templates/fragments/post.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index d320ba3b..1a6e02d4 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -293,7 +293,7 @@ function beans_comments_navigation() { $next_icon = beans_open_markup( 'beans_next_icon[_comments_navigation]', 'i', array( 'class' => 'uk-icon-angle-double-right uk-margin-small-right', ) ); - $next_icon .= beans_close_markup( 'beans_previous_icon[_comments_navigation]', 'i' ); + $next_icon .= beans_close_markup( 'beans_next_icon[_comments_navigation]', 'i' ); echo get_next_comments_link( beans_output( 'beans_next_text[_comments_navigation]', __( 'Next', 'tm-beans' ) ) . $next_icon diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 02cbf5d4..7557c0c8 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -305,7 +305,7 @@ function beans_post_more_link() { $output .= beans_open_markup( 'beans_next_icon[_more_link]', 'i', array( 'class' => 'uk-icon-angle-double-right uk-margin-small-left', ) ); - $output .= beans_close_markup( 'beans_previous_icon[_more_link]', 'i' ); + $output .= beans_close_markup( 'beans_next_icon[_more_link]', 'i' ); $output .= beans_close_markup( 'beans_post_more_link', 'a' ); @@ -429,7 +429,7 @@ function beans_next_post_link( $output, $format, $link, $post ) { 'class' => 'uk-icon-angle-double-right uk-margin-small-left', ) ); - $output .= beans_close_markup( 'beans_previous_icon[_post_navigation]', 'i' ); + $output .= beans_close_markup( 'beans_next_icon[_post_navigation]', 'i' ); $output .= beans_close_markup( 'beans_next_link[_post_navigation]', 'a' ); From d2ced20d10d1a443c09f01ee0e9b39dcea4d9d79 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Wed, 3 Jan 2018 11:15:29 -0600 Subject: [PATCH 020/800] Made private functions compliant (#92) `_beans_get_action`, `_beans_set_action`, `_beans_unset_action`, `_beans_merge_action`, and `_beans_get_current_action` received the following refactoring enhancements: 1. Made WPCS compliant 2. Added unit tests 3. Added DocBlock Added a new private function _beans_is_action_valid() to check if: 1. Each required parameter (key) is set 2. Each required value is not null. --- lib/api/actions/functions.php | 145 +++++++++++++----- .../unit/api/actions/beansGetAction.php | 119 ++++++++++++++ .../api/actions/beansGetCurrentAction.php | 140 +++++++++++++++++ .../unit/api/actions/beansIsActionValid.php | 122 +++++++++++++++ .../unit/api/actions/beansMergeAction.php | 108 +++++++++++++ .../unit/api/actions/beansSetAction.php | 144 +++++++++++++++++ .../unit/api/actions/beansUnsetAction.php | 123 +++++++++++++++ tests/phpunit/unit/class-test-case.php | 5 + 8 files changed, 867 insertions(+), 39 deletions(-) create mode 100644 tests/phpunit/unit/api/actions/beansGetAction.php create mode 100644 tests/phpunit/unit/api/actions/beansGetCurrentAction.php create mode 100644 tests/phpunit/unit/api/actions/beansIsActionValid.php create mode 100644 tests/phpunit/unit/api/actions/beansMergeAction.php create mode 100644 tests/phpunit/unit/api/actions/beansSetAction.php create mode 100644 tests/phpunit/unit/api/actions/beansUnsetAction.php diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 375af2a9..eec5de33 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -410,119 +410,186 @@ function beans_reset_action( $id ) { } /** - * Get action. + * Get the action's configuration for the given ID and status. Returns `false` if the action is not registered with + * Beans. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $status Status for which to get the action. + * + * @return array|bool */ function _beans_get_action( $id, $status ) { - global $_beans_registered_actions; - $id = _beans_unique_action_id( $id ); + $id = _beans_unique_action_id( $id ); + $registered_actions = beans_get( $status, $_beans_registered_actions ); - if ( ! $registered = beans_get( $status, $_beans_registered_actions ) ) { + // If the status is empty, return false, as no actions are registered. + if ( empty( $registered_actions ) ) { return false; } - if ( ! $action = beans_get( $id, $registered ) ) { + $action = beans_get( $id, $registered_actions ); + + // If the action is empty, return false. + if ( empty( $action ) ) { return false; } return (array) json_decode( $action ); - } /** - * Set action. + * Store the action's configuration for the given ID and status. * + * What happens if the action's configuration is already registered? If the `$overwrite` flag is set to `true`, + * then the new action's configuration is stored, overwriting the previous one. Else, the registered action's + * configuration is returned. + * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param array|mixed $action The action configuration to store. + * @param string $status Status for which to store the action. + * @param bool $overwrite Optional. When set to `true`, the new action's configuration is stored, overwriting a + * previously stored configuration (if one exists). + * + * @return array|mixed */ function _beans_set_action( $id, $action, $status, $overwrite = false ) { - - global $_beans_registered_actions; - $id = _beans_unique_action_id( $id ); - // Return action which already exist unless overwrite is set to true. - if ( ! $overwrite && ( $_action = _beans_get_action( $id, $status ) ) ) { - return $_action; + // Get the action, if it's already registered. + $registered_action = _beans_get_action( $id, $status ); + + // If the action is registered and we are not overwriting, return it. + if ( true !== $overwrite && ! empty( $registered_action ) ) { + return $registered_action; } - $_beans_registered_actions[ $status ][ $id ] = json_encode( $action ); + // Let's set (or overwrite) the action. + global $_beans_registered_actions; + $_beans_registered_actions[ $status ][ $id ] = wp_json_encode( $action ); return $action; - } /** - * Unset action. + * Unset the action's configuration for the given ID and status. Returns `false` if there are is no action + * registered with Beans actions for the given ID and status. Else, returns true when complete. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $status Status for which to get the action. + * + * @return bool */ function _beans_unset_action( $id, $status ) { - - global $_beans_registered_actions; - $id = _beans_unique_action_id( $id ); - // Stop here if the action doesn't exist. - if ( ! _beans_get_action( $id, $status ) ) { + // Bail out if the ID is not registered for the given status. + if ( false === _beans_get_action( $id, $status ) ) { return false; } + global $_beans_registered_actions; unset( $_beans_registered_actions[ $status ][ $id ] ); return true; - } /** - * Merge action. + * Merge the action's configuration and then store it for the given ID and status. * + * If the action's configuration has not already been registered with Beans, just store it. + * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param array $action The new action's configuration to merge and then store. + * @param string $status Status for which to merge/store this action. + * + * @return array */ -function _beans_merge_action( $id, $action, $status ) { - - global $_beans_registered_actions; +function _beans_merge_action( $id, array $action, $status ) { + $id = _beans_unique_action_id( $id ); + $registered_action = _beans_get_action( $id, $status ); - $id = _beans_unique_action_id( $id ); - - if ( $_action = _beans_get_action( $id, $status ) ) { - $action = array_merge( $_action, $action ); + // If the action's configuration is already registered with Beans, merge the new configuration with it. + if ( false !== $registered_action ) { + $action = array_merge( $registered_action, $action ); } + // Now store/register it. return _beans_set_action( $id, $action, $status, true ); - } /** - * Check all action status and return the current action. + * Get the current action, meaning get from the "added" and/or "modified" statuses. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * + * @return array|bool */ function _beans_get_current_action( $id ) { - - $action = array(); - + // Bail out if the action is "removed". if ( _beans_get_action( $id, 'removed' ) ) { return false; } - if ( $added = _beans_get_action( $id, 'added' ) ) { + $action = array(); + + $added = _beans_get_action( $id, 'added' ); + + if ( false !== $added ) { $action = $added; } - if ( $modified = _beans_get_action( $id, 'modified' ) ) { - $action = array_merge( $action, $modified ); + $modified = _beans_get_action( $id, 'modified' ); + + if ( false !== $modified ) { + $action = is_array( $action ) + ? array_merge( $action, $modified ) + : $modified; } // Stop here if the action is invalid. - if ( 4 != count( $action ) ) { + if ( ! _beans_is_action_valid( $action ) ) { return false; } return $action; +} +/** + * Validates the action's configuration to ensure "hook", "callback", "priority", and "args" are + * set and not null. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @param array $action Action's configuration. + * + * @return bool + */ +function _beans_is_action_valid( array $action ) { + return isset( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } /** diff --git a/tests/phpunit/unit/api/actions/beansGetAction.php b/tests/phpunit/unit/api/actions/beansGetAction.php new file mode 100644 index 00000000..72d88aec --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansGetAction.php @@ -0,0 +1,119 @@ +action_status = array( 'added', 'modified', 'removed', 'replaced' ); + require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; + + $this->action = array( + 'hook' => 'foo', + 'callback' => 'callback', + 'priority' => 10, + 'args' => 1, + ); + $this->encoded_action = wp_json_encode( $this->action ); + } + + /** + * Reset the test fixture. + */ + protected function tearDown() { + parent::tearDown(); + + global $_beans_registered_actions; + $_beans_registered_actions = array( + 'added' => array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + } + + /** + * Test _beans_get_action() should return false when the status is empty, i.e. no actions are registered. + */ + public function test_should_return_false_when_status_is_empty() { + foreach ( $this->action_status as $action_status ) { + $this->assertFalse( _beans_get_action( 'foo', $action_status ) ); + } + } + + /** + * Test _beans_get_action() should return false when the action is not registered. + */ + public function test_should_return_false_when_action_is_not_registered() { + global $_beans_registered_actions; + $_beans_registered_actions['added']['foo'] = $this->encoded_action; + + $this->assertFalse( _beans_get_action( 'foobar', 'added' ) ); + + // Make sure we get false on the other statuses. + foreach ( $this->action_status as $action_status ) { + + // Skip the 'added' status. + if ( 'added' === $action_status ) { + continue; + } + + $this->assertFalse( _beans_get_action( 'foo', $action_status ) ); + } + } + + /** + * Test _beans_get_action() should return the action's configuration when it's registered. + */ + public function test_should_return_action_when_registered() { + global $_beans_registered_actions; + + foreach ( $this->action_status as $action_status ) { + $_beans_registered_actions[ $action_status ]['foo'] = $this->encoded_action; + $this->assertEquals( $this->action, _beans_get_action( 'foo', $action_status ) ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php new file mode 100644 index 00000000..0870b7af --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php @@ -0,0 +1,140 @@ + array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + } + + /** + * Test _beans_get_current_action() should return false when the ID is registered with the "removed" status. + */ + public function test_should_return_false_when_removed_status() { + global $_beans_registered_actions; + $_beans_registered_actions['removed']['foo'] = wp_json_encode( array( + 'hook' => 'foo', + 'callback' => 'callback', + 'priority' => 10, + 'args' => 1, + ) ); + + $this->assertFalse( _beans_get_current_action( 'foo' ) ); + } + + /** + * Test _beans_get_current_action() should return false when the action is invalid. + */ + public function test_should_return_false_when_action_is_invalid() { + global $_beans_registered_actions; + + // Test "added" status. + $_beans_registered_actions['added']['foo'] = wp_json_encode( array( 'hook' => 'foo' ) ); + $this->assertFalse( _beans_get_current_action( 'foo' ) ); + + // Test "modified" status. + $_beans_registered_actions['modified']['bar'] = wp_json_encode( array( + 'hook' => 'bar', + 'priority' => 1, + ) ); + $this->assertFalse( _beans_get_current_action( 'bar' ) ); + + // Test merging "modified" into "added" status. + $_beans_registered_actions['modified']['foo'] = wp_json_encode( array( 'callback' => 'foo_cb' ) ); + $this->assertFalse( _beans_get_current_action( 'foo' ) ); + } + + /** + * Test _beans_get_current_action() should return the "added" configuration. + */ + public function test_should_return_added_action() { + global $_beans_registered_actions; + $action = array( + 'hook' => 'foo', + 'callback' => 'callback', + 'priority' => 10, + 'args' => 1, + ); + $_beans_registered_actions['added']['foo'] = wp_json_encode( $action ); + $this->assertEquals( $action, _beans_get_current_action( 'foo' ) ); + } + + /** + * Test _beans_get_current_action() should return the "modified" configuration. + */ + public function test_should_return_modified_action() { + global $_beans_registered_actions; + $action = array( + 'hook' => 'foo', + 'callback' => 'callback', + 'priority' => 10, + 'args' => 1, + ); + $_beans_registered_actions['modified']['foo'] = wp_json_encode( $action ); + $this->assertEquals( $action, _beans_get_current_action( 'foo' ) ); + } + + /** + * Test _beans_get_current_action() should merge "modified" action's configuration with the "added" configuration. + */ + public function test_should_merge_modified_with_added() { + global $_beans_registered_actions; + + $_beans_registered_actions['added']['foo'] = wp_json_encode( array( + 'hook' => 'foo', + 'callback' => 'callback', + 'priority' => 10, + 'args' => 1, + ) ); + + $_beans_registered_actions['modified']['foo'] = wp_json_encode( array( + 'priority' => 1, + ) ); + + $expected = array( + 'hook' => 'foo', + 'callback' => 'callback', + 'priority' => 1, + 'args' => 1, + ); + $this->assertEquals( $expected, _beans_get_current_action( 'foo' ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansIsActionValid.php b/tests/phpunit/unit/api/actions/beansIsActionValid.php new file mode 100644 index 00000000..b4ffbea3 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansIsActionValid.php @@ -0,0 +1,122 @@ +assertFalse( _beans_is_action_valid( array( 'hook' => 'foo' ) ) ); + $this->assertFalse( _beans_is_action_valid( array( 'callback' => 'cb' ) ) ); + + $this->assertFalse( _beans_is_action_valid( array( + 'hook' => 'foo', + 'callback' => 'cb', + ) ) ); + + $this->assertFalse( _beans_is_action_valid( array( + 'hook' => 'foo', + 'callback' => 'cb', + 'priority' => 10, + ) ) ); + + $this->assertFalse( _beans_is_action_valid( array( + 'hook' => 'foo', + 'callback' => 'cb', + 'args' => 2, + ) ) ); + + $this->assertFalse( _beans_is_action_valid( array( + 'hook' => 'foo', + 'priority' => 10, + 'args' => 2, + ) ) ); + + $this->assertFalse( _beans_is_action_valid( array( + 'callback' => 'cb', + 'priority' => 10, + 'args' => 2, + ) ) ); + + $this->assertFalse( _beans_is_action_valid( array( + 'callback' => 'cb', + 'priority' => 10, + 'args' => 2, + 'foo' => 'bar', + ) ) ); + } + + /** + * Test _beans_is_action_valid() should return false when one or more of the required parameters is set to null. + */ + public function test_should_return_false_when_parameter_is_null() { + $this->assertFalse( _beans_is_action_valid( array( + 'hook' => 'foo', + 'callback' => null, + 'priority' => 10, + 'args' => 2, + ) ) ); + } + + /** + * Test _beans_is_action_valid() should return true when the action's configuration is valid. + */ + public function test_should_return_true_when_action_is_valid() { + $this->assertTrue( _beans_is_action_valid( array( + 'hook' => 'foo', + 'callback' => 'cb', + 'priority' => 10, + 'args' => 2, + ) ) ); + + $this->assertTrue( _beans_is_action_valid( array( + 'hook' => 'start_loop', + 'callback' => 'foo_callback', + 'priority' => 20, + 'args' => 1, + ) ) ); + + $object = new \stdClass(); + $this->assertTrue( _beans_is_action_valid( array( + 'hook' => 'some_hook[_some_subhook]', + 'callback' => [ $object, 'callback_method' ], + 'priority' => 10, + 'args' => 2, + ) ) ); + + $this->assertTrue( _beans_is_action_valid( array( + 'hook' => 'post_title', + 'callback' => 'Some_Object::some_method', + 'priority' => 50, + 'args' => 3, + ) ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansMergeAction.php b/tests/phpunit/unit/api/actions/beansMergeAction.php new file mode 100644 index 00000000..e1bb8979 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansMergeAction.php @@ -0,0 +1,108 @@ +action_status = array( 'added', 'modified', 'removed', 'replaced' ); + require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; + + $this->action = array( + 'hook' => 'foo', + 'callback' => 'callback', + 'priority' => 10, + 'args' => 1, + ); + $this->encoded_action = wp_json_encode( $this->action ); + } + + /** + * Reset the test fixture. + */ + protected function tearDown() { + parent::tearDown(); + + global $_beans_registered_actions; + $_beans_registered_actions = array( + 'added' => array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + } + + /** + * Test _beans_set_action() should merge the new action's configuration with the registered one and then return it. + */ + public function test_should_merge_and_return() { + global $_beans_registered_actions; + + $expected = $this->action; + $expected['priority'] = 20; + + foreach ( $this->action_status as $action_status ) { + // Set the original action configuration. + _beans_set_action( 'foo', $this->action, $action_status ); + + // Now test that it does properly merge the action for the given status. + $this->assertEquals( $expected, _beans_merge_action( 'foo', array( 'priority' => 20 ), $action_status ) ); + $this->assertEquals( wp_json_encode( $expected ), $_beans_registered_actions[ $action_status ]['foo'] ); + } + } + + /** + * Test _beans_merge_action() should store new action's configuration, when it's not already registered. + */ + public function test_should_store_new_action() { + global $_beans_registered_actions; + + foreach ( $this->action_status as $action_status ) { + $this->assertEquals( $this->action, _beans_merge_action( 'foo', $this->action, $action_status ) ); + $this->assertEquals( $this->encoded_action, $_beans_registered_actions[ $action_status ]['foo'] ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansSetAction.php b/tests/phpunit/unit/api/actions/beansSetAction.php new file mode 100644 index 00000000..ef67a921 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansSetAction.php @@ -0,0 +1,144 @@ +action_status = array( 'added', 'modified', 'removed', 'replaced' ); + require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; + + $this->action = array( + 'hook' => 'foo', + 'callback' => 'callback', + 'priority' => 10, + 'args' => 1, + ); + $this->encoded_action = wp_json_encode( $this->action ); + } + + /** + * Reset the test fixture. + */ + protected function tearDown() { + parent::tearDown(); + + global $_beans_registered_actions; + $_beans_registered_actions = array( + 'added' => array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + } + + /** + * Test _beans_set_action() should set the action into the registered actions and then return it. + */ + public function test_should_set_and_return_action() { + global $_beans_registered_actions; + + foreach ( $this->action_status as $action_status ) { + // Check that it's not set before we start. + $this->assertFalse( isset( $_beans_registered_actions[ $action_status ]['foo'] ) ); + + // Now test that it does properly set the action for the given status. + $this->assertEquals( $this->action, _beans_set_action( 'foo', $this->action, $action_status ) ); + $this->assertArrayHasKey( 'foo', $_beans_registered_actions[ $action_status ] ); + $this->assertEquals( $this->encoded_action, $_beans_registered_actions[ $action_status ]['foo'] ); + } + } + + /** + * Test _beans_set_action() should not overwrite an existing registered action. + */ + public function test_should_not_overwrite_existing_registered_action() { + global $_beans_registered_actions; + + $new_action = array( + 'hook' => 'bar', + 'callback' => 'callback_bar', + 'priority' => 20, + 'args' => 2, + ); + + foreach ( $this->action_status as $action_status ) { + + // Register the original one first. + _beans_set_action( 'foo', $this->action, $action_status ); + + // Now test that it does not overwrite the previously registered action. + $this->assertEquals( $this->action, _beans_set_action( 'foo', $new_action, $action_status ) ); + $this->assertEquals( $this->encoded_action, $_beans_registered_actions[ $action_status ]['foo'] ); + } + } + + /** + * Test _beans_set_action() should overwrite the existing registered action when the "overwrite" + * argument is set to true. + */ + public function test_should_overwrite_existing_registered_action() { + global $_beans_registered_actions; + + $new_action = array( + 'hook' => 'bar', + 'callback' => 'callback_bar', + 'priority' => 20, + 'args' => 2, + ); + $encoded_new_action = wp_json_encode( $new_action ); + + foreach ( $this->action_status as $action_status ) { + + // Register the original one first. + _beans_set_action( 'foo', $this->action, $action_status ); + + // Now test that it does overwrite the previously registered action. + $this->assertEquals( $new_action, _beans_set_action( 'foo', $new_action, $action_status, true ) ); + $this->assertEquals( $encoded_new_action, $_beans_registered_actions[ $action_status ]['foo'] ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansUnsetAction.php b/tests/phpunit/unit/api/actions/beansUnsetAction.php new file mode 100644 index 00000000..282e4d5c --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansUnsetAction.php @@ -0,0 +1,123 @@ +action_status = array( 'added', 'modified', 'removed', 'replaced' ); + require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; + + $this->action = array( + 'hook' => 'foo', + 'callback' => 'callback', + 'priority' => 10, + 'args' => 1, + ); + $this->encoded_action = wp_json_encode( $this->action ); + } + + /** + * Reset the test fixture. + */ + protected function tearDown() { + parent::tearDown(); + + global $_beans_registered_actions; + $_beans_registered_actions = array( + 'added' => array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + } + + /** + * Test _beans_unset_action() should return false when action's configuration is not registered. + */ + public function test_should_return_false_when_not_registered() { + + foreach ( $this->action_status as $action_status ) { + $this->assertFalse( _beans_unset_action( 'foo', $action_status ) ); + } + } + + /** + * Test _beans_unset_action() should unset the registered action's configuration. + */ + public function test_should_unset_registered_action() { + global $_beans_registered_actions; + + foreach ( $this->action_status as $action_status ) { + + // First, register the action. + _beans_set_action( 'foo', $this->action, $action_status ); + $this->assertTrue( isset( $_beans_registered_actions[ $action_status ]['foo'] ) ); + + // Then test that unset does its job. + $this->assertTrue( _beans_unset_action( 'foo', $action_status ) ); + $this->assertFalse( isset( $_beans_registered_actions[ $action_status ]['foo'] ) ); + } + } + + /** + * Test _beans_unset_action() should return false when the status is invalid. + */ + public function test_should_return_false_when_status_is_invalid() { + $this->assertFalse( _beans_unset_action( 'foo', 'invalid_status' ) ); + $this->assertFalse( _beans_unset_action( 'foo', 'foo' ) ); + $this->assertFalse( _beans_unset_action( 'foo', 'not_valid_either' ) ); + + // Now store some configurations and test it again. + foreach ( $this->action_status as $action_status ) { + _beans_set_action( 'foo', $this->action, $action_status ); + } + + $this->assertFalse( _beans_unset_action( 'foo', 'invalid_status' ) ); + $this->assertFalse( _beans_unset_action( 'foo', 'foo' ) ); + $this->assertFalse( _beans_unset_action( 'foo', 'not_valid_either' ) ); + } +} diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index b6756c83..b92771c8 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -37,6 +37,11 @@ protected function setUp() { return $path; } ); + + Functions\when( 'wp_json_encode' )->alias( function ( $array ) { + // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.json_encode_json_encode - we are mocking the function here. + return json_encode( $array ); + } ); } /** From 119c192a6ee567039613758591c548734ec25b90 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Mon, 8 Jan 2018 14:37:18 -0600 Subject: [PATCH 021/800] Made beans_modify_action compliant (#94) * Made beans_modify_action compliant 1. Made WPCS compliant. 2. Added unit tests. 3. Added integration tests. 4. Improved comments and documentation. 5. Bail out if no action to modify. 6. Return add_action instead of true. Fixes #96 --- lib/api/actions/functions.php | 153 +++++++++++------- .../api/actions/beansModifyAction.php | 107 ++++++++++++ .../actions/beansModifyActionArguments.php | 97 +++++++++++ .../api/actions/beansModifyActionCallback.php | 57 +++++++ .../api/actions/beansModifyActionHook.php | 80 +++++++++ .../api/actions/beansModifyActionPriority.php | 97 +++++++++++ .../includes/class-actions-test-case.php | 101 ++++++++++++ .../api/actions/beansBuildActionArray.php | 143 ++++++++++++++++ .../unit/api/actions/beansModifyAction.php | 135 ++++++++++++++++ .../actions/beansModifyActionArguments.php | 89 ++++++++++ .../api/actions/beansModifyActionCallback.php | 79 +++++++++ .../api/actions/beansModifyActionHook.php | 82 ++++++++++ .../api/actions/beansModifyActionPriority.php | 87 ++++++++++ .../includes/class-actions-test-case.php | 95 +++++++++++ 14 files changed, 1340 insertions(+), 62 deletions(-) create mode 100644 tests/phpunit/integration/api/actions/beansModifyAction.php create mode 100644 tests/phpunit/integration/api/actions/beansModifyActionArguments.php create mode 100644 tests/phpunit/integration/api/actions/beansModifyActionCallback.php create mode 100644 tests/phpunit/integration/api/actions/beansModifyActionHook.php create mode 100644 tests/phpunit/integration/api/actions/beansModifyActionPriority.php create mode 100644 tests/phpunit/integration/api/actions/includes/class-actions-test-case.php create mode 100644 tests/phpunit/unit/api/actions/beansBuildActionArray.php create mode 100644 tests/phpunit/unit/api/actions/beansModifyAction.php create mode 100644 tests/phpunit/unit/api/actions/beansModifyActionArguments.php create mode 100644 tests/phpunit/unit/api/actions/beansModifyActionCallback.php create mode 100644 tests/phpunit/unit/api/actions/beansModifyActionHook.php create mode 100644 tests/phpunit/unit/api/actions/beansModifyActionPriority.php create mode 100644 tests/phpunit/unit/api/actions/includes/class-actions-test-case.php diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index eec5de33..44db619d 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -91,130 +91,119 @@ function beans_add_smart_action( $hook, $callback, $priority = 10, $args = 1 ) { } /** - * Modify an action. + * Modify one or more of the arguments for the given action, i.e. referenced by its Bean's ID. * - * This function modifies an action registered using {@see beans_add_action()} or - * {@see beans_add_smart_action()}. Each optional argument must be set to NULL to keep the orginal value. + * This function modifies a registered action using {@see beans_add_action()} or + * {@see beans_add_smart_action()}. Each optional argument must be set to NULL to keep the original value. * * The original action can be reset using {@see beans_reset_action()}. * * @since 1.0.0 + * @since 1.5.0 Improved action parameter filtering. + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string|null $hook Optional. The new action's event name to which the $callback is hooked. + * Use NULL to keep the original value. + * @param callable|null $callback Optional. The new callback (function or method) you wish to be called. + * Use NULL to keep the original value. + * @param int|null $priority Optional. The new priority. + * Use NULL to keep the original value. + * @param int|null $args Optional. The new number of arguments the $callback accepts. + * Use NULL to keep the original value. * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. - * Use NULL to keep the original value. - * @param callback $callback Optional. The name of the new function you wish to be called. - * Use NULL to keep the original value. - * @param int $priority Optional. The new priority. - * Use NULL to keep the original value. - * @param int $args Optional. The new number of arguments the function accept. - * Use NULL to keep the original value. - * - * @return bool Will always return true. + * @return bool */ function beans_modify_action( $id, $hook = null, $callback = null, $priority = null, $args = null ) { + $action = _beans_build_action_array( $hook, $callback, $priority, $args ); - // Remove action. - if ( $current = _beans_get_current_action( $id ) ) { - remove_action( $current['hook'], $current['callback'], $current['priority'], $current['args'] ); + // If no changes were passed in, there's nothing to modify. Bail out. + if ( empty( $action ) ) { + return false; } - $action = array_filter( array( - 'hook' => $hook, - 'callback' => $callback, - 'priority' => $priority, - 'args' => $args, - ) ); - - // Merge modified. - $action = _beans_merge_action( $id, $action, 'modified' ); - - // Replace if needed. - if ( $current ) { + $current_action = _beans_get_current_action( $id ); + $has_current_action = ! empty( $current_action ) && is_array( $current_action ); - $action = array_merge( $current, $action ); + // If the action is registered, let's remove it. + if ( $has_current_action ) { + remove_action( $current_action['hook'], $current_action['callback'], $current_action['priority'], $current_action['args'] ); + } - add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + // Merge the modified parameters and register with Beans. + $action = _beans_merge_action( $id, $action, 'modified' ); + // If there is no action to modify, bail out. + if ( ! $has_current_action ) { + return false; } - return true; - + // Overwrite the modified parameters. + $action = array_merge( $current_action, $action ); + return add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } /** - * Modify an action hook. + * Modify one or more of the arguments for the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. Use NULL to - * keep the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $hook The new action's event name to which the callback is hooked. * - * @return bool Will always return true. + * @return bool */ function beans_modify_action_hook( $id, $hook ) { - return beans_modify_action( $id, $hook ); - } /** - * Modify an action callback. + * Modify the callback of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param string $callback Optional. The name of the new function you wish to be called. Use NULL to keep - * the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param callable $callback The new callback (function or method) you wish to be called. * - * @return bool Will always return true. + * @return bool */ function beans_modify_action_callback( $id, $callback ) { - return beans_modify_action( $id, null, $callback ); - } /** - * Modify an action priority. + * Modify the priority of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $priority Optional. The new priority. Use NULL to keep the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param int|string $priority The new priority. * - * @return bool Will always return true. + * @return bool */ function beans_modify_action_priority( $id, $priority ) { - return beans_modify_action( $id, null, null, $priority ); - } /** - * Modify an action arguments. + * Modify the number of arguments of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $args Optional. The new number of arguments the function accepts. Use NULL to keep the - * original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param int|string $number_of_args The new number of arguments the $callback accepts. * - * @return bool Will always return true. + * @return bool */ -function beans_modify_action_arguments( $id, $args ) { - - return beans_modify_action( $id, null, null, null, $args ); - +function beans_modify_action_arguments( $id, $number_of_args ) { + return beans_modify_action( $id, null, null, null, $number_of_args ); } /** @@ -592,6 +581,46 @@ function _beans_is_action_valid( array $action ) { return isset( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } +/** + * Build the action's array for only the valid given arguments. + * + * @since 1.5.0 + * + * @param string|null $hook Optional. The action event's name to which the $callback is hooked. + * Valid when not falsey, + * i.e. (meaning not `null`, `false`, `0`, `0.0`, an empty string, or empty array). + * @param callable|null $callback Optional. The callback (function or method) you wish to be called when the event + * fires. Valid when not falsey, i.e. (meaning not `null`, `false`, `0`, `0.0`, an empty + * string, or empty array). + * @param int|null $priority Optional. Used to specify the order in which the functions associated with a + * particular action are executed. Valid when it's numeric, including 0. + * @param int|null $args Optional. The number of arguments the callback accepts. + * Valid when it's numeric, including 0. + * + * @return array + */ +function _beans_build_action_array( $hook = null, $callback = null, $priority = null, $args = null ) { + $action = array(); + + if ( ! empty( $hook ) ) { + $action['hook'] = $hook; + } + + if ( ! empty( $callback ) ) { + $action['callback'] = $callback; + } + + foreach ( array( 'priority', 'args' ) as $arg_name ) { + $arg = ${$arg_name}; + + if ( is_numeric( $arg ) ) { + $action[ $arg_name ] = (int) $arg; + } + } + + return $action; +} + /** * Add anonymous callback using a class since php 5.2 is still supported. * diff --git a/tests/phpunit/integration/api/actions/beansModifyAction.php b/tests/phpunit/integration/api/actions/beansModifyAction.php new file mode 100644 index 00000000..e3e47473 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansModifyAction.php @@ -0,0 +1,107 @@ +assertFalse( beans_modify_action( 'foo' ) ); + } + + /** + * Test beans_modify_action_callback() should return false when there's nothing to modify, + * i.e. no arguments passed. + */ + public function test_should_return_false_when_nothing_to_modify() { + $this->setup_original_action(); + $this->assertFalse( beans_modify_action( 'foo' ) ); + + $this->setup_original_action( 'beans' ); + $this->assertFalse( beans_modify_action( 'beans' ) ); + } + + /** + * Test beans_modify_action() should register with Beans as modified, but not with WordPress. + */ + public function test_should_register_with_beans_as_modified_but_not_with_wp() { + $action = array( + 'hook' => 'foo_hook', + 'callback' => 'my_callback', + ); + + $this->check_not_added( 'foo', $action['hook'] ); + + $this->assertFalse( beans_modify_action( 'foo', $action['hook'], $action['callback'] ) ); + + // Now check that it was not registered in WordPress. + $this->assertFalse( has_action( $action['hook'] ) ); + global $wp_filter; + $this->assertFalse( array_key_exists( $action['hook'], $wp_filter ) ); + + // Now check in Beans. + $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + } + + /** + * Test beans_modify_action() should modify the registered action's callback. + */ + public function test_should_modify_the_action_callback() { + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'callback' => 'my_callback', + ); + $this->assertTrue( beans_modify_action( 'beans', null, $modified_action['callback'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + } + + /** + * Test beans_modify_action() should modify the registered action's priority level. + */ + public function test_should_modify_the_action_priority() { + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'priority' => 20, + ); + $this->assertTrue( beans_modify_action( 'beans', null, null, $modified_action['priority'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + } + + /** + * Test beans_modify_action() should modify the registered action's number of arguments. + */ + public function test_should_modify_the_action_args() { + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'args' => 2, + ); + $this->assertTrue( beans_modify_action( 'beans', null, null, null, $modified_action['args'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + } +} diff --git a/tests/phpunit/integration/api/actions/beansModifyActionArguments.php b/tests/phpunit/integration/api/actions/beansModifyActionArguments.php new file mode 100644 index 00000000..53afdc09 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansModifyActionArguments.php @@ -0,0 +1,97 @@ + null, + 'bar' => 0, + 'baz' => 1, + 'beans' => '3', + ); + + foreach ( $ids as $id => $number_of_args ) { + $this->assertFalse( beans_modify_action_arguments( $id, $number_of_args ) ); + } + } + + /** + * Test beans_modify_action_arguments() should return false when new args is a non-integer value. + */ + public function test_should_return_false_when_args_is_non_integer() { + $ids = array( + 'foo' => null, + 'bar' => array( 10 ), + 'baz' => false, + 'beans' => '', + ); + + foreach ( $ids as $id => $number_of_args ) { + $action = $this->setup_original_action( $id, true ); + + $this->assertFalse( beans_modify_action_arguments( $id, $number_of_args ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + + // Check that the parameters did not change. + $this->check_parameters_registered_in_wp( $action ); + } + } + + /** + * Test beans_modify_action_arguments() should modify the action's "args" when the new one is zero. + */ + public function test_should_modify_action_when_args_is_zero() { + $ids = array( + 'foo' => 0, + 'bar' => 0.0, + 'baz' => '0', + 'beans' => '0.0', + ); + + foreach ( $ids as $id => $number_of_args ) { + $action = $this->setup_original_action( $id ); + $this->assertTrue( beans_modify_action_arguments( $id, $number_of_args ) ); + + // Manually change the original to the new one. Then test that it did change in WordPress. + $action['args'] = (int) $number_of_args; + $this->check_parameters_registered_in_wp( $action ); + } + } + + /** + * Test beans_modify_action_arguments() should modify the registered action's args. + */ + public function test_should_modify_the_action_args() { + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'args' => 3, + ); + $this->assertTrue( beans_modify_action_arguments( 'beans', $modified_action['args'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + } +} diff --git a/tests/phpunit/integration/api/actions/beansModifyActionCallback.php b/tests/phpunit/integration/api/actions/beansModifyActionCallback.php new file mode 100644 index 00000000..75b541d2 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansModifyActionCallback.php @@ -0,0 +1,57 @@ +assertFalse( beans_modify_action_callback( 'foo', null ) ); + $this->assertFalse( beans_modify_action_callback( 'foo', 'my_new_callback' ) ); + } + + /** + * Test beans_modify_action_callback() should return false when the new callback is null. + */ + public function test_should_return_false_when_new_callback_is_null() { + $this->setup_original_action(); + $this->assertFalse( beans_modify_action_callback( 'foo', null ) ); + + $this->setup_original_action( 'beans' ); + $this->assertFalse( beans_modify_action_callback( 'beans', null ) ); + } + + /** + * Test beans_modify_action_callback() should modify the registered action's callback. + */ + public function test_should_modify_the_action_callback() { + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'callback' => 'my_new_callback', + ); + $this->assertTrue( beans_modify_action_callback( 'beans', $modified_action['callback'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + } +} diff --git a/tests/phpunit/integration/api/actions/beansModifyActionHook.php b/tests/phpunit/integration/api/actions/beansModifyActionHook.php new file mode 100644 index 00000000..4cac7c30 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansModifyActionHook.php @@ -0,0 +1,80 @@ +assertFalse( beans_modify_action_hook( 'foo', null ) ); + $this->assertFalse( beans_modify_action_hook( 'foo', 'foo_hook' ) ); + $this->assertFalse( beans_modify_action_hook( 'beans', 'beans_hook' ) ); + } + + /** + * Test beans_modify_action_hook() should return false when new hook is null. + */ + public function test_should_return_false_when_new_hook_is_null() { + $this->setup_original_action(); + $this->assertFalse( beans_modify_action_hook( 'foo', null ) ); + + $this->setup_original_action( 'beans' ); + $this->assertFalse( beans_modify_action_hook( 'beans', null ) ); + } + + /** + * Test beans_modify_action_hook() should register with Beans as modified, but not with WordPress. + */ + public function test_should_register_with_beans_as_modified_but_not_with_wp() { + $action = array( + 'hook' => 'my_hook', + ); + + $this->check_not_added( 'foo', $action['hook'] ); + + $this->assertFalse( beans_modify_action_hook( 'foo', $action['hook'] ) ); + + // Check that it did register with Beans. + $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + + // Check that it did not add the action. + $this->assertFalse( has_action( $action['hook'] ) ); + } + + /** + * Test beans_modify_action_hook() should modify the registered action's hook. + */ + public function test_should_modify_the_action_hook() { + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'hook' => 'my_hook', + ); + $this->assertTrue( beans_modify_action_hook( 'beans', $modified_action['hook'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + + // Now check that it overwrote the "hook". + $this->assertFalse( has_action( $action['hook'] ) ); + $this->assertTrue( has_action( $modified_action['hook'] ) ); + $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + } +} diff --git a/tests/phpunit/integration/api/actions/beansModifyActionPriority.php b/tests/phpunit/integration/api/actions/beansModifyActionPriority.php new file mode 100644 index 00000000..9d0806ca --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansModifyActionPriority.php @@ -0,0 +1,97 @@ + null, + 'bar' => 0, + 'baz' => 10, + 'beans' => '20', + ); + + foreach ( $ids as $id => $priority ) { + $this->assertFalse( beans_modify_action_priority( $id, $priority ) ); + } + } + + /** + * Test beans_modify_action_priority() should return false when new priority is a non-integer. + */ + public function test_should_return_false_when_priority_is_non_integer() { + $ids = array( + 'foo' => null, + 'bar' => array( 10 ), + 'baz' => false, + 'beans' => '', + ); + + foreach ( $ids as $id => $priority ) { + $action = $this->setup_original_action( $id, true ); + + $this->assertFalse( beans_modify_action_priority( $id, $priority ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + + // Check that the parameters did not change. + $this->check_parameters_registered_in_wp( $action ); + } + } + + /** + * Test beans_modify_action_priority() should modify the action's priority when the new one is zero. + */ + public function test_should_modify_action_when_priority_is_zero() { + $ids = array( + 'foo' => 0, + 'bar' => 0.0, + 'baz' => '0', + 'beans' => '0.0', + ); + + foreach ( $ids as $id => $priority ) { + $action = $this->setup_original_action( $id ); + $this->assertTrue( beans_modify_action_priority( $id, $priority ) ); + + // Manually change the original to the new one. Then test that it did change in WordPress. + $action['priority'] = (int) $priority; + $this->check_parameters_registered_in_wp( $action ); + } + } + + /** + * Test beans_modify_action_priority() should modify the registered action's priority. + */ + public function test_should_modify_the_action_priority() { + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'priority' => 20, + ); + $this->assertTrue( beans_modify_action_priority( 'beans', $modified_action['priority'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + } +} diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php new file mode 100644 index 00000000..d8e96915 --- /dev/null +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -0,0 +1,101 @@ + array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + } + + /** + * Check that it is not registered first. + * + * @since 1.5.0 + * + * @param string $id The ID to check. + * @param string $hook The hook (event name) to check. + * + * @return void + */ + protected function check_not_added( $id, $hook ) { + $this->assertFalse( _beans_get_action( $id, 'added' ) ); + $this->assertFalse( has_action( $hook ) ); + } + + /** + * Check that the right parameters are registered in WordPress. + * + * @since 1.5.0 + * + * @param array $action The action that should be registered. + * @param bool $remove_action When true, it removes the action automatically to clean up this test. + * + * @return void + */ + protected function check_parameters_registered_in_wp( array $action, $remove_action = true ) { + global $wp_filter; + $registered_action = $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ]; + + $this->assertArrayHasKey( $action['callback'], $registered_action ); + $this->assertEquals( $action['callback'], $registered_action[ $action['callback'] ]['function'] ); + $this->assertEquals( $action['args'], $registered_action[ $action['callback'] ]['accepted_args'] ); + + // Then remove the action. + if ( $remove_action ) { + remove_action( $action['hook'], $action['callback'], $action['priority'] ); + } + } + + /** + * Setup the original action. + * + * @since 1.5.0 + * + * @param string $id Optional. Beans ID to register. Default is 'foo'. + * + * @return array + */ + protected function setup_original_action( $id = 'foo' ) { + $action = array( + 'hook' => "{$id}_hook", + 'callback' => "callback_{$id}", + 'priority' => 10, + 'args' => 1, + ); + + $this->check_not_added( $id, $action['hook'] ); + + // Add the original action to get us rolling. + beans_add_action( $id, $action['hook'], $action['callback'] ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->check_parameters_registered_in_wp( $action, false ); + + return $action; + } +} diff --git a/tests/phpunit/unit/api/actions/beansBuildActionArray.php b/tests/phpunit/unit/api/actions/beansBuildActionArray.php new file mode 100644 index 00000000..1a6f9711 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansBuildActionArray.php @@ -0,0 +1,143 @@ +assertEmpty( _beans_build_action_array() ); + $this->assertEmpty( _beans_build_action_array( '', '' ) ); + $this->assertEmpty( _beans_build_action_array( null, false, '', array( 1 ) ) ); + } + + /** + * Test _beans_build_action_array() should return only the "hook" parameter. + */ + public function test_should_return_only_hook() { + $hooks = array( 'foo', 'bar', 'baz', 'beans' ); + + foreach ( $hooks as $hook ) { + $this->assertEquals( array( 'hook' => $hook ), _beans_build_action_array( $hook ) ); + } + } + + /** + * Test _beans_build_action_array() should return only the "callback" parameter. + */ + public function test_should_return_only_callback() { + $callbacks = array( 'foo_callback', 'my_callback', 'Foo::cb', array( $this, __FUNCTION__ ) ); + + foreach ( $callbacks as $callback ) { + $this->assertEquals( + array( 'callback' => $callback ), + _beans_build_action_array( null, $callback ) + ); + } + } + + /** + * Test _beans_build_action_array() should return only the "priority" parameter. + */ + public function test_should_return_only_priority() { + $priorities = array( 10, 0, 50, '20' ); + + foreach ( $priorities as $priority ) { + $this->assertEquals( + array( 'priority' => (int) $priority ), + _beans_build_action_array( null, null, $priority ) + ); + } + } + + /** + * Test _beans_build_action_array() should return only the "args" parameter. + */ + public function test_should_return_only_args() { + + foreach ( array( 0, 1, 2, '3', '4.1' ) as $args ) { + $this->assertEquals( + array( 'args' => (int) $args ), + _beans_build_action_array( null, null, null, $args ) + ); + } + } + + /** + * Test _beans_build_action_array() should return only the valid arguments. + */ + public function test_should_return_valid_args() { + $this->assertEquals( + array( + 'hook' => 'foo', + 'callback' => 'cb', + ), + _beans_build_action_array( 'foo', 'cb', '', false ) + ); + + $this->assertEquals( + array( + 'hook' => 'foo', + 'callback' => 'cb', + 'args' => 1, + ), + _beans_build_action_array( 'foo', 'cb', '', 1 ) + ); + + $this->assertEquals( + array( + 'hook' => 'foo', + 'priority' => 50, + ), + _beans_build_action_array( 'foo', '', '50' ) + ); + + $this->assertEquals( + array( + 'hook' => 'foo', + 'callback' => 'my_callback', + 'priority' => 0, + 'args' => 0, + ), + _beans_build_action_array( 'foo', 'my_callback', 0, '0.0' ) + ); + + $this->assertEquals( + array( + 'hook' => 'baz', + 'callback' => 'baz_cb', + 'priority' => 20, + 'args' => 2, + ), + _beans_build_action_array( 'baz', 'baz_cb', 20, 2 ) + ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansModifyAction.php b/tests/phpunit/unit/api/actions/beansModifyAction.php new file mode 100644 index 00000000..edd2f946 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansModifyAction.php @@ -0,0 +1,135 @@ +assertFalse( _beans_get_action( $id, 'modified' ) ); + + $modified_action = array( + 'hook' => "{$id}_hook", + 'callback' => "{$id}_callback", + ); + $this->assertFalse( beans_modify_action( $id, $modified_action['hook'], $modified_action['callback'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( $id, 'modified' ) ); + $this->assertFalse( has_action( $modified_action['hook'] ) ); + } + } + + /** + * Test beans_modify_action_callback() should return false when there's nothing to modify, + * i.e. no arguments passed. + */ + public function test_should_return_false_when_nothing_to_modify() { + $ids = array( + 'foo', + 'bar', + 'baz', + 'beans', + ); + + foreach ( $ids as $id ) { + $this->assertFalse( beans_modify_action( $id ) ); + + // Check after we setup the original action...just to make sure. + $this->setup_original_action( $id ); + $this->assertFalse( beans_modify_action( $id ) ); + } + } + + /** + * Test beans_modify_action() should register with Beans as modified, but not with WordPress. + */ + public function test_should_register_with_beans_as_modified_but_not_with_wp() { + $action = array( + 'hook' => 'foo_hook', + 'callback' => 'my_callback', + ); + + $this->check_not_added( 'foo', $action['hook'] ); + + $this->assertFalse( beans_modify_action( 'foo', $action['hook'], $action['callback'] ) ); + + // Check that it did register with Beans. + $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + + // Check that it did not add the action. + $this->assertFalse( has_action( $action['hook'] ) ); + } + + /** + * Test beans_modify_action() should modify the registered action's callback. + */ + public function test_should_modify_the_action_callback() { + $container = Monkey\Container::instance(); + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'callback' => 'my_callback', + ); + $this->assertTrue( beans_modify_action( 'beans', null, $modified_action['callback'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $action['hook'], $modified_action['callback'] ) ); + } + + /** + * Test beans_modify_action() should modify the registered action's priority level. + */ + public function test_should_modify_the_action_priority() { + $container = Monkey\Container::instance(); + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'priority' => 20, + ); + $this->assertTrue( beans_modify_action( 'beans', null, null, $modified_action['priority'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $action['hook'], $action['callback'] ) ); + } + + /** + * Test beans_modify_action() should modify the registered action's number of arguments. + */ + public function test_should_modify_the_action_args() { + $container = Monkey\Container::instance(); + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'args' => 2, + ); + $this->assertTrue( beans_modify_action( 'beans', null, null, null, $modified_action['args'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $action['hook'], $action['callback'] ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansModifyActionArguments.php b/tests/phpunit/unit/api/actions/beansModifyActionArguments.php new file mode 100644 index 00000000..34619df5 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansModifyActionArguments.php @@ -0,0 +1,89 @@ + null, + 'bar' => 0, + 'baz' => 1, + 'beans' => '3', + ); + + foreach ( $ids as $id => $number_of_args ) { + $this->assertFalse( beans_modify_action_arguments( $id, $number_of_args ) ); + } + } + + /** + * Test beans_modify_action_arguments() should return false when new args is a non-integer value. + */ + public function test_should_return_false_when_args_is_non_integer() { + $ids = array( + 'foo' => null, + 'bar' => array( 10 ), + 'baz' => false, + 'beans' => '', + ); + + foreach ( $ids as $id => $number_of_args ) { + $action = $this->setup_original_action( $id, true ); + + $this->assertFalse( beans_modify_action_arguments( $id, $number_of_args ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + } + } + + /** + * Test beans_modify_action_priority() should return true when "args" is zero. + */ + public function test_should_return_true_when_args_is_zero() { + $ids = array( + 'foo' => 0, + 'bar' => 0.0, + 'baz' => '0', + 'beans' => '0.0', + ); + + foreach ( $ids as $id => $number_of_args ) { + $this->setup_original_action( $id ); + $this->assertTrue( beans_modify_action_arguments( $id, $number_of_args ) ); + } + } + + /** + * Test beans_modify_action_arguments() should modify the registered action's args. + */ + public function test_should_modify_the_action_args() { + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'args' => 3, + ); + $this->assertTrue( beans_modify_action_arguments( 'beans', $modified_action['args'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansModifyActionCallback.php b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php new file mode 100644 index 00000000..e63b97d7 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php @@ -0,0 +1,79 @@ +assertFalse( beans_modify_action_callback( 'foo', null ) ); + $this->assertFalse( beans_modify_action_callback( 'foo', 'my_new_callback' ) ); + $this->assertFalse( beans_modify_action_callback( 'beans', 'beans_callback' ) ); + } + + /** + * Test beans_modify_action_callback() should return false when the new callback is null. + */ + public function test_should_return_false_when_new_callback_is_null() { + $this->setup_original_action(); + $this->assertFalse( beans_modify_action_callback( 'foo', null ) ); + + $this->setup_original_action( 'beans' ); + $this->assertFalse( beans_modify_action_callback( 'beans', null ) ); + } + + /** + * Test beans_modify_action_callback() should register with Beans as modified, but not with WordPress. + */ + public function test_should_register_with_beans_as_modified_but_not_with_wp() { + $action = array( + 'callback' => 'my_callback', + ); + + $this->check_not_added( 'foo', 'foo_hook' ); + + $this->assertFalse( beans_modify_action_callback( 'foo', $action['callback'] ) ); + + // Check that it did register with Beans. + $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + + // Check that it did not add the action. + $this->assertFalse( has_action( 'foo_hook' ) ); + } + + /** + * Test beans_modify_action() should modify the registered action's callback. + */ + public function test_should_modify_the_action_callback() { + $container = Monkey\Container::instance(); + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'callback' => 'my_callback', + ); + $this->assertTrue( beans_modify_action_callback( 'beans', $modified_action['callback'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $action['hook'], $modified_action['callback'] ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansModifyActionHook.php b/tests/phpunit/unit/api/actions/beansModifyActionHook.php new file mode 100644 index 00000000..0ef49eb2 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansModifyActionHook.php @@ -0,0 +1,82 @@ +assertFalse( beans_modify_action_hook( 'foo', null ) ); + $this->assertFalse( beans_modify_action_hook( 'foo', 'foo_hook' ) ); + $this->assertFalse( beans_modify_action_hook( 'beans', 'beans_hook' ) ); + } + + /** + * Test beans_modify_action_hook() should return false when new hook is null. + */ + public function test_should_return_false_when_new_hook_is_null() { + $this->setup_original_action(); + $this->assertFalse( beans_modify_action_hook( 'foo', null ) ); + + $this->setup_original_action( 'beans' ); + $this->assertFalse( beans_modify_action_hook( 'beans', null ) ); + } + + /** + * Test beans_modify_action_hook() should register with Beans as modified, but not with WordPress. + */ + public function test_should_register_with_beans_as_modified_but_not_with_wp() { + $action = array( + 'hook' => 'my_hook', + ); + + $this->check_not_added( 'foo', $action['hook'] ); + + $this->assertFalse( beans_modify_action_hook( 'foo', $action['hook'] ) ); + + // Check that it did register with Beans. + $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + + // Check that it did not add the action. + $this->assertFalse( has_action( $action['hook'] ) ); + } + + /** + * Test beans_modify_action_hook() should modify the registered action's hook. + */ + public function test_should_modify_the_action_hook() { + $container = Monkey\Container::instance(); + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'hook' => 'my_hook', + ); + $this->assertTrue( beans_modify_action_hook( 'beans', $modified_action['hook'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + + // Now check that it overwrote the "hook". + $this->assertFalse( has_action( $action['hook'] ) ); + $this->assertTrue( has_action( $modified_action['hook'] ) ); + $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $modified_action['hook'], $action['callback'] ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansModifyActionPriority.php b/tests/phpunit/unit/api/actions/beansModifyActionPriority.php new file mode 100644 index 00000000..a7f5b9bb --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansModifyActionPriority.php @@ -0,0 +1,87 @@ + null, + 'bar' => 0, + 'baz' => 10, + 'beans' => '20', + ); + + foreach ( $ids as $id => $priority ) { + $this->assertFalse( beans_modify_action_priority( $id, $priority ) ); + } + } + + /** + * Test beans_modify_action_priority() should return false new priority is a non-integer. + */ + public function test_should_return_false_when_priority_is_non_integer() { + $ids = array( + 'foo' => null, + 'bar' => array( 10 ), + 'baz' => false, + 'beans' => '', + ); + + foreach ( $ids as $id => $priority ) { + $this->setup_original_action( $id ); + $this->assertFalse( beans_modify_action_priority( $id, $priority ) ); + } + } + + /** + * Test beans_modify_action_priority() should return true when priority is zero. + */ + public function test_should_return_true_when_priority_is_zero() { + $ids = array( + 'foo' => 0, + 'bar' => 0.0, + 'baz' => '0', + 'beans' => '0.0', + ); + + foreach ( $ids as $id => $priority ) { + $this->setup_original_action( $id ); + $this->assertTrue( beans_modify_action_priority( $id, $priority ) ); + } + } + + /** + * Test beans_modify_action_priority() should modify the registered action's priority. + */ + public function test_should_modify_the_action_priority() { + $action = $this->setup_original_action( 'beans' ); + $modified_action = array( + 'priority' => 20, + ); + $this->assertTrue( beans_modify_action_priority( 'beans', $modified_action['priority'] ) ); + $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); + $this->assertTrue( has_action( $action['hook'] ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php new file mode 100644 index 00000000..acc0358d --- /dev/null +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -0,0 +1,95 @@ + array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + } + + /** + * Check that is not registered first. + * + * @since 1.5.0 + * + * @param string $id The ID to check. + * @param string $hook The hook (event name) to check. + * + * @return void + */ + protected function check_not_added( $id, $hook ) { + $this->assertFalse( _beans_get_action( $id, 'added' ) ); + $this->assertFalse( has_action( $hook ) ); + } + + /** + * Setup the original action. + * + * @since 1.5.0 + * + * @param string $id Optional. Beans ID to register. Default is 'foo'. + * + * @return array + */ + protected function setup_original_action( $id = 'foo' ) { + $container = Monkey\Container::instance(); + $action = array( + 'hook' => "{$id}_hook", + 'callback' => "callback_{$id}", + 'priority' => 10, + 'args' => 1, + ); + + $this->check_not_added( $id, $action['hook'] ); + + // Add the original action to get us rolling. + beans_add_action( $id, $action['hook'], $action['callback'] ); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->assertTrue( + $container->hookStorage()->isHookAdded( + Monkey\Hook\HookStorage::ACTIONS, + $action['hook'], + $action['callback'] + ) + ); + + return $action; + } +} From 6cb7a85c33bb7b9b84b89a0f7625132aa2a78d85 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Wed, 10 Jan 2018 09:47:47 +0100 Subject: [PATCH 022/800] Updated to version 1.4.1 --- lib/init.php | 2 +- style.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/init.php b/lib/init.php index 6b1abd4f..0c4111b2 100644 --- a/lib/init.php +++ b/lib/init.php @@ -14,7 +14,7 @@ function beans_define_constants() { // Define version. - define( 'BEANS_VERSION', '1.4.0' ); + define( 'BEANS_VERSION', '1.4.1' ); // Define paths. if ( ! defined( 'BEANS_THEME_PATH' ) ) { diff --git a/style.css b/style.css index a323be96..299618f2 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Theme URI: http://www.getbeans.io/themes/beans/ Author: Beans Author URI: http://www.getbeans.io Description: The most innovative theme for WordPress. The real magic is under the hood. -Version: 1.4.0 +Version: 1.4.1 Text Domain: tm-beans Tags: white, light, one-column, two-columns, three-columns, right-sidebar, left-sidebar, responsive-layout, fluid-layout, fixed-layout, custom-header, custom-background, custom-menu, editor-style, featured-images, microformats, post-formats, translation-ready License: GNU General Public License v2 or later From 01b66496d7bd949f47943a8cfd0bf33a2f1d22ba Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Wed, 10 Jan 2018 09:47:44 -0600 Subject: [PATCH 023/800] Made beans_add_action and beans_add_smart_action compliant (#93) 1. Made WPCS compliant 2. Added unit tests 3. Added DocBlock --- lib/api/actions/functions.php | 79 +++++----- .../api/actions/beansAddAction.php | 135 ++++++++++++++++++ .../unit/api/actions/beansAddAction.php | 129 +++++++++++++++++ .../api/actions/beansGetCurrentAction.php | 31 +--- .../unit/api/actions/beansSetAction.php | 26 +--- .../unit/api/actions/beansUnsetAction.php | 26 +--- 6 files changed, 318 insertions(+), 108 deletions(-) create mode 100644 tests/phpunit/integration/api/actions/beansAddAction.php create mode 100644 tests/phpunit/unit/api/actions/beansAddAction.php diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 44db619d..6974dfaf 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -11,27 +11,27 @@ */ /** - * Hooks a function on to a specific action. + * Hooks a callback (function or method) to a specific action event. * * This function is similar to {@link http://codex.wordpress.org/Function_Reference/add_action add_action()} - * with the exception of being registered by ID in order to be manipulated by the other Beans Actions functions. + * with the exception of being registered by ID within Beans in order to be manipulated by the other Beans + * Actions functions. * * @since 1.0.0 + * @since 1.5.0 Returns false when action is not added via add_action. * - * @param string $id A unique string used as a reference. - * @param string $hook The name of the action to which the $callback is hooked. - * @param callback $callback The name of the function you wish to be called. - * @param int $priority Optional. Used to specify the order in which the functions - * associated with a particular action are executed. Default 10. - * Lower numbers correspond with earlier execution, - * and functions with the same priority are executed - * in the order in which they were added to the action. - * @param int $args Optional. The number of arguments the function accepts. Default 1. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $hook The name of the action to which the `$callback` is hooked. + * @param callable $callback The name of the function|method you wish to be called when the action event fires. + * @param int $priority Optional. Used to specify the order in which the callbacks associated with a particular + * action are executed. Default is 10. + * Lower numbers correspond with earlier execution. Callbacks with the same priority + * are executed in the order in which they were added to the action. + * @param int $args Optional. The number of arguments the callback accepts. Default is 1. * - * @return bool Will always return true. + * @return bool */ function beans_add_action( $id, $hook, $callback, $priority = 10, $args = 1 ) { - $action = array( 'hook' => $hook, 'callback' => $callback, @@ -39,55 +39,56 @@ function beans_add_action( $id, $hook, $callback, $priority = 10, $args = 1 ) { 'args' => $args, ); - // Replace original if set. - if ( $replaced = _beans_get_action( $id, 'replaced' ) ) { - $action = array_merge( $action, $replaced ); + $replaced_action = _beans_get_action( $id, 'replaced' ); + + // If the ID is set to be "replaced", then replace that(those) parameter(s). + if ( ! empty( $replaced_action ) && is_array( $replaced_action ) ) { + $action = array_merge( $action, $replaced_action ); } $action = _beans_set_action( $id, $action, 'added', true ); - // Stop here if removed. + // If the ID is set to be "removed", then bail out. if ( _beans_get_action( $id, 'removed' ) ) { - return; + return false; } - // Merge modified. - if ( $modified = _beans_get_action( $id, 'modified' ) ) { - $action = array_merge( $action, $modified ); - } + $modified_action = _beans_get_action( $id, 'modified' ); - // Validate action arguments. - if ( count( $action ) == 4 ) { - add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + // If the ID is set to be "modified", then modify that(those) parameter(s). + if ( ! empty( $modified_action ) && is_array( $modified_action ) ) { + $action = array_merge( $action, $modified_action ); } - return true; + // Bail out if it's not a valid action. + if ( ! _beans_is_action_valid( $action ) ) { + return false; + } + return add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } /** * Set {@see beans_add_action()} using the callback argument as the action ID. * - * This function is a shortcut of {@see beans_add_action()}. It does't require an ID - * to be specified and uses the callback argument instead. + * This function is a shortcut of {@see beans_add_action()}. It does't require a Beans ID as it uses the + * callback argument instead. * * @since 1.0.0 + * @since 1.5.0 Returns false when action is not added via add_action. * - * @param string $hook The name of the action to which the $callback is hooked. - * @param callback $callback The name of the function you wish to be called. Used to set the action ID. - * @param int $priority Optional. Used to specify the order in which the functions - * associated with a particular action are executed. Default 10. - * Lower numbers correspond with earlier execution, - * and functions with the same priority are executed - * in the order in which they were added to the action. - * @param int $args Optional. The number of arguments the function accept. Default 1. + * @param string $hook The name of the action to which the `$callback` is hooked. + * @param callable $callback The name of the function|method you wish to be called when the action event fires. + * @param int $priority Optional. Used to specify the order in which the callbacks associated with a particular + * action are executed. Default is 10. + * Lower numbers correspond with earlier execution. Callbacks with the same priority + * are executed in the order in which they were added to the action. + * @param int $args Optional. The number of arguments the callback accepts. Default is 1. * - * @return bool Will always return true. + * @return bool */ function beans_add_smart_action( $hook, $callback, $priority = 10, $args = 1 ) { - return beans_add_action( $callback, $hook, $callback, $priority, $args ); - } /** diff --git a/tests/phpunit/integration/api/actions/beansAddAction.php b/tests/phpunit/integration/api/actions/beansAddAction.php new file mode 100644 index 00000000..066cc2de --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansAddAction.php @@ -0,0 +1,135 @@ +action = array( + 'hook' => 'foo_hook', + 'callback' => 'callback_foo', + 'priority' => 10, + 'args' => 1, + ); + } + + /** + * Test beans_add_action() should register the action in WordPress. + */ + public function test_should_register_action_in_wordpress() { + $this->check_not_added( 'foo', $this->action['hook'] ); + + // Add the action. + $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + + // Now check that it was registered in WordPress. + $this->assertTrue( has_action( $this->action['hook'] ) ); + $this->check_parameters_registered_in_wp( $this->action ); + + // Now check in Beans. + $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + } + + /** + * Test beans_add_action() should use the action configuration in "replaced" status, when it's available. + */ + public function test_should_use_replaced_action_when_available() { + $this->check_not_added( 'foo', $this->action['hook'] ); + + // Setup by storing in the "replaced" status. + $replaced_action = array( + 'hook' => $this->action['hook'], + 'callback' => 'my_callback', + 'priority' => 20, + 'args' => 2, + ); + _beans_set_action( 'foo', $replaced_action, 'replaced', true ); + + // Add the action. + $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + + // Now check that it was registered in WordPress. + $this->assertTrue( has_action( $replaced_action['hook'] ) ); + $this->check_parameters_registered_in_wp( $replaced_action ); + + // Now check in Beans. + $this->assertEquals( $replaced_action, _beans_get_action( 'foo', 'added' ) ); + } + + /** + * Test beans_add_action() should return false when the ID is registered to the "removed" status. + */ + public function test_should_return_false_when_removed() { + $this->check_not_added( 'foo', $this->action['hook'] ); + + // Setup by storing in the "removed" status. + _beans_set_action( 'foo', $this->action, 'removed', true ); + + // Add the action. + $this->assertFalse( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + + // Now check that it was not registered in WordPress. + $this->assertFalse( has_action( $this->action['hook'] ) ); + global $wp_filter; + $this->assertFalse( array_key_exists( $this->action['hook'], $wp_filter ) ); + + // Now check in Beans. + $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + } + + /** + * Test beans_add_action() should merge the "modified" action configuration parameters. + */ + public function test_should_merge_modified_action_parameters() { + $this->check_not_added( 'foo', $this->action['hook'] ); + + // Setup by storing in the "modified" status. + $modified_action = array( + 'hook' => $this->action['hook'], + 'callback' => 'my_callback', + 'priority' => 20, + 'args' => 2, + ); + _beans_set_action( 'foo', $modified_action, 'modified', true ); + + // Add the action. + $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + + // Now check that it was registered in WordPress. + $this->assertTrue( has_action( $modified_action['hook'] ) ); + $this->check_parameters_registered_in_wp( $modified_action ); + + // Now check in Beans. + $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansAddAction.php b/tests/phpunit/unit/api/actions/beansAddAction.php new file mode 100644 index 00000000..b2e8e11e --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansAddAction.php @@ -0,0 +1,129 @@ +action = array( + 'hook' => 'foo_hook', + 'callback' => 'callback_foo', + 'priority' => 10, + 'args' => 1, + ); + } + + /** + * Test beans_add_action() should add (register) the action. + */ + public function test_should_add_the_action() { + $this->check_not_added( 'foo', $this->action['hook'] ); + + // Add the action. + $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + + // Now check. + $this->assertTrue( has_action( $this->action['hook'] ) ); + $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + } + + /** + * Test beans_add_action() should use the action configuration in "replaced" status, when it's available. + */ + public function test_should_use_replaced_action_when_available() { + $this->check_not_added( 'foo', $this->action['hook'] ); + + // Setup by storing in the "replaced" status. + $replaced_action = array( + 'hook' => $this->action['hook'], + 'callback' => 'my_callback', + 'priority' => 20, + 'args' => 2, + ); + _beans_set_action( 'foo', $replaced_action, 'replaced', true ); + + // Add the action. + $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + + // Now check. + $this->assertTrue( has_action( $replaced_action['hook'] ) ); + $this->assertEquals( $replaced_action, _beans_get_action( 'foo', 'added' ) ); + } + + /** + * Test beans_add_action() should return false when the ID is registered to the "removed" status. + */ + public function test_should_return_false_when_removed() { + $this->check_not_added( 'foo', $this->action['hook'] ); + + // Setup by storing in the "removed" status. + _beans_set_action( 'foo', $this->action, 'removed', true ); + + // Add the action. + $this->assertFalse( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + + // Now check. + $this->assertFalse( has_action( 'foo_hook' ) ); + $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + } + + /** + * Test beans_add_action() should merge the "modified" action configuration parameters. + */ + public function test_should_merge_modified_action_parameters() { + $this->check_not_added( 'foo', $this->action['hook'] ); + + // Setup by storing in the "modified" status. + $modified_action = array( + 'hook' => $this->action['hook'], + 'callback' => 'my_callback', + 'priority' => 20, + 'args' => 2, + ); + _beans_set_action( 'foo', $modified_action, 'modified', true ); + + // Add the action. + $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + + // Now check that it was registered in WordPress. + $this->assertTrue( has_action( $modified_action['hook'] ) ); + + // Check that the original action is registered with Beans. + $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + + // Finally, check that the "modified" action is registered via add_action. + $container = Monkey\Container::instance(); + $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, 'foo_hook', 'my_callback' ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php index 0870b7af..e0199731 100644 --- a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php @@ -9,7 +9,9 @@ namespace Beans\Framework\Tests\Unit\API\Actions; -use Beans\Framework\Tests\Unit\Test_Case; +use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; + +require_once __DIR__ . '/includes/class-actions-test-case.php'; /** * Class Tests_BeansGetCurrentAction @@ -18,32 +20,7 @@ * @group unit-tests * @group api */ -class Tests_BeansGetCurrentAction extends Test_Case { - - /** - * Setup test fixture. - */ - protected function setUp() { - parent::setUp(); - - require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; - } - - /** - * Reset the test fixture. - */ - protected function tearDown() { - parent::tearDown(); - - global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); - } +class Tests_BeansGetCurrentAction extends Actions_Test_Case { /** * Test _beans_get_current_action() should return false when the ID is registered with the "removed" status. diff --git a/tests/phpunit/unit/api/actions/beansSetAction.php b/tests/phpunit/unit/api/actions/beansSetAction.php index ef67a921..a6b4a34f 100644 --- a/tests/phpunit/unit/api/actions/beansSetAction.php +++ b/tests/phpunit/unit/api/actions/beansSetAction.php @@ -9,7 +9,9 @@ namespace Beans\Framework\Tests\Unit\API\Actions; -use Beans\Framework\Tests\Unit\Test_Case; +use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; + +require_once __DIR__ . '/includes/class-actions-test-case.php'; /** * Class Tests_BeansSetAction @@ -18,7 +20,7 @@ * @group unit-tests * @group api */ -class Tests_BeansSetAction extends Test_Case { +class Tests_BeansSetAction extends Actions_Test_Case { /** * Available action statuses. @@ -47,10 +49,7 @@ class Tests_BeansSetAction extends Test_Case { protected function setUp() { parent::setUp(); - $this->action_status = array( 'added', 'modified', 'removed', 'replaced' ); - require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; - + $this->action_status = array( 'added', 'modified', 'removed', 'replaced' ); $this->action = array( 'hook' => 'foo', 'callback' => 'callback', @@ -60,21 +59,6 @@ protected function setUp() { $this->encoded_action = wp_json_encode( $this->action ); } - /** - * Reset the test fixture. - */ - protected function tearDown() { - parent::tearDown(); - - global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); - } - /** * Test _beans_set_action() should set the action into the registered actions and then return it. */ diff --git a/tests/phpunit/unit/api/actions/beansUnsetAction.php b/tests/phpunit/unit/api/actions/beansUnsetAction.php index 282e4d5c..ce4c615f 100644 --- a/tests/phpunit/unit/api/actions/beansUnsetAction.php +++ b/tests/phpunit/unit/api/actions/beansUnsetAction.php @@ -9,7 +9,9 @@ namespace Beans\Framework\Tests\Unit\API\Actions; -use Beans\Framework\Tests\Unit\Test_Case; +use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; + +require_once __DIR__ . '/includes/class-actions-test-case.php'; /** * Class Tests_BeansUnsetAction @@ -18,7 +20,7 @@ * @group unit-tests * @group api */ -class Tests_BeansUnsetAction extends Test_Case { +class Tests_BeansUnsetAction extends Actions_Test_Case { /** * Available action statuses. @@ -47,10 +49,7 @@ class Tests_BeansUnsetAction extends Test_Case { protected function setUp() { parent::setUp(); - $this->action_status = array( 'added', 'modified', 'removed', 'replaced' ); - require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; - + $this->action_status = array( 'added', 'modified', 'removed', 'replaced' ); $this->action = array( 'hook' => 'foo', 'callback' => 'callback', @@ -60,21 +59,6 @@ protected function setUp() { $this->encoded_action = wp_json_encode( $this->action ); } - /** - * Reset the test fixture. - */ - protected function tearDown() { - parent::tearDown(); - - global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); - } - /** * Test _beans_unset_action() should return false when action's configuration is not registered. */ From ef0e700416189511f16152cb5ce96a702e89d52e Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sat, 13 Jan 2018 17:34:09 +0000 Subject: [PATCH 024/800] Remove duplicate gitignore entry (#100) `composer.lock` is ignored twice. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 641e724d..b7e87e2d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ composer.lock /vendor/ /logs/ /reports/ -composer.lock \ No newline at end of file From 9ce0b982e63245858c5ed5d38dc8257796cbcc09 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Mon, 15 Jan 2018 15:30:12 -0600 Subject: [PATCH 025/800] Made replace actions functions wpcs compliant + tests 1. Made WPCS compliant. 2. Added integration and unit tests. 3. Used real Beans actions for test fixtures. 4. Fixed a bug when replacing the action or its hook. --- lib/api/actions/functions.php | 96 +++---- .../api/actions/beansReplaceAction.php | 271 +++++++++++++++++ .../actions/beansReplaceActionArguments.php | 131 +++++++++ .../actions/beansReplaceActionCallback.php | 130 +++++++++ .../api/actions/beansReplaceActionHook.php | 132 +++++++++ .../actions/beansReplaceActionPriority.php | 130 +++++++++ .../api/actions/fixtures/test-actions.php | 29 ++ .../includes/class-actions-test-case.php | 44 +++ .../class-replace-action-test-case.php | 158 ++++++++++ .../unit/api/actions/beansReplaceAction.php | 272 ++++++++++++++++++ .../actions/beansReplaceActionArguments.php | 131 +++++++++ .../actions/beansReplaceActionCallback.php | 130 +++++++++ .../api/actions/beansReplaceActionHook.php | 132 +++++++++ .../actions/beansReplaceActionPriority.php | 130 +++++++++ .../api/actions/fixtures/test-actions.php | 29 ++ .../includes/class-actions-test-case.php | 73 ++++- .../class-replace-action-test-case.php | 52 ++++ 17 files changed, 2014 insertions(+), 56 deletions(-) create mode 100644 tests/phpunit/integration/api/actions/beansReplaceAction.php create mode 100644 tests/phpunit/integration/api/actions/beansReplaceActionArguments.php create mode 100644 tests/phpunit/integration/api/actions/beansReplaceActionCallback.php create mode 100644 tests/phpunit/integration/api/actions/beansReplaceActionHook.php create mode 100644 tests/phpunit/integration/api/actions/beansReplaceActionPriority.php create mode 100644 tests/phpunit/integration/api/actions/fixtures/test-actions.php create mode 100644 tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php create mode 100644 tests/phpunit/unit/api/actions/beansReplaceAction.php create mode 100644 tests/phpunit/unit/api/actions/beansReplaceActionArguments.php create mode 100644 tests/phpunit/unit/api/actions/beansReplaceActionCallback.php create mode 100644 tests/phpunit/unit/api/actions/beansReplaceActionHook.php create mode 100644 tests/phpunit/unit/api/actions/beansReplaceActionPriority.php create mode 100644 tests/phpunit/unit/api/actions/fixtures/test-actions.php create mode 100644 tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 6974dfaf..c7cf9607 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -208,122 +208,112 @@ function beans_modify_action_arguments( $id, $number_of_args ) { } /** - * Replace an action. + * Replace one or more of the arguments for the given action, i.e. referenced by its Bean's ID. * * This function replaces an action registered using {@see beans_add_action()} or * {@see beans_add_smart_action()}. Each optional argument must be set to NULL to keep - * the orginal value. + * the original value. * - * While {@see beans_modify_action()} will keep the original value registered, this function - * will overwrite the original action. If the action is reset using {@see beans_reset_action()}, - * the replaced values will be used. + * This function is not resettable as it overwrites the original action's argument(s). + * That means using {@see beans_reset_action()} will not restore the original action. * * @since 1.0.0 + * @since 1.5.0 Returns false when no replacement arguments are passed. * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. - * Use NULL to keep the original value. - * @param callback $callback Optional. The name of the new function you wish to be called. - * Use NULL to keep the original value. - * @param int $priority Optional. The new priority. - * Use NULL to keep the original value. - * @param int $args Optional. The new number of arguments the function accepts. - * Use NULL to keep the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string|null $hook Optional. The new action's event name to which the $callback is hooked. + * Use NULL to keep the original value. + * @param callable|null $callback Optional. The new callback (function or method) you wish to be called. + * Use NULL to keep the original value. + * @param int|null $priority Optional. The new priority. + * Use NULL to keep the original value. + * @param int|null $args Optional. The new number of arguments the $callback accepts. + * Use NULL to keep the original value. * - * @return bool Will always return true. + * @return bool */ function beans_replace_action( $id, $hook = null, $callback = null, $priority = null, $args = null ) { + $action = _beans_build_action_array( $hook, $callback, $priority, $args ); - $action = array( - 'hook' => $hook, - 'callback' => $callback, - 'priority' => $priority, - 'args' => $args, - ); + // If no changes were passed in, there's nothing to modify. Bail out. + if ( empty( $action ) ) { + return false; + } - // Set and get the latest replaced. - $action = _beans_merge_action( $id, array_filter( $action ), 'replaced' ); + // Set and get the latest "replaced" action. + $action = _beans_merge_action( $id, $action, 'replaced' ); - // Set and get the latest added. - $action = _beans_merge_action( $id, $action, 'added' ); + // Modify the action. + $is_modified = beans_modify_action( $id, $hook, $callback, $priority, $args ); - return beans_modify_action( $id, $hook, $callback, $priority, $args ); + // Now merge the current action with the replaced one. + _beans_merge_action( $id, $action, 'added' ); + return $is_modified; } /** - * Replace an action hook. + * Replace the action's event name (hook) for the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. Use NULL to keep - * the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $hook The new action's event name to which the callback is hooked. * - * @return bool Will always return true. + * @return bool */ function beans_replace_action_hook( $id, $hook ) { - return beans_replace_action( $id, $hook ); - } /** - * Replace an action callback. + * Replace the callback of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param string $callback Optional. The name of the new function you wish to be called. Use NULL to keep - * the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $callback The new callback (function or method) you wish to be called. * - * @return bool Will always return true. + * @return bool */ function beans_replace_action_callback( $id, $callback ) { - return beans_replace_action( $id, null, $callback ); - } /** - * Replace an action priority. + * Replace the priority of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $priority Optional. The new priority. Use NULL to keep the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param int $priority The new priority. * - * @return bool Will always return true. + * @return bool */ function beans_replace_action_priority( $id, $priority ) { - return beans_replace_action( $id, null, null, $priority ); - } /** - * Replace an action argument. + * Replace the number of arguments of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $args Optional. The new number of arguments the function accepts. Use NULL to keep the original - * value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param int $args The new number of arguments the $callback accepts. * - * @return bool Will always return true. + * @return bool */ function beans_replace_action_arguments( $id, $args ) { - return beans_replace_action( $id, null, null, null, $args ); - } /** diff --git a/tests/phpunit/integration/api/actions/beansReplaceAction.php b/tests/phpunit/integration/api/actions/beansReplaceAction.php new file mode 100644 index 00000000..5b022115 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansReplaceAction.php @@ -0,0 +1,271 @@ + 'my_new_callback', + ); + + foreach ( array_keys( static::$test_actions ) as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" hook. + $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); + + // Check that stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + } + + /** + * Test beans_replace_action() should store the "replaced" action when the original action + * has not yet been registered. Once the original action is registered, then it should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_action() { + $replaced_action = array( + 'callback' => 'my_new_callback', + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action( $beans_id, null, $replaced_action['callback'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should return false when there's nothing to replace, + * i.e. no arguments passed. + */ + public function test_should_return_false_when_nothing_to_replace() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action( $beans_id ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action() should replace the registered action's hook. + */ + public function test_should_replace_the_action_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the callback is what we think before we get rolling. + $this->assertEquals( $action_config['hook'], $original_action['hook'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'hook' => 'foo', + ); + + // Run the replace. + $this->assertTrue( beans_replace_action( $beans_id, $replaced_action['hook'] ) ); + + // Check if it replaced only the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should replace the registered action's callback. + */ + public function test_should_replace_the_action_callback() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the callback is what we think before we get rolling. + $this->assertEquals( $action_config['callback'], $original_action['callback'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'callback' => 'foo', + ); + + // Run the replace. + $this->assertTrue( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); + + // Check if it replaced only the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should replace the registered action's priority level. + */ + public function test_should_replace_the_action_priority() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the priority is what we think before we get rolling. + $this->assertEquals( $action_config['priority'], $original_action['priority'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'priority' => 50, + ); + + // Run the replace. + $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); + + // Check if it replaced only the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should replace the registered action's number of arguments. + */ + public function test_should_replace_the_action_args() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the args are what we think before we get rolling. + $this->assertEquals( $action_config['args'], $original_action['args'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'args' => 5, + ); + + // Run the replace. + $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); + + // Check if it replaced only the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $replaced_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should replace the original registered action. + */ + public function test_should_replace_the_action() { + // Setup what will get stored in Beans. + $replaced_action = array( + 'hook' => 'new_hook', + 'callback' => 'new_callback', + 'priority' => 99, + 'args' => 10, + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Make sure the action is what we think before we get rolling. + $this->assertEquals( $original_action, _beans_get_action( $beans_id, 'added' ) ); + + // Run the replace. + $this->assertTrue( beans_replace_action( + $beans_id, + $replaced_action['hook'], + $replaced_action['callback'], + $replaced_action['priority'], + $replaced_action['args'] + ) ); + + // Check that the "replaced" action has been stored in Beans. + $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); + $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the new action is now registered in WordPress. + $this->check_registered_in_wp( $replaced_action['hook'], $replaced_action ); + } + } +} diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php b/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php new file mode 100644 index 00000000..670ae450 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php @@ -0,0 +1,131 @@ + 10, + ); + + // Store the "replaced" action. + foreach ( static::$test_ids as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" args. + $this->assertFalse( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); + + // Check that it stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + } + + /** + * Test beans_replace_action_arguments() should store the "replaced" action when the original action + * has not yet been registered. Once the original action is registered, then the arguments should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_the_args() { + $replaced_action = array( + 'args' => 10, + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action_arguments( $beans_id, $replaced_action['args'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $replaced_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action_arguments() should return false when "args" is not passed. + */ + public function test_should_return_false_when_no_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action_arguments( $beans_id, '' ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action_arguments() should replace the registered action's args. + */ + public function test_should_replace_the_action_args() { + $replaced_action = array( + 'args' => 14, + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the args is what we think before we get rolling. + $this->assertEquals( $action_config['args'], $original_action['args'] ); + + // Run the replace. + $this->assertTrue( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); + + // Check if it replaced only the args. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $replaced_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } +} diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php b/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php new file mode 100644 index 00000000..df9dcf08 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php @@ -0,0 +1,130 @@ + 'my_new_callback', + ); + + foreach ( static::$test_ids as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" callback. + $this->assertFalse( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); + + // Check that stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + } + + /** + * Test beans_replace_action_callback() should store the "replaced" action when the original action + * has not yet been registered. Once the original action is registered, then the callback should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_the_callback() { + $replaced_action = array( + 'callback' => 'foo', + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action_callback( $beans_id, $replaced_action['callback'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action_callback() should return false when no hook was passed. + */ + public function test_should_return_false_when_no_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action_callback( $beans_id, '' ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action_callback() should replace the registered action's callback. + */ + public function test_should_replace_the_action_callback() { + $replaced_action = array( + 'callback' => 'beans_foo', + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the callback is what we think before we get rolling. + $this->assertEquals( $action_config['callback'], $original_action['callback'] ); + + // Run the replace. + $this->assertTrue( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); + + // Check if it replaced only the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } +} diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionHook.php b/tests/phpunit/integration/api/actions/beansReplaceActionHook.php new file mode 100644 index 00000000..a42858b1 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansReplaceActionHook.php @@ -0,0 +1,132 @@ + 'my_new_hook', + ); + + foreach ( static::$test_ids as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" hook. + $this->assertFalse( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); + + // Check that stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + } + + /** + * Test beans_replace_action_hook() should store the "replaced" action when the original action + * has not yet been registered. Once the original action is registered, then the hook should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_the_hook() { + $replaced_action = array( + 'hook' => 'foo', + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action_hook( $beans_id, $replaced_action['hook'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + $this->check_registered_in_wp( $replaced_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action_hook() should return false when no hook was passed. + */ + public function test_should_return_false_when_no_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action_hook( $beans_id, '' ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action_hook() should replace the registered action's hook. + */ + public function test_should_replace_the_action_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the callback is what we think before we get rolling. + $this->assertEquals( $action_config['hook'], $original_action['hook'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'hook' => 'beans_foo', + ); + + // Run the replace. + $this->assertTrue( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); + + // Check if it replaced only the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } +} diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php b/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php new file mode 100644 index 00000000..d74622da --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php @@ -0,0 +1,130 @@ + 99, + ); + + foreach ( static::$test_ids as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" priority. + $this->assertFalse( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); + + // Check that stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + } + + /** + * Test beans_replace_action_priority() should store the "replaced" action when the original action + * has not yet been registered. Once the original action is registered, then the priority should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_the_priority() { + $replaced_action = array( + 'priority' => 10000, + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action_priority( $beans_id, $replaced_action['priority'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action_priority() should return false when no priority is passed. + */ + public function test_should_return_false_when_no_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action_priority( $beans_id, '' ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action_priority() should replace the registered action's priority. + */ + public function test_should_replace_the_action_priority() { + $replaced_action = array( + 'priority' => 999, + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the priority is what we think before we get rolling. + $this->assertEquals( $action_config['priority'], $original_action['priority'] ); + + // Run the replace. + $this->assertTrue( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); + + // Check if it replaced only the priority. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } +} diff --git a/tests/phpunit/integration/api/actions/fixtures/test-actions.php b/tests/phpunit/integration/api/actions/fixtures/test-actions.php new file mode 100644 index 00000000..b73c61a2 --- /dev/null +++ b/tests/phpunit/integration/api/actions/fixtures/test-actions.php @@ -0,0 +1,29 @@ + array( + 'hook' => 'beans_post_header', + 'callback' => 'beans_post_meta', + 'priority' => 15, + 'args' => 1, + ), + 'beans_post_image' => array( + 'hook' => 'beans_post_body', + 'callback' => 'beans_post_image', + 'priority' => 5, + 'args' => 1, + ), + 'beans_previous_post_link' => array( + 'hook' => 'previous_post_link', + 'callback' => 'beans_previous_post_link', + 'priority' => 10, + 'args' => 4, + ), +); diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index d8e96915..16a35d31 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -18,12 +18,47 @@ */ abstract class Actions_Test_Case extends WP_UnitTestCase { + /** + * When true, reset $_beans_registered_actions at tear down. + * + * @var bool + */ + protected $reset_beans_registry = true; + + /** + * An array of actions to test. + * + * @var array + */ + protected static $test_actions; + + /** + * An array of Beans' IDs for our test actions. + * + * @var array + */ + protected static $test_ids; + + /** + * Setup the test before we run the test setups. + */ + public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + + static::$test_actions = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-actions.php'; + static::$test_ids = array_keys( static::$test_actions ); + } + /** * Reset the test fixture. */ public function tearDown() { parent::tearDown(); + if ( false === $this->reset_beans_registry ) { + return; + } + global $_beans_registered_actions; $_beans_registered_actions = array( 'added' => array(), @@ -98,4 +133,13 @@ protected function setup_original_action( $id = 'foo' ) { return $action; } + + /** + * Create a post, load it, and force the "template redirect" to fire. + */ + protected function go_to_post() { + $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); + $this->go_to( get_permalink( $post_id ) ); + do_action( 'template_redirect' ); // @codingStandardsIgnoreLine + } } diff --git a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php new file mode 100644 index 00000000..eb311e05 --- /dev/null +++ b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php @@ -0,0 +1,158 @@ +reset_beans_registry = false; + + parent::setUp(); + + // Just in case the original action is already registered, remove it. + $this->remove_original_action(); + } + + /** + * Reset the test fixture. + */ + public function tearDown() { + parent::tearDown(); + + // Reset and restore. + foreach ( static::$test_actions as $beans_id => $action ) { + // Reset Beans. + _beans_unset_action( $beans_id, 'modified' ); + _beans_unset_action( $beans_id, 'replaced' ); + _beans_unset_action( $beans_id, 'added' ); + + // Restore the original action. + beans_add_smart_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + } + } + + /** + * Store the original action and then remove it. These steps allow us to setup an + * initial test where the action is not registered. Then when we're doing testing, we can + * restore it. + * + * @since 1.5.0 + * + * @return void + */ + private function remove_original_action() { + + foreach ( static::$test_actions as $beans_id => $action ) { + _beans_unset_action( $beans_id, 'added' ); + + if ( has_action( $action['hook'], $action['callback'] ) ) { + remove_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + } + } + } + + /** + * Merge the action's configuration with the defaults. + * + * @since 1.5.0 + * + * @param array $action The action to merge. + * + * @return array + */ + protected function merge_action_with_defaults( array $action ) { + return array_merge( + array( + 'hook' => null, + 'callback' => null, + 'priority' => null, + 'args' => null, + ), + $action + ); + } + + /** + * Check that the "replaced" action has been stored in Beans. + * + * @since 1.5.0 + * + * @param string $beans_id The Beans unique ID. + * @param array $replaced_action The "replaced" action's configuration. + * + * @return void + */ + protected function check_stored_in_beans( $beans_id, array $replaced_action ) { + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + + /** + * Check that the "replaced" action has been stored in Beans. + * + * @since 1.5.0 + * + * @param string $hook The event's name (hook) that is registered in WordPress. + * @param array $new_action The "new" action's configuration (after the replace). + * @param bool $remove_action When true, it removes the action automatically to clean up this test. + * + * @return void + */ + protected function check_registered_in_wp( $hook, array $new_action, $remove_action = true ) { + $this->assertTrue( has_action( $hook, $new_action['callback'] ) !== false ); + $this->check_parameters_registered_in_wp( $new_action, $remove_action ); + } + + /** + * Restore the original action after the replace. + * + * @since 1.5.0 + * + * @param string $beans_id The Beans unique ID. + * + * @return void + */ + protected function restore_original( $beans_id ) { + $action = static::$test_actions[ $beans_id ]; + + _beans_unset_action( $beans_id, 'added' ); + + beans_add_smart_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + } + + /** + * Create a post, load it, and force the "template redirect" to fire. + * + * @since 1.5.0 + * + * @return void + */ + protected function go_to_post() { + parent::go_to_post(); + + /** + * Restore the actions. Why? The file loads once and initially adds the actions. But then we remove them + * during our tests. + */ + foreach ( static::$test_ids as $beans_id ) { + $this->restore_original( $beans_id ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansReplaceAction.php b/tests/phpunit/unit/api/actions/beansReplaceAction.php new file mode 100644 index 00000000..c4fe9c2c --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansReplaceAction.php @@ -0,0 +1,272 @@ + 'my_new_callback', + ); + + foreach ( static::$test_ids as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" hook. + $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); + + // Check that stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action() should store the "replaced" action when the original action + * has not yet been registered. Once the original action is registered, then it should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_action() { + $replaced_action = array( + 'callback' => 'my_new_callback', + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action( $beans_id, null, $replaced_action['callback'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should return false when there's nothing to replace, + * i.e. no arguments passed. + */ + public function test_should_return_false_when_nothing_to_replace() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action( $beans_id ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action() should replace the registered action's hook. + */ + public function test_should_replace_the_action_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the callback is what we think before we get rolling. + $this->assertEquals( $action_config['hook'], $original_action['hook'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'hook' => 'foo', + ); + + // Run the replace. + $this->assertTrue( beans_replace_action( $beans_id, $replaced_action['hook'] ) ); + + // Check if it replaced only the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should replace the registered action's callback. + */ + public function test_should_replace_the_action_callback() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the callback is what we think before we get rolling. + $this->assertEquals( $action_config['callback'], $original_action['callback'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'callback' => 'foo', + ); + + // Run the replace. + $this->assertTrue( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); + + // Check if it replaced only the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should replace the registered action's priority level. + */ + public function test_should_replace_the_action_priority() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the priority is what we think before we get rolling. + $this->assertEquals( $action_config['priority'], $original_action['priority'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'priority' => 50, + ); + + // Run the replace. + $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); + + // Check if it replaced only the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should replace the registered action's number of arguments. + */ + public function test_should_replace_the_action_args() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the args are what we think before we get rolling. + $this->assertEquals( $action_config['args'], $original_action['args'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'args' => 5, + ); + + // Run the replace. + $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); + + // Check if it replaced only the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $replaced_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action() should replace the original registered action. + */ + public function test_should_replace_the_action() { + // Setup what will get stored in Beans. + $replaced_action = array( + 'hook' => 'new_hook', + 'callback' => 'new_callback', + 'priority' => 99, + 'args' => 10, + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Make sure the action is what we think before we get rolling. + $this->assertEquals( $original_action, _beans_get_action( $beans_id, 'added' ) ); + + // Run the replace. + $this->assertTrue( beans_replace_action( + $beans_id, + $replaced_action['hook'], + $replaced_action['callback'], + $replaced_action['priority'], + $replaced_action['args'] + ) ); + + // Check that the "replaced" action has been stored in Beans. + $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); + $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the new action is now registered in WordPress. + $this->check_registered_in_wp( $replaced_action['hook'], $replaced_action ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php new file mode 100644 index 00000000..9122bd63 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php @@ -0,0 +1,131 @@ + 10, + ); + + // Store the "replaced" action. + foreach ( array_keys( static::$test_actions ) as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" args. + $this->assertFalse( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); + + // Check that it stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + } + + /** + * Test beans_replace_action_arguments() should store the "replaced" hook when the original action + * has not yet been registered. Once the original action is registered, then the hook should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_the_args() { + $replaced_action = array( + 'args' => 10, + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action_arguments( $beans_id, $replaced_action['args'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $replaced_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action_arguments() should return false when no args is passed. + */ + public function test_should_return_false_when_no_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action_arguments( $beans_id, '' ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action_arguments() should replace the registered action's args. + */ + public function test_should_replace_the_action_args() { + $replaced_action = array( + 'args' => 14, + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the args is what we think before we get rolling. + $this->assertEquals( $action_config['args'], $original_action['args'] ); + + // Run the replace. + $this->assertTrue( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); + + // Check if it replaced only the args. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $replaced_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php new file mode 100644 index 00000000..ca060b08 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php @@ -0,0 +1,130 @@ + 'my_new_callback', + ); + + foreach ( array_keys( static::$test_actions ) as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" callback. + $this->assertFalse( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); + + // Check that stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + } + + /** + * Test beans_replace_action_callback() should store the "replaced" hook when the original action + * has not yet been registered. Once the original action is registered, then the hook should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_the_callback() { + $replaced_action = array( + 'callback' => 'foo', + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action_callback( $beans_id, $replaced_action['callback'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action_callback() should return false when no hook was passed. + */ + public function test_should_return_false_when_no_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action_callback( $beans_id, '' ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action_callback() should replace the registered action's callback. + */ + public function test_should_replace_the_action_callback() { + $replaced_action = array( + 'callback' => 'beans_foo', + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the callback is what we think before we get rolling. + $this->assertEquals( $action_config['callback'], $original_action['callback'] ); + + // Run the replace. + $this->assertTrue( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); + + // Check if it replaced only the callback. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php new file mode 100644 index 00000000..3bd261a3 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php @@ -0,0 +1,132 @@ + 'my_new_hook', + ); + + foreach ( array_keys( static::$test_actions ) as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" hook. + $this->assertFalse( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); + + // Check that stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + } + + /** + * Test beans_replace_action_hook() should store the "replaced" hook when the original action + * has not yet been registered. Once the original action is registered, then the hook should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_the_hook() { + $replaced_action = array( + 'hook' => 'foo', + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action_hook( $beans_id, $replaced_action['hook'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + $this->check_registered_in_wp( $replaced_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action_hook() should return false when no hook was passed. + */ + public function test_should_return_false_when_no_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action_hook( $beans_id, '' ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action_hook() should replace the registered action's hook. + */ + public function test_should_replace_the_action_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the callback is what we think before we get rolling. + $this->assertEquals( $action_config['hook'], $original_action['hook'] ); + + // Setup what will get stored in Beans. + $replaced_action = array( + 'hook' => 'beans_foo', + ); + + // Run the replace. + $this->assertTrue( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); + + // Check if it replaced only the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $original_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php new file mode 100644 index 00000000..160b9965 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php @@ -0,0 +1,130 @@ + 99, + ); + + foreach ( array_keys( static::$test_actions ) as $beans_id ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + + // Now store away the "replace" priority. + $this->assertFalse( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); + + // Check that stored. + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + } + + /** + * Test beans_replace_action_priority() should store the "replaced" hook when the original action + * has not yet been registered. Once the original action is registered, then the hook should be replaced. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_replace_the_priority() { + $replaced_action = array( + 'priority' => 10000, + ); + + // Now replace the actions. + foreach ( static::$test_ids as $beans_id ) { + beans_replace_action_priority( $beans_id, $replaced_action['priority'] ); + } + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check if it replaced the hook. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } + } + + /** + * Test beans_replace_action_priority() should return false when no priority is passed. + */ + public function test_should_return_false_when_no_hook() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $this->assertFalse( beans_replace_action_priority( $beans_id, '' ) ); + + // Verify that it did not get stored in "replaced" or "modified". + global $_beans_registered_actions; + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action has not been replaced. + $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + } + } + + /** + * Test beans_replace_action_priority() should replace the registered action's priority. + */ + public function test_should_replace_the_action_priority() { + $replaced_action = array( + 'priority' => 999, + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action_config ) { + $original_action = _beans_get_action( $beans_id, 'added' ); + + // Make sure the priority is what we think before we get rolling. + $this->assertEquals( $action_config['priority'], $original_action['priority'] ); + + // Run the replace. + $this->assertTrue( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); + + // Check if it replaced only the priority. + $new_action = _beans_get_action( $beans_id, 'added' ); + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $original_action['callback'], $new_action['callback'] ); + $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Check that the "replaced" action has been stored in Beans and WordPress. + $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/fixtures/test-actions.php b/tests/phpunit/unit/api/actions/fixtures/test-actions.php new file mode 100644 index 00000000..b73c61a2 --- /dev/null +++ b/tests/phpunit/unit/api/actions/fixtures/test-actions.php @@ -0,0 +1,29 @@ + array( + 'hook' => 'beans_post_header', + 'callback' => 'beans_post_meta', + 'priority' => 15, + 'args' => 1, + ), + 'beans_post_image' => array( + 'hook' => 'beans_post_body', + 'callback' => 'beans_post_image', + 'priority' => 5, + 'args' => 1, + ), + 'beans_previous_post_link' => array( + 'hook' => 'previous_post_link', + 'callback' => 'beans_previous_post_link', + 'priority' => 10, + 'args' => 4, + ), +); diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index acc0358d..56d5de9b 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -20,10 +20,27 @@ abstract class Actions_Test_Case extends Test_Case { /** - * Setup test fixture. + * An array of actions to test. + * + * @var array + */ + protected static $test_actions; + + /** + * An array of Beans' IDs for our test actions. + * + * @var array */ - protected function setUp() { - parent::setUp(); + protected static $test_ids; + + /** + * Setup the test before we run the test setups. + */ + public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + + static::$test_actions = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-actions.php'; + static::$test_ids = array_keys( static::$test_actions ); require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; @@ -42,6 +59,8 @@ protected function tearDown() { 'removed' => array(), 'replaced' => array(), ); + + $this->remove_test_actions(); } /** @@ -92,4 +111,52 @@ protected function setup_original_action( $id = 'foo' ) { return $action; } + + /** + * Simulate going to the post and loading in the template and fragments. + */ + protected function go_to_post() { + + foreach ( static::$test_actions as $beans_id => $action ) { + beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + } + } + + /** + * Remove the test actions. + */ + protected function remove_test_actions() { + + foreach ( static::$test_actions as $beans_id => $action ) { + _beans_unset_action( $beans_id, 'added' ); + remove_action( $action['hook'], $action['callback'], $action['priority'] ); + } + } + + /** + * Check that the right parameters are registered in WordPress. + * + * @since 1.5.0 + * + * @param array $action The action that should be registered. + * @param bool $remove_action When true, it removes the action automatically to clean up this test. + * + * @return void + */ + protected function check_parameters_registered_in_wp( array $action, $remove_action = true ) { + $container = Monkey\Container::instance(); + $this->assertTrue( has_action( $action['hook'] ) ); + $this->assertTrue( + $container->hookStorage()->isHookAdded( + Monkey\Hook\HookStorage::ACTIONS, + $action['hook'], + $action['callback'] + ) + ); + + // Then remove the action. + if ( $remove_action ) { + remove_action( $action['hook'], $action['callback'], $action['priority'] ); + } + } } diff --git a/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php new file mode 100644 index 00000000..0d5372c4 --- /dev/null +++ b/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php @@ -0,0 +1,52 @@ +assertEquals( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + } + + /** + * Check that the "replaced" action has been stored in Beans. + * + * @since 1.5.0 + * + * @param string $hook The event's name (hook) that is registered in WordPress. + * @param array $new_action The "new" action's configuration (after the replace). + * @param bool $remove_action When true, it removes the action automatically to clean up this test. + * + * @return void + */ + protected function check_registered_in_wp( $hook, array $new_action, $remove_action = true ) { + $this->assertTrue( has_action( $hook, $new_action['callback'] ) !== false ); + $this->check_parameters_registered_in_wp( $new_action, $remove_action ); + } +} From db7a04cfd65ffe4b3a805a37b59b99163d85ef58 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 1 Feb 2018 15:59:52 -0600 Subject: [PATCH 026/800] Made WPCS compliant. Added tests. (#103) * Made beans_remove_action wpcs compliant. Added tests. 1. Made WPCS compliant. 2. Added integration tests. 3. Added unit tests. 4. Stores a "default" configuration when no current action. 5. Checks if the action is valid before remove_action. --- lib/api/actions/functions.php | 68 ++- .../api/actions/beansRemoveAction.php | 103 ++++ .../api/actions/beansReplaceAction.php | 16 +- .../actions/beansReplaceActionArguments.php | 6 +- .../actions/beansReplaceActionCallback.php | 2 +- .../api/actions/beansReplaceActionHook.php | 4 +- .../actions/beansReplaceActionPriority.php | 2 +- .../api/actions/beansResetAction.php | 513 ++++++++++++++++++ .../includes/class-actions-test-case.php | 57 +- .../class-replace-action-test-case.php | 42 +- .../unit/api/actions/beansRemoveAction.php | 102 ++++ .../unit/api/actions/beansReplaceAction.php | 16 +- .../actions/beansReplaceActionArguments.php | 10 +- .../actions/beansReplaceActionCallback.php | 12 +- .../api/actions/beansReplaceActionHook.php | 4 +- .../actions/beansReplaceActionPriority.php | 10 +- .../unit/api/actions/beansResetAction.php | 414 ++++++++++++++ .../includes/class-actions-test-case.php | 48 +- .../class-replace-action-test-case.php | 3 - 19 files changed, 1325 insertions(+), 107 deletions(-) create mode 100644 tests/phpunit/integration/api/actions/beansRemoveAction.php create mode 100644 tests/phpunit/integration/api/actions/beansResetAction.php create mode 100644 tests/phpunit/unit/api/actions/beansRemoveAction.php create mode 100644 tests/phpunit/unit/api/actions/beansResetAction.php diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index c7cf9607..c2429911 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -322,55 +322,75 @@ function beans_replace_action_arguments( $id, $args ) { * This function removes an action registered using {@see beans_add_action()} or * {@see beans_add_smart_action()}. The original action can be re-added using {@see beans_reset_action()}. * + * This function is "load order" agnostic, meaning that you can remove an action before it's added. + * * @since 1.0.0 + * @since 1.5.0 When no current action, sets "removed" to default configuration. * - * @param string $id The action ID. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. * - * @return bool Will always return true. + * @return bool */ function beans_remove_action( $id ) { + $action = _beans_get_current_action( $id ); - // Remove. - if ( $action = _beans_get_current_action( $id ) ) { - remove_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + // If the action is not registered yet, set it to a default configuration. + if ( empty( $action ) ) { + $action = array( + 'hook' => null, + 'callback' => null, + 'priority' => null, + 'args' => null, + ); } - // Register as removed. - _beans_set_action( $id, $action, 'removed' ); - - return true; + // When there is a current action, remove it. + if ( _beans_is_action_valid( $action ) ) { + remove_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + } + // Store as "removed". + return _beans_set_action( $id, $action, 'removed' ); } /** * Reset an action. * * This function resets an action registered using {@see beans_add_action()} or - * {@see beans_add_smart_action()}. If the original values were replaced using - * {@see beans_replace_action()}, these values will be used. + * {@see beans_add_smart_action()}. + * + * If the original values were replaced using {@see beans_replace_action()}, these values will be used, as + * {@see beans_replace_action()} is not resettable. * * @since 1.0.0 + * @since 1.5.0 Bail out if the action does not need to be reset. * - * @param string $id The action ID. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. * - * @return bool Will always return true. + * @return bool */ function beans_reset_action( $id ) { - _beans_unset_action( $id, 'modified' ); _beans_unset_action( $id, 'removed' ); $action = _beans_get_action( $id, 'added' ); - if ( $current = _beans_get_current_action( $id ) ) { + // Bail out if there is no action. + if ( ! _beans_is_action_valid( $action ) ) { + return false; + } - remove_action( $current['hook'], $current['callback'], $current['priority'], $current['args'] ); - add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + $current = _beans_get_current_action( $id ); + // Return the action if there is no current action. + if ( ! _beans_is_action_valid( $current ) ) { + return $action; } - return $action; + remove_action( $current['hook'], $current['callback'], $current['priority'], $current['args'] ); + add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + return $action; } /** @@ -564,11 +584,19 @@ function _beans_get_current_action( $id ) { * @ignore * @access private * - * @param array $action Action's configuration. + * @param array|mixed $action Action's configuration. * * @return bool */ -function _beans_is_action_valid( array $action ) { +function _beans_is_action_valid( $action ) { + if ( empty( $action ) ) { + return false; + } + + if ( ! is_array( $action ) ) { + return; + } + return isset( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } diff --git a/tests/phpunit/integration/api/actions/beansRemoveAction.php b/tests/phpunit/integration/api/actions/beansRemoveAction.php new file mode 100644 index 00000000..7ec45cff --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansRemoveAction.php @@ -0,0 +1,103 @@ + null, + 'callback' => null, + 'priority' => null, + 'args' => null, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_current_action( $beans_id ) ); + + // Remove the action. Test that an empty action is returned. + $this->assertSame( $empty_action, beans_remove_action( $beans_id ) ); + + // Check that the "empty" action is registered as "removed". + $this->assertSame( $empty_action, _beans_get_action( $beans_id, 'removed' ) ); + + // Check that the original action is not registered in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } + } + + /** + * Test beans_remove_action() should store the "removed" action before the original action is "added". + * Once the original action is registered, then it should be removed. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_remove_action() { + + // Remove the actions. + foreach ( static::$test_actions as $beans_id => $action ) { + beans_remove_action( $beans_id ); + } + + // Load the post, which runs beans_add_action for each of our test actions. + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Check that the action is registered as "added". + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + + // Check that the action is not registered in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } + } + + /** + * Test beans_remove_action() should remove a registered action. + */ + public function test_should_remove_a_registered_action() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Check that the action is registered with Beans. + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + + // Check that the action is registered with WordPress. + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + // Remove it. + $this->assertSame( $action, beans_remove_action( $beans_id ) ); + + // Check that the action is registered as "removed". + $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); + + // Check that the action is no longer registered with WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } + } +} diff --git a/tests/phpunit/integration/api/actions/beansReplaceAction.php b/tests/phpunit/integration/api/actions/beansReplaceAction.php index 5b022115..c3f78d82 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceAction.php +++ b/tests/phpunit/integration/api/actions/beansReplaceAction.php @@ -40,7 +40,7 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" hook. $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); - // Check that stored. + // Check that it was stored as "modified". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } } @@ -109,7 +109,7 @@ public function test_should_replace_the_action_hook() { // Make sure the callback is what we think before we get rolling. $this->assertEquals( $action_config['hook'], $original_action['hook'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'hook' => 'foo', ); @@ -142,7 +142,7 @@ public function test_should_replace_the_action_callback() { // Make sure the callback is what we think before we get rolling. $this->assertEquals( $action_config['callback'], $original_action['callback'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'callback' => 'foo', ); @@ -175,7 +175,7 @@ public function test_should_replace_the_action_priority() { // Make sure the priority is what we think before we get rolling. $this->assertEquals( $action_config['priority'], $original_action['priority'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'priority' => 50, ); @@ -183,7 +183,7 @@ public function test_should_replace_the_action_priority() { // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); - // Check if it replaced only the callback. + // Check if it replaced only the priority. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -208,7 +208,7 @@ public function test_should_replace_the_action_args() { // Make sure the args are what we think before we get rolling. $this->assertEquals( $action_config['args'], $original_action['args'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'args' => 5, ); @@ -216,7 +216,7 @@ public function test_should_replace_the_action_args() { // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); - // Check if it replaced only the callback. + // Check if it replaced only the args. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -233,7 +233,7 @@ public function test_should_replace_the_action_args() { * Test beans_replace_action() should replace the original registered action. */ public function test_should_replace_the_action() { - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'hook' => 'new_hook', 'callback' => 'new_callback', diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php b/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php index 670ae450..9b13aa43 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php @@ -41,7 +41,7 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" args. $this->assertFalse( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); - // Check that it stored. + // Check that it was stored as "modified". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } } @@ -65,7 +65,7 @@ public function test_should_store_and_then_replace_the_args() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the hook. + // Check if it replaced the args. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -81,7 +81,7 @@ public function test_should_store_and_then_replace_the_args() { /** * Test beans_replace_action_arguments() should return false when "args" is not passed. */ - public function test_should_return_false_when_no_hook() { + public function test_should_return_false_when_no_args() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $action_config ) { diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php b/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php index df9dcf08..fafd938f 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php @@ -40,7 +40,7 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" callback. $this->assertFalse( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); - // Check that stored. + // Check that it was stored as "modified". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } } diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionHook.php b/tests/phpunit/integration/api/actions/beansReplaceActionHook.php index a42858b1..3e86f990 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionHook.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionHook.php @@ -40,7 +40,7 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" hook. $this->assertFalse( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); - // Check that stored. + // Check that it was stored as "modified". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } } @@ -109,7 +109,7 @@ public function test_should_replace_the_action_hook() { // Make sure the callback is what we think before we get rolling. $this->assertEquals( $action_config['hook'], $original_action['hook'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'hook' => 'beans_foo', ); diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php b/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php index d74622da..72edf018 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php @@ -40,7 +40,7 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" priority. $this->assertFalse( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); - // Check that stored. + // Check that it was stored as "modified". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } } diff --git a/tests/phpunit/integration/api/actions/beansResetAction.php b/tests/phpunit/integration/api/actions/beansResetAction.php new file mode 100644 index 00000000..f8500aa7 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansResetAction.php @@ -0,0 +1,513 @@ + $action ) { + $this->assertFalse( beans_reset_action( $beans_id ) ); + } + } + + /** + * Test beans_reset_action() should reset the original action after it was "removed" via beans_remove_action(). + */ + public function test_should_reset_after_remove() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + // Remove it. + beans_remove_action( $beans_id ); + + // Check that the action did get removed. + $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + + // Let's reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); + + // Check that the action was reset. + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); + $this->check_the_action( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's hook after it was "modified". + */ + public function test_should_reset_after_modifying_the_hook() { + $modified_action = array( + 'hook' => 'foo', + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + // Now modify the hook. + beans_modify_action_hook( $beans_id, $modified_action['hook'] ); + + // Check that the hook was modified. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertTrue( has_action( $modified_action['hook'], $action['callback'] ) !== false ); + + // Let's reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); + + // Check that the action was reset. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->check_the_action( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's callback after it was "modified". + */ + public function test_should_reset_after_modifying_the_callback() { + global $wp_filter; + + $modified_action = array( + 'callback' => 'my_callback', + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + // Grab what's registered in WordPress. + $action_in_wp = $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ]; + + // Modify the callback. + beans_modify_action_callback( $beans_id, $modified_action['callback'] ); + + // Check that the action's callback was modified. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( $action['callback'], $action_in_wp[ $action['callback'] ]['function'] ); + + // Let's reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); + + // Check that the action was reset. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->check_the_action( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's priority after it was "modified". + */ + public function test_should_reset_after_modifying_the_priority() { + global $wp_filter; + + $modified_action = array( + 'priority' => 9999, + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, do a hard check to ensure the original priority is registered. + $this->assertEquals( + $action['callback'], + $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['function'] + ); + + // Modify the priority. + beans_modify_action_priority( $beans_id, $modified_action['priority'] ); + + // Check that the priority was modified. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( + $action['callback'], + $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $action['callback'] ]['function'] + ); + + // Let's reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); + + // Check that the action was reset. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->check_the_action( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's args after it was "modified". + */ + public function test_should_reset_after_modifying_the_args() { + global $wp_filter; + + $modified_action = array( + 'args' => 14, + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, do a hard check to ensure the original number of args is registered. + $this->assertEquals( + $action['args'], + $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['accepted_args'] + ); + + // Modify the number of arguments. + beans_modify_action_arguments( $beans_id, $modified_action['args'] ); + + // Check that the number of arguments was modified. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( + $modified_action['args'], + $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['accepted_args'] + ); + + // Let's reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); + + // Check that the action was reset. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->check_the_action( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's callback and args after they were "modified". + */ + public function test_should_reset_after_modifying_callback_and_args() { + global $wp_filter; + + $this->go_to_post(); + + $modified_action = array( + 'callback' => 'my_callback', + 'args' => 14, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->check_the_action( $beans_id, $action ); + + // Modify the action. + beans_modify_action( $beans_id, null, $modified_action['callback'], null, $modified_action['args'] ); + + // Check that the action was modified. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertTrue( has_action( $action['hook'], $modified_action['callback'] ) !== false ); + $this->assertEquals( + array( + 'function' => $modified_action['callback'], + 'accepted_args' => $modified_action['args'], + ), + $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $modified_action['callback'] ] + ); + + // Let's reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); + + // Check that the action was reset. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->check_the_action( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's priority and args after they were "modified". + */ + public function test_should_reset_after_modifying_priority_and_args() { + global $wp_filter; + + $this->go_to_post(); + + $modified_action = array( + 'priority' => 79, + 'args' => 14, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->check_the_action( $beans_id, $action ); + + // Modify the action. + beans_modify_action( $beans_id, null, null, $modified_action['priority'], $modified_action['args'] ); + + // Check that the action was modified. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( + array( + 'function' => $action['callback'], + 'accepted_args' => $modified_action['args'], + ), + $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $action['callback'] ] + ); + + // Let's reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); + + // Check that the action was reset. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->check_the_action( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's callback and priority after they were "modified". + */ + public function test_should_reset_after_modifying_callback_and_priority() { + global $wp_filter; + + $this->go_to_post(); + + $modified_action = array( + 'callback' => 'foo', + 'priority' => 39, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->check_the_action( $beans_id, $action ); + + // Modify the action. + beans_modify_action( $beans_id, null, $modified_action['callback'], $modified_action['priority'] ); + + // Check that the action was modified. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( + array( + 'function' => $modified_action['callback'], + 'accepted_args' => $action['args'], + ), + $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $modified_action['callback'] ] + ); + + // Let's reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); + + // Check that the action was reset. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->check_the_action( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's callback, priority, and args after they were + * "modified". + */ + public function test_should_reset_after_modifying_all_but_hook() { + global $wp_filter; + + $this->go_to_post(); + + $modified_action = array( + 'callback' => 'foo', + 'priority' => 39, + 'args' => 24, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->check_the_action( $beans_id, $action ); + + // Modify the action. + beans_modify_action( $beans_id, null, $modified_action['callback'], $modified_action['priority'], $modified_action['args'] ); + + // Check that the action was modified. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( + array( + 'function' => $modified_action['callback'], + 'accepted_args' => $modified_action['args'], + ), + $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $modified_action['callback'] ] + ); + + // Let's reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); + + // Check that the action was reset. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->check_the_action( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should not reset after replacing the action's hook. + * + * Why? "Replace" overwrites and is not resettable. + */ + public function test_should_not_reset_after_replacing_hook() { + $hook = 'foo'; + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + // Run the replace. + beans_replace_action_hook( $beans_id, $hook ); + + // Let's try to reset the action. + $this->assertSame( $hook, beans_reset_action( $beans_id )['hook'] ); + + // Check that the action was not reset. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertTrue( has_action( $hook, $action['callback'] ) !== false ); + } + } + + /** + * Test beans_reset_action() should not reset after replacing the action's callback. + * + * Why? "Replace" overwrites and is not resettable. + */ + public function test_should_not_reset_after_replacing_callback() { + $callback = 'foo_cb'; + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + // Run the replace. + beans_replace_action_callback( $beans_id, $callback ); + + // Let's try to reset the action. + $this->assertSame( $callback, beans_reset_action( $beans_id )['callback'] ); + + // Check that the action was not reset. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertTrue( has_action( $action['hook'], $callback ) !== false ); + } + } + + /** + * Test beans_reset_action() should not reset after replacing the action's priority. + * + * Why? "Replace" overwrites and is not resettable. + */ + public function test_should_not_reset_after_replacing_priority() { + global $wp_filter; + + $priority = 17; + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, do a hard check to ensure the original priority is registered. + $this->assertEquals( + array( + 'function' => $action['callback'], + 'accepted_args' => $action['args'], + ), + $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ] + ); + + // Run the replace. + beans_replace_action_priority( $beans_id, $priority ); + + // Let's try to reset the action. + $this->assertSame( $priority, beans_reset_action( $beans_id )['priority'] ); + + // Check that the action was not reset. + $this->assertEquals( + array( + 'function' => $action['callback'], + 'accepted_args' => $action['args'], + ), + $wp_filter[ $action['hook'] ]->callbacks[ $priority ][ $action['callback'] ] + ); + } + } + + /** + * Test beans_reset_action() should not reset after replacing the action's args. + * + * Why? "Replace" overwrites and is not resettable. + */ + public function test_should_not_reset_after_replacing_args() { + global $wp_filter; + + $args = 29; + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, do a hard check to ensure the original number of args is registered. + $this->assertEquals( + $action['args'], + $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['accepted_args'] + ); + + // Run the replace. + beans_replace_action_arguments( $beans_id, $args ); + + // Let's try to reset the action. + $this->assertSame( $args, beans_reset_action( $beans_id )['args'] ); + + // Check that the action was not reset. + $this->assertEquals( + $args, + $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['accepted_args'] + ); + } + } + + /** + * Check that the action was reset. + * + * @since 1.5.0 + * + * @param string $beans_id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param array $action The action to check. + * + * @return void + */ + protected function check_the_action( $beans_id, array $action ) { + global $wp_filter; + + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + $this->assertEquals( + array( + 'function' => $action['callback'], + 'accepted_args' => $action['args'], + ), + $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ] + ); + } +} diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index 16a35d31..946ead31 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -40,7 +40,7 @@ abstract class Actions_Test_Case extends WP_UnitTestCase { protected static $test_ids; /** - * Setup the test before we run the test setups. + * Set up the test before we run the test setups. */ public static function setUpBeforeClass() { parent::setUpBeforeClass(); @@ -49,6 +49,29 @@ public static function setUpBeforeClass() { static::$test_ids = array_keys( static::$test_actions ); } + /** + * Tear down the test before we exit this class. + */ + public static function tearDownAfterClass() { + parent::tearDownAfterClass(); + + global $_beans_registered_actions; + $_beans_registered_actions = array( + 'added' => array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + + // Remove the test actions. + foreach ( static::$test_actions as $beans_id => $action ) { + remove_action( $action['hook'], $action['callback'], $action['priority'] ); + } + + static::$test_actions = null; + static::$test_ids = null; + } + /** * Reset the test fixture. */ @@ -68,6 +91,23 @@ public function tearDown() { ); } + /** + * Restore the original action. + * + * @since 1.5.0 + * + * @param string $beans_id The Beans unique ID. + * + * @return void + */ + protected function restore_original( $beans_id ) { + $action = static::$test_actions[ $beans_id ]; + + _beans_unset_action( $beans_id, 'added' ); + + beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + } + /** * Check that it is not registered first. * @@ -135,9 +175,22 @@ protected function setup_original_action( $id = 'foo' ) { } /** - * Create a post, load it, and force the "template redirect" to fire. + * Simulate going to the post and loading in the template and fragments. + * + * @since 1.5.0 + * + * @return void */ protected function go_to_post() { + + /** + * Restore the actions. Why? The file loads once and initially adds the actions. But then we remove them + * during our tests. + */ + foreach ( static::$test_ids as $beans_id ) { + $this->restore_original( $beans_id ); + } + $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); $this->go_to( get_permalink( $post_id ) ); do_action( 'template_redirect' ); // @codingStandardsIgnoreLine diff --git a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php index eb311e05..24db47e6 100644 --- a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php @@ -19,7 +19,7 @@ abstract class Replace_Action_Test_Case extends Actions_Test_Case { /** - * Setup the test fixture. + * Set up the test fixture. */ public function setUp() { $this->reset_beans_registry = false; @@ -49,7 +49,7 @@ public function tearDown() { } /** - * Store the original action and then remove it. These steps allow us to setup an + * Store the original action and then remove it. These steps allow us to set up an * initial test where the action is not registered. Then when we're doing testing, we can * restore it. * @@ -105,7 +105,7 @@ protected function check_stored_in_beans( $beans_id, array $replaced_action ) { } /** - * Check that the "replaced" action has been stored in Beans. + * Check that the "replaced" action has been registered in WordPress. * * @since 1.5.0 * @@ -119,40 +119,4 @@ protected function check_registered_in_wp( $hook, array $new_action, $remove_act $this->assertTrue( has_action( $hook, $new_action['callback'] ) !== false ); $this->check_parameters_registered_in_wp( $new_action, $remove_action ); } - - /** - * Restore the original action after the replace. - * - * @since 1.5.0 - * - * @param string $beans_id The Beans unique ID. - * - * @return void - */ - protected function restore_original( $beans_id ) { - $action = static::$test_actions[ $beans_id ]; - - _beans_unset_action( $beans_id, 'added' ); - - beans_add_smart_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); - } - - /** - * Create a post, load it, and force the "template redirect" to fire. - * - * @since 1.5.0 - * - * @return void - */ - protected function go_to_post() { - parent::go_to_post(); - - /** - * Restore the actions. Why? The file loads once and initially adds the actions. But then we remove them - * during our tests. - */ - foreach ( static::$test_ids as $beans_id ) { - $this->restore_original( $beans_id ); - } - } } diff --git a/tests/phpunit/unit/api/actions/beansRemoveAction.php b/tests/phpunit/unit/api/actions/beansRemoveAction.php new file mode 100644 index 00000000..802a65f3 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansRemoveAction.php @@ -0,0 +1,102 @@ + null, + 'callback' => null, + 'priority' => null, + 'args' => null, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Test that the original action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_current_action( $beans_id ) ); + + // Remove the action. Test that an empty action is returned. + $this->assertSame( $empty_action, beans_remove_action( $beans_id ) ); + + // Check that the "empty" action is registered as "removed". + $this->assertSame( $empty_action, _beans_get_action( $beans_id, 'removed' ) ); + + // Check that the original action is not registered in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } + } + + /** + * Test beans_remove_action() should store the "removed" action before the original action is "added". + * Once the original action is registered, then it should be removed. + * + * Intent: We are testing to ensure Beans is "load order" agnostic. + */ + public function test_should_store_and_then_remove_action() { + + // Remove the actions. + foreach ( static::$test_actions as $beans_id => $action ) { + beans_remove_action( $beans_id ); + } + + // Load the post, which runs beans_add_action for each of our test actions. + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Check that the action is registered as "added". + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + + // Check that the action is not registered in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } + } + + /** + * Test beans_remove_action() should remove the registered action. + */ + public function test_should_remove_registered_action() { + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Check that the action is registered with Beans. + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + + // Check that the action is registered with WordPress. + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + // Remove it. + $this->assertSame( $action, beans_remove_action( $beans_id ) ); + + // Check that the action is registered as "removed". + $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); + + // Check that the action is no longer registered with WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansReplaceAction.php b/tests/phpunit/unit/api/actions/beansReplaceAction.php index c4fe9c2c..15b5b42a 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceAction.php +++ b/tests/phpunit/unit/api/actions/beansReplaceAction.php @@ -40,7 +40,7 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" hook. $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); - // Check that stored. + // Check that it was stored as "modified" and "added". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); } @@ -110,7 +110,7 @@ public function test_should_replace_the_action_hook() { // Make sure the callback is what we think before we get rolling. $this->assertEquals( $action_config['hook'], $original_action['hook'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'hook' => 'foo', ); @@ -143,7 +143,7 @@ public function test_should_replace_the_action_callback() { // Make sure the callback is what we think before we get rolling. $this->assertEquals( $action_config['callback'], $original_action['callback'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'callback' => 'foo', ); @@ -176,7 +176,7 @@ public function test_should_replace_the_action_priority() { // Make sure the priority is what we think before we get rolling. $this->assertEquals( $action_config['priority'], $original_action['priority'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'priority' => 50, ); @@ -184,7 +184,7 @@ public function test_should_replace_the_action_priority() { // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); - // Check if it replaced only the callback. + // Check if it replaced only the priority. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -209,7 +209,7 @@ public function test_should_replace_the_action_args() { // Make sure the args are what we think before we get rolling. $this->assertEquals( $action_config['args'], $original_action['args'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'args' => 5, ); @@ -217,7 +217,7 @@ public function test_should_replace_the_action_args() { // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); - // Check if it replaced only the callback. + // Check if it replaced only the args. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -234,7 +234,7 @@ public function test_should_replace_the_action_args() { * Test beans_replace_action() should replace the original registered action. */ public function test_should_replace_the_action() { - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'hook' => 'new_hook', 'callback' => 'new_callback', diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php index 9122bd63..29068600 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php @@ -41,14 +41,14 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" args. $this->assertFalse( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); - // Check that it stored. + // Check that it was stored as "modified". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } } /** - * Test beans_replace_action_arguments() should store the "replaced" hook when the original action - * has not yet been registered. Once the original action is registered, then the hook should be replaced. + * Test beans_replace_action_arguments() should store the "replaced" args when the original action + * has not yet been registered. Once the original action is registered, then the args should be replaced. * * Intent: We are testing to ensure Beans is "load order" agnostic. */ @@ -65,7 +65,7 @@ public function test_should_store_and_then_replace_the_args() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the hook. + // Check if it replaced the args. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -81,7 +81,7 @@ public function test_should_store_and_then_replace_the_args() { /** * Test beans_replace_action_arguments() should return false when no args is passed. */ - public function test_should_return_false_when_no_hook() { + public function test_should_return_false_when_no_args() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $action_config ) { diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php index ca060b08..7bbbea2b 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php @@ -40,14 +40,14 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" callback. $this->assertFalse( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); - // Check that stored. + // Check that it was stored as "modified". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } } /** - * Test beans_replace_action_callback() should store the "replaced" hook when the original action - * has not yet been registered. Once the original action is registered, then the hook should be replaced. + * Test beans_replace_action_callback() should store the "replaced" callback when the original action + * has not yet been registered. Once the original action is registered, then the callback should be replaced. * * Intent: We are testing to ensure Beans is "load order" agnostic. */ @@ -64,7 +64,7 @@ public function test_should_store_and_then_replace_the_callback() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the hook. + // Check if it replaced the callback. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); @@ -78,9 +78,9 @@ public function test_should_store_and_then_replace_the_callback() { } /** - * Test beans_replace_action_callback() should return false when no hook was passed. + * Test beans_replace_action_callback() should return false when no callback was passed. */ - public function test_should_return_false_when_no_hook() { + public function test_should_return_false_when_no_callback() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $action_config ) { diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php index 3bd261a3..1d2d1917 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php @@ -40,7 +40,7 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" hook. $this->assertFalse( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); - // Check that stored. + // Check that it was stored as "modified". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } } @@ -109,7 +109,7 @@ public function test_should_replace_the_action_hook() { // Make sure the callback is what we think before we get rolling. $this->assertEquals( $action_config['hook'], $original_action['hook'] ); - // Setup what will get stored in Beans. + // Set up what will get stored in Beans. $replaced_action = array( 'hook' => 'beans_foo', ); diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php index 160b9965..f278242f 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php @@ -40,14 +40,14 @@ public function test_should_store_when_action_is_not_registered() { // Now store away the "replace" priority. $this->assertFalse( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); - // Check that stored. + // Check that it was stored as "modified". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } } /** - * Test beans_replace_action_priority() should store the "replaced" hook when the original action - * has not yet been registered. Once the original action is registered, then the hook should be replaced. + * Test beans_replace_action_priority() should store the "replaced" priority when the original action + * has not yet been registered. Once the original action is registered, then the priority should be replaced. * * Intent: We are testing to ensure Beans is "load order" agnostic. */ @@ -64,7 +64,7 @@ public function test_should_store_and_then_replace_the_priority() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the hook. + // Check if it replaced the priority. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -80,7 +80,7 @@ public function test_should_store_and_then_replace_the_priority() { /** * Test beans_replace_action_priority() should return false when no priority is passed. */ - public function test_should_return_false_when_no_hook() { + public function test_should_return_false_when_no_priority() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $action_config ) { diff --git a/tests/phpunit/unit/api/actions/beansResetAction.php b/tests/phpunit/unit/api/actions/beansResetAction.php new file mode 100644 index 00000000..0a066192 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansResetAction.php @@ -0,0 +1,414 @@ + $action ) { + $this->assertFalse( beans_reset_action( $beans_id ) ); + } + } + + /** + * Test beans_reset_action() should reset the original action after it was "removed". + */ + public function test_should_reset_after_remove() { + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Remove the action. + beans_remove_action( $beans_id ); + + // Check that the action was removed in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + + // Check that the action was "removed" in Beans. + $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); + + // Reset and then check in WordPress and Beans. + $this->reset_and_check( $beans_id, $action, true ); + } + } + + /** + * Test beans_reset_action() should reset the original action's hook after it was "modified". + */ + public function test_should_reset_after_modifying_the_hook() { + $modified_action = array( + 'hook' => 'foo', + ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $modified_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action ) { + // Check that the parameters remain unchanged in WordPress. + $this->assertSame( $action['callback'], $callback ); + $this->assertSame( $action['priority'], $priority ); + $this->assertSame( $action['args'], $args ); + } ); + + // Modify the action's hook. + beans_modify_action_hook( $beans_id, $modified_action['hook'] ); + + // Check that the action was modified in Beans. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Reset and then check in WordPress and Beans. + $this->reset_and_check( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's callback after it was "modified". + */ + public function test_should_reset_after_modifying_the_callback() { + $modified_action = array( + 'callback' => 'my_callback', + ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { + // Check that the callback was modified in WordPress. + $this->assertSame( $modified_action['callback'], $callback ); + // Check that the other parameters remain unchanged. + $this->assertSame( $action['priority'], $priority ); + $this->assertSame( $action['args'], $args ); + } ); + + // Modify the action's callback. + beans_modify_action_callback( $beans_id, $modified_action['callback'] ); + + // Check that the action was modified in Beans. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Reset and then check in WordPress and Beans. + $this->reset_and_check( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's priority after it was "modified". + */ + public function test_should_reset_after_modifying_the_priority() { + $modified_action = array( + 'priority' => 9999, + ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { + // Check that the priority was modified in WordPress. + $this->assertSame( $modified_action['priority'], $priority ); + // Check that the other parameters remain unchanged. + $this->assertSame( $action['callback'], $callback ); + $this->assertSame( $action['args'], $args ); + } ); + + // Modify the action's priority. + beans_modify_action_priority( $beans_id, $modified_action['priority'] ); + + // Check that the action was modified in Beans. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Reset and then check in WordPress and Beans. + $this->reset_and_check( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's args after it was "modified". + */ + public function test_should_reset_after_modifying_the_args() { + $modified_action = array( + 'args' => 14, + ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { + // Check that the args was modified in WordPress. + $this->assertSame( $modified_action['args'], $args ); + // Check that the other parameters remain unchanged. + $this->assertSame( $action['callback'], $callback ); + $this->assertSame( $action['priority'], $priority ); + } ); + + // Modify the action's args. + beans_modify_action_arguments( $beans_id, $modified_action['args'] ); + + // Check that the action was modified in Beans. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Reset and then check in WordPress and Beans. + $this->reset_and_check( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's callback and args after they were "modified". + */ + public function test_should_reset_after_modifying_callback_and_args() { + $modified_action = array( + 'callback' => 'my_callback', + 'args' => 14, + ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { + // Check that the callback and args were modified in WordPress. + $this->assertSame( $modified_action['callback'], $callback ); + $this->assertSame( $modified_action['args'], $args ); + // Check that the priority remains unchanged. + $this->assertSame( $action['priority'], $priority ); + } ); + + // Modify the action's callback and args. + beans_modify_action( $beans_id, null, $modified_action['callback'], null, $modified_action['args'] ); + + // Check that the action was modified in Beans. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Reset and then check in WordPress and Beans. + $this->reset_and_check( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's priority and args after they were "modified". + */ + public function test_should_reset_after_modifying_priority_and_args() { + $modified_action = array( + 'priority' => 79, + 'args' => 14, + ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { + // Check that the priority and args were modified in WordPress. + $this->assertSame( $modified_action['priority'], $priority ); + $this->assertSame( $modified_action['args'], $args ); + // Check that the callback remains unchanged. + $this->assertSame( $action['callback'], $callback ); + } ); + + // Modify the action's priority and args. + beans_modify_action( $beans_id, null, null, $modified_action['priority'], $modified_action['args'] ); + + // Check that the action was modified in Beans. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Reset and then check in WordPress and Beans. + $this->reset_and_check( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's callback and priority after they were "modified". + */ + public function test_should_reset_after_modifying_callback_and_priority() { + $modified_action = array( + 'callback' => 'foo', + 'priority' => 39, + ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { + // Check that the callback and priority were modified in WordPress. + $this->assertSame( $modified_action['callback'], $callback ); + $this->assertSame( $modified_action['priority'], $priority ); + // Check that the args remains unchanged. + $this->assertSame( $action['args'], $args ); + } ); + + // Modify the action's callback and priority. + beans_modify_action( $beans_id, null, $modified_action['callback'], $modified_action['priority'] ); + + // Check that the action was modified in Beans. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Reset and then check in WordPress and Beans. + $this->reset_and_check( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should reset the original action's callback, priority, and args after they were + * "modified". + */ + public function test_should_reset_after_modifying_all_but_hook() { + $modified_action = array( + 'callback' => 'foo', + 'priority' => 39, + 'args' => 24, + ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { + // Check that all of the parameters were modified in WordPress. + $this->assertSame( $modified_action['callback'], $callback ); + $this->assertSame( $modified_action['priority'], $priority ); + $this->assertSame( $modified_action['args'], $args ); + } ); + + // Modify the action. + beans_modify_action( $beans_id, null, $modified_action['callback'], $modified_action['priority'], $modified_action['args'] ); + + // Check that the action was modified in Beans. + $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Reset and then check in WordPress and Beans. + $this->reset_and_check( $beans_id, $action ); + } + } + + /** + * Test beans_reset_action() should not reset after replacing the action's hook. + * + * Why? "Replace" overwrites and is not resettable. + */ + public function test_should_not_reset_after_replacing_hook() { + $hook = 'foo'; + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + // Run the replace. + beans_replace_action_hook( $beans_id, $hook ); + + // Let's try to reset the action. + $this->assertSame( $hook, beans_reset_action( $beans_id )['hook'] ); + + // Check that the action was not reset. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertTrue( has_action( $hook, $action['callback'] ) !== false ); + } + } + + /** + * Test beans_reset_action() should not reset after replacing the action's callback. + * + * Why? "Replace" overwrites and is not resettable. + */ + public function test_should_not_reset_after_replacing_callback() { + $callback = 'foo_cb'; + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Before we start, check that the action is registered. + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + + // Run the replace. + beans_replace_action_callback( $beans_id, $callback ); + + // Let's try to reset the action. + $this->assertSame( $callback, beans_reset_action( $beans_id )['callback'] ); + + // Check that the action was not reset. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertTrue( has_action( $action['hook'], $callback ) !== false ); + } + } + + /** + * Reset the action. + * + * 1. Set up the WordPress simulator before we reset the action. + * 2. Then reset the action. + * 3. Check that the action was reset in WordPress. + * 4. Check that the action was reset in Beans. + * + * @since 1.5.0 + * + * @param string $beans_id Beans' action ID. + * @param array $original_action Action's original configuration. + * @param bool $after_remove Set to true when resetting after a remove. + * + * @return void + * @throws Monkey\Expectation\Exception\NotAllowedMethod Throws when callback is invalid. + */ + protected function reset_and_check( $beans_id, $original_action, $after_remove = false ) { + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { + $this->assertSame( $original_action['args'], $args ); + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + } ); + + $this->assertSame( $original_action, beans_reset_action( $beans_id ) ); + + if ( $after_remove ) { + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); + } else { + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + } + + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); + } +} diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index 56d5de9b..e64fe106 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -34,7 +34,7 @@ abstract class Actions_Test_Case extends Test_Case { protected static $test_ids; /** - * Setup the test before we run the test setups. + * Set up the test before we run the test setups. */ public static function setUpBeforeClass() { parent::setUpBeforeClass(); @@ -46,6 +46,29 @@ public static function setUpBeforeClass() { require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } + /** + * Tear down the test before we exit this class. + */ + public static function tearDownAfterClass() { + parent::tearDownAfterClass(); + + global $_beans_registered_actions; + $_beans_registered_actions = array( + 'added' => array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + + // Remove the test actions. + foreach ( static::$test_actions as $beans_id => $action ) { + remove_action( $action['hook'], $action['callback'], $action['priority'] ); + } + + static::$test_actions = null; + static::$test_ids = null; + } + /** * Reset the test fixture. */ @@ -114,11 +137,32 @@ protected function setup_original_action( $id = 'foo' ) { /** * Simulate going to the post and loading in the template and fragments. + * + * @since 1.5.0 + * + * @param bool $expect_added Optional. When true, runs tests to ensure it's been added. + * + * @return void + * @throws Monkey\Expectation\Exception\NotAllowedMethod Thrown from Monkey. */ - protected function go_to_post() { + protected function go_to_post( $expect_added = false ) { foreach ( static::$test_actions as $beans_id => $action ) { + if ( $expect_added ) { + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action ) { + $this->assertSame( $action['callback'], $callback ); + $this->assertSame( $action['priority'], $priority ); + $this->assertSame( $action['args'], $args ); + } ); + } + beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + + if ( $expect_added ) { + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + } } } diff --git a/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php index 0d5372c4..aa723245 100644 --- a/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php @@ -9,9 +9,6 @@ namespace Beans\Framework\Tests\Unit\API\Actions\Includes; -use Beans\Framework\Tests\Unit\Test_Case; -use Brain\Monkey; - /** * Abstract Class Replace_Action_Test_Case * From 5c1dc302c2a41cc9db4c4a81b9bec871fb859eef Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 1 Feb 2018 19:14:08 -0600 Subject: [PATCH 027/800] Improves Actions API tests (#104) 1. Using our new test data fixtures, this PR improves the integration and unit tests for all of the Actions API functions. 2. Bail out checks added for replace/modify hook and callback functions. --- lib/api/actions/functions.php | 27 ++- .../api/actions/beansAddAction.php | 146 +++++++------- .../api/actions/beansAddAnonymousAction.php | 2 +- .../api/actions/beansModifyAction.php | 177 +++++++++++++---- .../actions/beansModifyActionArguments.php | 142 +++++++++----- .../api/actions/beansModifyActionCallback.php | 80 ++++++-- .../api/actions/beansModifyActionHook.php | 95 +++++---- .../api/actions/beansModifyActionPriority.php | 178 ++++++++++++----- .../api/actions/beansReplaceAction.php | 98 +++++----- .../includes/class-actions-test-case.php | 16 ++ .../class-replace-action-test-case.php | 16 -- .../unit/api/actions/beansAddAction.php | 182 ++++++++++------- .../unit/api/actions/beansGetAction.php | 136 +++++++------ .../api/actions/beansGetCurrentAction.php | 87 ++++----- .../unit/api/actions/beansMergeAction.php | 90 +++------ .../unit/api/actions/beansModifyAction.php | 184 ++++++++++++------ .../actions/beansModifyActionArguments.php | 118 +++++++---- .../api/actions/beansModifyActionCallback.php | 93 ++++++--- .../api/actions/beansModifyActionHook.php | 97 +++++---- .../api/actions/beansModifyActionPriority.php | 117 +++++++---- .../unit/api/actions/beansReplaceAction.php | 177 ++++++++++------- .../actions/beansReplaceActionArguments.php | 53 +++-- .../actions/beansReplaceActionCallback.php | 54 +++-- .../api/actions/beansReplaceActionHook.php | 56 ++++-- .../actions/beansReplaceActionPriority.php | 50 +++-- .../unit/api/actions/beansSetAction.php | 86 ++++---- .../unit/api/actions/beansUnsetAction.php | 90 ++++----- .../includes/class-actions-test-case.php | 76 -------- .../class-replace-action-test-case.php | 16 -- 29 files changed, 1653 insertions(+), 1086 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index c2429911..c2690f3f 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -149,6 +149,7 @@ function beans_modify_action( $id, $hook = null, $callback = null, $priority = n * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 + * @since 1.5.0 Return false if the hook is empty or not a string. * * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. * @param string $hook The new action's event name to which the callback is hooked. @@ -156,6 +157,11 @@ function beans_modify_action( $id, $hook = null, $callback = null, $priority = n * @return bool */ function beans_modify_action_hook( $id, $hook ) { + + if ( empty( $hook ) || ! is_string( $hook ) ) { + return false; + } + return beans_modify_action( $id, $hook ); } @@ -165,6 +171,7 @@ function beans_modify_action_hook( $id, $hook ) { * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 + * @since 1.5.0 Return false if the callback is empty. * * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. * @param callable $callback The new callback (function or method) you wish to be called. @@ -172,6 +179,11 @@ function beans_modify_action_hook( $id, $hook ) { * @return bool */ function beans_modify_action_callback( $id, $callback ) { + + if ( empty( $callback ) ) { + return false; + } + return beans_modify_action( $id, null, $callback ); } @@ -258,6 +270,7 @@ function beans_replace_action( $id, $hook = null, $callback = null, $priority = * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 + * @since 1.5.0 Return false if the hook is empty or not a string. * * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. * @param string $hook The new action's event name to which the callback is hooked. @@ -265,6 +278,11 @@ function beans_replace_action( $id, $hook = null, $callback = null, $priority = * @return bool */ function beans_replace_action_hook( $id, $hook ) { + + if ( empty( $hook ) || ! is_string( $hook ) ) { + return false; + } + return beans_replace_action( $id, $hook ); } @@ -274,6 +292,7 @@ function beans_replace_action_hook( $id, $hook ) { * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 + * @since 1.5.0 Return false if the callback is empty. * * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. * @param string $callback The new callback (function or method) you wish to be called. @@ -281,6 +300,11 @@ function beans_replace_action_hook( $id, $hook ) { * @return bool */ function beans_replace_action_callback( $id, $callback ) { + + if ( empty( $callback ) ) { + return false; + } + return beans_replace_action( $id, null, $callback ); } @@ -425,7 +449,6 @@ function beans_reset_action( $id ) { function _beans_get_action( $id, $status ) { global $_beans_registered_actions; - $id = _beans_unique_action_id( $id ); $registered_actions = beans_get( $status, $_beans_registered_actions ); // If the status is empty, return false, as no actions are registered. @@ -433,6 +456,7 @@ function _beans_get_action( $id, $status ) { return false; } + $id = _beans_unique_action_id( $id ); $action = beans_get( $id, $registered_actions ); // If the action is empty, return false. @@ -547,6 +571,7 @@ function _beans_merge_action( $id, array $action, $status ) { * @return array|bool */ function _beans_get_current_action( $id ) { + // Bail out if the action is "removed". if ( _beans_get_action( $id, 'removed' ) ) { return false; diff --git a/tests/phpunit/integration/api/actions/beansAddAction.php b/tests/phpunit/integration/api/actions/beansAddAction.php index 066cc2de..6fc3d472 100644 --- a/tests/phpunit/integration/api/actions/beansAddAction.php +++ b/tests/phpunit/integration/api/actions/beansAddAction.php @@ -17,119 +17,129 @@ * Class Tests_BeansAddAction * * @package Beans\Framework\Tests\Integration\API\Actions - * @group unit-integration + * @group integration-tests * @group api */ class Tests_BeansAddAction extends Actions_Test_Case { /** - * The action. - * - * @var array + * Test beans_add_action() should add the action in both Beans and WordPress. */ - protected $action; + public function test_should_add_action() { - /** - * Setup test fixture. - */ - public function setUp() { - parent::setUp(); - - $this->action = array( - 'hook' => 'foo_hook', - 'callback' => 'callback_foo', - 'priority' => 10, - 'args' => 1, - ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Test that the action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + + // Let's add it. + $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); + + // Now check that it was registered in Beans and WordPress. + $this->assertEquals( $action, _beans_get_action( $beans_id, 'added' ) ); + $this->check_registered_in_wp( $action['hook'], $action ); + } } /** - * Test beans_add_action() should register the action in WordPress. + * Test beans_add_action() should overwrite the action in both Beans and WordPress. + * + * This test makes sure nothing breaks if beans_add_action() is called more than once + * with the exact same set of conditions. */ - public function test_should_register_action_in_wordpress() { - $this->check_not_added( 'foo', $this->action['hook'] ); + public function test_should_overwrite_add_action() { - // Add the action. - $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Let's add it the first time. + $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); - // Now check that it was registered in WordPress. - $this->assertTrue( has_action( $this->action['hook'] ) ); - $this->check_parameters_registered_in_wp( $this->action ); + // Add it again. + $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); - // Now check in Beans. - $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + // Now check that it's still registered in both Beans and WordPress. + $this->assertEquals( $action, _beans_get_action( $beans_id, 'added' ) ); + $this->check_registered_in_wp( $action['hook'], $action ); + } } /** * Test beans_add_action() should use the action configuration in "replaced" status, when it's available. */ public function test_should_use_replaced_action_when_available() { - $this->check_not_added( 'foo', $this->action['hook'] ); - - // Setup by storing in the "replaced" status. $replaced_action = array( - 'hook' => $this->action['hook'], - 'callback' => 'my_callback', - 'priority' => 20, - 'args' => 2, + 'callback' => 'my_new_callback', + 'priority' => 47, ); - _beans_set_action( 'foo', $replaced_action, 'replaced', true ); - // Add the action. - $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // We want to store the "replaced" action first, before we add the original action. + _beans_set_action( $beans_id, $replaced_action, 'replaced', true ); + + // Next, add the original action. + beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); + + // Get the newly created action. + $new_action = _beans_get_action( $beans_id, 'added' ); - // Now check that it was registered in WordPress. - $this->assertTrue( has_action( $replaced_action['hook'] ) ); - $this->check_parameters_registered_in_wp( $replaced_action ); + // Check if the callback and priority were replaced. + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); - // Now check in Beans. - $this->assertEquals( $replaced_action, _beans_get_action( 'foo', 'added' ) ); + // Now check that the action was replaced in WordPress. + $this->check_registered_in_wp( $new_action['hook'], $new_action ); + } } /** * Test beans_add_action() should return false when the ID is registered to the "removed" status. */ public function test_should_return_false_when_removed() { - $this->check_not_added( 'foo', $this->action['hook'] ); + $empty_action = array( + 'hook' => null, + 'callback' => null, + 'priority' => null, + 'args' => null, + ); - // Setup by storing in the "removed" status. - _beans_set_action( 'foo', $this->action, 'removed', true ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the "removed" action before we call beans_add_action(). + _beans_set_action( $beans_id, $empty_action, 'removed', true ); - // Add the action. - $this->assertFalse( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + // Next, add the action. + beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ); - // Now check that it was not registered in WordPress. - $this->assertFalse( has_action( $this->action['hook'] ) ); - global $wp_filter; - $this->assertFalse( array_key_exists( $this->action['hook'], $wp_filter ) ); + // Check if the action is stored as "added". + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - // Now check in Beans. - $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + // Check that the action is not registered in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } } /** * Test beans_add_action() should merge the "modified" action configuration parameters. */ public function test_should_merge_modified_action_parameters() { - $this->check_not_added( 'foo', $this->action['hook'] ); - - // Setup by storing in the "modified" status. $modified_action = array( - 'hook' => $this->action['hook'], - 'callback' => 'my_callback', - 'priority' => 20, - 'args' => 2, + 'callback' => 'foo', + 'priority' => 17, ); - _beans_set_action( 'foo', $modified_action, 'modified', true ); - // Add the action. - $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // We want to store the "modified" action first, before we add the original action. + _beans_set_action( $beans_id, $modified_action, 'modified', true ); + + // Next, add the original action. + beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); - // Now check that it was registered in WordPress. - $this->assertTrue( has_action( $modified_action['hook'] ) ); - $this->check_parameters_registered_in_wp( $modified_action ); + // Test that the original action is stored away, which allows us to reset it (if we want). + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - // Now check in Beans. - $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + // Now check that the action was modified in WordPress. + $new_action = array_merge( $original_action, $modified_action ); + $this->check_registered_in_wp( $original_action['hook'], $new_action ); + } } } diff --git a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php index f3506364..60628895 100644 --- a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php +++ b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php @@ -16,7 +16,7 @@ * Class Tests_BeansAddAnonymousAction * * @package Beans\Framework\Integration\Unit\API\Actions - * @group unit-integration + * @group integration-tests * @group api */ class Tests_BeansAddAnonymousAction extends WP_UnitTestCase { diff --git a/tests/phpunit/integration/api/actions/beansModifyAction.php b/tests/phpunit/integration/api/actions/beansModifyAction.php index e3e47473..ea190730 100644 --- a/tests/phpunit/integration/api/actions/beansModifyAction.php +++ b/tests/phpunit/integration/api/actions/beansModifyAction.php @@ -17,91 +17,188 @@ * Class Tests_BeansModifyAction * * @package Beans\Framework\Tests\Integration\API\Actions - * @group unit-integration + * @group integration-tests * @group api */ class Tests_BeansModifyAction extends Actions_Test_Case { /** - * Test beans_modify_action() should return false when the ID is not registered. + * Test beans_modify_action() should return false when there's nothing to modify, + * i.e. no arguments passed. */ - public function test_should_return_false_when_id_not_registered() { - $this->assertFalse( beans_modify_action( 'foo' ) ); + public function test_should_return_false_when_nothing_to_modify() { + global $_beans_registered_actions; + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that it returns false. + $this->assertFalse( beans_modify_action( $beans_id ) ); + + // Verify that the action was not stored as "modified". + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action was not replaced. + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); + } } /** - * Test beans_modify_action_callback() should return false when there's nothing to modify, - * i.e. no arguments passed. + * Test beans_modify_action() should register with Beans as "modified", but not add the action. */ - public function test_should_return_false_when_nothing_to_modify() { - $this->setup_original_action(); - $this->assertFalse( beans_modify_action( 'foo' ) ); + public function test_should_register_as_modified_but_not_add_action() { + + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Check that it returns false. + $this->assertFalse( beans_modify_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); - $this->setup_original_action( 'beans' ); - $this->assertFalse( beans_modify_action( 'beans' ) ); + // Check that it did register as "modified" in Beans. + $this->assertEquals( $action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } } /** - * Test beans_modify_action() should register with Beans as modified, but not with WordPress. + * Test beans_modify_action() should modify the registered action's hook. */ - public function test_should_register_with_beans_as_modified_but_not_with_wp() { - $action = array( - 'hook' => 'foo_hook', - 'callback' => 'my_callback', + public function test_should_modify_the_action_hook() { + $modified_action = array( + 'hook' => 'foo', ); - $this->check_not_added( 'foo', $action['hook'] ); + $this->go_to_post(); - $this->assertFalse( beans_modify_action( 'foo', $action['hook'], $action['callback'] ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that the original action is registered in WordPress and in Beans as "added". + $this->check_registered_in_wp( $original_action['hook'], $original_action ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - // Now check that it was not registered in WordPress. - $this->assertFalse( has_action( $action['hook'] ) ); - global $wp_filter; - $this->assertFalse( array_key_exists( $action['hook'], $wp_filter ) ); + // Modify the action's hook. + $this->assertTrue( beans_modify_action( $beans_id, $modified_action['hook'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - // Now check in Beans. - $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the modified action was added in WordPress. + $this->assertTrue( has_action( $modified_action['hook'], $original_action['callback'] ) !== false ); + } } /** * Test beans_modify_action() should modify the registered action's callback. */ public function test_should_modify_the_action_callback() { - $action = $this->setup_original_action( 'beans' ); $modified_action = array( 'callback' => 'my_callback', ); - $this->assertTrue( beans_modify_action( 'beans', null, $modified_action['callback'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that the original action is registered in WordPress and in Beans as "added". + $this->check_registered_in_wp( $original_action['hook'], $original_action ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); + + // Modify the action's callback. + $this->assertTrue( beans_modify_action( $beans_id, null, $modified_action['callback'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the modified action was added in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); + } } /** * Test beans_modify_action() should modify the registered action's priority level. */ public function test_should_modify_the_action_priority() { - $action = $this->setup_original_action( 'beans' ); + global $wp_filter; + $modified_action = array( 'priority' => 20, ); - $this->assertTrue( beans_modify_action( 'beans', null, null, $modified_action['priority'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check the starting state. + $this->assertEquals( + array( + 'function' => $original_action['callback'], + 'accepted_args' => $original_action['args'], + ), + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] + ); + + // Modify the action's priority. + $this->assertTrue( beans_modify_action( $beans_id, null, null, $modified_action['priority'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the original action was removed from WordPress. + $callbacks_in_wp = $wp_filter[ $original_action['hook'] ]->callbacks; + if ( isset( $callbacks_in_wp[ $original_action['priority'] ] ) ) { + $this->assertArrayNotHasKey( $original_action['callback'], $callbacks_in_wp[ $original_action['priority'] ] ); + } else { + $this->assertArrayNotHasKey( $original_action['priority'], $callbacks_in_wp ); + } + + // Check that the action's priority was modified in WordPress. + $this->assertEquals( + array( + 'function' => $original_action['callback'], + 'accepted_args' => $original_action['args'], + ), + $callbacks_in_wp[ $modified_action['priority'] ][ $original_action['callback'] ] + ); + } } /** * Test beans_modify_action() should modify the registered action's number of arguments. */ public function test_should_modify_the_action_args() { - $action = $this->setup_original_action( 'beans' ); + global $wp_filter; + $modified_action = array( - 'args' => 2, + 'args' => 7, ); - $this->assertTrue( beans_modify_action( 'beans', null, null, null, $modified_action['args'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check the starting state. + $this->assertEquals( + $original_action['args'], + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] + ); + + // Modify the action's number of arguments. + $this->assertTrue( beans_modify_action( $beans_id, null, null, null, $modified_action['args'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the action's number of arguments was modified in WordPress. + $this->assertEquals( + $modified_action['args'], + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] + ); + } } } diff --git a/tests/phpunit/integration/api/actions/beansModifyActionArguments.php b/tests/phpunit/integration/api/actions/beansModifyActionArguments.php index 53afdc09..bd991eb7 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionArguments.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionArguments.php @@ -17,81 +17,133 @@ * Class Tests_BeansModifyActionArguments * * @package Beans\Framework\Tests\Integration\API\Actions - * @group unit-integration + * @group integration-tests * @group api */ class Tests_BeansModifyActionArguments extends Actions_Test_Case { /** - * Test beans_modify_action_arguments() should return false when the ID is not registered. + * Test beans_modify_action_arguments() should return false when new args is a non-integer value. */ - public function test_should_return_false_when_id_not_registered() { - $ids = array( - 'foo' => null, - 'bar' => 0, - 'baz' => 1, - 'beans' => '3', + public function test_should_return_false_when_args_is_non_integer() { + global $wp_filter; + + $arguments = array( + null, + array( 10 ), + false, + '', ); - foreach ( $ids as $id => $number_of_args ) { - $this->assertFalse( beans_modify_action_arguments( $id, $number_of_args ) ); + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check the starting state. + $this->assertEquals( + $original_action['args'], + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] + ); + + foreach ( $arguments as $number_of_args ) { + // Check that it returns false. + $this->assertFalse( beans_modify_action_arguments( $beans_id, $number_of_args ) ); + + // Check that the modification was not stored in Beans. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the number of arguments did not change in WordPress. + $this->assertEquals( + $original_action['args'], + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] + ); + } } } /** - * Test beans_modify_action_arguments() should return false when new args is a non-integer value. + * Test beans_modify_action_arguments() should modify the action's "args" when the new one is zero. */ - public function test_should_return_false_when_args_is_non_integer() { - $ids = array( - 'foo' => null, - 'bar' => array( 10 ), - 'baz' => false, - 'beans' => '', - ); + public function test_should_modify_action_when_args_is_zero() { + global $wp_filter; + + $arguments = array( 0, 0.0, '0', '0.0' ); + + $this->go_to_post(); - foreach ( $ids as $id => $number_of_args ) { - $action = $this->setup_original_action( $id, true ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check the starting state. + $this->assertEquals( + $original_action['args'], + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] + ); - $this->assertFalse( beans_modify_action_arguments( $id, $number_of_args ) ); - $this->assertTrue( has_action( $action['hook'] ) ); + foreach ( $arguments as $number_of_args ) { + // Modify the action's callback. + $this->assertTrue( beans_modify_action_arguments( $beans_id, $number_of_args ) ); - // Check that the parameters did not change. - $this->check_parameters_registered_in_wp( $action ); + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( array( 'args' => (int) $number_of_args ), _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the action's number of arguments was modified in WordPress. + $this->assertEquals( + $number_of_args, + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] + ); + } } } /** - * Test beans_modify_action_arguments() should modify the action's "args" when the new one is zero. + * Test beans_modify_action_arguments() should register with Beans as "modified", but not add the action. */ - public function test_should_modify_action_when_args_is_zero() { - $ids = array( - 'foo' => 0, - 'bar' => 0.0, - 'baz' => '0', - 'beans' => '0.0', - ); + public function test_should_register_as_modified_but_not_add_action() { - foreach ( $ids as $id => $number_of_args ) { - $action = $this->setup_original_action( $id ); - $this->assertTrue( beans_modify_action_arguments( $id, $number_of_args ) ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - // Manually change the original to the new one. Then test that it did change in WordPress. - $action['args'] = (int) $number_of_args; - $this->check_parameters_registered_in_wp( $action ); + // Check that it returns false. + $this->assertFalse( beans_modify_action_arguments( $beans_id, $action['args'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( array( 'args' => $action['args'] ), _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); } } /** - * Test beans_modify_action_arguments() should modify the registered action's args. + * Test beans_modify_action_arguments() should modify the registered action's number of arguments. */ public function test_should_modify_the_action_args() { - $action = $this->setup_original_action( 'beans' ); + global $wp_filter; + $modified_action = array( - 'args' => 3, + 'args' => 7, ); - $this->assertTrue( beans_modify_action_arguments( 'beans', $modified_action['args'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Test the action before we start. + $this->assertEquals( + $original_action['args'], + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] + ); + + // Modify the action's number of arguments. + $this->assertTrue( beans_modify_action_arguments( $beans_id, $modified_action['args'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the action's number of arguments was modified in WordPress. + $this->assertEquals( + $modified_action['args'], + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] + ); + } } } diff --git a/tests/phpunit/integration/api/actions/beansModifyActionCallback.php b/tests/phpunit/integration/api/actions/beansModifyActionCallback.php index 75b541d2..c6cd8d45 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionCallback.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionCallback.php @@ -17,41 +17,87 @@ * Class Tests_BeansModifyActionCallback * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-integration + * @group integration-tests * @group api */ class Tests_BeansModifyActionCallback extends Actions_Test_Case { /** - * Test beans_modify_action_callback() should return false when the ID is not registered. + * Test beans_modify_action_callback() should not modify when the callback is invalid. */ - public function test_should_return_false_when_id_not_registered() { - $this->assertFalse( beans_modify_action_callback( 'foo', null ) ); - $this->assertFalse( beans_modify_action_callback( 'foo', 'my_new_callback' ) ); + public function test_should_not_modify_when_invalid_callback() { + $callbacks = array( + null, + false, + '', + ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check the starting state. + $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); + + foreach ( $callbacks as $callback ) { + // Check that it returns false. + $this->assertFalse( beans_modify_action_callback( $beans_id, $callback ) ); + + // Check that the callback did not get stored as "modified" in Beans. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the callback did not change in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); + } + } } /** - * Test beans_modify_action_callback() should return false when the new callback is null. + * Test beans_modify_action_callback() should register with Beans as "modified", but not add the action. */ - public function test_should_return_false_when_new_callback_is_null() { - $this->setup_original_action(); - $this->assertFalse( beans_modify_action_callback( 'foo', null ) ); + public function test_should_register_as_modified_but_not_add_action() { + + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Check that it returns false. + $this->assertFalse( beans_modify_action_callback( $beans_id, $action['callback'] ) ); - $this->setup_original_action( 'beans' ); - $this->assertFalse( beans_modify_action_callback( 'beans', null ) ); + // Check that it did register as "modified" in Beans. + $this->assertEquals( array( 'callback' => $action['callback'] ), _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } } /** * Test beans_modify_action_callback() should modify the registered action's callback. */ public function test_should_modify_the_action_callback() { - $action = $this->setup_original_action( 'beans' ); $modified_action = array( - 'callback' => 'my_new_callback', + 'callback' => 'my_callback', ); - $this->assertTrue( beans_modify_action_callback( 'beans', $modified_action['callback'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that the original action is registered in WordPress and in Beans as "added". + $this->check_registered_in_wp( $original_action['hook'], $original_action ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); + + // Modify the callback. + $this->assertTrue( beans_modify_action_callback( $beans_id, $modified_action['callback'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the modified action was added in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); + } } } diff --git a/tests/phpunit/integration/api/actions/beansModifyActionHook.php b/tests/phpunit/integration/api/actions/beansModifyActionHook.php index 4cac7c30..c4cad3f5 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionHook.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionHook.php @@ -17,64 +17,91 @@ * Class Tests_BeansModifyActionHook * * @package Beans\Framework\Tests\Integration\API\Actions - * @group unit-integration + * @group integration-tests * @group api */ class Tests_BeansModifyActionHook extends Actions_Test_Case { /** - * Test beans_modify_action_hook() should return false when the ID is not registered. + * Test beans_modify_action_hook() should not modify the action when the hook is invalid. */ - public function test_should_return_false_when_id_not_registered() { - $this->assertFalse( beans_modify_action_hook( 'foo', null ) ); - $this->assertFalse( beans_modify_action_hook( 'foo', 'foo_hook' ) ); - $this->assertFalse( beans_modify_action_hook( 'beans', 'beans_hook' ) ); - } + public function test_should_not_modify_when_invalid_hook() { + $hooks = array( + null, + false, + array( 'foo' ), + '', + 0, + 0.0, + '0', + ); - /** - * Test beans_modify_action_hook() should return false when new hook is null. - */ - public function test_should_return_false_when_new_hook_is_null() { - $this->setup_original_action(); - $this->assertFalse( beans_modify_action_hook( 'foo', null ) ); + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check the starting state. + $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); + + foreach ( $hooks as $hook ) { + // Check that it returns false. + $this->assertFalse( beans_modify_action_hook( $beans_id, $hook ) ); + + // Check that the hook did not get stored as "modified" in Beans. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->setup_original_action( 'beans' ); - $this->assertFalse( beans_modify_action_hook( 'beans', null ) ); + // Check that the hook did not change in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); + } + } } /** - * Test beans_modify_action_hook() should register with Beans as modified, but not with WordPress. + * Test beans_modify_action_hook() should register with Beans as "modified", but not add the action. */ - public function test_should_register_with_beans_as_modified_but_not_with_wp() { - $action = array( - 'hook' => 'my_hook', - ); + public function test_should_register_as_modified_but_not_add_action() { - $this->check_not_added( 'foo', $action['hook'] ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->assertFalse( beans_modify_action_hook( 'foo', $action['hook'] ) ); + // Check that it returns false. + $this->assertFalse( beans_modify_action_hook( $beans_id, $action['hook'] ) ); - // Check that it did register with Beans. - $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + // Check that it did register as "modified" in Beans. + $this->assertEquals( array( 'hook' => $action['hook'] ), _beans_get_action( $beans_id, 'modified' ) ); - // Check that it did not add the action. - $this->assertFalse( has_action( $action['hook'] ) ); + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } } /** * Test beans_modify_action_hook() should modify the registered action's hook. */ public function test_should_modify_the_action_hook() { - $action = $this->setup_original_action( 'beans' ); $modified_action = array( - 'hook' => 'my_hook', + 'hook' => 'foo', ); - $this->assertTrue( beans_modify_action_hook( 'beans', $modified_action['hook'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - // Now check that it overwrote the "hook". - $this->assertFalse( has_action( $action['hook'] ) ); - $this->assertTrue( has_action( $modified_action['hook'] ) ); - $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that the original action is registered in WordPress and in Beans as "added". + $this->check_registered_in_wp( $original_action['hook'], $original_action ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); + + // Modify the action's hook. + $this->assertTrue( beans_modify_action_hook( $beans_id, $modified_action['hook'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the modified action was added in WordPress. + $this->assertTrue( has_action( $modified_action['hook'], $original_action['callback'] ) !== false ); + } } } diff --git a/tests/phpunit/integration/api/actions/beansModifyActionPriority.php b/tests/phpunit/integration/api/actions/beansModifyActionPriority.php index 9d0806ca..42997165 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionPriority.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionPriority.php @@ -17,81 +17,171 @@ * Class Tests_BeansModifyActionPriority * * @package Beans\Framework\Tests\Integration\API\Actions - * @group unit-integration + * @group integration-tests * @group api */ class Tests_BeansModifyActionPriority extends Actions_Test_Case { /** - * Test beans_modify_action_priority() should return false when the ID is not registered. + * Test beans_modify_action_priority() should return false when new priority is a non-integer. */ - public function test_should_return_false_when_id_not_registered() { - $ids = array( - 'foo' => null, - 'bar' => 0, - 'baz' => 10, - 'beans' => '20', + public function test_should_return_false_when_priority_is_non_integer() { + global $wp_filter; + + $priorities = array( + null, + array( 10 ), + false, + '', ); - foreach ( $ids as $id => $priority ) { - $this->assertFalse( beans_modify_action_priority( $id, $priority ) ); + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check the starting state. + $this->assertEquals( + array( + 'function' => $original_action['callback'], + 'accepted_args' => $original_action['args'], + ), + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] + ); + + foreach ( $priorities as $priority ) { + // Check that it returns false. + $this->assertFalse( beans_modify_action_priority( $beans_id, $priority ) ); + + // Check that the priority did not get stored as "modified" in Beans. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the priority did not change in WordPress. + $this->assertEquals( + array( + 'function' => $original_action['callback'], + 'accepted_args' => $original_action['args'], + ), + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] + ); + } } } /** - * Test beans_modify_action_priority() should return false when new priority is a non-integer. + * Test beans_modify_action_priority() should modify the action's priority when the new one is zero. */ - public function test_should_return_false_when_priority_is_non_integer() { - $ids = array( - 'foo' => null, - 'bar' => array( 10 ), - 'baz' => false, - 'beans' => '', - ); + public function test_should_modify_action_when_priority_is_zero() { + global $wp_filter; + + $priorities = array( 0, 0.0, '0', '0.0' ); + + $this->go_to_post(); - foreach ( $ids as $id => $priority ) { - $action = $this->setup_original_action( $id, true ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check the starting state. + $this->assertEquals( + array( + 'function' => $original_action['callback'], + 'accepted_args' => $original_action['args'], + ), + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] + ); - $this->assertFalse( beans_modify_action_priority( $id, $priority ) ); - $this->assertTrue( has_action( $action['hook'] ) ); + foreach ( $priorities as $priority ) { + // Modify the priority. + $this->assertTrue( beans_modify_action_priority( $beans_id, $priority ) ); - // Check that the parameters did not change. - $this->check_parameters_registered_in_wp( $action ); + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( array( 'priority' => (int) $priority ), _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the priority did change in WordPress. + $this->check_modified_in_wp( $original_action, (int) $priority ); + } } } /** - * Test beans_modify_action_priority() should modify the action's priority when the new one is zero. + * Test beans_modify_action_priority() should register with Beans as "modified", but not add the action. */ - public function test_should_modify_action_when_priority_is_zero() { - $ids = array( - 'foo' => 0, - 'bar' => 0.0, - 'baz' => '0', - 'beans' => '0.0', - ); + public function test_should_register_as_modified_but_not_add_action() { - foreach ( $ids as $id => $priority ) { - $action = $this->setup_original_action( $id ); - $this->assertTrue( beans_modify_action_priority( $id, $priority ) ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - // Manually change the original to the new one. Then test that it did change in WordPress. - $action['priority'] = (int) $priority; - $this->check_parameters_registered_in_wp( $action ); + // Check that it returns false. + $this->assertFalse( beans_modify_action_priority( $beans_id, $action['priority'] ) ); + + // Check that it did register as "modified" in Beans. + $this->assertEquals( array( 'priority' => $action['priority'] ), _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); } } /** - * Test beans_modify_action_priority() should modify the registered action's priority. + * Test beans_modify_action_priority() should modify the registered action's priority level. */ public function test_should_modify_the_action_priority() { - $action = $this->setup_original_action( 'beans' ); + global $wp_filter; + $modified_action = array( 'priority' => 20, ); - $this->assertTrue( beans_modify_action_priority( 'beans', $modified_action['priority'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->check_parameters_registered_in_wp( array_merge( $action, $modified_action ) ); + + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check the starting state. + $this->assertEquals( + array( + 'function' => $original_action['callback'], + 'accepted_args' => $original_action['args'], + ), + $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] + ); + + // Modify the action's priority. + $this->assertTrue( beans_modify_action_priority( $beans_id, $modified_action['priority'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the priority did change in WordPress. + $this->check_modified_in_wp( $original_action, $modified_action['priority'] ); + } + } + + /** + * Check that the priority was modified in WordPress. + * + * @since 1.5.0 + * + * @param array $original_action The original action. + * @param int $new_priority The new priority. + * + * @return void + */ + protected function check_modified_in_wp( $original_action, $new_priority ) { + global $wp_filter; + + $callbacks_in_wp = $wp_filter[ $original_action['hook'] ]->callbacks; + + // Check that the original action was removed from WordPress. + if ( isset( $callbacks_in_wp[ $original_action['priority'] ] ) ) { + $this->assertArrayNotHasKey( $original_action['callback'], $callbacks_in_wp[ $original_action['priority'] ] ); + } else { + $this->assertArrayNotHasKey( $original_action['priority'], $callbacks_in_wp ); + } + + // Check that the action's priority was modified in WordPress. + $this->assertEquals( + array( + 'function' => $original_action['callback'], + 'accepted_args' => $original_action['args'], + ), + $callbacks_in_wp[ $new_priority ][ $original_action['callback'] ] + ); } } diff --git a/tests/phpunit/integration/api/actions/beansReplaceAction.php b/tests/phpunit/integration/api/actions/beansReplaceAction.php index c3f78d82..a2fa1a76 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceAction.php +++ b/tests/phpunit/integration/api/actions/beansReplaceAction.php @@ -33,15 +33,16 @@ public function test_should_store_when_action_is_not_registered() { 'callback' => 'my_new_callback', ); - foreach ( array_keys( static::$test_actions ) as $beans_id ) { + foreach ( static::$test_ids as $beans_id ) { // Test that the original action has not yet been added. $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); // Now store away the "replace" hook. $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); - // Check that it was stored as "modified". + // Check that it was stored as "modified" and "added". $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); } } @@ -64,7 +65,7 @@ public function test_should_store_and_then_replace_action() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the callback. + // Check that the original action's callback was replaced in Beans. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); @@ -84,7 +85,8 @@ public function test_should_store_and_then_replace_action() { public function test_should_return_false_when_nothing_to_replace() { $this->go_to_post(); - foreach ( static::$test_actions as $beans_id => $action_config ) { + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check it returns false. $this->assertFalse( beans_replace_action( $beans_id ) ); // Verify that it did not get stored in "replaced" or "modified". @@ -93,7 +95,7 @@ public function test_should_return_false_when_nothing_to_replace() { $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); } } @@ -101,23 +103,21 @@ public function test_should_return_false_when_nothing_to_replace() { * Test beans_replace_action() should replace the registered action's hook. */ public function test_should_replace_the_action_hook() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $replaced_action = array( + 'hook' => 'foo', + ); - // Make sure the callback is what we think before we get rolling. - $this->assertEquals( $action_config['hook'], $original_action['hook'] ); + $this->go_to_post(); - // Set up what will get stored in Beans. - $replaced_action = array( - 'hook' => 'foo', - ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that the original action is registered in WordPress and in Beans as "added". + $this->check_registered_in_wp( $original_action['hook'], $original_action ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, $replaced_action['hook'] ) ); - // Check if it replaced only the hook. + // Check that only the hook was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -134,23 +134,21 @@ public function test_should_replace_the_action_hook() { * Test beans_replace_action() should replace the registered action's callback. */ public function test_should_replace_the_action_callback() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $replaced_action = array( + 'callback' => 'foo', + ); - // Make sure the callback is what we think before we get rolling. - $this->assertEquals( $action_config['callback'], $original_action['callback'] ); + $this->go_to_post(); - // Set up what will get stored in Beans. - $replaced_action = array( - 'callback' => 'foo', - ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that the original action is registered in WordPress and in Beans as "added". + $this->check_registered_in_wp( $original_action['hook'], $original_action ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); - // Check if it replaced only the callback. + // Check that only the callback was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); @@ -167,23 +165,21 @@ public function test_should_replace_the_action_callback() { * Test beans_replace_action() should replace the registered action's priority level. */ public function test_should_replace_the_action_priority() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $replaced_action = array( + 'priority' => 52, + ); - // Make sure the priority is what we think before we get rolling. - $this->assertEquals( $action_config['priority'], $original_action['priority'] ); + $this->go_to_post(); - // Set up what will get stored in Beans. - $replaced_action = array( - 'priority' => 50, - ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that the original action is registered in WordPress and in Beans as "added". + $this->check_registered_in_wp( $original_action['hook'], $original_action ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); - // Check if it replaced only the priority. + // Check that only the priority was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -200,23 +196,21 @@ public function test_should_replace_the_action_priority() { * Test beans_replace_action() should replace the registered action's number of arguments. */ public function test_should_replace_the_action_args() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $replaced_action = array( + 'args' => 6, + ); - // Make sure the args are what we think before we get rolling. - $this->assertEquals( $action_config['args'], $original_action['args'] ); + $this->go_to_post(); - // Set up what will get stored in Beans. - $replaced_action = array( - 'args' => 5, - ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that the original action is registered in WordPress and in Beans as "added". + $this->check_registered_in_wp( $original_action['hook'], $original_action ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); - // Check if it replaced only the args. + // Check that only the number of arguments was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -233,7 +227,6 @@ public function test_should_replace_the_action_args() { * Test beans_replace_action() should replace the original registered action. */ public function test_should_replace_the_action() { - // Set up what will get stored in Beans. $replaced_action = array( 'hook' => 'new_hook', 'callback' => 'new_callback', @@ -244,8 +237,9 @@ public function test_should_replace_the_action() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { - // Make sure the action is what we think before we get rolling. - $this->assertEquals( $original_action, _beans_get_action( $beans_id, 'added' ) ); + // Check that the original action is registered in WordPress and in Beans as "added". + $this->check_registered_in_wp( $original_action['hook'], $original_action ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); // Run the replace. $this->assertTrue( beans_replace_action( diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index 946ead31..6a1b3ce0 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -123,6 +123,22 @@ protected function check_not_added( $id, $hook ) { $this->assertFalse( has_action( $hook ) ); } + /** + * Check that the action has been registered in WordPress. + * + * @since 1.5.0 + * + * @param string $hook The event's name (hook) that is registered in WordPress. + * @param array $action The action to be checked. + * @param bool $remove_action When true, it removes the action automatically to clean up this test. + * + * @return void + */ + protected function check_registered_in_wp( $hook, array $action, $remove_action = true ) { + $this->assertTrue( has_action( $hook, $action['callback'] ) !== false ); + $this->check_parameters_registered_in_wp( $action, $remove_action ); + } + /** * Check that the right parameters are registered in WordPress. * diff --git a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php index 24db47e6..6186b975 100644 --- a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php @@ -103,20 +103,4 @@ protected function check_stored_in_beans( $beans_id, array $replaced_action ) { $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } - - /** - * Check that the "replaced" action has been registered in WordPress. - * - * @since 1.5.0 - * - * @param string $hook The event's name (hook) that is registered in WordPress. - * @param array $new_action The "new" action's configuration (after the replace). - * @param bool $remove_action When true, it removes the action automatically to clean up this test. - * - * @return void - */ - protected function check_registered_in_wp( $hook, array $new_action, $remove_action = true ) { - $this->assertTrue( has_action( $hook, $new_action['callback'] ) !== false ); - $this->check_parameters_registered_in_wp( $new_action, $remove_action ); - } } diff --git a/tests/phpunit/unit/api/actions/beansAddAction.php b/tests/phpunit/unit/api/actions/beansAddAction.php index b2e8e11e..7548aa2a 100644 --- a/tests/phpunit/unit/api/actions/beansAddAction.php +++ b/tests/phpunit/unit/api/actions/beansAddAction.php @@ -24,106 +24,154 @@ class Tests_BeansAddAction extends Actions_Test_Case { /** - * The action. - * - * @var array - */ - protected $action; - - /** - * Setup test fixture. + * Test beans_add_action() should add the action in both Beans and WordPress. */ - protected function setUp() { - parent::setUp(); - - $this->action = array( - 'hook' => 'foo_hook', - 'callback' => 'callback_foo', - 'priority' => 10, - 'args' => 1, - ); + public function test_should_add_action() { + + foreach ( static::$test_actions as $beans_id => $action ) { + // Test that the action has not yet been added. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + + // Set up the WordPress simulator before we add the action. + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $action ) { + // Check that the parameters were added in WordPress. + $this->assertSame( $action['callback'], $callback ); + $this->assertSame( $action['priority'], $priority ); + $this->assertSame( $action['args'], $args ); + } ); + + // Let's add the action. + $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); + + // Check that it was registered in Beans and WordPress. + $this->assertEquals( $action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + } } /** - * Test beans_add_action() should add (register) the action. + * Test beans_add_action() should overwrite the action in both Beans and WordPress. + * + * This test makes sure nothing breaks if beans_add_action() is called more than once + * with the exact same set of conditions. */ - public function test_should_add_the_action() { - $this->check_not_added( 'foo', $this->action['hook'] ); + public function test_should_overwrite_add_action() { - // Add the action. - $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Let's add it the first time. + $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); - // Now check. - $this->assertTrue( has_action( $this->action['hook'] ) ); - $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + // Add it again. + $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); + + // Now check that it's still registered in both Beans and WordPress. + $this->assertEquals( $action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + } } /** * Test beans_add_action() should use the action configuration in "replaced" status, when it's available. */ public function test_should_use_replaced_action_when_available() { - $this->check_not_added( 'foo', $this->action['hook'] ); - - // Setup by storing in the "replaced" status. $replaced_action = array( - 'hook' => $this->action['hook'], - 'callback' => 'my_callback', - 'priority' => 20, - 'args' => 2, + 'callback' => 'my_new_callback', + 'priority' => 47, ); - _beans_set_action( 'foo', $replaced_action, 'replaced', true ); - // Add the action. - $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); - - // Now check. - $this->assertTrue( has_action( $replaced_action['hook'] ) ); - $this->assertEquals( $replaced_action, _beans_get_action( 'foo', 'added' ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // We want to store the "replaced" action first, before we add the original action. + _beans_set_action( $beans_id, $replaced_action, 'replaced', true ); + + // Set up the WordPress simulator before we add the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the callback and priority were replaced in WordPress. + $this->assertSame( $replaced_action['callback'], $callback ); + $this->assertSame( $replaced_action['priority'], $priority ); + // Check that the number of arguments remains unchanged in WordPress. + $this->assertSame( $original_action['args'], $args ); + } ); + + // Next, add the original action. + beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); + + // Get the newly created action. + $new_action = _beans_get_action( $beans_id, 'added' ); + + // Check if the callback and priority were replaced. + $this->assertEquals( $original_action['hook'], $new_action['hook'] ); + $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); + $this->assertEquals( $original_action['args'], $new_action['args'] ); + + // Now check that the action was replaced in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $replaced_action['callback'] ) !== false ); + } } /** * Test beans_add_action() should return false when the ID is registered to the "removed" status. */ public function test_should_return_false_when_removed() { - $this->check_not_added( 'foo', $this->action['hook'] ); + $empty_action = array( + 'hook' => null, + 'callback' => null, + 'priority' => null, + 'args' => null, + ); - // Setup by storing in the "removed" status. - _beans_set_action( 'foo', $this->action, 'removed', true ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the "removed" action before we call beans_add_action(). + _beans_set_action( $beans_id, $empty_action, 'removed', true ); - // Add the action. - $this->assertFalse( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); + // Next, add the action. + beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ); - // Now check. - $this->assertFalse( has_action( 'foo_hook' ) ); - $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); + // Check if the action is stored as "added". + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + + // Check that the action is not registered in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } } /** * Test beans_add_action() should merge the "modified" action configuration parameters. */ public function test_should_merge_modified_action_parameters() { - $this->check_not_added( 'foo', $this->action['hook'] ); - - // Setup by storing in the "modified" status. $modified_action = array( - 'hook' => $this->action['hook'], - 'callback' => 'my_callback', - 'priority' => 20, - 'args' => 2, + 'callback' => 'foo', + 'priority' => 17, ); - _beans_set_action( 'foo', $modified_action, 'modified', true ); - - // Add the action. - $this->assertTrue( beans_add_action( 'foo', $this->action['hook'], $this->action['callback'] ) ); - - // Now check that it was registered in WordPress. - $this->assertTrue( has_action( $modified_action['hook'] ) ); - - // Check that the original action is registered with Beans. - $this->assertEquals( $this->action, _beans_get_action( 'foo', 'added' ) ); - // Finally, check that the "modified" action is registered via add_action. - $container = Monkey\Container::instance(); - $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, 'foo_hook', 'my_callback' ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // We want to store the "modified" action first, before we add the original action. + _beans_set_action( $beans_id, $modified_action, 'modified', true ); + + // Set up the WordPress simulator before we add the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { + // Check that the callback and priority were modified in WordPress. + $this->assertSame( $modified_action['callback'], $callback ); + $this->assertSame( $modified_action['priority'], $priority ); + // Check that the number of arguments remains unchanged in WordPress. + $this->assertSame( $original_action['args'], $args ); + } ); + + // Next, add the original action. + beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); + + // Test that the original action is stored away, which allows us to reset it (if we want). + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); + + // Now check that the action was modified in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); + } } } diff --git a/tests/phpunit/unit/api/actions/beansGetAction.php b/tests/phpunit/unit/api/actions/beansGetAction.php index 72d88aec..022d8457 100644 --- a/tests/phpunit/unit/api/actions/beansGetAction.php +++ b/tests/phpunit/unit/api/actions/beansGetAction.php @@ -9,7 +9,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; -use Beans\Framework\Tests\Unit\Test_Case; +use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; /** * Class Tests_BeansGetAction @@ -18,102 +18,110 @@ * @group unit-tests * @group api */ -class Tests_BeansGetAction extends Test_Case { +class Tests_BeansGetAction extends Actions_Test_Case { /** - * Available action statuses. - * - * @var array + * Test _beans_get_action() should return false when registry is empty. */ - protected $action_status; + public function test_should_return_false_when_registry_is_empty() { + global $_beans_registered_actions; - /** - * Action to be/is registered. - * - * @var array - */ - protected $action; + foreach ( array_keys( $_beans_registered_actions ) as $status ) { + $this->assertEmpty( $_beans_registered_actions[ $status ] ); + $this->assertFalse( _beans_get_action( 'foo', $status ) ); + } + } /** - * The json_encode() version of the above action. - * - * @var string + * Test _beans_get_action() should return false when the action is not registered. */ - protected $encoded_action; + public function test_should_return_false_when_action_is_not_registered() { - /** - * Setup test fixture. - */ - protected function setUp() { - parent::setUp(); - - $this->action_status = array( 'added', 'modified', 'removed', 'replaced' ); - require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; - - $this->action = array( - 'hook' => 'foo', - 'callback' => 'callback', - 'priority' => 10, - 'args' => 1, - ); - $this->encoded_action = wp_json_encode( $this->action ); + foreach ( static::$test_ids as $beans_id ) { + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); + } } /** - * Reset the test fixture. + * Test _beans_get_action() should return the "added" action. */ - protected function tearDown() { - parent::tearDown(); - + public function test_should_return_added_action() { global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['added'][ $beans_id ] = wp_json_encode( $action ); + + // Test that we get the "added" action. + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + + // Make sure that it is not stored in the other registries. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); + } } /** - * Test _beans_get_action() should return false when the status is empty, i.e. no actions are registered. + * Test _beans_get_action() should return the "modified" action. */ - public function test_should_return_false_when_status_is_empty() { - foreach ( $this->action_status as $action_status ) { - $this->assertFalse( _beans_get_action( 'foo', $action_status ) ); + public function test_should_return_modified_action() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['modified'][ $beans_id ] = wp_json_encode( $action ); + + // Test that we get the "modified" action. + $this->assertSame( $action, _beans_get_action( $beans_id, 'modified' ) ); + + // Make sure that it is not stored in the other registries. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); } } /** - * Test _beans_get_action() should return false when the action is not registered. + * Test _beans_get_action() should return the "removed" action. */ - public function test_should_return_false_when_action_is_not_registered() { + public function test_should_return_removed_action() { global $_beans_registered_actions; - $_beans_registered_actions['added']['foo'] = $this->encoded_action; - $this->assertFalse( _beans_get_action( 'foobar', 'added' ) ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['removed'][ $beans_id ] = wp_json_encode( $action ); - // Make sure we get false on the other statuses. - foreach ( $this->action_status as $action_status ) { + // Test that we get the "removed" action. + $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); - // Skip the 'added' status. - if ( 'added' === $action_status ) { - continue; - } - - $this->assertFalse( _beans_get_action( 'foo', $action_status ) ); + // Make sure that it is not stored in the other registries. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); } } /** - * Test _beans_get_action() should return the action's configuration when it's registered. + * Test _beans_get_action() should return the "replaced" action. */ - public function test_should_return_action_when_registered() { + public function test_should_return_replaced_action() { global $_beans_registered_actions; - foreach ( $this->action_status as $action_status ) { - $_beans_registered_actions[ $action_status ]['foo'] = $this->encoded_action; - $this->assertEquals( $this->action, _beans_get_action( 'foo', $action_status ) ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['replaced'][ $beans_id ] = wp_json_encode( $action ); + + // Test that we get the "replaced" action. + $this->assertSame( $action, _beans_get_action( $beans_id, 'replaced' ) ); + + // Make sure that it is not stored in the other registries. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); } } } diff --git a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php index e0199731..af6ea11e 100644 --- a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php @@ -23,18 +23,18 @@ class Tests_BeansGetCurrentAction extends Actions_Test_Case { /** - * Test _beans_get_current_action() should return false when the ID is registered with the "removed" status. + * Test _beans_get_current_action() should return false when the ID is registered as a "removed" action. */ public function test_should_return_false_when_removed_status() { global $_beans_registered_actions; - $_beans_registered_actions['removed']['foo'] = wp_json_encode( array( - 'hook' => 'foo', - 'callback' => 'callback', - 'priority' => 10, - 'args' => 1, - ) ); - $this->assertFalse( _beans_get_current_action( 'foo' ) ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['removed'][ $beans_id ] = wp_json_encode( $action ); + + // Test that it returns false. + $this->assertFalse( _beans_get_current_action( $beans_id ) ); + } } /** @@ -60,58 +60,57 @@ public function test_should_return_false_when_action_is_invalid() { } /** - * Test _beans_get_current_action() should return the "added" configuration. + * Test _beans_get_current_action() should return the "added" action. */ public function test_should_return_added_action() { global $_beans_registered_actions; - $action = array( - 'hook' => 'foo', - 'callback' => 'callback', - 'priority' => 10, - 'args' => 1, - ); - $_beans_registered_actions['added']['foo'] = wp_json_encode( $action ); - $this->assertEquals( $action, _beans_get_current_action( 'foo' ) ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['added'][ $beans_id ] = wp_json_encode( $action ); + + // Test that we get the "added" action. + $this->assertSame( $action, _beans_get_current_action( $beans_id ) ); + } } /** - * Test _beans_get_current_action() should return the "modified" configuration. + * Test _beans_get_current_action() should return the "modified" action. */ public function test_should_return_modified_action() { global $_beans_registered_actions; - $action = array( - 'hook' => 'foo', - 'callback' => 'callback', - 'priority' => 10, - 'args' => 1, - ); - $_beans_registered_actions['modified']['foo'] = wp_json_encode( $action ); - $this->assertEquals( $action, _beans_get_current_action( 'foo' ) ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['modified'][ $beans_id ] = wp_json_encode( $action ); + + // Test that we get the "modified" action. + $this->assertSame( $action, _beans_get_current_action( $beans_id ) ); + } } /** - * Test _beans_get_current_action() should merge "modified" action's configuration with the "added" configuration. + * Test _beans_get_current_action() should return the merged "added" and "modified" action. */ - public function test_should_merge_modified_with_added() { + public function test_should_return_merged_added_and_modified() { global $_beans_registered_actions; - $_beans_registered_actions['added']['foo'] = wp_json_encode( array( - 'hook' => 'foo', - 'callback' => 'callback', - 'priority' => 10, - 'args' => 1, - ) ); - - $_beans_registered_actions['modified']['foo'] = wp_json_encode( array( - 'priority' => 1, - ) ); - - $expected = array( - 'hook' => 'foo', + $modified_action = array( 'callback' => 'callback', - 'priority' => 1, - 'args' => 1, + 'priority' => 27, + 'args' => 14, ); - $this->assertEquals( $expected, _beans_get_current_action( 'foo' ) ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['added'][ $beans_id ] = wp_json_encode( $action ); + $_beans_registered_actions['modified'][ $beans_id ] = wp_json_encode( $modified_action ); + + // Test that it merges the action. + $this->assertSame( + array_merge( $action, $modified_action ), + _beans_get_current_action( $beans_id ) + ); + } } } diff --git a/tests/phpunit/unit/api/actions/beansMergeAction.php b/tests/phpunit/unit/api/actions/beansMergeAction.php index e1bb8979..97332482 100644 --- a/tests/phpunit/unit/api/actions/beansMergeAction.php +++ b/tests/phpunit/unit/api/actions/beansMergeAction.php @@ -9,7 +9,9 @@ namespace Beans\Framework\Tests\Unit\API\Actions; -use Beans\Framework\Tests\Unit\Test_Case; +use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; + +require_once __DIR__ . '/includes/class-actions-test-case.php'; /** * Class Tests_BeansMergeAction @@ -18,62 +20,14 @@ * @group unit-tests * @group api */ -class Tests_BeansMergeAction extends Test_Case { +class Tests_BeansMergeAction extends Actions_Test_Case { /** - * Available action statuses. + * The registered actions' status. * * @var array */ - protected $action_status; - - /** - * Action to be/is registered. - * - * @var array - */ - protected $action; - - /** - * The json_encode() version of the above action. - * - * @var string - */ - protected $encoded_action; - - /** - * Setup test fixture. - */ - protected function setUp() { - parent::setUp(); - - $this->action_status = array( 'added', 'modified', 'removed', 'replaced' ); - require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; - - $this->action = array( - 'hook' => 'foo', - 'callback' => 'callback', - 'priority' => 10, - 'args' => 1, - ); - $this->encoded_action = wp_json_encode( $this->action ); - } - - /** - * Reset the test fixture. - */ - protected function tearDown() { - parent::tearDown(); - - global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); - } + protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); /** * Test _beans_set_action() should merge the new action's configuration with the registered one and then return it. @@ -81,28 +35,36 @@ protected function tearDown() { public function test_should_merge_and_return() { global $_beans_registered_actions; - $expected = $this->action; - $expected['priority'] = 20; + $modified_action = array( + 'priority' => 29, + ); - foreach ( $this->action_status as $action_status ) { - // Set the original action configuration. - _beans_set_action( 'foo', $this->action, $action_status ); + foreach ( static::$test_actions as $beans_id => $action ) { + $encoded_action = wp_json_encode( $action ); + $merged_action = array_merge( $action, $modified_action ); - // Now test that it does properly merge the action for the given status. - $this->assertEquals( $expected, _beans_merge_action( 'foo', array( 'priority' => 20 ), $action_status ) ); - $this->assertEquals( wp_json_encode( $expected ), $_beans_registered_actions[ $action_status ]['foo'] ); + // Test each status. + foreach ( $this->statuses as $status ) { + $_beans_registered_actions[ $status ][ $beans_id ] = $encoded_action; + $this->assertSame( $merged_action, _beans_merge_action( $beans_id, $modified_action, $status ) ); + } } } /** - * Test _beans_merge_action() should store new action's configuration, when it's not already registered. + * Test _beans_merge_action() should store a unregistered action. */ public function test_should_store_new_action() { global $_beans_registered_actions; - foreach ( $this->action_status as $action_status ) { - $this->assertEquals( $this->action, _beans_merge_action( 'foo', $this->action, $action_status ) ); - $this->assertEquals( $this->encoded_action, $_beans_registered_actions[ $action_status ]['foo'] ); + foreach ( static::$test_actions as $beans_id => $action ) { + $encoded_action = wp_json_encode( $action ); + + // Test each status. + foreach ( $this->statuses as $status ) { + $this->assertSame( $action, _beans_merge_action( $beans_id, $action, $status ) ); + $this->assertSame( $encoded_action, $_beans_registered_actions[ $status ][ $beans_id ] ); + } } } } diff --git a/tests/phpunit/unit/api/actions/beansModifyAction.php b/tests/phpunit/unit/api/actions/beansModifyAction.php index edd2f946..14359e3b 100644 --- a/tests/phpunit/unit/api/actions/beansModifyAction.php +++ b/tests/phpunit/unit/api/actions/beansModifyAction.php @@ -24,112 +24,174 @@ class Tests_BeansModifyAction extends Actions_Test_Case { /** - * Test beans_modify_action() should return false when the ID is not registered. + * Test beans_modify_action() should return false when there's nothing to modify, + * i.e. no arguments passed. */ - public function test_should_return_false_when_id_not_registered() { - $ids = array( - 'foo', - 'bar', - 'baz', - 'beans', - ); + public function test_should_return_false_when_nothing_to_modify() { + global $_beans_registered_actions; + + $this->go_to_post( true ); - foreach ( $ids as $id ) { - $this->assertFalse( _beans_get_action( $id, 'modified' ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + $this->assertFalse( beans_modify_action( $beans_id ) ); - $modified_action = array( - 'hook' => "{$id}_hook", - 'callback' => "{$id}_callback", - ); - $this->assertFalse( beans_modify_action( $id, $modified_action['hook'], $modified_action['callback'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( $id, 'modified' ) ); - $this->assertFalse( has_action( $modified_action['hook'] ) ); + // Verify that the action was not stored as "modified". + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + + // Check that the original action was not replaced. + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); } } /** - * Test beans_modify_action_callback() should return false when there's nothing to modify, - * i.e. no arguments passed. + * Test beans_modify_action() should register with Beans as "modified", but not add the action. */ - public function test_should_return_false_when_nothing_to_modify() { - $ids = array( - 'foo', - 'bar', - 'baz', - 'beans', - ); + public function test_should_register_as_modified_but_not_add_action() { + + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Check that it returns false. + $this->assertFalse( beans_modify_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); - foreach ( $ids as $id ) { - $this->assertFalse( beans_modify_action( $id ) ); + // Check that it did register as "modified" in Beans. + $this->assertEquals( $action, _beans_get_action( $beans_id, 'modified' ) ); - // Check after we setup the original action...just to make sure. - $this->setup_original_action( $id ); - $this->assertFalse( beans_modify_action( $id ) ); + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); } } /** - * Test beans_modify_action() should register with Beans as modified, but not with WordPress. + * Test beans_modify_action() should modify the registered action's hook. */ - public function test_should_register_with_beans_as_modified_but_not_with_wp() { - $action = array( - 'hook' => 'foo_hook', - 'callback' => 'my_callback', + public function test_should_modify_the_action_hook() { + $modified_action = array( + 'hook' => 'foo', ); - $this->check_not_added( 'foo', $action['hook'] ); + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $modified_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { + // Check that the parameters remain unchanged in WordPress. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); - $this->assertFalse( beans_modify_action( 'foo', $action['hook'], $action['callback'] ) ); + // Modify the hook. + $this->assertTrue( beans_modify_action( $beans_id, $modified_action['hook'] ) ); - // Check that it did register with Beans. - $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - // Check that it did not add the action. - $this->assertFalse( has_action( $action['hook'] ) ); + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the modified action was added in WordPress. + $this->assertTrue( has_action( $modified_action['hook'], $original_action['callback'] ) !== false ); + } } /** * Test beans_modify_action() should modify the registered action's callback. */ public function test_should_modify_the_action_callback() { - $container = Monkey\Container::instance(); - $action = $this->setup_original_action( 'beans' ); $modified_action = array( 'callback' => 'my_callback', ); - $this->assertTrue( beans_modify_action( 'beans', null, $modified_action['callback'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $action['hook'], $modified_action['callback'] ) ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { + // Check that the callback was modified in WordPress. + $this->assertSame( $modified_action['callback'], $callback ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Modify the action's callback. + $this->assertTrue( beans_modify_action( $beans_id, null, $modified_action['callback'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the modified action was added in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); + } } /** * Test beans_modify_action() should modify the registered action's priority level. */ public function test_should_modify_the_action_priority() { - $container = Monkey\Container::instance(); - $action = $this->setup_original_action( 'beans' ); $modified_action = array( 'priority' => 20, ); - $this->assertTrue( beans_modify_action( 'beans', null, null, $modified_action['priority'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $action['hook'], $action['callback'] ) ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { + // Check that the priority was modified in WordPress. + $this->assertSame( $modified_action['priority'], $priority ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Modify the action's priority. + $this->assertTrue( beans_modify_action( $beans_id, null, null, $modified_action['priority'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + } } /** * Test beans_modify_action() should modify the registered action's number of arguments. */ public function test_should_modify_the_action_args() { - $container = Monkey\Container::instance(); - $action = $this->setup_original_action( 'beans' ); $modified_action = array( - 'args' => 2, + 'args' => 7, ); - $this->assertTrue( beans_modify_action( 'beans', null, null, null, $modified_action['args'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $action['hook'], $action['callback'] ) ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { + // Check that the number of arguments was modified in WordPress. + $this->assertSame( $modified_action['args'], $args ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + } ); + + // Modify the action's number of arguments. + $this->assertTrue( beans_modify_action( $beans_id, null, null, null, $modified_action['args'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + } } } diff --git a/tests/phpunit/unit/api/actions/beansModifyActionArguments.php b/tests/phpunit/unit/api/actions/beansModifyActionArguments.php index 34619df5..aed25675 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionArguments.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionArguments.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-actions-test-case.php'; @@ -23,67 +24,108 @@ class Tests_BeansModifyActionArguments extends Actions_Test_Case { /** - * Test beans_modify_action_arguments() should return false when the ID is not registered. + * Test beans_modify_action_arguments() should return false when new args is a non-integer value. */ - public function test_should_return_false_when_id_not_registered() { - $ids = array( - 'foo' => null, - 'bar' => 0, - 'baz' => 1, - 'beans' => '3', + public function test_should_return_false_when_args_is_non_integer() { + $arguments = array( + null, + array( 10 ), + false, + '', ); - foreach ( $ids as $id => $number_of_args ) { - $this->assertFalse( beans_modify_action_arguments( $id, $number_of_args ) ); + $this->go_to_post(); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + + foreach ( $arguments as $number_of_args ) { + $this->assertFalse( beans_modify_action_arguments( $beans_id, $number_of_args ) ); + + // Check that the modification was not stored in Beans. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + } } } /** - * Test beans_modify_action_arguments() should return false when new args is a non-integer value. + * Test beans_modify_action_arguments() should modify the action's "args" when the new one is zero. */ - public function test_should_return_false_when_args_is_non_integer() { - $ids = array( - 'foo' => null, - 'bar' => array( 10 ), - 'baz' => false, - 'beans' => '', - ); + public function test_should_modify_action_when_args_is_zero() { + $arguments = array( 0, 0.0, '0', '0.0' ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { - foreach ( $ids as $id => $number_of_args ) { - $action = $this->setup_original_action( $id, true ); + foreach ( $arguments as $number_of_args ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $number_of_args ) { + // Check that the number of arguments was modified in WordPress. + $this->assertSame( (int) $number_of_args, $args ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + } ); - $this->assertFalse( beans_modify_action_arguments( $id, $number_of_args ) ); - $this->assertTrue( has_action( $action['hook'] ) ); + // Modify the action's number of arguments. + $this->assertTrue( beans_modify_action_arguments( $beans_id, $number_of_args ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( array( 'args' => (int) $number_of_args ), _beans_get_action( $beans_id, 'modified' ) ); + } } } /** - * Test beans_modify_action_priority() should return true when "args" is zero. + * Test beans_modify_action() should register with Beans as "modified", but not add the action. */ - public function test_should_return_true_when_args_is_zero() { - $ids = array( - 'foo' => 0, - 'bar' => 0.0, - 'baz' => '0', - 'beans' => '0.0', - ); + public function test_should_register_as_modified_but_not_add_action() { + + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Check that it returns false. + $this->assertFalse( beans_modify_action_arguments( $beans_id, $action['args'] ) ); + + // Check that it did register as "modified" in Beans. + $this->assertEquals( array( 'args' => $action['args'] ), _beans_get_action( $beans_id, 'modified' ) ); - foreach ( $ids as $id => $number_of_args ) { - $this->setup_original_action( $id ); - $this->assertTrue( beans_modify_action_arguments( $id, $number_of_args ) ); + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); } } /** - * Test beans_modify_action_arguments() should modify the registered action's args. + * Test beans_modify_action() should modify the registered action's number of arguments. */ public function test_should_modify_the_action_args() { - $action = $this->setup_original_action( 'beans' ); $modified_action = array( - 'args' => 3, + 'args' => 7, ); - $this->assertTrue( beans_modify_action_arguments( 'beans', $modified_action['args'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { + // Check that the number of arguments was modified in WordPress. + $this->assertSame( $modified_action['args'], $args ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + } ); + + // Modify the action's number of arguments. + $this->assertTrue( beans_modify_action_arguments( $beans_id, $modified_action['args'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + } } } diff --git a/tests/phpunit/unit/api/actions/beansModifyActionCallback.php b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php index e63b97d7..8d5ea018 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionCallback.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php @@ -24,56 +24,85 @@ class Tests_BeansModifyActionCallback extends Actions_Test_Case { /** - * Test beans_modify_action_callback() should return false when the ID is not registered. + * Test beans_modify_action_callback() should not modify when the callback is invalid. */ - public function test_should_return_false_when_id_not_registered() { - $this->assertFalse( beans_modify_action_callback( 'foo', null ) ); - $this->assertFalse( beans_modify_action_callback( 'foo', 'my_new_callback' ) ); - $this->assertFalse( beans_modify_action_callback( 'beans', 'beans_callback' ) ); - } + public function test_should_not_modify_when_invalid_callback() { + $callbacks = array( + null, + false, + '', + ); - /** - * Test beans_modify_action_callback() should return false when the new callback is null. - */ - public function test_should_return_false_when_new_callback_is_null() { - $this->setup_original_action(); - $this->assertFalse( beans_modify_action_callback( 'foo', null ) ); + $this->go_to_post( true ); - $this->setup_original_action( 'beans' ); - $this->assertFalse( beans_modify_action_callback( 'beans', null ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + + foreach ( $callbacks as $callback ) { + $this->assertFalse( beans_modify_action_callback( $beans_id, $callback ) ); + + // Check that the callback did not get stored as "modified" in Beans. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the callback did not change in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); + } + } } /** - * Test beans_modify_action_callback() should register with Beans as modified, but not with WordPress. + * Test beans_modify_action_callback() should register with Beans as "modified", but not add the action. */ - public function test_should_register_with_beans_as_modified_but_not_with_wp() { - $action = array( - 'callback' => 'my_callback', - ); + public function test_should_register_as_modified_but_not_add_action() { - $this->check_not_added( 'foo', 'foo_hook' ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->assertFalse( beans_modify_action_callback( 'foo', $action['callback'] ) ); + // Check that it returns false. + $this->assertFalse( beans_modify_action_callback( $beans_id, $action['callback'] ) ); - // Check that it did register with Beans. - $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + // Check that it did register as "modified" in Beans. + $this->assertEquals( array( 'callback' => $action['callback'] ), _beans_get_action( $beans_id, 'modified' ) ); - // Check that it did not add the action. - $this->assertFalse( has_action( 'foo_hook' ) ); + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } } /** - * Test beans_modify_action() should modify the registered action's callback. + * Test beans_modify_action_callback() should modify the registered action's callback. */ public function test_should_modify_the_action_callback() { - $container = Monkey\Container::instance(); - $action = $this->setup_original_action( 'beans' ); $modified_action = array( 'callback' => 'my_callback', ); - $this->assertTrue( beans_modify_action_callback( 'beans', $modified_action['callback'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $action['hook'], $modified_action['callback'] ) ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { + // Check that the callback was modified in WordPress. + $this->assertSame( $modified_action['callback'], $callback ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Modify the action's callback. + $this->assertTrue( beans_modify_action_callback( $beans_id, $modified_action['callback'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the modified action was added in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); + } } } diff --git a/tests/phpunit/unit/api/actions/beansModifyActionHook.php b/tests/phpunit/unit/api/actions/beansModifyActionHook.php index 0ef49eb2..a37d18ac 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionHook.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionHook.php @@ -24,59 +24,88 @@ class Tests_BeansModifyActionHook extends Actions_Test_Case { /** - * Test beans_modify_action_hook() should return false when the ID is not registered. + * Test beans_modify_action_hook() should not modify when the hook is invalid. */ - public function test_should_return_false_when_id_not_registered() { - $this->assertFalse( beans_modify_action_hook( 'foo', null ) ); - $this->assertFalse( beans_modify_action_hook( 'foo', 'foo_hook' ) ); - $this->assertFalse( beans_modify_action_hook( 'beans', 'beans_hook' ) ); - } + public function test_should_not_modify_when_invalid_hook() { + $hooks = array( + null, + false, + array( 'foo' ), + '', + 0, + 0.0, + '0', + ); - /** - * Test beans_modify_action_hook() should return false when new hook is null. - */ - public function test_should_return_false_when_new_hook_is_null() { - $this->setup_original_action(); - $this->assertFalse( beans_modify_action_hook( 'foo', null ) ); + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + + foreach ( $hooks as $hook ) { + $this->assertFalse( beans_modify_action_hook( $beans_id, $hook ) ); + + // Check that the hook did not get stored as "modified" in Beans. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->setup_original_action( 'beans' ); - $this->assertFalse( beans_modify_action_hook( 'beans', null ) ); + // Check that the hook did not change in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); + } + } } /** - * Test beans_modify_action_hook() should register with Beans as modified, but not with WordPress. + * Test beans_modify_action_hook() should register with Beans as "modified", but not add the action. */ - public function test_should_register_with_beans_as_modified_but_not_with_wp() { - $action = array( - 'hook' => 'my_hook', - ); + public function test_should_register_as_modified_but_not_add_action() { - $this->check_not_added( 'foo', $action['hook'] ); + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->assertFalse( beans_modify_action_hook( 'foo', $action['hook'] ) ); + // Check that it returns false. + $this->assertFalse( beans_modify_action_hook( $beans_id, $action['hook'] ) ); - // Check that it did register with Beans. - $this->assertEquals( $action, _beans_get_action( 'foo', 'modified' ) ); + // Check that it did register as "modified" in Beans. + $this->assertEquals( array( 'hook' => $action['hook'] ), _beans_get_action( $beans_id, 'modified' ) ); - // Check that it did not add the action. - $this->assertFalse( has_action( $action['hook'] ) ); + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + } } /** * Test beans_modify_action_hook() should modify the registered action's hook. */ public function test_should_modify_the_action_hook() { - $container = Monkey\Container::instance(); - $action = $this->setup_original_action( 'beans' ); $modified_action = array( - 'hook' => 'my_hook', + 'hook' => 'foo', ); - $this->assertTrue( beans_modify_action_hook( 'beans', $modified_action['hook'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - // Now check that it overwrote the "hook". - $this->assertFalse( has_action( $action['hook'] ) ); - $this->assertTrue( has_action( $modified_action['hook'] ) ); - $this->assertTrue( $container->hookStorage()->isHookAdded( Monkey\Hook\HookStorage::ACTIONS, $modified_action['hook'], $action['callback'] ) ); + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $modified_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { + // Check that the parameters remain unchanged in WordPress. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Modify the callback. + $this->assertTrue( beans_modify_action_hook( $beans_id, $modified_action['hook'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the modified action was added in WordPress. + $this->assertTrue( has_action( $modified_action['hook'], $original_action['callback'] ) !== false ); + } } } diff --git a/tests/phpunit/unit/api/actions/beansModifyActionPriority.php b/tests/phpunit/unit/api/actions/beansModifyActionPriority.php index a7f5b9bb..f1d5f393 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionPriority.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionPriority.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-actions-test-case.php'; @@ -23,65 +24,109 @@ class Tests_BeansModifyActionPriority extends Actions_Test_Case { /** - * Test beans_modify_action_priority() should return false when the ID is not registered. + * Test beans_modify_action_priority() should return false when new priority is a non-integer. */ - public function test_should_return_false_when_id_not_registered() { - $ids = array( - 'foo' => null, - 'bar' => 0, - 'baz' => 10, - 'beans' => '20', + public function test_should_return_false_when_priority_is_non_integer() { + $priorities = array( + null, + array( 10 ), + false, + '', ); - foreach ( $ids as $id => $priority ) { - $this->assertFalse( beans_modify_action_priority( $id, $priority ) ); + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + + foreach ( $priorities as $priority ) { + // Check that it returns false. + $this->assertFalse( beans_modify_action_priority( $beans_id, $priority ) ); + + // Check that the priority did not get stored as "modified" in Beans. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + } } } /** - * Test beans_modify_action_priority() should return false new priority is a non-integer. + * Test beans_modify_action_priority() should modify the action's priority when the new priority level is zero. */ - public function test_should_return_false_when_priority_is_non_integer() { - $ids = array( - 'foo' => null, - 'bar' => array( 10 ), - 'baz' => false, - 'beans' => '', - ); + public function test_should_modify_action_when_priority_is_zero() { + $priorities = array( 0, 0.0, '0', '0.0' ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + + foreach ( $priorities as $modified_priority ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_priority ) { + // Check that the priority was modified in WordPress. + $this->assertSame( (int) $modified_priority, $priority ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Modify the priority. + $this->assertTrue( beans_modify_action_priority( $beans_id, $modified_priority ) ); - foreach ( $ids as $id => $priority ) { - $this->setup_original_action( $id ); - $this->assertFalse( beans_modify_action_priority( $id, $priority ) ); + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( array( 'priority' => (int) $modified_priority ), _beans_get_action( $beans_id, 'modified' ) ); + } } } /** - * Test beans_modify_action_priority() should return true when priority is zero. + * Test beans_modify_action_priority() should register with Beans as "modified", but not add the action. */ - public function test_should_return_true_when_priority_is_zero() { - $ids = array( - 'foo' => 0, - 'bar' => 0.0, - 'baz' => '0', - 'beans' => '0.0', - ); + public function test_should_register_as_modified_but_not_add_action() { + + foreach ( static::$test_actions as $beans_id => $action ) { + // Check the starting state. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Check that it returns false. + $this->assertFalse( beans_modify_action_priority( $beans_id, $action['priority'] ) ); - foreach ( $ids as $id => $priority ) { - $this->setup_original_action( $id ); - $this->assertTrue( beans_modify_action_priority( $id, $priority ) ); + // Check that it did register as "modified" in Beans. + $this->assertEquals( array( 'priority' => $action['priority'] ), _beans_get_action( $beans_id, 'modified' ) ); + + // Check that the action was not added in WordPress. + $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); } } /** - * Test beans_modify_action_priority() should modify the registered action's priority. + * Test beans_modify_action() should modify the registered action's priority level. */ public function test_should_modify_the_action_priority() { - $action = $this->setup_original_action( 'beans' ); $modified_action = array( 'priority' => 20, ); - $this->assertTrue( beans_modify_action_priority( 'beans', $modified_action['priority'] ) ); - $this->assertEquals( $modified_action, _beans_get_action( 'beans', 'modified' ) ); - $this->assertTrue( has_action( $action['hook'] ) ); + + $this->go_to_post( true ); + + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we modify the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { + // Check that the priority was modified in WordPress. + $this->assertSame( $modified_action['priority'], $priority ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Modify the action's priority. + $this->assertTrue( beans_modify_action_priority( $beans_id, $modified_action['priority'] ) ); + + // Check that the modified action is registered as "modified" in Beans. + $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + } } } diff --git a/tests/phpunit/unit/api/actions/beansReplaceAction.php b/tests/phpunit/unit/api/actions/beansReplaceAction.php index 15b5b42a..3db9b8da 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceAction.php +++ b/tests/phpunit/unit/api/actions/beansReplaceAction.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Replace_Action_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-replace-action-test-case.php'; @@ -62,10 +63,22 @@ public function test_should_store_and_then_replace_action() { beans_replace_action( $beans_id, null, $replaced_action['callback'] ); } - $this->go_to_post(); - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the callback. + // Set up the WordPress simulator before we add the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the callback was replaced in WordPress. + $this->assertSame( $replaced_action['callback'], $callback ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Now add the original action. + beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); + + // Check that the original action's callback was replaced in Beans. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); @@ -74,7 +87,7 @@ public function test_should_store_and_then_replace_action() { // Check that the "replaced" action has been stored in Beans and WordPress. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); + $this->assertTrue( has_action( $original_action['hook'], $replaced_action['callback'] ) !== false ); } } @@ -85,7 +98,8 @@ public function test_should_store_and_then_replace_action() { public function test_should_return_false_when_nothing_to_replace() { $this->go_to_post(); - foreach ( static::$test_actions as $beans_id => $action_config ) { + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check it returns false. $this->assertFalse( beans_replace_action( $beans_id ) ); // Verify that it did not get stored in "replaced" or "modified". @@ -94,7 +108,7 @@ public function test_should_return_false_when_nothing_to_replace() { $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); } } @@ -102,32 +116,41 @@ public function test_should_return_false_when_nothing_to_replace() { * Test beans_replace_action() should replace the registered action's hook. */ public function test_should_replace_the_action_hook() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $replaced_action = array( + 'hook' => 'foo', + ); - // Make sure the callback is what we think before we get rolling. - $this->assertEquals( $action_config['hook'], $original_action['hook'] ); + $this->go_to_post( true ); - // Set up what will get stored in Beans. - $replaced_action = array( - 'hook' => 'foo', - ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we replace the action. + Monkey\Actions\expectAdded( $replaced_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { + // Check that the parameters remain unchanged in WordPress. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, $replaced_action['hook'] ) ); - // Check if it replaced only the hook. + // Check that only the hook was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); $this->assertEquals( $original_action['priority'], $new_action['priority'] ); $this->assertEquals( $original_action['args'], $new_action['args'] ); - // Check that the "replaced" action has been stored in Beans and WordPress. + // Check that the "replaced" action has been stored in Beans. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the replace action was added in WordPress. + $this->assertTrue( has_action( $replaced_action['hook'], $original_action['callback'] ) !== false ); } } @@ -135,32 +158,42 @@ public function test_should_replace_the_action_hook() { * Test beans_replace_action() should replace the registered action's callback. */ public function test_should_replace_the_action_callback() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $replaced_action = array( + 'callback' => 'foo', + ); - // Make sure the callback is what we think before we get rolling. - $this->assertEquals( $action_config['callback'], $original_action['callback'] ); + $this->go_to_post( true ); - // Set up what will get stored in Beans. - $replaced_action = array( - 'callback' => 'foo', - ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we replace the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the callback was replaced in WordPress. + $this->assertSame( $replaced_action['callback'], $callback ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); - // Check if it replaced only the callback. + // Check that only the callback was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); $this->assertEquals( $original_action['priority'], $new_action['priority'] ); $this->assertEquals( $original_action['args'], $new_action['args'] ); - // Check that the "replaced" action has been stored in Beans and WordPress. + // Check that the "replaced" action has been stored in Beans. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the replace action was added in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $replaced_action['callback'] ) !== false ); } } @@ -168,32 +201,36 @@ public function test_should_replace_the_action_callback() { * Test beans_replace_action() should replace the registered action's priority level. */ public function test_should_replace_the_action_priority() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $replaced_action = array( + 'priority' => 52, + ); - // Make sure the priority is what we think before we get rolling. - $this->assertEquals( $action_config['priority'], $original_action['priority'] ); + $this->go_to_post( true ); - // Set up what will get stored in Beans. - $replaced_action = array( - 'priority' => 50, - ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we replace the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the priority was replaced in WordPress. + $this->assertSame( $replaced_action['priority'], $priority ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['args'], $args ); + } ); // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); - // Check if it replaced only the priority. + // Check that only the priority was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); $this->assertEquals( $original_action['args'], $new_action['args'] ); - // Check that the "replaced" action has been stored in Beans and WordPress. + // Check that the "replaced" action has been stored in Beans. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); } } @@ -201,32 +238,36 @@ public function test_should_replace_the_action_priority() { * Test beans_replace_action() should replace the registered action's number of arguments. */ public function test_should_replace_the_action_args() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $replaced_action = array( + 'args' => 6, + ); - // Make sure the args are what we think before we get rolling. - $this->assertEquals( $action_config['args'], $original_action['args'] ); + $this->go_to_post( true ); - // Set up what will get stored in Beans. - $replaced_action = array( - 'args' => 5, - ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we replace the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the number of arguments was replaced in WordPress. + $this->assertSame( $replaced_action['args'], $args ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + } ); // Run the replace. $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); - // Check if it replaced only the args. + // Check that only the number of arguments was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); $this->assertEquals( $original_action['priority'], $new_action['priority'] ); $this->assertEquals( $replaced_action['args'], $new_action['args'] ); - // Check that the "replaced" action has been stored in Beans and WordPress. + // Check that the "replaced" action has been stored in Beans. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); } } @@ -234,7 +275,6 @@ public function test_should_replace_the_action_args() { * Test beans_replace_action() should replace the original registered action. */ public function test_should_replace_the_action() { - // Set up what will get stored in Beans. $replaced_action = array( 'hook' => 'new_hook', 'callback' => 'new_callback', @@ -242,11 +282,18 @@ public function test_should_replace_the_action() { 'args' => 10, ); - $this->go_to_post(); + $this->go_to_post( true ); foreach ( static::$test_actions as $beans_id => $original_action ) { - // Make sure the action is what we think before we get rolling. - $this->assertEquals( $original_action, _beans_get_action( $beans_id, 'added' ) ); + // Set up the WordPress simulator before we replace the action. + Monkey\Actions\expectAdded( $replaced_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $replaced_action ) { + // Check that all parameters were replaced in WordPress. + $this->assertSame( $replaced_action['callback'], $callback ); + $this->assertSame( $replaced_action['priority'], $priority ); + $this->assertSame( $replaced_action['args'], $args ); + } ); // Run the replace. $this->assertTrue( beans_replace_action( @@ -257,7 +304,7 @@ public function test_should_replace_the_action() { $replaced_action['args'] ) ); - // Check that the "replaced" action has been stored in Beans. + // Check that the replaced action has been stored in Beans. $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); @@ -265,8 +312,8 @@ public function test_should_replace_the_action() { // Check that the original action was removed from WordPress. $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - // Check that the new action is now registered in WordPress. - $this->check_registered_in_wp( $replaced_action['hook'], $replaced_action ); + // Check that the replaced action is now registered in WordPress. + $this->assertTrue( has_action( $replaced_action['hook'], $replaced_action['callback'] ) !== false ); } } } diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php index 29068600..78688d57 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Replace_Action_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-replace-action-test-case.php'; @@ -33,7 +34,6 @@ public function test_should_store_when_action_is_not_registered() { 'args' => 10, ); - // Store the "replaced" action. foreach ( array_keys( static::$test_actions ) as $beans_id ) { // Test that the original action has not yet been added. $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); @@ -62,10 +62,22 @@ public function test_should_store_and_then_replace_the_args() { beans_replace_action_arguments( $beans_id, $replaced_action['args'] ); } - $this->go_to_post(); - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the args. + // Set up the WordPress simulator before we add the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the number of arguments was replaced in WordPress. + $this->assertSame( $replaced_action['args'], $args ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + } ); + + // Now add the original action. + beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); + + // Check that only the number of arguments was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -74,7 +86,6 @@ public function test_should_store_and_then_replace_the_args() { // Check that the "replaced" action has been stored in Beans and WordPress. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); } } @@ -84,7 +95,8 @@ public function test_should_store_and_then_replace_the_args() { public function test_should_return_false_when_no_args() { $this->go_to_post(); - foreach ( static::$test_actions as $beans_id => $action_config ) { + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check it returns false. $this->assertFalse( beans_replace_action_arguments( $beans_id, '' ) ); // Verify that it did not get stored in "replaced" or "modified". @@ -93,7 +105,7 @@ public function test_should_return_false_when_no_args() { $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); } } @@ -102,30 +114,35 @@ public function test_should_return_false_when_no_args() { */ public function test_should_replace_the_action_args() { $replaced_action = array( - 'args' => 14, + 'args' => 6, ); - $this->go_to_post(); + $this->go_to_post( true ); - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); - - // Make sure the args is what we think before we get rolling. - $this->assertEquals( $action_config['args'], $original_action['args'] ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we replace the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the number of arguments was replaced in WordPress. + $this->assertSame( $replaced_action['args'], $args ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + } ); // Run the replace. - $this->assertTrue( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); + $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); - // Check if it replaced only the args. + // Check that only the number of arguments was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); $this->assertEquals( $original_action['priority'], $new_action['priority'] ); $this->assertEquals( $replaced_action['args'], $new_action['args'] ); - // Check that the "replaced" action has been stored in Beans and WordPress. + // Check that the "replaced" action has been stored in Beans. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); } } } diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php index 7bbbea2b..41a5d969 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Replace_Action_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-replace-action-test-case.php'; @@ -61,10 +62,22 @@ public function test_should_store_and_then_replace_the_callback() { beans_replace_action_callback( $beans_id, $replaced_action['callback'] ); } - $this->go_to_post(); - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the callback. + // Set up the WordPress simulator before we add the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the callback was replaced in WordPress. + $this->assertSame( $replaced_action['callback'], $callback ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Now add the original action. + beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); + + // Check that only the callback was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); @@ -73,7 +86,6 @@ public function test_should_store_and_then_replace_the_callback() { // Check that the "replaced" action has been stored in Beans and WordPress. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); } } @@ -84,6 +96,7 @@ public function test_should_return_false_when_no_callback() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $action_config ) { + // Check it returns false. $this->assertFalse( beans_replace_action_callback( $beans_id, '' ) ); // Verify that it did not get stored in "replaced" or "modified". @@ -101,30 +114,41 @@ public function test_should_return_false_when_no_callback() { */ public function test_should_replace_the_action_callback() { $replaced_action = array( - 'callback' => 'beans_foo', + 'callback' => 'foo', ); - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $this->go_to_post( true ); - // Make sure the callback is what we think before we get rolling. - $this->assertEquals( $action_config['callback'], $original_action['callback'] ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we replace the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the callback was replaced in WordPress. + $this->assertSame( $replaced_action['callback'], $callback ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); // Run the replace. - $this->assertTrue( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); + $this->assertTrue( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); - // Check if it replaced only the callback. + // Check that only the callback was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); $this->assertEquals( $original_action['priority'], $new_action['priority'] ); $this->assertEquals( $original_action['args'], $new_action['args'] ); - // Check that the "replaced" action has been stored in Beans and WordPress. + // Check that the "replaced" action has been stored in Beans. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the replace action was added in WordPress. + $this->assertTrue( has_action( $original_action['hook'], $replaced_action['callback'] ) !== false ); } } } diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php index 1d2d1917..0c9eb94d 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Replace_Action_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-replace-action-test-case.php'; @@ -61,10 +62,21 @@ public function test_should_store_and_then_replace_the_hook() { beans_replace_action_hook( $beans_id, $replaced_action['hook'] ); } - $this->go_to_post(); - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the hook. + // Set up the WordPress simulator before we add the action. + Monkey\Actions\expectAdded( $replaced_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { + // Check that all of the parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Now add the original action. + beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); + + // Check that only the hook was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); @@ -74,7 +86,7 @@ public function test_should_store_and_then_replace_the_hook() { // Check that the "replaced" action has been stored in Beans and WordPress. $this->check_stored_in_beans( $beans_id, $replaced_action ); $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - $this->check_registered_in_wp( $replaced_action['hook'], $new_action ); + $this->assertTrue( has_action( $replaced_action['hook'], $original_action['callback'] ) !== false ); } } @@ -85,6 +97,7 @@ public function test_should_return_false_when_no_hook() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $action_config ) { + // Check it returns false. $this->assertFalse( beans_replace_action_hook( $beans_id, '' ) ); // Verify that it did not get stored in "replaced" or "modified". @@ -101,32 +114,41 @@ public function test_should_return_false_when_no_hook() { * Test beans_replace_action_hook() should replace the registered action's hook. */ public function test_should_replace_the_action_hook() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $replaced_action = array( + 'hook' => 'foo', + ); - // Make sure the callback is what we think before we get rolling. - $this->assertEquals( $action_config['hook'], $original_action['hook'] ); + $this->go_to_post( true ); - // Set up what will get stored in Beans. - $replaced_action = array( - 'hook' => 'beans_foo', - ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we replace the action. + Monkey\Actions\expectAdded( $replaced_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { + // Check that the parameters remain unchanged in WordPress. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['priority'], $priority ); + $this->assertSame( $original_action['args'], $args ); + } ); // Run the replace. $this->assertTrue( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); - // Check if it replaced only the hook. + // Check that only the hook was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); $this->assertEquals( $original_action['priority'], $new_action['priority'] ); $this->assertEquals( $original_action['args'], $new_action['args'] ); - // Check that the "replaced" action has been stored in Beans and WordPress. + // Check that the "replaced" action has been stored in Beans. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); + + // Check that the original action was removed from WordPress. + $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + + // Check that the replace action was added in WordPress. + $this->assertTrue( has_action( $replaced_action['hook'], $original_action['callback'] ) !== false ); } } } diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php index f278242f..2f04e801 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Replace_Action_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-replace-action-test-case.php'; @@ -61,19 +62,30 @@ public function test_should_store_and_then_replace_the_priority() { beans_replace_action_priority( $beans_id, $replaced_action['priority'] ); } - $this->go_to_post(); - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the priority. + // Set up the WordPress simulator before we add the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the priority was replaced in WordPress. + $this->assertSame( $replaced_action['priority'], $priority ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['args'], $args ); + } ); + + // Now add the original action. + beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); + + // Check that only the priority was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); $this->assertEquals( $original_action['args'], $new_action['args'] ); - // Check that the "replaced" action has been stored in Beans and WordPress. + // Check that the "replaced" action has been stored in Beans. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); } } @@ -84,6 +96,7 @@ public function test_should_return_false_when_no_priority() { $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $action_config ) { + // Check it returns false. $this->assertFalse( beans_replace_action_priority( $beans_id, '' ) ); // Verify that it did not get stored in "replaced" or "modified". @@ -101,30 +114,35 @@ public function test_should_return_false_when_no_priority() { */ public function test_should_replace_the_action_priority() { $replaced_action = array( - 'priority' => 999, + 'priority' => 52, ); - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); + $this->go_to_post( true ); - // Make sure the priority is what we think before we get rolling. - $this->assertEquals( $action_config['priority'], $original_action['priority'] ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Set up the WordPress simulator before we replace the action. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { + // Check that the priority was replaced in WordPress. + $this->assertSame( $replaced_action['priority'], $priority ); + // Check that the other parameters remain unchanged. + $this->assertSame( $original_action['callback'], $callback ); + $this->assertSame( $original_action['args'], $args ); + } ); // Run the replace. - $this->assertTrue( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); + $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); - // Check if it replaced only the priority. + // Check that only the priority was replaced. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $original_action['callback'], $new_action['callback'] ); $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); $this->assertEquals( $original_action['args'], $new_action['args'] ); - // Check that the "replaced" action has been stored in Beans and WordPress. + // Check that the "replaced" action has been stored in Beans. $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); } } } diff --git a/tests/phpunit/unit/api/actions/beansSetAction.php b/tests/phpunit/unit/api/actions/beansSetAction.php index a6b4a34f..745c91f3 100644 --- a/tests/phpunit/unit/api/actions/beansSetAction.php +++ b/tests/phpunit/unit/api/actions/beansSetAction.php @@ -23,56 +23,31 @@ class Tests_BeansSetAction extends Actions_Test_Case { /** - * Available action statuses. + * The registered actions' status. * * @var array */ - protected $action_status; + protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); /** - * Action to be/is registered. - * - * @var array - */ - protected $action; - - /** - * The json_encode() version of the above action. - * - * @var string - */ - protected $encoded_action; - - /** - * Setup test fixture. - */ - protected function setUp() { - parent::setUp(); - - $this->action_status = array( 'added', 'modified', 'removed', 'replaced' ); - $this->action = array( - 'hook' => 'foo', - 'callback' => 'callback', - 'priority' => 10, - 'args' => 1, - ); - $this->encoded_action = wp_json_encode( $this->action ); - } - - /** - * Test _beans_set_action() should set the action into the registered actions and then return it. + * Test _beans_set_action() should set (registered) the action and then return it. */ public function test_should_set_and_return_action() { global $_beans_registered_actions; - foreach ( $this->action_status as $action_status ) { - // Check that it's not set before we start. - $this->assertFalse( isset( $_beans_registered_actions[ $action_status ]['foo'] ) ); + foreach ( static::$test_actions as $beans_id => $action ) { + $encoded_action = wp_json_encode( $action ); + + // Test each status. + foreach ( $this->statuses as $status ) { + // Before we start, check that the action is not set. + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); - // Now test that it does properly set the action for the given status. - $this->assertEquals( $this->action, _beans_set_action( 'foo', $this->action, $action_status ) ); - $this->assertArrayHasKey( 'foo', $_beans_registered_actions[ $action_status ] ); - $this->assertEquals( $this->encoded_action, $_beans_registered_actions[ $action_status ]['foo'] ); + // Now do the tests. + $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); + $this->assertArrayHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + $this->assertSame( $encoded_action, $_beans_registered_actions[ $status ][ $beans_id ] ); + } } } @@ -89,14 +64,18 @@ public function test_should_not_overwrite_existing_registered_action() { 'args' => 2, ); - foreach ( $this->action_status as $action_status ) { + foreach ( static::$test_actions as $beans_id => $action ) { + $encoded_action = wp_json_encode( $action ); - // Register the original one first. - _beans_set_action( 'foo', $this->action, $action_status ); + // Test each status. + foreach ( $this->statuses as $status ) { + // Register the original action. + $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); - // Now test that it does not overwrite the previously registered action. - $this->assertEquals( $this->action, _beans_set_action( 'foo', $new_action, $action_status ) ); - $this->assertEquals( $this->encoded_action, $_beans_registered_actions[ $action_status ]['foo'] ); + // Now test that it does not overwrite the previously registered action. + $this->assertSame( $action, _beans_set_action( $beans_id, $new_action, $status ) ); + $this->assertSame( $encoded_action, $_beans_registered_actions[ $status ][ $beans_id ] ); + } } } @@ -115,14 +94,17 @@ public function test_should_overwrite_existing_registered_action() { ); $encoded_new_action = wp_json_encode( $new_action ); - foreach ( $this->action_status as $action_status ) { + foreach ( static::$test_actions as $beans_id => $action ) { - // Register the original one first. - _beans_set_action( 'foo', $this->action, $action_status ); + // Test each status. + foreach ( $this->statuses as $status ) { + // Register the original action. + $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); - // Now test that it does overwrite the previously registered action. - $this->assertEquals( $new_action, _beans_set_action( 'foo', $new_action, $action_status, true ) ); - $this->assertEquals( $encoded_new_action, $_beans_registered_actions[ $action_status ]['foo'] ); + // Now test that it does overwrite the previously registered action. + $this->assertSame( $new_action, _beans_set_action( $beans_id, $new_action, $status, true ) ); + $this->assertSame( $encoded_new_action, $_beans_registered_actions[ $status ][ $beans_id ] ); + } } } } diff --git a/tests/phpunit/unit/api/actions/beansUnsetAction.php b/tests/phpunit/unit/api/actions/beansUnsetAction.php index ce4c615f..cb89bae1 100644 --- a/tests/phpunit/unit/api/actions/beansUnsetAction.php +++ b/tests/phpunit/unit/api/actions/beansUnsetAction.php @@ -23,67 +23,46 @@ class Tests_BeansUnsetAction extends Actions_Test_Case { /** - * Available action statuses. + * The registered actions' status. * * @var array */ - protected $action_status; + protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); /** - * Action to be/is registered. - * - * @var array - */ - protected $action; - - /** - * The json_encode() version of the above action. - * - * @var string - */ - protected $encoded_action; - - /** - * Setup test fixture. - */ - protected function setUp() { - parent::setUp(); - - $this->action_status = array( 'added', 'modified', 'removed', 'replaced' ); - $this->action = array( - 'hook' => 'foo', - 'callback' => 'callback', - 'priority' => 10, - 'args' => 1, - ); - $this->encoded_action = wp_json_encode( $this->action ); - } - - /** - * Test _beans_unset_action() should return false when action's configuration is not registered. + * Test _beans_unset_action() should return false when action is not registered. */ public function test_should_return_false_when_not_registered() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { - foreach ( $this->action_status as $action_status ) { - $this->assertFalse( _beans_unset_action( 'foo', $action_status ) ); + // Test each status. + foreach ( $this->statuses as $status ) { + $this->assertFalse( _beans_unset_action( $beans_id, $status ) ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + } } } /** - * Test _beans_unset_action() should unset the registered action's configuration. + * Test _beans_unset_action() should unset the registered action. */ public function test_should_unset_registered_action() { global $_beans_registered_actions; - foreach ( $this->action_status as $action_status ) { + foreach ( static::$test_actions as $beans_id => $action ) { - // First, register the action. - _beans_set_action( 'foo', $this->action, $action_status ); - $this->assertTrue( isset( $_beans_registered_actions[ $action_status ]['foo'] ) ); + // Test each status. + foreach ( $this->statuses as $status ) { + // Register the action first. + _beans_set_action( $beans_id, $action, $status ); + $this->assertArrayHasKey( $beans_id, $_beans_registered_actions[ $status ] ); - // Then test that unset does its job. - $this->assertTrue( _beans_unset_action( 'foo', $action_status ) ); - $this->assertFalse( isset( $_beans_registered_actions[ $action_status ]['foo'] ) ); + // Test that it unsets the action. + $this->assertTrue( _beans_unset_action( $beans_id, $status ) ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + } } } @@ -91,17 +70,22 @@ public function test_should_unset_registered_action() { * Test _beans_unset_action() should return false when the status is invalid. */ public function test_should_return_false_when_status_is_invalid() { - $this->assertFalse( _beans_unset_action( 'foo', 'invalid_status' ) ); - $this->assertFalse( _beans_unset_action( 'foo', 'foo' ) ); - $this->assertFalse( _beans_unset_action( 'foo', 'not_valid_either' ) ); - // Now store some configurations and test it again. - foreach ( $this->action_status as $action_status ) { - _beans_set_action( 'foo', $this->action, $action_status ); - } + foreach ( static::$test_actions as $beans_id => $action ) { + + $this->assertFalse( _beans_unset_action( $beans_id, 'invalid_status' ) ); + $this->assertFalse( _beans_unset_action( $beans_id, 'foo' ) ); + $this->assertFalse( _beans_unset_action( $beans_id, 'not_valid_either' ) ); - $this->assertFalse( _beans_unset_action( 'foo', 'invalid_status' ) ); - $this->assertFalse( _beans_unset_action( 'foo', 'foo' ) ); - $this->assertFalse( _beans_unset_action( 'foo', 'not_valid_either' ) ); + // Now store the action in each status. + foreach ( $this->statuses as $status ) { + _beans_set_action( $beans_id, $action, $status ); + } + + // Run the tests again. + $this->assertFalse( _beans_unset_action( $beans_id, 'invalid_status' ) ); + $this->assertFalse( _beans_unset_action( $beans_id, 'foo' ) ); + $this->assertFalse( _beans_unset_action( $beans_id, 'not_valid_either' ) ); + } } } diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index e64fe106..1f7afc92 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -86,55 +86,6 @@ protected function tearDown() { $this->remove_test_actions(); } - /** - * Check that is not registered first. - * - * @since 1.5.0 - * - * @param string $id The ID to check. - * @param string $hook The hook (event name) to check. - * - * @return void - */ - protected function check_not_added( $id, $hook ) { - $this->assertFalse( _beans_get_action( $id, 'added' ) ); - $this->assertFalse( has_action( $hook ) ); - } - - /** - * Setup the original action. - * - * @since 1.5.0 - * - * @param string $id Optional. Beans ID to register. Default is 'foo'. - * - * @return array - */ - protected function setup_original_action( $id = 'foo' ) { - $container = Monkey\Container::instance(); - $action = array( - 'hook' => "{$id}_hook", - 'callback' => "callback_{$id}", - 'priority' => 10, - 'args' => 1, - ); - - $this->check_not_added( $id, $action['hook'] ); - - // Add the original action to get us rolling. - beans_add_action( $id, $action['hook'], $action['callback'] ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->assertTrue( - $container->hookStorage()->isHookAdded( - Monkey\Hook\HookStorage::ACTIONS, - $action['hook'], - $action['callback'] - ) - ); - - return $action; - } - /** * Simulate going to the post and loading in the template and fragments. * @@ -176,31 +127,4 @@ protected function remove_test_actions() { remove_action( $action['hook'], $action['callback'], $action['priority'] ); } } - - /** - * Check that the right parameters are registered in WordPress. - * - * @since 1.5.0 - * - * @param array $action The action that should be registered. - * @param bool $remove_action When true, it removes the action automatically to clean up this test. - * - * @return void - */ - protected function check_parameters_registered_in_wp( array $action, $remove_action = true ) { - $container = Monkey\Container::instance(); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->assertTrue( - $container->hookStorage()->isHookAdded( - Monkey\Hook\HookStorage::ACTIONS, - $action['hook'], - $action['callback'] - ) - ); - - // Then remove the action. - if ( $remove_action ) { - remove_action( $action['hook'], $action['callback'], $action['priority'] ); - } - } } diff --git a/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php index aa723245..80fea233 100644 --- a/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php @@ -30,20 +30,4 @@ protected function check_stored_in_beans( $beans_id, array $replaced_action ) { $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); } - - /** - * Check that the "replaced" action has been stored in Beans. - * - * @since 1.5.0 - * - * @param string $hook The event's name (hook) that is registered in WordPress. - * @param array $new_action The "new" action's configuration (after the replace). - * @param bool $remove_action When true, it removes the action automatically to clean up this test. - * - * @return void - */ - protected function check_registered_in_wp( $hook, array $new_action, $remove_action = true ) { - $this->assertTrue( has_action( $hook, $new_action['callback'] ) !== false ); - $this->check_parameters_registered_in_wp( $new_action, $remove_action ); - } } From f41914f053c796da2431be583c53f98d39b43add Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 1 Feb 2018 19:15:53 -0600 Subject: [PATCH 028/800] Made Filters API compliant & tested. (#105) 1. Made WPCS compliant. 2. Added integration tests. 3. Added unit tests. 4. Improved documentation. --- .../filters/class-beans-anonymous-filters.php | 56 +++++++ lib/api/filters/class.php | 48 ------ lib/api/filters/functions.php | 156 ++++++++++-------- .../api/filters/beansAddAnonymousFilter.php | 60 +++++++ .../api/filters/beansAddFilter.php | 77 +++++++++ .../api/filters/beansApplyFilters.php | 98 +++++++++++ .../api/filters/beansHasFilters.php | 57 +++++++ .../api/filters/fixtures/test-filters.php | 41 +++++ .../includes/class-filters-test-case.php | 71 ++++++++ .../api/filters/stubs/functions.php | 65 ++++++++ .../api/filters/beansAddAnonymousFilter.php | 82 +++++++++ .../unit/api/filters/beansAddFilter.php | 74 +++++++++ .../unit/api/filters/beansApplyFilters.php | 148 +++++++++++++++++ .../unit/api/filters/beansHasFilters.php | 57 +++++++ .../api/filters/fixtures/test-filters.php | 41 +++++ .../includes/class-filters-test-case.php | 57 +++++++ .../unit/api/filters/stubs/functions.php | 65 ++++++++ 17 files changed, 1133 insertions(+), 120 deletions(-) create mode 100644 lib/api/filters/class-beans-anonymous-filters.php delete mode 100644 lib/api/filters/class.php create mode 100644 tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php create mode 100644 tests/phpunit/integration/api/filters/beansAddFilter.php create mode 100644 tests/phpunit/integration/api/filters/beansApplyFilters.php create mode 100644 tests/phpunit/integration/api/filters/beansHasFilters.php create mode 100644 tests/phpunit/integration/api/filters/fixtures/test-filters.php create mode 100644 tests/phpunit/integration/api/filters/includes/class-filters-test-case.php create mode 100644 tests/phpunit/integration/api/filters/stubs/functions.php create mode 100644 tests/phpunit/unit/api/filters/beansAddAnonymousFilter.php create mode 100644 tests/phpunit/unit/api/filters/beansAddFilter.php create mode 100644 tests/phpunit/unit/api/filters/beansApplyFilters.php create mode 100644 tests/phpunit/unit/api/filters/beansHasFilters.php create mode 100644 tests/phpunit/unit/api/filters/fixtures/test-filters.php create mode 100644 tests/phpunit/unit/api/filters/includes/class-filters-test-case.php create mode 100644 tests/phpunit/unit/api/filters/stubs/functions.php diff --git a/lib/api/filters/class-beans-anonymous-filters.php b/lib/api/filters/class-beans-anonymous-filters.php new file mode 100644 index 00000000..dd9b2a82 --- /dev/null +++ b/lib/api/filters/class-beans-anonymous-filters.php @@ -0,0 +1,56 @@ +value_to_return = $value_to_return; + + add_filter( $hook, array( $this, 'callback' ), $priority, $args ); + } + + /** + * Get filter content and set it as the callback. + * + * @since 1.0.0 + * + * @return array + */ + public function callback() { + return $this->value_to_return; + } +} diff --git a/lib/api/filters/class.php b/lib/api/filters/class.php deleted file mode 100644 index 44bf626e..00000000 --- a/lib/api/filters/class.php +++ /dev/null @@ -1,48 +0,0 @@ -callback = $callback; - - add_filter( $id, array( $this, 'callback' ), $priority, $args ); - - } - - /** - * Get filter content and set it as the callback. - */ - public function callback() { - - return $this->callback; - - } -} diff --git a/lib/api/filters/functions.php b/lib/api/filters/functions.php index 15b79649..88cd3716 100644 --- a/lib/api/filters/functions.php +++ b/lib/api/filters/functions.php @@ -6,34 +6,34 @@ */ /** - * Hooks a function or method to a specific filter action. + * Hooks a callback (function or method) to a specific filter event. * * This function is similar to {@link http://codex.wordpress.org/Function_Reference/add_filter add_filter()} - * with the exception that it accepts a $callback argument which is used to automatically create an + * with the exception that it accepts a $callback_or_value argument which is used to automatically create an * anonymous function. * * @since 1.0.0 * - * @param string $id The filter ID. - * @param callback $callback The name of the function you wish to be called. Inline content will automatically - * create an anonymous function. - * @param int $priority Optional. Used to specify the order in which the functions - * associated with a particular action are executed. Default 10. - * Lower numbers correspond with earlier execution, - * and functions with the same priority are executed - * in the order in which they were added to the action. - * @param int $args Optional. The number of arguments the function accepts. Default 1. - * - * @return bool Will always return true. + * @param string $hook The name of the filter event to which the callback is hooked. + * @param callable|mixed $callback_or_value For a callback, specify the name of the function|method you wish to be + * called when the filter event fires. + * For a value, specify the value to be returned when the filter event fires. + * Beans creates an anonymous function to hook into the filter event. + * @param int $priority Optional. Used to specify the order in which the callbacks associated with + * a particular action are executed. Default is 10. Lower numbers correspond + * with earlier execution. Callbacks with the same priority are executed in + * the order in which they were added to the filter. + * @param int $args Optional. The number of arguments the callback accepts. Default is 1. + * + * @return bool */ -function beans_add_filter( $id, $callback, $priority = 10, $args = 1 ) { +function beans_add_filter( $hook, $callback_or_value, $priority = 10, $args = 1 ) { - if ( is_callable( $callback ) ) { - return add_filter( $id, $callback, $priority, $args ); + if ( is_callable( $callback_or_value ) ) { + return add_filter( $hook, $callback_or_value, $priority, $args ); } - return _beans_add_anonymous_filter( $id, $callback, $priority, $args ); - + return _beans_add_anonymous_filter( $hook, $callback_or_value, $priority, $args ); } /** @@ -61,55 +61,50 @@ function beans_add_filter( $id, $callback, $priority = 10, $args = 1 ) { * @return mixed The filtered value after all hooked functions are applied to it. */ function beans_apply_filters( $id, $value ) { - $args = func_get_args(); - // Return simple filter if no sub-hook is set. - if ( ! preg_match_all( '#\[(.*?)\]#', $args[0], $matches ) ) { + // Return simple filter if no sub-hook(s) is(are) set. + if ( ! preg_match_all( '#\[(.*?)\]#', $args[0], $sub_hooks ) ) { return call_user_func_array( 'apply_filters', $args ); } - $prefix = current( explode( '[', $args[0] ) ); + $prefix = current( explode( '[', $args[0] ) ); $variable_prefix = $prefix; - $suffix = preg_replace( '/^.*\]\s*/', '', $args[0] ); + $suffix = preg_replace( '/^.*\]\s*/', '', $args[0] ); // Base filter. $args[0] = $prefix . $suffix; - $value = call_user_func_array( 'apply_filters', $args ); + $value = call_user_func_array( 'apply_filters', $args ); - foreach ( $matches[0] as $i => $subhook ) { + foreach ( (array) $sub_hooks[0] as $index => $sub_hook ) { - $variable_prefix = $variable_prefix . $subhook; - $levels = array( $prefix . $subhook . $suffix ); - - // Cascade sub-hooks. - if ( $i > 0 ) { + // If there are more than 3 sub-hooks, stop processing. + if ( $index > 2 ) { + break; + } - if ( count( $matches[0] ) > 2 ) { - $levels[] = str_replace( $subhook, '', $id ); - } + $variable_prefix .= $sub_hook; + $levels = array( $prefix . $sub_hook . $suffix ); + // Cascade sub-hooks. + if ( $index > 0 ) { $levels[] = $variable_prefix . $suffix; - } // Apply sub-hooks. foreach ( $levels as $level ) { - $args[0] = $level; $args[1] = $value; - $value = call_user_func_array( 'apply_filters', $args ); + $value = call_user_func_array( 'apply_filters', $args ); - // Apply filter whithout square brackets for backwards compatibility. + // Apply filter without square brackets for backwards compatibility. $args[0] = preg_replace( '#(\[|\])#', '', $args[0] ); $args[1] = $value; - $value = call_user_func_array( 'apply_filters', $args ); - + $value = call_user_func_array( 'apply_filters', $args ); } } return $value; - } /** @@ -120,72 +115,89 @@ function beans_apply_filters( $id, $value ) { * * @since 1.0.0 * - * @param string $id The filter ID. - * @param callback|bool $callback Optional. The callback to check for. Default false. + * @param string $id A unique string used as a reference. Sub-hook(s) must be set in square brackets. + * @param callable|bool $callback Optional. The callback to check for. Default false. * - * @return bool|int If $callback is omitted, returns boolean for whether the hook has - * anything registered. When checking a specific function, the priority of that - * hook is returned, or false if the function is not attached. When using the - * $callback argument, this function may return a non-boolean value - * that evaluates to false (e.g. 0), so use the === operator for testing the - * return value. + * @return bool|int If $callback is omitted, returns boolean for whether the hook has any callbacks registered. + * When checking a specific callback, returns the priority of that hook when a callback is registered; + * else, it returns false. When using the `$callback` argument, this function may return a non-boolean + * value that evaluates to false (e.g. 0). Make sure you use the === operator for testing the return + * value. */ function beans_has_filters( $id, $callback = false ) { - // Check simple filter if no subhook is set. - if ( ! preg_match_all( '#\[(.*?)\]#', $id, $matches ) ) { + // Check simple filter if no sub-hook is set. + if ( ! preg_match_all( '#\[(.*?)\]#', $id, $sub_hooks ) ) { return has_filter( $id, $callback ); } - $prefix = current( explode( '[', $id ) ); + $prefix = current( explode( '[', $id ) ); $variable_prefix = $prefix; - $suffix = preg_replace( '/^.*\]\s*/', '', $id ); + $suffix = preg_replace( '/^.*\]\s*/', '', $id ); // Check base filter. - if ( has_filter( $prefix . $suffix, $callback ) ) { - return true; + $priority_number = has_filter( $prefix . $suffix, $callback ); + + if ( false !== $priority_number ) { + return $priority_number; } - foreach ( $matches[0] as $i => $subhook ) { + foreach ( (array) $sub_hooks[0] as $index => $sub_hook ) { - $variable_prefix = $variable_prefix . $subhook; - $levels = array( $prefix . $subhook . $suffix ); + // If there are more than 3 sub-hooks, return false. + if ( $index > 2 ) { + return false; + } - // Cascade sub-hooks. - if ( $i > 0 ) { + $variable_prefix .= $sub_hook; + $levels = array( $prefix . $sub_hook . $suffix ); - $levels[] = str_replace( $subhook, '', $id ); + // Cascade sub-hooks. + if ( $index > 0 ) { $levels[] = $variable_prefix . $suffix; - } // Apply sub-hooks. foreach ( $levels as $level ) { + $priority_number = has_filter( $level, $callback ); - if ( has_filter( $level, $callback ) ) { - return true; + if ( false !== $priority_number ) { + return $priority_number; } - // Check filter whithout square brackets for backwards compatibility. - if ( has_filter( preg_replace( '#(\[|\])#', '', $level ), $callback ) ) { - return true; + // Check filter without square brackets for backwards compatibility. + $priority_number = has_filter( preg_replace( '#(\[|\])#', '', $level ), $callback ); + + if ( false !== $priority_number ) { + return $priority_number; } } } return false; - } /** * Add anonymous callback using a class since php 5.2 is still supported. * + * @since 1.0.0 + * @since 1.5.0 Returns the object. * @ignore + * @access private + * + * @param string $hook The name of the filter event to which the callback is hooked. + * @param mixed $value The value that will be returned when the anonymous callback runs. + * @param int $priority Optional. Used to specify the order in which the functions + * associated with a particular filter are executed. Default 10. + * Lower numbers correspond with earlier execution, + * and functions with the same priority are executed + * in the order in which they were added to the filter. + * @param int $args Optional. The number of arguments the function accepts. Default 1. + * + * @return _Beans_Anonymous_Filters */ -function _beans_add_anonymous_filter( $id, $callback, $priority = 10, $args = 1 ) { - - require_once( BEANS_API_PATH . 'filters/class.php' ); - - new _Beans_Anonymous_Filters( $id, $callback, $priority, $args ); +function _beans_add_anonymous_filter( $hook, $value, $priority = 10, $args = 1 ) { + require_once BEANS_API_PATH . 'filters/class-beans-anonymous-filters.php'; + return new _Beans_Anonymous_Filters( $hook, $value, $priority, $args ); } diff --git a/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php b/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php new file mode 100644 index 00000000..74cdda14 --- /dev/null +++ b/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php @@ -0,0 +1,60 @@ +assertSame( 'foo', $object->value_to_return ); + + // Clean up. + remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + } + + /** + * Test _beans_add_anonymous_filter() should register callback to the given hook. + */ + public function test_should_register_callback_to_hook() { + $object = _beans_add_anonymous_filter( 'do_foo', false, 20 ); + + $this->assertTrue( has_filter( 'do_foo', array( $object, 'callback' ) ) !== false ); + + // Clean up. + remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + } + + /** + * Test _beans_add_anonymous_filter() should call callback on the given hook. + */ + public function test_should_call_callback() { + foreach ( [ false, 'beans', 19, [ 'foo' ] ] as $value ) { + $object = _beans_add_anonymous_filter( 'beans_test_do_foo', $value, 20 ); + + $this->assertSame( $value, apply_filters( 'beans_test_do_foo', 'foo' ) ); + + // Clean up. + remove_action( 'beans_test_do_foo', array( $object, 'callback' ), 20 ); + } + } +} diff --git a/tests/phpunit/integration/api/filters/beansAddFilter.php b/tests/phpunit/integration/api/filters/beansAddFilter.php new file mode 100644 index 00000000..71ace5f8 --- /dev/null +++ b/tests/phpunit/integration/api/filters/beansAddFilter.php @@ -0,0 +1,77 @@ + $filter ) { + + if ( ! isset( $filter['callback'] ) ) { + continue; + } + + // Test that the filter has not yet been added. + $this->assertFalse( has_filter( $filter['hook'], $filter['callback'] ) ); + + // Let's add it. + $this->assertTrue( beans_add_filter( $filter['hook'], $filter['callback'], $filter['priority'], $filter['args'] ) ); + + // Check that the filter was registered. + $this->assertTrue( has_filter( $filter['hook'], $filter['callback'] ) !== false ); + + // Clean up. + remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); + } + } + + /** + * Test beans_add_filter() should add (register) the "anonymous" filter. + * + * Note: When the callback is not callable, Beans creates an anonymous filter, where the "callback" parameter in + * the filter is actually the "value" that will be returned when the filter fires. + */ + public function test_should_add_anonymous_filter() { + + foreach ( static::$test_filters as $beans_id => $filter ) { + + if ( ! isset( $filter['value_to_return'] ) ) { + continue; + } + + // Let's add it. + $object = beans_add_filter( $filter['hook'], $filter['value_to_return'], $filter['priority'], $filter['args'] ); + + // Check that the value stored in the anonymous callback matches our filter. + $this->assertSame( $filter['value_to_return'], $object->value_to_return ); + + // Check that the filter was registered. + $this->assertTrue( has_filter( $filter['hook'], array( $object, 'callback' ) ) !== false ); + + // Clean up. + remove_filter( $filter['hook'], array( $object, 'callback' ), $filter['priority'] ); + } + } +} diff --git a/tests/phpunit/integration/api/filters/beansApplyFilters.php b/tests/phpunit/integration/api/filters/beansApplyFilters.php new file mode 100644 index 00000000..6c9b3920 --- /dev/null +++ b/tests/phpunit/integration/api/filters/beansApplyFilters.php @@ -0,0 +1,98 @@ +assertSame( 'foo', beans_apply_filters( $filter, 'foo' ) ); + } + } + + /** + * Test beans_apply_filters() should return value after calling one level of sub-hooks. + */ + public function test_should_return_value_after_calling_one_level_of_sub_hooks() { + add_filter( 'beans_loop_query_args', 'beans_loop_query_args_base' ); + add_filter( 'beans_loop_query_args[_main]', 'beans_loop_query_args_main' ); + + $this->assertSame( array( 'base', '_main' ), beans_apply_filters( 'beans_loop_query_args[_main]', 'foo' ) ); + } + + /** + * Test beans_apply_filters() should return value after calling two levels of sub-hooks. + */ + public function test_should_return_value_after_calling_two_levels_of_sub_hooks() { + add_filter( 'beans_loop_query_args', 'beans_loop_query_args_base' ); + add_filter( 'beans_loop_query_args[_main]', 'beans_loop_query_args_main' ); + add_filter( 'beans_loop_query_args[_second]', function( $args ) { + $args[] = '_second'; + return $args; + } ); + add_filter( 'beans_loop_query_args[_main][_second]', function( $args ) { + $args[] = '[_main][_second]'; + return $args; + } ); + + $this->assertSame( + array( 'base', '_main', '_second', '[_main][_second]' ), + beans_apply_filters( 'beans_loop_query_args[_main][_second]', 'foo' ) + ); + } + + /** + * Test beans_apply_filters() should return value after calling three levels of sub-hooks. + */ + public function test_should_return_value_after_calling_three_levels_of_sub_hooks() { + add_filter( 'beans_loop_query_args', 'beans_loop_query_args_base' ); + add_filter( 'beans_loop_query_args[_main]', 'beans_loop_query_args_main' ); + add_filter( 'beans_loop_query_args[_second]', function( $args ) { + $args[] = '_second'; + return $args; + } ); + add_filter( 'beans_loop_query_args[_main][_second]', function( $args ) { + $args[] = '[_main][_second]'; + return $args; + } ); + add_filter( 'beans_loop_query_args[_third]', function( $args ) { + $args[] = '_third'; + return $args; + } ); + add_filter( 'beans_loop_query_args[_main][_second][_third]', function( $args ) { + $args[] = '[_main][_second][_third]'; + return $args; + } ); + + $this->assertSame( + array( 'base', '_main', '_second', '[_main][_second]', '_third', '[_main][_second][_third]' ), + beans_apply_filters( 'beans_loop_query_args[_main][_second][_third]', 'foo' ) + ); + } +} diff --git a/tests/phpunit/integration/api/filters/beansHasFilters.php b/tests/phpunit/integration/api/filters/beansHasFilters.php new file mode 100644 index 00000000..8c75f0b0 --- /dev/null +++ b/tests/phpunit/integration/api/filters/beansHasFilters.php @@ -0,0 +1,57 @@ +assertFalse( beans_has_filters( $filter['hook'], $filter['callback'] ) ); + } + } + + /** + * Test beans_has_filters() should return priority number when a callback is registered. + */ + public function test_should_return_priority_number_when_callback_registered() { + + foreach ( static::$test_filters as $filter ) { + + if ( ! isset( $filter['callback'] ) ) { + continue; + } + + beans_add_filter( $filter['hook'], $filter['callback'], $filter['priority'], $filter['args'] ); + + $this->assertSame( $filter['priority'], beans_has_filters( $filter['hook'], $filter['callback'] ) ); + + remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); + } + } +} diff --git a/tests/phpunit/integration/api/filters/fixtures/test-filters.php b/tests/phpunit/integration/api/filters/fixtures/test-filters.php new file mode 100644 index 00000000..4a415b2b --- /dev/null +++ b/tests/phpunit/integration/api/filters/fixtures/test-filters.php @@ -0,0 +1,41 @@ + array( + 'hook' => 'beans_field_description_markup', + 'value_to_return' => 'p', + 'priority' => 10, + 'args' => 1, + ), + 'beans_widget_content_categories_output' => array( + 'hook' => 'beans_widget_content_categories_output', + 'callback' => 'beans_modify_widget_count', + 'priority' => 10, + 'args' => 1, + ), + 'beans_loop_query_args' => array( + 'hook' => 'beans_loop_query_args', + 'callback' => 'beans_loop_query_args_base', + 'priority' => 20, + 'args' => 1, + ), + 'beans_loop_query_args[_main]' => array( + 'hook' => 'beans_loop_query_args[_main]', + 'callback' => 'beans_loop_query_args_main', + 'priority' => 20, + 'args' => 1, + ), + 'the_content' => array( + 'hook' => 'the_content', + 'callback' => 'beans_test_the_content', + 'priority' => 20, + 'args' => 2, + ), +); diff --git a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php new file mode 100644 index 00000000..383ed76f --- /dev/null +++ b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php @@ -0,0 +1,71 @@ +callbacks[ $filter['priority'] ]; + + $this->assertArrayHasKey( $filter['callback'], $registered_filter ); + $this->assertEquals( $filter['callback'], $registered_filter[ $filter['callback'] ]['function'] ); + $this->assertEquals( $filter['args'], $registered_filter[ $filter['callback'] ]['accepted_args'] ); + + // Then remove the filter. + if ( $remove_filter ) { + remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); + } + } + + /** + * Create a post, load it, and force the "template redirect" to fire. + */ + protected function go_to_post() { + $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); + $this->go_to( get_permalink( $post_id ) ); + do_action( 'template_redirect' ); // @codingStandardsIgnoreLine + } +} diff --git a/tests/phpunit/integration/api/filters/stubs/functions.php b/tests/phpunit/integration/api/filters/stubs/functions.php new file mode 100644 index 00000000..6ccd2a4e --- /dev/null +++ b/tests/phpunit/integration/api/filters/stubs/functions.php @@ -0,0 +1,65 @@ +assertSame( 'foo', $object->value_to_return ); + + // Clean up. + remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + } + + /** + * Test _beans_add_anonymous_filter() should register callback to the given hook. + */ + public function test_should_register_callback_to_hook() { + $object = _beans_add_anonymous_filter( 'do_foo', false, 20 ); + + $this->assertTrue( has_filter( 'do_foo', array( $object, 'callback' ) ) !== false ); + + // Clean up. + remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + } + + /** + * Test _beans_add_anonymous_filter() should call callback on the given hook. + */ + public function test_should_call_callback() { + + foreach ( [ false, 'beans', 19, [ 'foo' ] ] as $value ) { + $object = _beans_add_anonymous_filter( 'beans_test_do_foo', $value, 20 ); + + Filters\expectApplied( 'beans_test_do_foo' ) + ->once() + ->andReturnUsing( function( $arg ) use ( $object, $value ) { + $this->assertSame( 'foo', $arg ); + $this->assertSame( $value, $object->callback() ); + return $object->callback(); + } ); + + $this->assertSame( $value, apply_filters( 'beans_test_do_foo', 'foo' ) ); + + // Clean up. + remove_action( 'beans_test_do_foo', array( $object, 'callback' ), 20 ); + } + } +} diff --git a/tests/phpunit/unit/api/filters/beansAddFilter.php b/tests/phpunit/unit/api/filters/beansAddFilter.php new file mode 100644 index 00000000..4cc56891 --- /dev/null +++ b/tests/phpunit/unit/api/filters/beansAddFilter.php @@ -0,0 +1,74 @@ + $filter ) { + + if ( ! isset( $filter['callback'] ) ) { + continue; + } + + // Test that the filter has not yet been added. + $this->assertFalse( has_filter( $filter['hook'], $filter['callback'] ) ); + + // Let's add it. + $this->assertTrue( beans_add_filter( $filter['hook'], $filter['callback'], $filter['priority'], $filter['args'] ) ); + + // Check that the filter was registered. + $this->assertTrue( has_filter( $filter['hook'], $filter['callback'] ) !== false ); + } + } + + /** + * Test beans_add_filter() should add (register) the "anonymous" filter. + * + * Note: When the callback is not callable, Beans creates an anonymous filter, where the "callback" parameter in + * the filter is actually the "value" that will be returned when the filter fires. + */ + public function test_should_add_anonymous_filter() { + + foreach ( static::$test_filters as $beans_id => $filter ) { + + if ( ! isset( $filter['value_to_return'] ) ) { + continue; + } + + // Let's add it. + $object = beans_add_filter( $filter['hook'], $filter['value_to_return'], $filter['priority'], $filter['args'] ); + + // Check that the value stored in the anonymous callback matches our filter. + $this->assertSame( $filter['value_to_return'], $object->value_to_return ); + + // Check that the filter was registered. + $this->assertTrue( has_filter( $filter['hook'], array( $object, 'callback' ) ) !== false ); + + // Clean up. + remove_filter( $filter['hook'], array( $object, 'callback' ), $filter['priority'] ); + } + } +} diff --git a/tests/phpunit/unit/api/filters/beansApplyFilters.php b/tests/phpunit/unit/api/filters/beansApplyFilters.php new file mode 100644 index 00000000..b923908d --- /dev/null +++ b/tests/phpunit/unit/api/filters/beansApplyFilters.php @@ -0,0 +1,148 @@ +assertSame( 'foo', beans_apply_filters( $filter, 'foo' ) ); + } + } + + /** + * Test beans_apply_filters() should return value after calling one level of sub-hooks. + */ + public function test_should_return_value_after_calling_one_level_of_sub_hooks() { + $filters = array( + 'beans_loop_query_args[_main]' => array( + 'beans_loop_query_args', + 'beans_loop_query_args[_main]', + ), + 'beans_loop_query_args[_foo]' => array( + 'beans_loop_query_args', + 'beans_loop_query_args[_foo]', + ), + 'beans_widgets_area_args[_sidebar_primary]' => array( + 'beans_widgets_area_args', + 'beans_widgets_area_args[_sidebar_primary]', + ), + 'beans_widgets_area_args[_offcanvas_menu]' => array( + 'beans_widgets_area_args', + 'beans_widgets_area_args[_offcanvas_menu]', + ), + ); + + foreach ( $filters as $filter => $events ) { + + // Set up the WordPress simulator for each of the filter events that will fire. + foreach ( $events as $index => $event_name ) { + Monkey\Filters\expectApplied( $events[ $index ] ) + ->once() + ->with( 0 === $index ? 'foo' : $events[ $index - 1 ] ) + ->andReturn( $events[ $index ] ); + } + + $this->assertSame( end( $events ), beans_apply_filters( $filter, 'foo' ) ); + } + } + + /** + * Test beans_apply_filters() should return value after calling two levels of sub-hooks. + */ + public function test_should_return_value_after_calling_two_levels_of_sub_hooks() { + $filters = array( + 'beans_loop_query_args[_first][_second]' => array( + 'beans_loop_query_args', + 'beans_loop_query_args[_first]', + 'beans_loop_query_args[_second]', + 'beans_loop_query_args[_first][_second]', + ), + 'beans_widgets_area_args[_first][_second]' => array( + 'beans_widgets_area_args', + 'beans_widgets_area_args[_first]', + 'beans_widgets_area_args[_second]', + 'beans_widgets_area_args[_first][_second]', + ), + ); + + foreach ( $filters as $filter => $events ) { + + // Set up the WordPress simulator for each of the filter events that will fire. + foreach ( $events as $index => $event_name ) { + Monkey\Filters\expectApplied( $events[ $index ] ) + ->once() + ->with( 0 === $index ? 'bar' : $events[ $index - 1 ] ) + ->andReturn( $events[ $index ] ); + } + + $this->assertSame( end( $events ), beans_apply_filters( $filter, 'bar' ) ); + } + } + + /** + * Test beans_apply_filters() should return value after calling three levels of sub-hooks. + */ + public function test_should_return_value_after_calling_three_levels_of_sub_hooks() { + $filters = array( + 'beans_loop_query_args[_first][_second][_third]' => array( + 'beans_loop_query_args', + 'beans_loop_query_args[_first]', + 'beans_loop_query_args[_second]', + 'beans_loop_query_args[_first][_second]', + 'beans_loop_query_args[_third]', + 'beans_loop_query_args[_first][_second][_third]', + ), + 'beans_widgets_area_args[_first][_second][_third]' => array( + 'beans_widgets_area_args', + 'beans_widgets_area_args[_first]', + 'beans_widgets_area_args[_second]', + 'beans_widgets_area_args[_first][_second]', + 'beans_widgets_area_args[_third]', + 'beans_widgets_area_args[_first][_second][_third]', + ), + ); + + foreach ( $filters as $filter => $events ) { + + // Set up the WordPress simulator for each of the filter events that will fire. + foreach ( $events as $index => $event_name ) { + Monkey\Filters\expectApplied( $events[ $index ] ) + ->once() + ->with( 0 === $index ? 'beans' : $events[ $index - 1 ] ) + ->andReturn( $events[ $index ] ); + } + + $this->assertSame( end( $events ), beans_apply_filters( $filter, 'beans' ) ); + } + } +} diff --git a/tests/phpunit/unit/api/filters/beansHasFilters.php b/tests/phpunit/unit/api/filters/beansHasFilters.php new file mode 100644 index 00000000..7e3ace56 --- /dev/null +++ b/tests/phpunit/unit/api/filters/beansHasFilters.php @@ -0,0 +1,57 @@ +assertFalse( beans_has_filters( $filter['hook'], $filter['callback'] ) ); + } + } + + /** + * Test beans_has_filters() should return priority number when a callback is registered. + */ + public function test_should_return_priority_number_when_callback_registered() { + + foreach ( static::$test_filters as $filter ) { + + if ( ! isset( $filter['callback'] ) ) { + continue; + } + + beans_add_filter( $filter['hook'], $filter['callback'] ); + + $this->assertTrue( beans_has_filters( $filter['hook'], $filter['callback'] ) ); + + remove_filter( $filter['hook'], $filter['callback'] ); + } + } +} diff --git a/tests/phpunit/unit/api/filters/fixtures/test-filters.php b/tests/phpunit/unit/api/filters/fixtures/test-filters.php new file mode 100644 index 00000000..f08aef83 --- /dev/null +++ b/tests/phpunit/unit/api/filters/fixtures/test-filters.php @@ -0,0 +1,41 @@ + array( + 'hook' => 'beans_field_description_markup', + 'value_to_return' => 'p', + 'priority' => 10, + 'args' => 1, + ), + 'beans_widget_content_categories_output' => array( + 'hook' => 'beans_widget_content_categories_output', + 'callback' => 'beans_modify_widget_count', + 'priority' => 10, + 'args' => 1, + ), + 'beans_loop_query_args[_main]' => array( + 'hook' => 'beans_loop_query_args[_main]', + 'callback' => 'beans_loop_query_args_base', + 'priority' => 20, + 'args' => 1, + ), + 'beans_loop_query_args[_main]' => array( + 'hook' => 'beans_loop_query_args[_main]', + 'callback' => 'beans_loop_query_args_main', + 'priority' => 20, + 'args' => 1, + ), + 'the_content' => array( + 'hook' => 'the_content', + 'callback' => 'beans_test_the_content', + 'priority' => 20, + 'args' => 2, + ), +); diff --git a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php new file mode 100644 index 00000000..25ac78d9 --- /dev/null +++ b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php @@ -0,0 +1,57 @@ + $filter ) { + + if ( ! isset( $filter['callback'] ) ) { + continue; + } + + remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); + } + } +} diff --git a/tests/phpunit/unit/api/filters/stubs/functions.php b/tests/phpunit/unit/api/filters/stubs/functions.php new file mode 100644 index 00000000..6ccd2a4e --- /dev/null +++ b/tests/phpunit/unit/api/filters/stubs/functions.php @@ -0,0 +1,65 @@ + Date: Fri, 9 Feb 2018 03:59:15 -0600 Subject: [PATCH 029/800] Improved beans_get tests. --- tests/phpunit/unit/api/utilities/beansGet.php | 91 +++++++++++++++---- 1 file changed, 73 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/unit/api/utilities/beansGet.php b/tests/phpunit/unit/api/utilities/beansGet.php index 5e35574c..ab4327fe 100644 --- a/tests/phpunit/unit/api/utilities/beansGet.php +++ b/tests/phpunit/unit/api/utilities/beansGet.php @@ -30,35 +30,90 @@ protected function setUp() { } /** - * Test beans_get() should return the default value. + * Test beans_get() should find the needle when an array is given. */ - public function test_should_return_default() { - $this->assertEquals( 10, beans_get( 'foo', 'bar', 10 ) ); - $this->assertNull( beans_get( 'foo', array( 'oof' => 'found me' ) ) ); - $this->assertNull( beans_get( 'foo', array( 10, 'bar', 'baz' ) ) ); - $this->assertFalse( beans_get( 'foo', (object) array( 'bar', 'baz' ), false ) ); + public function test_should_find_needle_when_array_given() { + $haystack = array( + 'post_type' => 'foo', + 'number_of_posts' => 5, + ); + + $this->assertSame( $haystack['number_of_posts'], beans_get( 'number_of_posts', $haystack ) ); + $this->assertSame( 'foo', beans_get( 'post_type', $haystack ) ); } /** - * Test beans_get() should find the needle. + * Test beans_get() should return default value when an array is given. */ - public function test_should_find_needle() { - $this->assertEquals( 'bar', beans_get( 0, 'bar', 10 ) ); + public function test_should_return_default_when_array_given() { + $haystack = array( + 'post_type' => 'foo', + 'number_of_posts' => 5, + ); - $data = array( - 'foo' => 'found me', + $this->assertSame( 'published', beans_get( 'post_status', $haystack, 'published' ) ); + $this->assertFalse( beans_get( 'post_status', $haystack, false ) ); + $this->assertNull( beans_get( 'post_status', $haystack ) ); + } + + /** + * Test beans_get() should find the needle when an object is given. + */ + public function test_should_find_needle_when_object_given() { + $haystack = (object) array( + 'post_type' => 'foo', + 'number_of_posts' => 5, + ); + + $this->assertSame( $haystack->number_of_posts, beans_get( 'number_of_posts', $haystack ) ); + $this->assertSame( 'foo', beans_get( 'post_type', $haystack ) ); + } + + /** + * Test beans_get() should return default value when an object is given. + */ + public function test_should_return_default_when_object_given() { + $haystack = (object) array( + 'post_type' => 'foo', + 'number_of_posts' => 5, ); - $this->assertEquals( 'found me', beans_get( 'foo', $data, 10 ) ); - $this->assertEquals( 'found me', beans_get( 'foo', (object) $data, 10 ) ); + + $this->assertSame( 'published', beans_get( 'post_status', $haystack, 'published' ) ); + $this->assertFalse( beans_get( 'post_status', $haystack, false ) ); + $this->assertNull( beans_get( 'post_status', $haystack ) ); + } + + /** + * Test beans_get() should return default value when a literal (hard coded) value is given. + */ + public function test_should_return_default_when_literal_given() { + $this->assertNull( beans_get( 'foo', 'bar' ) ); + $this->assertSame( 'foo', beans_get( 'foo', 10, 'foo' ) ); + $this->assertFalse( beans_get( 10, 'Testing is fun!', false ) ); + } + + /** + * Test beans_get() should find the needle when the array's index is given. + */ + public function test_should_find_needle_when_index_given() { + $this->assertEquals( 'bar', beans_get( 0, 'bar', 10 ) ); $data = array( - 'baz' => 'zab', - 'rab' => 'bar', 'red', + 'white', + 'foo' => 'baz', + 'green', ); $this->assertEquals( 'red', beans_get( 0, $data ) ); - $this->assertEquals( 'zab', beans_get( 'baz', $data ) ); - $this->assertEquals( 'red', beans_get( 0, (object) $data ) ); - $this->assertEquals( 'zab', beans_get( 'baz', (object) $data ) ); + $this->assertEquals( 'white', beans_get( 1, $data ) ); + $this->assertEquals( 'green', beans_get( 2, $data ) ); + } + + /** + * Test beans_get() should return the value from the $_GET superglobal. + */ + public function test_should_get_value_from_get_superglobal() { + $_GET['beans'] = 'Testing is fun!'; + $this->assertSame( 'Testing is fun!', beans_get( 'beans' ) ); } } From eb9f5a83b84e7fec1e004dff53d2a06d9db6db19 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Fri, 9 Feb 2018 04:00:58 -0600 Subject: [PATCH 030/800] Tests Bootstrap improvements * Improved tests bootstraps. 1. Corrected/added @group 2. Switched die() to trigger_error() for consistency. 3. Changes BEANS_ROOT_DIR to BEANS_THEME_DIR for consistency. 4. Abstracted the task of finding the WP tests dir into a function in integration bootstrap to improve readability. 5. Stripped off the trailing directory separator, if it exists. * Fixed Tests PSR mapping. * Added color to the test scripts. Why? It forces the color for setups that do not work with the color parameter in the XML file. * Made file loads consistent. * Removed extra directory separator for registering theme directory. * Improved error messages & comments. * Removed unnecessary check that the constant is defined. --- composer.json | 7 +-- tests/phpunit/integration/bootstrap.php | 54 ++++++++++++------- .../unit/api/utilities/beansPathToUrl.php | 2 +- .../unit/api/utilities/beansSanitizePath.php | 8 +-- tests/phpunit/unit/bootstrap.php | 14 ++--- 5 files changed, 53 insertions(+), 32 deletions(-) diff --git a/composer.json b/composer.json index a2a96abb..bebdc6db 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ }, "autoload-dev": { "psr-4": { - "Beans\\Framework\\Tests\\": "tests/" + "Beans\\Framework\\Tests\\Unit\\": "tests/phpunit/unit/", + "Beans\\Framework\\Tests\\Integration\\": "tests/phpunit/integration/" } }, "repositories": [ @@ -62,7 +63,7 @@ "@phpcs-src", "@phpcs-tests" ], - "test-unit": "\"vendor/bin/phpunit\" --testsuite unit", - "test-integration": "\"vendor/bin/phpunit\" --testsuite integration --configuration tests/phpunit/integration/phpunit.xml.dist" + "test-unit": "\"vendor/bin/phpunit\" --testsuite unit --color=always", + "test-integration": "\"vendor/bin/phpunit\" --testsuite integration --configuration tests/phpunit/integration/phpunit.xml.dist --color=always" } } diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index b842cdd3..b600ebd2 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -7,46 +7,64 @@ * @link http://www.getbeans.io * @license GNU-2.0+ * - * @group integrationtests + * @group integration-tests */ if ( ! file_exists( '../../../wp-content' ) ) { - return; + trigger_error( 'Unable to run the integration tests, because the wp-content folder does not exist.', E_USER_ERROR ); // @codingStandardsIgnoreLine. } +define( 'BEANS_TESTS_DIR', __DIR__ ); define( 'BEANS_THEME_DIR', dirname( dirname( dirname( __DIR__ ) ) ) ); define( 'WP_CONTENT_DIR', dirname( dirname( dirname( getcwd() ) ) ) . '/wp-content/' ); // @codingStandardsIgnoreLine. -if ( defined( 'WP_CONTENT_DIR' ) && ! defined( 'WP_PLUGIN_DIR' ) ) { +if ( ! defined( 'WP_PLUGIN_DIR' ) ) { define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . 'plugins/' ); // @codingStandardsIgnoreLine. } -$beans_tests_dir = getenv( 'WP_TESTS_DIR' ); +/** + * Get the WordPress' tests suite directory. + * + * @since 1.5.0 + * + * @return string + */ +function beans_get_wp_tests_dir() { + $tests_dir = getenv( 'WP_TESTS_DIR' ); -// Travis CI & Vagrant SSH tests directory. -if ( empty( $beans_tests_dir ) ) { - $beans_tests_dir = '/tmp/wordpress-tests'; -} + // Travis CI & Vagrant SSH tests directory. + if ( empty( $tests_dir ) ) { + $tests_dir = '/tmp/wordpress-tests'; + } -// Relative path to Core tests directory. -if ( ! file_exists( $beans_tests_dir . '/includes/' ) ) { - $beans_tests_dir = '../../../../tests/phpunit'; -} + // If the tests' includes directory does not exist, try a relative path to the Core tests directory. + if ( ! file_exists( $tests_dir . '/includes/' ) ) { + $tests_dir = '../../../../tests/phpunit'; + } -if ( ! file_exists( $beans_tests_dir . '/includes/' ) ) { - trigger_error( 'Unable to locate wordpress-tests-lib', E_USER_ERROR ); // @codingStandardsIgnoreLine. + // Check it again. If it doesn't exist, stop here and post a message as to why we stopped. + if ( ! file_exists( $tests_dir . '/includes/' ) ) { + trigger_error( 'Unable to run the integration tests, because the WordPress test suite could not be located.', E_USER_ERROR ); // @codingStandardsIgnoreLine. + } + + // Strip off the trailing directory separator, if it exists. + return rtrim( $tests_dir, DIRECTORY_SEPARATOR ); } +// Find the WP tests suite directory. +$beans_tests_dir = beans_get_wp_tests_dir(); + // Give access to tests_add_filter() function. -require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php'; +require_once $beans_tests_dir . '/includes/functions.php'; /** - * Loads theme. + * Register with "setup_theme" in the WP tests suite to set the themes directory + * and load the Beans framework. */ tests_add_filter( 'setup_theme', function() { - register_theme_directory( WP_CONTENT_DIR . '/themes' ); + register_theme_directory( WP_CONTENT_DIR . 'themes' ); switch_theme( basename( BEANS_THEME_DIR ) ); } ); // Start up the WP testing environment. -require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php'; +require_once $beans_tests_dir . '/includes/bootstrap.php'; diff --git a/tests/phpunit/unit/api/utilities/beansPathToUrl.php b/tests/phpunit/unit/api/utilities/beansPathToUrl.php index 0563f8b5..3b507ef8 100644 --- a/tests/phpunit/unit/api/utilities/beansPathToUrl.php +++ b/tests/phpunit/unit/api/utilities/beansPathToUrl.php @@ -46,7 +46,7 @@ protected function setUp() { if ( ! $this->beans_relative_path ) { $abspath = rtrim( ABSPATH, '/' ); $this->beans_relative_path = wp_normalize_path( - rtrim( str_replace( $abspath, '', BEANS_ROOT_DIR ), DIRECTORY_SEPARATOR ) + rtrim( str_replace( $abspath, '', BEANS_THEME_DIR ), DIRECTORY_SEPARATOR ) ); $this->beans_tests_relative_path = wp_normalize_path( str_replace( $abspath, '', BEANS_TESTS_DIR ) diff --git a/tests/phpunit/unit/api/utilities/beansSanitizePath.php b/tests/phpunit/unit/api/utilities/beansSanitizePath.php index 05a139b0..caf2a509 100644 --- a/tests/phpunit/unit/api/utilities/beansSanitizePath.php +++ b/tests/phpunit/unit/api/utilities/beansSanitizePath.php @@ -53,13 +53,13 @@ public function test_should_sanitize_for_filesystem() { // Test Beans' theme root path. $this->assertSame( - $this->prepare_path( rtrim( BEANS_ROOT_DIR, DIRECTORY_SEPARATOR ) ), - beans_sanitize_path( BEANS_ROOT_DIR ) + $this->prepare_path( rtrim( BEANS_THEME_DIR, DIRECTORY_SEPARATOR ) ), + beans_sanitize_path( BEANS_THEME_DIR ) ); $directory_separator = '\\' === DIRECTORY_SEPARATOR ? '/' : ''; $this->assertSame( - $this->prepare_path( BEANS_ROOT_DIR ) . $directory_separator . 'functions.php', - beans_sanitize_path( BEANS_ROOT_DIR . 'functions.php' ) + $this->prepare_path( BEANS_THEME_DIR ) . $directory_separator . 'functions.php', + beans_sanitize_path( BEANS_THEME_DIR . 'functions.php' ) ); } diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index 7ccef788..00451ab8 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -6,26 +6,28 @@ * @since 1.5.0 * @link http://www.getbeans.io * @license GNU-2.0+ + * + * @group unit-tests */ if ( version_compare( phpversion(), '5.6.0', '<' ) ) { - die( 'Beans Unit Tests require PHP 5.6 or higher.' ); + trigger_error( 'Beans Unit Tests require PHP 5.6 or higher.', E_USER_ERROR ); // @codingStandardsIgnoreLine. } define( 'BEANS_TESTS_DIR', __DIR__ ); -define( 'BEANS_ROOT_DIR', dirname( dirname( dirname( __DIR__ ) ) ) . DIRECTORY_SEPARATOR ); -define( 'BEANS_TESTS_LIB_DIR', BEANS_ROOT_DIR . 'lib' . DIRECTORY_SEPARATOR ); +define( 'BEANS_THEME_DIR', dirname( dirname( dirname( __DIR__ ) ) ) . DIRECTORY_SEPARATOR ); +define( 'BEANS_TESTS_LIB_DIR', BEANS_THEME_DIR . 'lib' . DIRECTORY_SEPARATOR ); // Let's define ABSPATH as it is in WordPress, i.e. relative to the filesystem's WordPress root path. if ( ! defined( 'ABSPATH' ) ) { - define( 'ABSPATH', dirname( dirname( dirname( BEANS_ROOT_DIR ) ) ) . '/' ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - ABSPATH is required. + define( 'ABSPATH', dirname( dirname( dirname( BEANS_THEME_DIR ) ) ) . '/' ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - ABSPATH is required. } // Time to load Composer's autoloader. -$beans_autoload_path = BEANS_ROOT_DIR . 'vendor/'; +$beans_autoload_path = BEANS_THEME_DIR . 'vendor/'; if ( ! file_exists( $beans_autoload_path . 'autoload.php' ) ) { - die( 'Whoops, we need Composer before we start running tests. Please type: `composer install`. When done, try running `phpunit` again.' ); + trigger_error( 'Whoops, we need Composer before we start running tests. Please type: `composer install`. When done, try running `phpunit` again.', E_USER_ERROR ); // @codingStandardsIgnoreLine. } require_once $beans_autoload_path . 'autoload.php'; unset( $beans_autoload_path ); From 1f99939f70d83b7b33063cd9297023f84bf83061 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 11:30:59 -0600 Subject: [PATCH 031/800] Fixed 112. Removed encoding/decoding actions being stored in the container. See issue #112 for more information. --- lib/api/actions/functions.php | 4 ++-- .../unit/api/actions/beansGetAction.php | 8 ++++---- .../unit/api/actions/beansGetCurrentAction.php | 18 +++++++++--------- .../unit/api/actions/beansMergeAction.php | 6 ++---- .../unit/api/actions/beansSetAction.php | 10 ++++------ 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index c2690f3f..6e18150b 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -464,7 +464,7 @@ function _beans_get_action( $id, $status ) { return false; } - return (array) json_decode( $action ); + return $action; } /** @@ -499,7 +499,7 @@ function _beans_set_action( $id, $action, $status, $overwrite = false ) { // Let's set (or overwrite) the action. global $_beans_registered_actions; - $_beans_registered_actions[ $status ][ $id ] = wp_json_encode( $action ); + $_beans_registered_actions[ $status ][ $id ] = $action; return $action; } diff --git a/tests/phpunit/unit/api/actions/beansGetAction.php b/tests/phpunit/unit/api/actions/beansGetAction.php index 022d8457..e11ac2ac 100644 --- a/tests/phpunit/unit/api/actions/beansGetAction.php +++ b/tests/phpunit/unit/api/actions/beansGetAction.php @@ -53,7 +53,7 @@ public function test_should_return_added_action() { foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. - $_beans_registered_actions['added'][ $beans_id ] = wp_json_encode( $action ); + $_beans_registered_actions['added'][ $beans_id ] = $action; // Test that we get the "added" action. $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); @@ -73,7 +73,7 @@ public function test_should_return_modified_action() { foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. - $_beans_registered_actions['modified'][ $beans_id ] = wp_json_encode( $action ); + $_beans_registered_actions['modified'][ $beans_id ] = $action; // Test that we get the "modified" action. $this->assertSame( $action, _beans_get_action( $beans_id, 'modified' ) ); @@ -93,7 +93,7 @@ public function test_should_return_removed_action() { foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. - $_beans_registered_actions['removed'][ $beans_id ] = wp_json_encode( $action ); + $_beans_registered_actions['removed'][ $beans_id ] = $action; // Test that we get the "removed" action. $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); @@ -113,7 +113,7 @@ public function test_should_return_replaced_action() { foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. - $_beans_registered_actions['replaced'][ $beans_id ] = wp_json_encode( $action ); + $_beans_registered_actions['replaced'][ $beans_id ] = $action; // Test that we get the "replaced" action. $this->assertSame( $action, _beans_get_action( $beans_id, 'replaced' ) ); diff --git a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php index af6ea11e..008134be 100644 --- a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php @@ -30,7 +30,7 @@ public function test_should_return_false_when_removed_status() { foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. - $_beans_registered_actions['removed'][ $beans_id ] = wp_json_encode( $action ); + $_beans_registered_actions['removed'][ $beans_id ] = $action; // Test that it returns false. $this->assertFalse( _beans_get_current_action( $beans_id ) ); @@ -44,18 +44,18 @@ public function test_should_return_false_when_action_is_invalid() { global $_beans_registered_actions; // Test "added" status. - $_beans_registered_actions['added']['foo'] = wp_json_encode( array( 'hook' => 'foo' ) ); + $_beans_registered_actions['added']['foo'] = array( 'hook' => 'foo' ); $this->assertFalse( _beans_get_current_action( 'foo' ) ); // Test "modified" status. - $_beans_registered_actions['modified']['bar'] = wp_json_encode( array( + $_beans_registered_actions['modified']['bar'] = array( 'hook' => 'bar', 'priority' => 1, - ) ); + ); $this->assertFalse( _beans_get_current_action( 'bar' ) ); // Test merging "modified" into "added" status. - $_beans_registered_actions['modified']['foo'] = wp_json_encode( array( 'callback' => 'foo_cb' ) ); + $_beans_registered_actions['modified']['foo'] = array( 'callback' => 'foo_cb' ); $this->assertFalse( _beans_get_current_action( 'foo' ) ); } @@ -67,7 +67,7 @@ public function test_should_return_added_action() { foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. - $_beans_registered_actions['added'][ $beans_id ] = wp_json_encode( $action ); + $_beans_registered_actions['added'][ $beans_id ] = $action; // Test that we get the "added" action. $this->assertSame( $action, _beans_get_current_action( $beans_id ) ); @@ -82,7 +82,7 @@ public function test_should_return_modified_action() { foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. - $_beans_registered_actions['modified'][ $beans_id ] = wp_json_encode( $action ); + $_beans_registered_actions['modified'][ $beans_id ] = $action; // Test that we get the "modified" action. $this->assertSame( $action, _beans_get_current_action( $beans_id ) ); @@ -103,8 +103,8 @@ public function test_should_return_merged_added_and_modified() { foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. - $_beans_registered_actions['added'][ $beans_id ] = wp_json_encode( $action ); - $_beans_registered_actions['modified'][ $beans_id ] = wp_json_encode( $modified_action ); + $_beans_registered_actions['added'][ $beans_id ] = $action; + $_beans_registered_actions['modified'][ $beans_id ] = $modified_action; // Test that it merges the action. $this->assertSame( diff --git a/tests/phpunit/unit/api/actions/beansMergeAction.php b/tests/phpunit/unit/api/actions/beansMergeAction.php index 97332482..228796d1 100644 --- a/tests/phpunit/unit/api/actions/beansMergeAction.php +++ b/tests/phpunit/unit/api/actions/beansMergeAction.php @@ -40,12 +40,11 @@ public function test_should_merge_and_return() { ); foreach ( static::$test_actions as $beans_id => $action ) { - $encoded_action = wp_json_encode( $action ); $merged_action = array_merge( $action, $modified_action ); // Test each status. foreach ( $this->statuses as $status ) { - $_beans_registered_actions[ $status ][ $beans_id ] = $encoded_action; + $_beans_registered_actions[ $status ][ $beans_id ] = $action; $this->assertSame( $merged_action, _beans_merge_action( $beans_id, $modified_action, $status ) ); } } @@ -58,12 +57,11 @@ public function test_should_store_new_action() { global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { - $encoded_action = wp_json_encode( $action ); // Test each status. foreach ( $this->statuses as $status ) { $this->assertSame( $action, _beans_merge_action( $beans_id, $action, $status ) ); - $this->assertSame( $encoded_action, $_beans_registered_actions[ $status ][ $beans_id ] ); + $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); } } } diff --git a/tests/phpunit/unit/api/actions/beansSetAction.php b/tests/phpunit/unit/api/actions/beansSetAction.php index 745c91f3..10e01392 100644 --- a/tests/phpunit/unit/api/actions/beansSetAction.php +++ b/tests/phpunit/unit/api/actions/beansSetAction.php @@ -36,7 +36,6 @@ public function test_should_set_and_return_action() { global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { - $encoded_action = wp_json_encode( $action ); // Test each status. foreach ( $this->statuses as $status ) { @@ -46,7 +45,7 @@ public function test_should_set_and_return_action() { // Now do the tests. $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); $this->assertArrayHasKey( $beans_id, $_beans_registered_actions[ $status ] ); - $this->assertSame( $encoded_action, $_beans_registered_actions[ $status ][ $beans_id ] ); + $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); } } } @@ -65,7 +64,6 @@ public function test_should_not_overwrite_existing_registered_action() { ); foreach ( static::$test_actions as $beans_id => $action ) { - $encoded_action = wp_json_encode( $action ); // Test each status. foreach ( $this->statuses as $status ) { @@ -74,7 +72,7 @@ public function test_should_not_overwrite_existing_registered_action() { // Now test that it does not overwrite the previously registered action. $this->assertSame( $action, _beans_set_action( $beans_id, $new_action, $status ) ); - $this->assertSame( $encoded_action, $_beans_registered_actions[ $status ][ $beans_id ] ); + $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); } } } @@ -92,7 +90,6 @@ public function test_should_overwrite_existing_registered_action() { 'priority' => 20, 'args' => 2, ); - $encoded_new_action = wp_json_encode( $new_action ); foreach ( static::$test_actions as $beans_id => $action ) { @@ -100,10 +97,11 @@ public function test_should_overwrite_existing_registered_action() { foreach ( $this->statuses as $status ) { // Register the original action. $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); + $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); // Now test that it does overwrite the previously registered action. $this->assertSame( $new_action, _beans_set_action( $beans_id, $new_action, $status, true ) ); - $this->assertSame( $encoded_new_action, $_beans_registered_actions[ $status ][ $beans_id ] ); + $this->assertSame( $new_action, $_beans_registered_actions[ $status ][ $beans_id ] ); } } } From d99b059bc391437c109d2fa6f6367e9edd0e91a9 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 11:59:12 -0600 Subject: [PATCH 032/800] Optimized _beans_set_action. 1. If we are not overwriting the action, then go get the registered action and do the check. 2. Only store in the container IF the action is not empty or the status is "removed". --- lib/api/actions/functions.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 6e18150b..afb91f76 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -489,17 +489,21 @@ function _beans_get_action( $id, $status ) { function _beans_set_action( $id, $action, $status, $overwrite = false ) { $id = _beans_unique_action_id( $id ); - // Get the action, if it's already registered. - $registered_action = _beans_get_action( $id, $status ); - - // If the action is registered and we are not overwriting, return it. - if ( true !== $overwrite && ! empty( $registered_action ) ) { - return $registered_action; + // If not overwriting, let's check if an action is already registered for that id. + if ( ! $overwrite ) { + // Get the action, if it's already registered. + $registered_action = _beans_get_action( $id, $status ); + + // If yes, return the registered action. + if ( ! empty( $registered_action ) ) { + return $registered_action; + } } - // Let's set (or overwrite) the action. - global $_beans_registered_actions; - $_beans_registered_actions[ $status ][ $id ] = $action; + if ( ! empty( $action ) || 'removed' === $status ) { + global $_beans_registered_actions; + $_beans_registered_actions[ $status ][ $id ] = $action; + } return $action; } From dabff920f7dd36d7f50408a9a2ba601ffcc2dfe5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 12:04:01 -0600 Subject: [PATCH 033/800] Standardized action check to use "empty()". --- lib/api/actions/functions.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index afb91f76..d316764a 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -42,7 +42,7 @@ function beans_add_action( $id, $hook, $callback, $priority = 10, $args = 1 ) { $replaced_action = _beans_get_action( $id, 'replaced' ); // If the ID is set to be "replaced", then replace that(those) parameter(s). - if ( ! empty( $replaced_action ) && is_array( $replaced_action ) ) { + if ( ! empty( $replaced_action ) ) { $action = array_merge( $action, $replaced_action ); } @@ -56,7 +56,7 @@ function beans_add_action( $id, $hook, $callback, $priority = 10, $args = 1 ) { $modified_action = _beans_get_action( $id, 'modified' ); // If the ID is set to be "modified", then modify that(those) parameter(s). - if ( ! empty( $modified_action ) && is_array( $modified_action ) ) { + if ( ! empty( $modified_action ) ) { $action = array_merge( $action, $modified_action ); } @@ -122,11 +122,10 @@ function beans_modify_action( $id, $hook = null, $callback = null, $priority = n return false; } - $current_action = _beans_get_current_action( $id ); - $has_current_action = ! empty( $current_action ) && is_array( $current_action ); + $current_action = _beans_get_current_action( $id ); // If the action is registered, let's remove it. - if ( $has_current_action ) { + if ( ! empty( $current_action ) ) { remove_action( $current_action['hook'], $current_action['callback'], $current_action['priority'], $current_action['args'] ); } @@ -134,7 +133,7 @@ function beans_modify_action( $id, $hook = null, $callback = null, $priority = n $action = _beans_merge_action( $id, $action, 'modified' ); // If there is no action to modify, bail out. - if ( ! $has_current_action ) { + if ( empty( $current_action ) ) { return false; } @@ -555,7 +554,7 @@ function _beans_merge_action( $id, array $action, $status ) { $registered_action = _beans_get_action( $id, $status ); // If the action's configuration is already registered with Beans, merge the new configuration with it. - if ( false !== $registered_action ) { + if ( ! empty( $registered_action ) ) { $action = array_merge( $registered_action, $action ); } @@ -585,13 +584,13 @@ function _beans_get_current_action( $id ) { $added = _beans_get_action( $id, 'added' ); - if ( false !== $added ) { + if ( ! empty( $added ) ) { $action = $added; } $modified = _beans_get_action( $id, 'modified' ); - if ( false !== $modified ) { + if ( ! empty( $modified ) ) { $action = is_array( $action ) ? array_merge( $action, $modified ) : $modified; @@ -618,6 +617,7 @@ function _beans_get_current_action( $id ) { * @return bool */ function _beans_is_action_valid( $action ) { + if ( empty( $action ) ) { return false; } From 23ca789b67fb6cb59c08400ec619d90cf35fc6e5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 12:08:44 -0600 Subject: [PATCH 034/800] Removed passing args to remove_action in beans_remove_action --- lib/api/actions/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index d316764a..4b461f33 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -369,7 +369,7 @@ function beans_remove_action( $id ) { // When there is a current action, remove it. if ( _beans_is_action_valid( $action ) ) { - remove_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + remove_action( $action['hook'], $action['callback'], $action['priority'] ); } // Store as "removed". From fbb56bb0a62357f144b9e586e7bbe78f5c0bb2c0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 12:19:14 -0600 Subject: [PATCH 035/800] Optimized _beans_get_current_action. Changed the function: It is highly unlikely that we would modify all 4 of the action parameters. Therefore, using that assumption, we do not need to get or merge the "modified" action WHEN there is no "added" action. Optimizations: 1. Bails out if there is no "added" action. 2. Returns the merged added + modified action instead of assigning it to a variable and then returning it later. --- lib/api/actions/functions.php | 19 ++++------- .../api/actions/beansGetCurrentAction.php | 32 ++++--------------- 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 4b461f33..490edf74 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -580,28 +580,21 @@ function _beans_get_current_action( $id ) { return false; } - $action = array(); - $added = _beans_get_action( $id, 'added' ); - if ( ! empty( $added ) ) { - $action = $added; + // If there is not "added" action registered, bail out. + if ( empty( $added ) ) { + return false; } $modified = _beans_get_action( $id, 'modified' ); + // If the action is set to be modified, merge the changes and return the action. if ( ! empty( $modified ) ) { - $action = is_array( $action ) - ? array_merge( $action, $modified ) - : $modified; - } - - // Stop here if the action is invalid. - if ( ! _beans_is_action_valid( $action ) ) { - return false; + return array_merge( $added, $modified ); } - return $action; + return $added; } /** diff --git a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php index 008134be..fda5b0d7 100644 --- a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php @@ -37,28 +37,6 @@ public function test_should_return_false_when_removed_status() { } } - /** - * Test _beans_get_current_action() should return false when the action is invalid. - */ - public function test_should_return_false_when_action_is_invalid() { - global $_beans_registered_actions; - - // Test "added" status. - $_beans_registered_actions['added']['foo'] = array( 'hook' => 'foo' ); - $this->assertFalse( _beans_get_current_action( 'foo' ) ); - - // Test "modified" status. - $_beans_registered_actions['modified']['bar'] = array( - 'hook' => 'bar', - 'priority' => 1, - ); - $this->assertFalse( _beans_get_current_action( 'bar' ) ); - - // Test merging "modified" into "added" status. - $_beans_registered_actions['modified']['foo'] = array( 'callback' => 'foo_cb' ); - $this->assertFalse( _beans_get_current_action( 'foo' ) ); - } - /** * Test _beans_get_current_action() should return the "added" action. */ @@ -75,17 +53,19 @@ public function test_should_return_added_action() { } /** - * Test _beans_get_current_action() should return the "modified" action. + * Test _beans_get_current_action() should return false when there's a "modified" action but no "added" action. */ - public function test_should_return_modified_action() { + public function test_should_return_false_when_modified_but_no_added() { global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. $_beans_registered_actions['modified'][ $beans_id ] = $action; - // Test that we get the "modified" action. - $this->assertSame( $action, _beans_get_current_action( $beans_id ) ); + // Run the tests. + $this->assertFalse( _beans_get_current_action( $beans_id ) ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['added'] ); + $this->assertSame( $action, $_beans_registered_actions['modified'][ $beans_id ] ); } } From 52681ee3860dc9dc0de38cfc5b869d3d1b784f82 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 12:29:01 -0600 Subject: [PATCH 036/800] Optimized beans_reset_action. Both the "added" and "current" actions will contain all 4 parameters (else we do not store them in the container). Therefore, we can eliminate the isset checks and use empty. --- lib/api/actions/functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 490edf74..54168ac5 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -398,15 +398,15 @@ function beans_reset_action( $id ) { $action = _beans_get_action( $id, 'added' ); - // Bail out if there is no action. - if ( ! _beans_is_action_valid( $action ) ) { + // If there is no "added" action, bail out. + if ( empty( $action ) ) { return false; } $current = _beans_get_current_action( $id ); - // Return the action if there is no current action. - if ( ! _beans_is_action_valid( $current ) ) { + // If there's no current action, return the "added" action. + if ( empty( $current ) ) { return $action; } From ef7f144485d6c57d465933d7b040adf3d37bf4ce Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 12:31:02 -0600 Subject: [PATCH 037/800] Removed passing args to "remove_action". --- lib/api/actions/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 54168ac5..46ed1c74 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -126,7 +126,7 @@ function beans_modify_action( $id, $hook = null, $callback = null, $priority = n // If the action is registered, let's remove it. if ( ! empty( $current_action ) ) { - remove_action( $current_action['hook'], $current_action['callback'], $current_action['priority'], $current_action['args'] ); + remove_action( $current_action['hook'], $current_action['callback'], $current_action['priority'] ); } // Merge the modified parameters and register with Beans. @@ -410,7 +410,7 @@ function beans_reset_action( $id ) { return $action; } - remove_action( $current['hook'], $current['callback'], $current['priority'], $current['args'] ); + remove_action( $current['hook'], $current['callback'], $current['priority'] ); add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); return $action; From a5b2e77f825b1d9b3dfa143595d01d5a86548d11 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 12:40:26 -0600 Subject: [PATCH 038/800] Optimized beans_add_action. As we are assigning the values to the right keys, we will not limit someone from assigning "null" to any of the parameters. Instead, we will rely on the developer to know how to add an action. Shifting that design approach allows us to remove the _beans_is_action_valid check at the end of the function. --- lib/api/actions/functions.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 46ed1c74..dde80906 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -60,11 +60,6 @@ function beans_add_action( $id, $hook, $callback, $priority = 10, $args = 1 ) { $action = array_merge( $action, $modified_action ); } - // Bail out if it's not a valid action. - if ( ! _beans_is_action_valid( $action ) ) { - return false; - } - return add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } From 62ab69bec0794a801423485b2cb24d42b1eaff40 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 12:45:12 -0600 Subject: [PATCH 039/800] Optimized beans_remove_action. _beans_get_current_action will return false or a full action with all the required parameters. Therefore, we can simply check that it is not empty to do the remove_action. This change removes the _beans_is_action_valid check and all of the isset checks for each of the action parameters. It now runs 0.005ms faster than Beans 1.4.0. --- lib/api/actions/functions.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index dde80906..92ca31ec 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -352,8 +352,11 @@ function beans_replace_action_arguments( $id, $args ) { function beans_remove_action( $id ) { $action = _beans_get_current_action( $id ); - // If the action is not registered yet, set it to a default configuration. - if ( empty( $action ) ) { + // When there is a current action, remove it. + if ( ! empty( $action ) ) { + remove_action( $action['hook'], $action['callback'], $action['priority'] ); + } else { + // If the action is not registered yet, set it to a default configuration. $action = array( 'hook' => null, 'callback' => null, @@ -362,11 +365,6 @@ function beans_remove_action( $id ) { ); } - // When there is a current action, remove it. - if ( _beans_is_action_valid( $action ) ) { - remove_action( $action['hook'], $action['callback'], $action['priority'] ); - } - // Store as "removed". return _beans_set_action( $id, $action, 'removed' ); } From 7864b0a58c8a7f5303ba8bcc0fb50676c2e86b92 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 12:56:50 -0600 Subject: [PATCH 040/800] Removed _beans_is_action_valid function. --- lib/api/actions/functions.php | 25 ---- .../unit/api/actions/beansIsActionValid.php | 122 ------------------ 2 files changed, 147 deletions(-) delete mode 100644 tests/phpunit/unit/api/actions/beansIsActionValid.php diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 92ca31ec..651393aa 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -590,31 +590,6 @@ function _beans_get_current_action( $id ) { return $added; } -/** - * Validates the action's configuration to ensure "hook", "callback", "priority", and "args" are - * set and not null. - * - * @since 1.5.0 - * @ignore - * @access private - * - * @param array|mixed $action Action's configuration. - * - * @return bool - */ -function _beans_is_action_valid( $action ) { - - if ( empty( $action ) ) { - return false; - } - - if ( ! is_array( $action ) ) { - return; - } - - return isset( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); -} - /** * Build the action's array for only the valid given arguments. * diff --git a/tests/phpunit/unit/api/actions/beansIsActionValid.php b/tests/phpunit/unit/api/actions/beansIsActionValid.php deleted file mode 100644 index b4ffbea3..00000000 --- a/tests/phpunit/unit/api/actions/beansIsActionValid.php +++ /dev/null @@ -1,122 +0,0 @@ -assertFalse( _beans_is_action_valid( array( 'hook' => 'foo' ) ) ); - $this->assertFalse( _beans_is_action_valid( array( 'callback' => 'cb' ) ) ); - - $this->assertFalse( _beans_is_action_valid( array( - 'hook' => 'foo', - 'callback' => 'cb', - ) ) ); - - $this->assertFalse( _beans_is_action_valid( array( - 'hook' => 'foo', - 'callback' => 'cb', - 'priority' => 10, - ) ) ); - - $this->assertFalse( _beans_is_action_valid( array( - 'hook' => 'foo', - 'callback' => 'cb', - 'args' => 2, - ) ) ); - - $this->assertFalse( _beans_is_action_valid( array( - 'hook' => 'foo', - 'priority' => 10, - 'args' => 2, - ) ) ); - - $this->assertFalse( _beans_is_action_valid( array( - 'callback' => 'cb', - 'priority' => 10, - 'args' => 2, - ) ) ); - - $this->assertFalse( _beans_is_action_valid( array( - 'callback' => 'cb', - 'priority' => 10, - 'args' => 2, - 'foo' => 'bar', - ) ) ); - } - - /** - * Test _beans_is_action_valid() should return false when one or more of the required parameters is set to null. - */ - public function test_should_return_false_when_parameter_is_null() { - $this->assertFalse( _beans_is_action_valid( array( - 'hook' => 'foo', - 'callback' => null, - 'priority' => 10, - 'args' => 2, - ) ) ); - } - - /** - * Test _beans_is_action_valid() should return true when the action's configuration is valid. - */ - public function test_should_return_true_when_action_is_valid() { - $this->assertTrue( _beans_is_action_valid( array( - 'hook' => 'foo', - 'callback' => 'cb', - 'priority' => 10, - 'args' => 2, - ) ) ); - - $this->assertTrue( _beans_is_action_valid( array( - 'hook' => 'start_loop', - 'callback' => 'foo_callback', - 'priority' => 20, - 'args' => 1, - ) ) ); - - $object = new \stdClass(); - $this->assertTrue( _beans_is_action_valid( array( - 'hook' => 'some_hook[_some_subhook]', - 'callback' => [ $object, 'callback_method' ], - 'priority' => 10, - 'args' => 2, - ) ) ); - - $this->assertTrue( _beans_is_action_valid( array( - 'hook' => 'post_title', - 'callback' => 'Some_Object::some_method', - 'priority' => 50, - 'args' => 3, - ) ) ); - } -} From a27aa96517fe253d5ec770f39b9f679b67965ebf Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 12:58:23 -0600 Subject: [PATCH 041/800] Fixed formatting. --- tests/phpunit/unit/api/actions/beansMergeAction.php | 2 +- tests/phpunit/unit/api/actions/beansSetAction.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansMergeAction.php b/tests/phpunit/unit/api/actions/beansMergeAction.php index 228796d1..6f06d338 100644 --- a/tests/phpunit/unit/api/actions/beansMergeAction.php +++ b/tests/phpunit/unit/api/actions/beansMergeAction.php @@ -40,7 +40,7 @@ public function test_should_merge_and_return() { ); foreach ( static::$test_actions as $beans_id => $action ) { - $merged_action = array_merge( $action, $modified_action ); + $merged_action = array_merge( $action, $modified_action ); // Test each status. foreach ( $this->statuses as $status ) { diff --git a/tests/phpunit/unit/api/actions/beansSetAction.php b/tests/phpunit/unit/api/actions/beansSetAction.php index 10e01392..71328f9c 100644 --- a/tests/phpunit/unit/api/actions/beansSetAction.php +++ b/tests/phpunit/unit/api/actions/beansSetAction.php @@ -84,7 +84,7 @@ public function test_should_not_overwrite_existing_registered_action() { public function test_should_overwrite_existing_registered_action() { global $_beans_registered_actions; - $new_action = array( + $new_action = array( 'hook' => 'bar', 'callback' => 'callback_bar', 'priority' => 20, From 713f515820ad1865bea7e70f74908ffdfde18b55 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Feb 2018 13:00:41 -0600 Subject: [PATCH 042/800] Fixed docblock @since --- lib/api/actions/functions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 651393aa..f608a86f 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -559,6 +559,7 @@ function _beans_merge_action( $id, array $action, $status ) { * Get the current action, meaning get from the "added" and/or "modified" statuses. * * @since 1.0.0 + * @since 1.5.0 Bails out if there is not "added" action. * @ignore * @access private * From 1986ae2eec702ff61e93b026b7c59d8d6444ec24 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 10:35:59 -0600 Subject: [PATCH 043/800] Made wpcs-compliant --- lib/api/components.php | 2 +- lib/api/html/class-beans-attributes.php | 154 ++++++++++++++++++++++++ lib/api/html/class.php | 115 ------------------ lib/api/html/functions.php | 18 +-- 4 files changed, 161 insertions(+), 128 deletions(-) create mode 100644 lib/api/html/class-beans-attributes.php delete mode 100644 lib/api/html/class.php diff --git a/lib/api/components.php b/lib/api/components.php index 4a541fc4..1cb1a72a 100644 --- a/lib/api/components.php +++ b/lib/api/components.php @@ -30,7 +30,7 @@ function beans_load_api_components( $components ) { $common = array( 'html' => array( $root . 'html/functions.php', - $root . 'html/class.php', + $root . 'html/class-beans-attributes.php', ), 'actions' => $root . 'actions/functions.php', 'filters' => $root . 'filters/functions.php', diff --git a/lib/api/html/class-beans-attributes.php b/lib/api/html/class-beans-attributes.php new file mode 100644 index 00000000..6304762e --- /dev/null +++ b/lib/api/html/class-beans-attributes.php @@ -0,0 +1,154 @@ +id = $id; + $this->attribute = $attribute; + $this->value = $value; + $this->new_value = $new_value; + } + + /** + * Initialize by registering the attribute filter. + * + * @since 1.0.0 + * + * @param array $method Method to register as the callback for this filter. + * + * @return void + */ + public function init( $method ) { + beans_add_filter( $this->id . '_attributes', array( $this, $method ) ); + } + + /** + * Add the given attribute(s). + * + * @since 1.0.0 + * + * @param array $attributes Array of attributes to add. + * + * @return array + */ + public function add( $attributes ) { + + if ( ! isset( $attributes[ $this->attribute ] ) ) { + $attributes[ $this->attribute ] = $this->value; + } else { + $attributes[ $this->attribute ] = $attributes[ $this->attribute ] . ' ' . $this->value; + } + + return $attributes; + } + + /** + * Add the given attribute(s). + * + * @since 1.0.0 + * + * @param array $attributes Array of attributes to add. + * + * @return array + */ + public function replace( $attributes ) { + + if ( $this->new_value ) { + + if ( isset( $attributes[ $this->attribute ] ) ) { + $attributes[ $this->attribute ] = str_replace( $this->value, $this->new_value, $attributes[ $this->attribute ] ); + } else { + $attributes[ $this->attribute ] = $this->new_value; + } + } else { + $attributes[ $this->attribute ] = $this->value; + } + + return $attributes; + } + + /** + * Remove the given attribute(s). + * + * @since 1.0.0 + * + * @param array $attributes Array of attributes to remove. + * + * @return array + */ + public function remove( $attributes ) { + + if ( ! isset( $attributes[ $this->attribute ] ) ) { + return $attributes; + } + + if ( is_null( $this->value ) ) { + unset( $attributes[ $this->attribute ] ); + } else { + $attributes[ $this->attribute ] = str_replace( $this->value, '', $attributes[ $this->attribute ] ); + } + + return $attributes; + } +} diff --git a/lib/api/html/class.php b/lib/api/html/class.php deleted file mode 100644 index 64fe5867..00000000 --- a/lib/api/html/class.php +++ /dev/null @@ -1,115 +0,0 @@ -id = $id; - $this->attribute = $attribute; - $this->value = $value; - $this->new_value = $new_value; - - } - - /** - * Initialize action. - */ - public function init( $action ) { - - beans_add_filter( $this->id . '_attributes', array( $this, $action ) ); - - } - - /** - * Add attribute. - */ - public function add( $attributes ) { - - if ( ! isset( $attributes[ $this->attribute ] ) ) { - $attributes[ $this->attribute ] = $this->value; - } else { - $attributes[ $this->attribute ] = $attributes[ $this->attribute ] . ' ' . $this->value; - } - - return $attributes; - - } - - /** - * Replace attribute. - */ - public function replace( $attributes ) { - - if ( $this->new_value ) { - - if ( isset( $attributes[ $this->attribute ] ) ) { - $attributes[ $this->attribute ] = str_replace( $this->value, $this->new_value, $attributes[ $this->attribute ] ); - } else { - $attributes[ $this->attribute ] = $this->new_value; - } - } else { - - $attributes[ $this->attribute ] = $this->value; - - } - - return $attributes; - - } - - /** - * Remove attribute. - */ - public function remove( $attributes ) { - - if ( ! isset( $attributes[ $this->attribute ] ) ) { - return $attributes; - } - - if ( is_null( $this->value ) ) { - unset( $attributes[ $this->attribute ] ); - } else { - $attributes[ $this->attribute ] = str_replace( $this->value, '', $attributes[ $this->attribute ] ); - } - - return $attributes; - - } -} diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index cc53e94f..5e0f2d21 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -545,14 +545,12 @@ function beans_reset_attributes( $id ) { * (e.g. class=""). Setting it to 'false' will only display the attribute name * (e.g. data-example). Setting it to 'null' will not display anything. * - * @return array All targeted markup attributes. + * @return void */ function beans_add_attribute( $id, $attribute, $value ) { - $class = new _Beans_Attributes( $id, $attribute, $value ); - return $class->init( 'add' ); - + $class->init( 'add' ); } /** @@ -572,14 +570,12 @@ function beans_add_attribute( $id, $attribute, $value ) { * (e.g. class=""). Setting it to 'false' will only display the attribute name * (e.g. data-example). Setting it to 'null' will not display anything. * - * @return array All targeted markup attributes. + * @return void */ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { - $class = new _Beans_Attributes( $id, $attribute, $value, $new_value ); - return $class->init( 'replace' ); - + $class->init( 'replace' ); } /** @@ -596,14 +592,12 @@ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { * @param string $attribute Name of the HTML attribute to target. * @param string $value Optional. Name of the value to remove. Set it to 'false' to completely remove the attribute. * - * @return array All targeted markup attributes remaining. + * @return void */ function beans_remove_attribute( $id, $attribute, $value = null ) { - $class = new _Beans_Attributes( $id, $attribute, $value ); - return $class->init( 'remove' ); - + $class->init( 'remove' ); } /** From 0f080fddf40fde2f1ca9cefd42c127b8bdcc6363 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 10:39:55 -0600 Subject: [PATCH 044/800] Changed class name to singular The class represents one attribute and not many attributes. The new name reflects its actual object. --- lib/api/components.php | 2 +- ...lass-beans-attributes.php => class-beans-attribute.php} | 7 ++++--- lib/api/html/functions.php | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) rename lib/api/html/{class-beans-attributes.php => class-beans-attribute.php} (94%) diff --git a/lib/api/components.php b/lib/api/components.php index 1cb1a72a..83cf2405 100644 --- a/lib/api/components.php +++ b/lib/api/components.php @@ -30,7 +30,7 @@ function beans_load_api_components( $components ) { $common = array( 'html' => array( $root . 'html/functions.php', - $root . 'html/class-beans-attributes.php', + $root . 'html/class-beans-attribute.php', ), 'actions' => $root . 'actions/functions.php', 'filters' => $root . 'filters/functions.php', diff --git a/lib/api/html/class-beans-attributes.php b/lib/api/html/class-beans-attribute.php similarity index 94% rename from lib/api/html/class-beans-attributes.php rename to lib/api/html/class-beans-attribute.php index 6304762e..c20796c2 100644 --- a/lib/api/html/class-beans-attributes.php +++ b/lib/api/html/class-beans-attribute.php @@ -1,6 +1,6 @@ init( 'add' ); } @@ -573,7 +573,7 @@ function beans_add_attribute( $id, $attribute, $value ) { * @return void */ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { - $class = new _Beans_Attributes( $id, $attribute, $value, $new_value ); + $class = new _Beans_Attribute( $id, $attribute, $value, $new_value ); $class->init( 'replace' ); } @@ -595,7 +595,7 @@ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { * @return void */ function beans_remove_attribute( $id, $attribute, $value = null ) { - $class = new _Beans_Attributes( $id, $attribute, $value ); + $class = new _Beans_Attribute( $id, $attribute, $value ); $class->init( 'remove' ); } From b5f7b9568d8fc4eea050008f274ef71ab95b4220 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 10:54:00 -0600 Subject: [PATCH 045/800] Returned object for chaining and testing. --- lib/api/html/class-beans-attribute.php | 5 ++++- lib/api/html/functions.php | 15 +++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/api/html/class-beans-attribute.php b/lib/api/html/class-beans-attribute.php index c20796c2..3571944e 100644 --- a/lib/api/html/class-beans-attribute.php +++ b/lib/api/html/class-beans-attribute.php @@ -75,13 +75,16 @@ public function __construct( $id, $attribute, $value = null, $new_value = null ) * Initialize by registering the attribute filter. * * @since 1.0.0 + * @since 1.5.0 Return self, for chaining and testing. * * @param array $method Method to register as the callback for this filter. * - * @return void + * @return self (for chaining) */ public function init( $method ) { beans_add_filter( $this->id . '_attributes', array( $this, $method ) ); + + return $this; } /** diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 721dd14e..c3ca35a3 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -538,6 +538,7 @@ function beans_reset_attributes( $id ) { * easy to find the content ID when inspecting an element in a web browser. * * @since 1.0.0 + * @since 1.5.0 Return the object. * * @param string $id The markup ID. * @param string $attribute Name of the HTML attribute. @@ -545,12 +546,12 @@ function beans_reset_attributes( $id ) { * (e.g. class=""). Setting it to 'false' will only display the attribute name * (e.g. data-example). Setting it to 'null' will not display anything. * - * @return void + * @return _Beans_Attribute */ function beans_add_attribute( $id, $attribute, $value ) { $class = new _Beans_Attribute( $id, $attribute, $value ); - $class->init( 'add' ); + return $class->init( 'add' ); } /** @@ -562,6 +563,7 @@ function beans_add_attribute( $id, $attribute, $value ) { * easy to find the content ID when inspecting an element in a web browser. * * @since 1.0.0 + * @since 1.5.0 Return the object. * * @param string $id The markup ID. * @param string $attribute Name of the HTML attribute to target. @@ -570,12 +572,12 @@ function beans_add_attribute( $id, $attribute, $value ) { * (e.g. class=""). Setting it to 'false' will only display the attribute name * (e.g. data-example). Setting it to 'null' will not display anything. * - * @return void + * @return _Beans_Attribute */ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { $class = new _Beans_Attribute( $id, $attribute, $value, $new_value ); - $class->init( 'replace' ); + return $class->init( 'replace' ); } /** @@ -587,17 +589,18 @@ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { * easy to find the content ID when inspecting an element in a web browser. * * @since 1.0.0 + * @since 1.5.0 Return the object. * * @param string $id The markup ID. * @param string $attribute Name of the HTML attribute to target. * @param string $value Optional. Name of the value to remove. Set it to 'false' to completely remove the attribute. * - * @return void + * @return _Beans_Attribute */ function beans_remove_attribute( $id, $attribute, $value = null ) { $class = new _Beans_Attribute( $id, $attribute, $value ); - $class->init( 'remove' ); + return $class->init( 'remove' ); } /** From 578ce07c2f60b866b0a2fb353d6f4ba677269acb Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 11:05:18 -0600 Subject: [PATCH 046/800] Tested beans_add_attribute. --- .../api/html/beansAddAttribute.php | 71 ++++++++++++++++ .../api/html/fixtures/test-markup.php | 64 ++++++++++++++ .../html/includes/class-html-test-case.php | 46 ++++++++++ .../unit/api/html/beansAddAttribute.php | 84 +++++++++++++++++++ .../unit/api/html/fixtures/test-markup.php | 64 ++++++++++++++ .../html/includes/class-html-test-case.php | 49 +++++++++++ 6 files changed, 378 insertions(+) create mode 100644 tests/phpunit/integration/api/html/beansAddAttribute.php create mode 100644 tests/phpunit/integration/api/html/fixtures/test-markup.php create mode 100644 tests/phpunit/integration/api/html/includes/class-html-test-case.php create mode 100644 tests/phpunit/unit/api/html/beansAddAttribute.php create mode 100644 tests/phpunit/unit/api/html/fixtures/test-markup.php create mode 100644 tests/phpunit/unit/api/html/includes/class-html-test-case.php diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php new file mode 100644 index 00000000..890a8342 --- /dev/null +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -0,0 +1,71 @@ + $markup ) { + $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); + $attributes = beans_add_attribute( $beans_id, 'data-test', '' ); + $event = $beans_id . '_attributes'; + + // Run the tests. + $this->assertSame( 10, has_filter( $event, array( $attributes, 'add' ), 10 ) ); + $expected = $markup_attributes; + $expected['data-test'] = ''; + $this->assertSame( $expected, apply_filters( $event, $markup_attributes ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'add' ), 10 ); + } + } + + /** + * Test beans_add_attribute() should add the value when the attribute exists. + */ + public function test_should_add_value_when_attribute_exists() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + + // Skip if it doesn't have a class attribute. + if ( ! isset( $markup['attributes']['class'] ) ) { + continue; + } + + $attributes = beans_add_attribute( $beans_id, 'class', 'beans-test' ); + $event = $beans_id . '_attributes'; + + // Run the tests. + $this->assertSame( 10, has_filter( $event, array( $attributes, 'add' ), 10 ) ); + $expected = $markup['attributes']; + $expected['class'] .= ' beans-test'; + $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'add' ), 10 ); + } + } +} diff --git a/tests/phpunit/integration/api/html/fixtures/test-markup.php b/tests/phpunit/integration/api/html/fixtures/test-markup.php new file mode 100644 index 00000000..c473e7ae --- /dev/null +++ b/tests/phpunit/integration/api/html/fixtures/test-markup.php @@ -0,0 +1,64 @@ + array( + 'id' => 'beans_post', + 'tag' => 'article', + 'attributes' => array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box post-47 post type-post status-publish format-standard has-post-thumbnail hentry category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ), + ), + 'beans_post_header' => array( + 'id' => 'beans_post_header', + 'tag' => 'header', + ), + 'beans_post_body' => array( + 'id' => 'beans_post_body', + 'tag' => 'div', + 'attributes' => array( + 'itemprop' => 'articleBody', + ), + ), + 'beans_post_title' => array( + 'id' => 'beans_post_title', + 'tag' => 'h1', + 'attributes' => array( + 'class' => 'uk-article-title', + 'itemprop' => 'headline', + ), + ), + 'beans_post_meta' => array( + 'id' => 'beans_post_meta', + 'tag' => 'ul', + 'attributes' => array( + 'class' => 'uk-article-meta uk-subnav uk-subnav-line', + ), + ), + 'beans_post_meta_item[_date]' => array( + 'id' => 'beans_post_meta_item[_date]', + 'tag' => 'li', + ), + 'beans_post_meta_item[_author]' => array( + 'id' => 'beans_post_meta_item[_author]', + 'tag' => 'li', + ), + 'beans_post_image_link' => array( + 'id' => 'beans_post_image_link', + 'tag' => 'a', + 'attributes' => array( + 'href' => 'http://example.com/image.png', + 'title' => 'Some cool image', + ), + ), +); diff --git a/tests/phpunit/integration/api/html/includes/class-html-test-case.php b/tests/phpunit/integration/api/html/includes/class-html-test-case.php new file mode 100644 index 00000000..51777d7a --- /dev/null +++ b/tests/phpunit/integration/api/html/includes/class-html-test-case.php @@ -0,0 +1,46 @@ + $markup ) { + $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); + $attributes = beans_add_attribute( $beans_id, 'data-test', '' ); + $event = $beans_id . '_attributes'; + + // Set up the WordPress simulator. + Monkey\Filters\expectApplied( $event ) + ->once() + ->with( $markup_attributes ) + ->andReturn( $attributes->add( $markup_attributes ) ); + + // Run the tests. + $this->assertTrue( has_filter( $event, array( $attributes, 'add' ), 10 ) ); + $expected = $markup_attributes; + $expected['data-test'] = ''; + $this->assertSame( $expected, apply_filters( $event, $markup_attributes ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'add' ), 10 ); + } + } + + /** + * Test beans_add_attribute() should add the value when the attribute exists. + */ + public function test_should_add_value_when_attribute_exists() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + + // Skip if it doesn't have a class attribute. + if ( ! isset( $markup['attributes']['class'] ) ) { + continue; + } + + $attributes = beans_add_attribute( $beans_id, 'class', 'beans-test' ); + $event = $beans_id . '_attributes'; + + // Set up the WordPress simulator. + Monkey\Filters\expectApplied( $event ) + ->once() + ->with( $markup['attributes'] ) + ->andReturn( $attributes->add( $markup['attributes'] ) ); + + // Run the tests. + $this->assertTrue( has_filter( $event, array( $attributes, 'add' ), 10 ) ); + $expected = $markup['attributes']; + $expected['class'] .= ' beans-test'; + $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'add' ), 10 ); + } + } +} diff --git a/tests/phpunit/unit/api/html/fixtures/test-markup.php b/tests/phpunit/unit/api/html/fixtures/test-markup.php new file mode 100644 index 00000000..c473e7ae --- /dev/null +++ b/tests/phpunit/unit/api/html/fixtures/test-markup.php @@ -0,0 +1,64 @@ + array( + 'id' => 'beans_post', + 'tag' => 'article', + 'attributes' => array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box post-47 post type-post status-publish format-standard has-post-thumbnail hentry category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ), + ), + 'beans_post_header' => array( + 'id' => 'beans_post_header', + 'tag' => 'header', + ), + 'beans_post_body' => array( + 'id' => 'beans_post_body', + 'tag' => 'div', + 'attributes' => array( + 'itemprop' => 'articleBody', + ), + ), + 'beans_post_title' => array( + 'id' => 'beans_post_title', + 'tag' => 'h1', + 'attributes' => array( + 'class' => 'uk-article-title', + 'itemprop' => 'headline', + ), + ), + 'beans_post_meta' => array( + 'id' => 'beans_post_meta', + 'tag' => 'ul', + 'attributes' => array( + 'class' => 'uk-article-meta uk-subnav uk-subnav-line', + ), + ), + 'beans_post_meta_item[_date]' => array( + 'id' => 'beans_post_meta_item[_date]', + 'tag' => 'li', + ), + 'beans_post_meta_item[_author]' => array( + 'id' => 'beans_post_meta_item[_author]', + 'tag' => 'li', + ), + 'beans_post_image_link' => array( + 'id' => 'beans_post_image_link', + 'tag' => 'a', + 'attributes' => array( + 'href' => 'http://example.com/image.png', + 'title' => 'Some cool image', + ), + ), +); diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php new file mode 100644 index 00000000..bb685c25 --- /dev/null +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -0,0 +1,49 @@ + Date: Tue, 13 Feb 2018 11:10:59 -0600 Subject: [PATCH 047/800] Tested beans_remove_attribute. --- .../api/html/beansRemoveAttribute.php | 69 ++++++++++++++++ .../unit/api/html/beansRemoveAttribute.php | 82 +++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 tests/phpunit/integration/api/html/beansRemoveAttribute.php create mode 100644 tests/phpunit/unit/api/html/beansRemoveAttribute.php diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php new file mode 100644 index 00000000..a089bf79 --- /dev/null +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -0,0 +1,69 @@ + $markup ) { + $attribute = key( $markup['attributes'] ); + + $attributes = beans_remove_attribute( $beans_id, $attribute ); + $event = $beans_id . '_attributes'; + + // Run the tests. + $this->assertSame( 10, has_filter( $event, array( $attributes, 'remove' ), 10 ) ); + $expected = $markup['attributes']; + unset( $expected[ $attribute ] ); + $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'remove' ), 10 ); + } + } + + /** + * Test beans_remove_attribute() should remove the given value from the attribute. + */ + public function test_should_remove_the_given_value_from_attribute() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); + + $attributes = beans_remove_attribute( $beans_id, $attribute, $value ); + $event = $beans_id . '_attributes'; + + // Run the tests. + $this->assertSame( 10, has_filter( $event, array( $attributes, 'remove' ), 10 ) ); + $expected = $markup['attributes']; + $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); + $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'remove' ), 10 ); + } + } +} diff --git a/tests/phpunit/unit/api/html/beansRemoveAttribute.php b/tests/phpunit/unit/api/html/beansRemoveAttribute.php new file mode 100644 index 00000000..a08b2ba0 --- /dev/null +++ b/tests/phpunit/unit/api/html/beansRemoveAttribute.php @@ -0,0 +1,82 @@ + $markup ) { + $attribute = key( $markup['attributes'] ); + + $attributes = beans_remove_attribute( $beans_id, $attribute ); + $event = $beans_id . '_attributes'; + + // Set up the WordPress simulator. + Monkey\Filters\expectApplied( $event ) + ->once() + ->with( $markup['attributes'] ) + ->andReturn( $attributes->remove( $markup['attributes'] ) ); + + // Run the tests. + $this->assertTrue( has_filter( $event, array( $attributes, 'remove' ), 10 ) ); + $expected = $markup['attributes']; + unset( $expected[ $attribute ] ); + $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'remove' ), 10 ); + } + } + + /** + * Test beans_remove_attribute() should remove the given value from the attribute. + */ + public function test_should_remove_the_given_value_from_attribute() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); + + $attributes = beans_remove_attribute( $beans_id, $attribute, $value ); + $event = $beans_id . '_attributes'; + + // Set up the WordPress simulator. + Monkey\Filters\expectApplied( $event ) + ->once() + ->with( $markup['attributes'] ) + ->andReturn( $attributes->remove( $markup['attributes'] ) ); + + // Run the tests. + $this->assertTrue( has_filter( $event, array( $attributes, 'remove' ), 10 ) ); + $expected = $markup['attributes']; + $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); + $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'remove' ), 10 ); + } + } +} From 9ed72aac144d458db9a1b7df3acaae75caae9d1b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 11:15:28 -0600 Subject: [PATCH 048/800] Tested beans_replace_attribute. --- .../api/html/beansReplaceAttribute.php | 68 ++++++++++++++++ .../api/html/fixtures/test-markup.php | 26 +++--- .../unit/api/html/beansReplaceAttribute.php | 81 +++++++++++++++++++ .../unit/api/html/fixtures/test-markup.php | 24 +++--- 4 files changed, 174 insertions(+), 25 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beansReplaceAttribute.php create mode 100644 tests/phpunit/unit/api/html/beansReplaceAttribute.php diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php new file mode 100644 index 00000000..f4ca7d4a --- /dev/null +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -0,0 +1,68 @@ + $markup ) { + $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); + $attributes = beans_replace_attribute( $beans_id, 'data-test', '' ); + $event = $beans_id . '_attributes'; + + // Run the tests. + $this->assertSame( 10, has_filter( $event, array( $attributes, 'replace' ), 10 ) ); + $expected = $markup_attributes; + $expected['data-test'] = ''; + $this->assertSame( $expected, apply_filters( $event, $markup_attributes ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'replace' ), 10 ); + } + } + + /** + * Test beans_add_attribute() should replace an existing attribute value. + */ + public function test_should_replace_existing_attribute_value() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); + + $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); + $event = $beans_id . '_attributes'; + + // Run the tests. + $this->assertSame( 10, has_filter( $event, array( $attributes, 'replace' ), 10 ) ); + $expected = $markup['attributes']; + $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); + $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'replace' ), 10 ); + } + } +} diff --git a/tests/phpunit/integration/api/html/fixtures/test-markup.php b/tests/phpunit/integration/api/html/fixtures/test-markup.php index c473e7ae..cb482e4d 100644 --- a/tests/phpunit/integration/api/html/fixtures/test-markup.php +++ b/tests/phpunit/integration/api/html/fixtures/test-markup.php @@ -2,13 +2,13 @@ /** * Array of test HTML markup and attributes. * - * @package Beans\Framework\Tests\Unit\API\HTML\Fixtures + * @package Beans\Framework\Tests\Integration\API\HTML\Fixtures * * @since 1.5.0 */ return array( - 'beans_post' => array( + 'beans_post' => array( 'id' => 'beans_post', 'tag' => 'article', 'attributes' => array( @@ -19,18 +19,18 @@ 'itemprop' => 'beans_post', ), ), - 'beans_post_header' => array( + 'beans_post_header' => array( 'id' => 'beans_post_header', 'tag' => 'header', ), - 'beans_post_body' => array( + 'beans_post_body' => array( 'id' => 'beans_post_body', 'tag' => 'div', 'attributes' => array( 'itemprop' => 'articleBody', ), ), - 'beans_post_title' => array( + 'beans_post_title' => array( 'id' => 'beans_post_title', 'tag' => 'h1', 'attributes' => array( @@ -38,22 +38,22 @@ 'itemprop' => 'headline', ), ), - 'beans_post_meta' => array( + 'beans_post_meta' => array( 'id' => 'beans_post_meta', 'tag' => 'ul', 'attributes' => array( - 'class' => 'uk-article-meta uk-subnav uk-subnav-line', + 'class' => 'uk-article-meta uk-subnav uk-subnav-line', ), ), 'beans_post_meta_item[_date]' => array( - 'id' => 'beans_post_meta_item[_date]', - 'tag' => 'li', + 'id' => 'beans_post_meta_item[_date]', + 'tag' => 'li', ), - 'beans_post_meta_item[_author]' => array( - 'id' => 'beans_post_meta_item[_author]', - 'tag' => 'li', + 'beans_post_meta_item[_author]' => array( + 'id' => 'beans_post_meta_item[_author]', + 'tag' => 'li', ), - 'beans_post_image_link' => array( + 'beans_post_image_link' => array( 'id' => 'beans_post_image_link', 'tag' => 'a', 'attributes' => array( diff --git a/tests/phpunit/unit/api/html/beansReplaceAttribute.php b/tests/phpunit/unit/api/html/beansReplaceAttribute.php new file mode 100644 index 00000000..ba5b205f --- /dev/null +++ b/tests/phpunit/unit/api/html/beansReplaceAttribute.php @@ -0,0 +1,81 @@ + $markup ) { + $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); + $attributes = beans_replace_attribute( $beans_id, 'data-test', '' ); + $event = $beans_id . '_attributes'; + + // Set up the WordPress simulator. + Monkey\Filters\expectApplied( $event ) + ->once() + ->with( $markup_attributes ) + ->andReturn( $attributes->add( $markup_attributes ) ); + + // Run the tests. + $this->assertTrue( has_filter( $event, array( $attributes, 'replace' ), 10 ) ); + $expected = $markup_attributes; + $expected['data-test'] = ''; + $this->assertSame( $expected, apply_filters( $event, $markup_attributes ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'replace' ), 10 ); + } + } + + /** + * Test beans_add_attribute() should replace an existing attribute value. + */ + public function test_should_replace_existing_attribute_value() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); + + $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); + $event = $beans_id . '_attributes'; + + // Set up the WordPress simulator. + Monkey\Filters\expectApplied( $event ) + ->once() + ->with( $markup['attributes'] ) + ->andReturn( $attributes->replace( $markup['attributes'] ) ); + + // Run the tests. + $this->assertTrue( has_filter( $event, array( $attributes, 'replace' ), 10 ) ); + $expected = $markup['attributes']; + $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); + $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + + // Clean up. + remove_filter( $event, array( $attributes, 'replace' ), 10 ); + } + } +} diff --git a/tests/phpunit/unit/api/html/fixtures/test-markup.php b/tests/phpunit/unit/api/html/fixtures/test-markup.php index c473e7ae..06660ac8 100644 --- a/tests/phpunit/unit/api/html/fixtures/test-markup.php +++ b/tests/phpunit/unit/api/html/fixtures/test-markup.php @@ -8,7 +8,7 @@ */ return array( - 'beans_post' => array( + 'beans_post' => array( 'id' => 'beans_post', 'tag' => 'article', 'attributes' => array( @@ -19,18 +19,18 @@ 'itemprop' => 'beans_post', ), ), - 'beans_post_header' => array( + 'beans_post_header' => array( 'id' => 'beans_post_header', 'tag' => 'header', ), - 'beans_post_body' => array( + 'beans_post_body' => array( 'id' => 'beans_post_body', 'tag' => 'div', 'attributes' => array( 'itemprop' => 'articleBody', ), ), - 'beans_post_title' => array( + 'beans_post_title' => array( 'id' => 'beans_post_title', 'tag' => 'h1', 'attributes' => array( @@ -38,22 +38,22 @@ 'itemprop' => 'headline', ), ), - 'beans_post_meta' => array( + 'beans_post_meta' => array( 'id' => 'beans_post_meta', 'tag' => 'ul', 'attributes' => array( - 'class' => 'uk-article-meta uk-subnav uk-subnav-line', + 'class' => 'uk-article-meta uk-subnav uk-subnav-line', ), ), 'beans_post_meta_item[_date]' => array( - 'id' => 'beans_post_meta_item[_date]', - 'tag' => 'li', + 'id' => 'beans_post_meta_item[_date]', + 'tag' => 'li', ), - 'beans_post_meta_item[_author]' => array( - 'id' => 'beans_post_meta_item[_author]', - 'tag' => 'li', + 'beans_post_meta_item[_author]' => array( + 'id' => 'beans_post_meta_item[_author]', + 'tag' => 'li', ), - 'beans_post_image_link' => array( + 'beans_post_image_link' => array( 'id' => 'beans_post_image_link', 'tag' => 'a', 'attributes' => array( From d2353c49428850a9b4e9d75edc9a00ab32fc0adf Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 11:25:02 -0600 Subject: [PATCH 049/800] Made compliant. --- .../api/html/beansAddAttribute.php | 18 ++++++++--------- .../api/html/beansRemoveAttribute.php | 16 +++++++-------- .../api/html/beansReplaceAttribute.php | 16 +++++++-------- .../unit/api/html/beansAddAttribute.php | 20 +++++++++---------- .../unit/api/html/beansRemoveAttribute.php | 20 +++++++++---------- .../unit/api/html/beansReplaceAttribute.php | 20 +++++++++---------- 6 files changed, 55 insertions(+), 55 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php index 890a8342..7d3c95c9 100644 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -30,16 +30,16 @@ public function test_should_add_empty_value_when_no_value_given() { foreach ( static::$test_markup as $beans_id => $markup ) { $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); $attributes = beans_add_attribute( $beans_id, 'data-test', '' ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Run the tests. - $this->assertSame( 10, has_filter( $event, array( $attributes, 'add' ), 10 ) ); + $this->assertSame( 10, has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup_attributes; $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $event, $markup_attributes ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'add' ), 10 ); + remove_filter( $hook, array( $attributes, 'add' ), 10 ); } } @@ -56,16 +56,16 @@ public function test_should_add_value_when_attribute_exists() { } $attributes = beans_add_attribute( $beans_id, 'class', 'beans-test' ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Run the tests. - $this->assertSame( 10, has_filter( $event, array( $attributes, 'add' ), 10 ) ); - $expected = $markup['attributes']; + $this->assertSame( 10, has_filter( $hook, array( $attributes, 'add' ), 10 ) ); + $expected = $markup['attributes']; $expected['class'] .= ' beans-test'; - $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'add' ), 10 ); + remove_filter( $hook, array( $attributes, 'add' ), 10 ); } } } diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php index a089bf79..26e9aa3b 100644 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -31,16 +31,16 @@ public function test_should_remove_attribute_when_null_given() { $attribute = key( $markup['attributes'] ); $attributes = beans_remove_attribute( $beans_id, $attribute ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Run the tests. - $this->assertSame( 10, has_filter( $event, array( $attributes, 'remove' ), 10 ) ); + $this->assertSame( 10, has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; unset( $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'remove' ), 10 ); + remove_filter( $hook, array( $attributes, 'remove' ), 10 ); } } @@ -54,16 +54,16 @@ public function test_should_remove_the_given_value_from_attribute() { $attribute = key( $markup['attributes'] ); $attributes = beans_remove_attribute( $beans_id, $attribute, $value ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Run the tests. - $this->assertSame( 10, has_filter( $event, array( $attributes, 'remove' ), 10 ) ); + $this->assertSame( 10, has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'remove' ), 10 ); + remove_filter( $hook, array( $attributes, 'remove' ), 10 ); } } } diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index f4ca7d4a..6b802e8b 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -30,16 +30,16 @@ public function test_should_add_attribute_when_it_does_not_exist() { foreach ( static::$test_markup as $beans_id => $markup ) { $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); $attributes = beans_replace_attribute( $beans_id, 'data-test', '' ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Run the tests. - $this->assertSame( 10, has_filter( $event, array( $attributes, 'replace' ), 10 ) ); + $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup_attributes; $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $event, $markup_attributes ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'replace' ), 10 ); + remove_filter( $hook, array( $attributes, 'replace' ), 10 ); } } @@ -53,16 +53,16 @@ public function test_should_replace_existing_attribute_value() { $attribute = key( $markup['attributes'] ); $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Run the tests. - $this->assertSame( 10, has_filter( $event, array( $attributes, 'replace' ), 10 ) ); + $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'replace' ), 10 ); + remove_filter( $hook, array( $attributes, 'replace' ), 10 ); } } } diff --git a/tests/phpunit/unit/api/html/beansAddAttribute.php b/tests/phpunit/unit/api/html/beansAddAttribute.php index 520dc78f..f6848bc6 100644 --- a/tests/phpunit/unit/api/html/beansAddAttribute.php +++ b/tests/phpunit/unit/api/html/beansAddAttribute.php @@ -31,22 +31,22 @@ public function test_should_add_empty_value_when_no_value_given() { foreach ( static::$test_markup as $beans_id => $markup ) { $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); $attributes = beans_add_attribute( $beans_id, 'data-test', '' ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $event ) + Monkey\Filters\expectApplied( $hook ) ->once() ->with( $markup_attributes ) ->andReturn( $attributes->add( $markup_attributes ) ); // Run the tests. - $this->assertTrue( has_filter( $event, array( $attributes, 'add' ), 10 ) ); + $this->assertTrue( has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup_attributes; $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $event, $markup_attributes ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'add' ), 10 ); + remove_filter( $hook, array( $attributes, 'add' ), 10 ); } } @@ -63,22 +63,22 @@ public function test_should_add_value_when_attribute_exists() { } $attributes = beans_add_attribute( $beans_id, 'class', 'beans-test' ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $event ) + Monkey\Filters\expectApplied( $hook ) ->once() ->with( $markup['attributes'] ) ->andReturn( $attributes->add( $markup['attributes'] ) ); // Run the tests. - $this->assertTrue( has_filter( $event, array( $attributes, 'add' ), 10 ) ); + $this->assertTrue( has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup['attributes']; $expected['class'] .= ' beans-test'; - $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'add' ), 10 ); + remove_filter( $hook, array( $attributes, 'add' ), 10 ); } } } diff --git a/tests/phpunit/unit/api/html/beansRemoveAttribute.php b/tests/phpunit/unit/api/html/beansRemoveAttribute.php index a08b2ba0..8d991520 100644 --- a/tests/phpunit/unit/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/unit/api/html/beansRemoveAttribute.php @@ -32,22 +32,22 @@ public function test_should_remove_attribute_when_null_given() { $attribute = key( $markup['attributes'] ); $attributes = beans_remove_attribute( $beans_id, $attribute ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $event ) + Monkey\Filters\expectApplied( $hook ) ->once() ->with( $markup['attributes'] ) ->andReturn( $attributes->remove( $markup['attributes'] ) ); // Run the tests. - $this->assertTrue( has_filter( $event, array( $attributes, 'remove' ), 10 ) ); + $this->assertTrue( has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; unset( $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'remove' ), 10 ); + remove_filter( $hook, array( $attributes, 'remove' ), 10 ); } } @@ -61,22 +61,22 @@ public function test_should_remove_the_given_value_from_attribute() { $attribute = key( $markup['attributes'] ); $attributes = beans_remove_attribute( $beans_id, $attribute, $value ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $event ) + Monkey\Filters\expectApplied( $hook ) ->once() ->with( $markup['attributes'] ) ->andReturn( $attributes->remove( $markup['attributes'] ) ); // Run the tests. - $this->assertTrue( has_filter( $event, array( $attributes, 'remove' ), 10 ) ); + $this->assertTrue( has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'remove' ), 10 ); + remove_filter( $hook, array( $attributes, 'remove' ), 10 ); } } } diff --git a/tests/phpunit/unit/api/html/beansReplaceAttribute.php b/tests/phpunit/unit/api/html/beansReplaceAttribute.php index ba5b205f..fcd586b1 100644 --- a/tests/phpunit/unit/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/unit/api/html/beansReplaceAttribute.php @@ -31,22 +31,22 @@ public function test_should_add_attribute_when_it_does_not_exist() { foreach ( static::$test_markup as $beans_id => $markup ) { $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); $attributes = beans_replace_attribute( $beans_id, 'data-test', '' ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $event ) + Monkey\Filters\expectApplied( $hook ) ->once() ->with( $markup_attributes ) ->andReturn( $attributes->add( $markup_attributes ) ); // Run the tests. - $this->assertTrue( has_filter( $event, array( $attributes, 'replace' ), 10 ) ); + $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup_attributes; $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $event, $markup_attributes ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'replace' ), 10 ); + remove_filter( $hook, array( $attributes, 'replace' ), 10 ); } } @@ -60,22 +60,22 @@ public function test_should_replace_existing_attribute_value() { $attribute = key( $markup['attributes'] ); $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); - $event = $beans_id . '_attributes'; + $hook = $beans_id . '_attributes'; // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $event ) + Monkey\Filters\expectApplied( $hook ) ->once() ->with( $markup['attributes'] ) ->andReturn( $attributes->replace( $markup['attributes'] ) ); // Run the tests. - $this->assertTrue( has_filter( $event, array( $attributes, 'replace' ), 10 ) ); + $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $event, $markup['attributes'] ) ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. - remove_filter( $event, array( $attributes, 'replace' ), 10 ); + remove_filter( $hook, array( $attributes, 'replace' ), 10 ); } } } From cfe76bd818adf7d8b067b0807a20ed9338d3ecf4 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 11:29:11 -0600 Subject: [PATCH 050/800] Changed variable naming to reflect what the object is. --- lib/api/html/functions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index c3ca35a3..2b2b8c1a 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -549,9 +549,9 @@ function beans_reset_attributes( $id ) { * @return _Beans_Attribute */ function beans_add_attribute( $id, $attribute, $value ) { - $class = new _Beans_Attribute( $id, $attribute, $value ); + $attribute = new _Beans_Attribute( $id, $attribute, $value ); - return $class->init( 'add' ); + return $attribute->init( 'add' ); } /** @@ -575,9 +575,9 @@ function beans_add_attribute( $id, $attribute, $value ) { * @return _Beans_Attribute */ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { - $class = new _Beans_Attribute( $id, $attribute, $value, $new_value ); + $attribute = new _Beans_Attribute( $id, $attribute, $value, $new_value ); - return $class->init( 'replace' ); + return $attribute->init( 'replace' ); } /** @@ -598,9 +598,9 @@ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { * @return _Beans_Attribute */ function beans_remove_attribute( $id, $attribute, $value = null ) { - $class = new _Beans_Attribute( $id, $attribute, $value ); + $attribute = new _Beans_Attribute( $id, $attribute, $value ); - return $class->init( 'remove' ); + return $attribute->init( 'remove' ); } /** From a052d4852e3abf412f698efe6c15e8277a04b78d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 11:31:30 -0600 Subject: [PATCH 051/800] Added array type hinting. --- lib/api/html/class-beans-attribute.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/html/class-beans-attribute.php b/lib/api/html/class-beans-attribute.php index 3571944e..72cbf37b 100644 --- a/lib/api/html/class-beans-attribute.php +++ b/lib/api/html/class-beans-attribute.php @@ -96,7 +96,7 @@ public function init( $method ) { * * @return array */ - public function add( $attributes ) { + public function add( array $attributes ) { if ( ! isset( $attributes[ $this->attribute ] ) ) { $attributes[ $this->attribute ] = $this->value; @@ -116,7 +116,7 @@ public function add( $attributes ) { * * @return array */ - public function replace( $attributes ) { + public function replace( array $attributes ) { if ( $this->new_value ) { @@ -141,7 +141,7 @@ public function replace( $attributes ) { * * @return array */ - public function remove( $attributes ) { + public function remove( array $attributes ) { if ( ! isset( $attributes[ $this->attribute ] ) ) { return $attributes; From 116762d27312c97fbbb926798f0213c50c60b6c8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 12:08:52 -0600 Subject: [PATCH 052/800] Refactored and improved documentation. --- lib/api/html/class-beans-attribute.php | 64 ++++++++++++++++++-------- lib/api/html/functions.php | 10 ++-- 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/lib/api/html/class-beans-attribute.php b/lib/api/html/class-beans-attribute.php index 72cbf37b..6de99c6a 100644 --- a/lib/api/html/class-beans-attribute.php +++ b/lib/api/html/class-beans-attribute.php @@ -88,71 +88,97 @@ public function init( $method ) { } /** - * Add the given attribute(s). + * Add a value to an existing attribute or add a new attribute. * * @since 1.0.0 * - * @param array $attributes Array of attributes to add. + * @param array $attributes Array of HTML markup attributes. * * @return array */ public function add( array $attributes ) { - if ( ! isset( $attributes[ $this->attribute ] ) ) { - $attributes[ $this->attribute ] = $this->value; + if ( $this->has_attribute( $attributes ) ) { + $attributes[ $this->attribute ] .= ' ' . $this->value; } else { - $attributes[ $this->attribute ] = $attributes[ $this->attribute ] . ' ' . $this->value; + $attributes[ $this->attribute ] = $this->value; } return $attributes; } /** - * Add the given attribute(s). + * Replace a specific value from the attribute. If the attribute does not exist, it is added with the new value. * * @since 1.0.0 * - * @param array $attributes Array of attributes to add. + * @param array $attributes Array of HTML markup attributes. * * @return array */ public function replace( array $attributes ) { - if ( $this->new_value ) { - - if ( isset( $attributes[ $this->attribute ] ) ) { - $attributes[ $this->attribute ] = str_replace( $this->value, $this->new_value, $attributes[ $this->attribute ] ); - } else { - $attributes[ $this->attribute ] = $this->new_value; - } - } else { + if ( ! $this->new_value ) { $attributes[ $this->attribute ] = $this->value; + return $attributes; } + $attributes[ $this->attribute ] = $this->has_attribute( $attributes ) + ? $this->replace_value( $attributes[ $this->attribute ] ) + : $this->new_value; + return $attributes; } /** - * Remove the given attribute(s). + * Remove a specific value from the attribute or remove the entire attribute. + * + * When the attribute value to remove is null, the attribute is removed; else, the value is removed. * * @since 1.0.0 * - * @param array $attributes Array of attributes to remove. + * @param array $attributes Array of HTML markup attributes. * * @return array */ public function remove( array $attributes ) { - if ( ! isset( $attributes[ $this->attribute ] ) ) { + if ( ! $this->has_attribute( $attributes ) ) { return $attributes; } if ( is_null( $this->value ) ) { unset( $attributes[ $this->attribute ] ); } else { - $attributes[ $this->attribute ] = str_replace( $this->value, '', $attributes[ $this->attribute ] ); + $attributes[ $this->attribute ] = $this->replace_value( $attributes[ $this->attribute ] ); } return $attributes; } + + /** + * Checks if the attribute exists in the given attributes. + * + * @since 1.5.0 + * + * @param array $attributes Array of HTML markup attributes. + * + * @return bool + */ + private function has_attribute( array $attributes ) { + return isset( $attributes[ $this->attribute ] ); + } + + /** + * Replace the attribute's value. + * + * @since 1.5.0 + * + * @param string $value The current attribute's value. + * + * @return string + */ + private function replace_value( $value ) { + return str_replace( $this->value, $this->new_value, $value ); + } } diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 2b2b8c1a..45e36fcb 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -530,7 +530,7 @@ function beans_reset_attributes( $id ) { } /** - * Add attribute to markup. + * Add a value to an existing attribute or add a new attribute. * * This function must be called before the targeted markup is called. * @@ -555,7 +555,7 @@ function beans_add_attribute( $id, $attribute, $value ) { } /** - * Replace attribute to markup. + * Replace a specific value from the attribute. If the attribute does not exist, it is added with the new value. * * This function must be called before the targeted markup is called. * @@ -581,7 +581,7 @@ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { } /** - * Remove markup attribute. + * Remove a specific value from the attribute or remove the entire attribute. * * This function must be called before the targeted markup is called. * @@ -593,12 +593,12 @@ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { * * @param string $id The markup ID. * @param string $attribute Name of the HTML attribute to target. - * @param string $value Optional. Name of the value to remove. Set it to 'false' to completely remove the attribute. + * @param string $value Optional. The attribute value to remove. Set it to 'false' or null to completely remove the attribute. * * @return _Beans_Attribute */ function beans_remove_attribute( $id, $attribute, $value = null ) { - $attribute = new _Beans_Attribute( $id, $attribute, $value ); + $attribute = new _Beans_Attribute( $id, $attribute, $value, '' ); return $attribute->init( 'remove' ); } From eb2cb2c3c3dd2c3f67d5344ee97adc22a3918139 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 13:38:32 -0600 Subject: [PATCH 053/800] Improved beans_replace_attribute. The previous code switched to using the value when the new_value was empty. That is confusing as it mixes up the intent of the "value" and "new value" parameters. Improvements: 1. Always use the "new_value" for overwriting the current value. 2. Added the ability to replace ALL of the values. How? Set the "value" argument to an empty (false, empty string, or null). --- lib/api/html/class-beans-attribute.php | 14 ++- lib/api/html/functions.php | 6 +- .../api/html/beansReplaceAttribute.php | 78 ++++++++++++--- .../unit/api/html/beansReplaceAttribute.php | 95 ++++++++++++++++--- 4 files changed, 156 insertions(+), 37 deletions(-) diff --git a/lib/api/html/class-beans-attribute.php b/lib/api/html/class-beans-attribute.php index 6de99c6a..d47d0dc1 100644 --- a/lib/api/html/class-beans-attribute.php +++ b/lib/api/html/class-beans-attribute.php @@ -108,9 +108,10 @@ public function add( array $attributes ) { } /** - * Replace a specific value from the attribute. If the attribute does not exist, it is added with the new value. + * Replace the attribute's value. If the attribute does not exist, it is added with the new value. * * @since 1.0.0 + * @since 1.5.0 Allows replacement of all values. * * @param array $attributes Array of HTML markup attributes. * @@ -118,15 +119,12 @@ public function add( array $attributes ) { */ public function replace( array $attributes ) { - if ( ! $this->new_value ) { - $attributes[ $this->attribute ] = $this->value; - return $attributes; + if ( $this->has_attribute( $attributes ) && ! empty( $this->value ) ) { + $attributes[ $this->attribute ] = $this->replace_value( $attributes[ $this->attribute ] ); + } else { + $attributes[ $this->attribute ] = $this->new_value; } - $attributes[ $this->attribute ] = $this->has_attribute( $attributes ) - ? $this->replace_value( $attributes[ $this->attribute ] ) - : $this->new_value; - return $attributes; } diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 45e36fcb..20ac9381 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -555,7 +555,7 @@ function beans_add_attribute( $id, $attribute, $value ) { } /** - * Replace a specific value from the attribute. If the attribute does not exist, it is added with the new value. + * Replace the attribute's value. If the attribute does not exist, it is added with the new value. * * This function must be called before the targeted markup is called. * @@ -563,11 +563,11 @@ function beans_add_attribute( $id, $attribute, $value ) { * easy to find the content ID when inspecting an element in a web browser. * * @since 1.0.0 - * @since 1.5.0 Return the object. + * @since 1.5.0 Return the object. Allows replacement of all values. * * @param string $id The markup ID. * @param string $attribute Name of the HTML attribute to target. - * @param string $value Value which should be replaced. + * @param string $value Value which should be replaced. When empty ('', false, or null), it replaces all of the values for this attribute. * @param string $new_value Optional. Replacement value. If set to '' will display the attribute value as empty * (e.g. class=""). Setting it to 'false' will only display the attribute name * (e.g. data-example). Setting it to 'null' will not display anything. diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index 6b802e8b..521b9040 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -23,20 +23,22 @@ class Tests_BeansReplaceAttribute extends HTML_Test_Case { /** - * Test beans_add_attribute() should add the attribute when it does not exist. + * Test beans_replace_attribute() should replace an existing attribute value. */ - public function test_should_add_attribute_when_it_does_not_exist() { + public function test_should_replace_existing_attribute_value() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); - foreach ( static::$test_markup as $beans_id => $markup ) { - $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); - $attributes = beans_replace_attribute( $beans_id, 'data-test', '' ); - $hook = $beans_id . '_attributes'; + $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); + $hook = $beans_id . '_attributes'; // Run the tests. $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup_attributes; - $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $expected = $markup['attributes']; + $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); @@ -44,15 +46,15 @@ public function test_should_add_attribute_when_it_does_not_exist() { } /** - * Test beans_add_attribute() should replace an existing attribute value. + * Test beans_replace_attribute() should replace all attribute values with new value when no value given. */ - public function test_should_replace_existing_attribute_value() { + public function test_should_replace_all_attributes_when_no_value_given() { foreach ( static::$test_attributes as $beans_id => $markup ) { $value = current( $markup['attributes'] ); $attribute = key( $markup['attributes'] ); - $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); + $attributes = beans_replace_attribute( $beans_id, $attribute, null, 'beans-test' ); $hook = $beans_id . '_attributes'; // Run the tests. @@ -65,4 +67,56 @@ public function test_should_replace_existing_attribute_value() { remove_filter( $hook, array( $attributes, 'replace' ), 10 ); } } + + /** + * Test beans_replace_attribute() should replace all values with null when no value is passed. + */ + public function test_should_replace_all_values_with_null_when_no_value_passed() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); + + $attributes = beans_replace_attribute( $beans_id, $attribute, '' ); + $hook = $beans_id . '_attributes'; + + // Run the tests. + $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); + $expected = $markup['attributes']; + $expected[ $attribute ] = null; + $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, $actual ); + $this->assertNotSame( $value, $actual[ $attribute ] ); + $this->assertNull( $actual[ $attribute ] ); + + // Clean up. + remove_filter( $hook, array( $attributes, 'replace' ), 10 ); + } + } + + /** + * Test beans_replace_attribute() should replace all values when an empty value is given as the new value. + */ + public function test_should_replace_all_values_when_empty_given() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); + + $attributes = beans_replace_attribute( $beans_id, $attribute, null, '' ); + $hook = $beans_id . '_attributes'; + + // Run the tests. + $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); + $expected = $markup['attributes']; + $expected[ $attribute ] = ''; + $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, $actual ); + $this->assertNotSame( $value, $actual[ $attribute ] ); + $this->assertSame( '', $actual[ $attribute ] ); + + // Clean up. + remove_filter( $hook, array( $attributes, 'replace' ), 10 ); + } + } } diff --git a/tests/phpunit/unit/api/html/beansReplaceAttribute.php b/tests/phpunit/unit/api/html/beansReplaceAttribute.php index fcd586b1..51ba6d8b 100644 --- a/tests/phpunit/unit/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/unit/api/html/beansReplaceAttribute.php @@ -24,42 +24,45 @@ class Tests_BeansReplaceAttribute extends HTML_Test_Case { /** - * Test beans_add_attribute() should add the attribute when it does not exist. + * Test beans_replace_attribute() should replace an existing attribute value. */ - public function test_should_add_attribute_when_it_does_not_exist() { + public function test_should_replace_existing_attribute_value() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); - foreach ( static::$test_markup as $beans_id => $markup ) { - $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); - $attributes = beans_replace_attribute( $beans_id, 'data-test', '' ); - $hook = $beans_id . '_attributes'; + $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); + $hook = $beans_id . '_attributes'; // Set up the WordPress simulator. Monkey\Filters\expectApplied( $hook ) ->once() - ->with( $markup_attributes ) - ->andReturn( $attributes->add( $markup_attributes ) ); + ->with( $markup['attributes'] ) + ->andReturn( $attributes->replace( $markup['attributes'] ) ); // Run the tests. $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup_attributes; - $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $expected = $markup['attributes']; + $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); } } + /** - * Test beans_add_attribute() should replace an existing attribute value. + * Test beans_replace_attribute() should replace all attribute values with new value when no value given. */ - public function test_should_replace_existing_attribute_value() { + public function test_should_replace_all_attributes_when_no_value_given() { foreach ( static::$test_attributes as $beans_id => $markup ) { $value = current( $markup['attributes'] ); $attribute = key( $markup['attributes'] ); - $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); + $attributes = beans_replace_attribute( $beans_id, $attribute, null, 'beans-test' ); $hook = $beans_id . '_attributes'; // Set up the WordPress simulator. @@ -78,4 +81,68 @@ public function test_should_replace_existing_attribute_value() { remove_filter( $hook, array( $attributes, 'replace' ), 10 ); } } + + /** + * Test beans_replace_attribute() should replace all values with null when no value is passed. + */ + public function test_should_replace_all_values_with_null_when_no_value_passed() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); + + $attributes = beans_replace_attribute( $beans_id, $attribute, '' ); + $hook = $beans_id . '_attributes'; + + // Set up the WordPress simulator. + Monkey\Filters\expectApplied( $hook ) + ->once() + ->with( $markup['attributes'] ) + ->andReturn( $attributes->replace( $markup['attributes'] ) ); + + // Run the tests. + $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); + $expected = $markup['attributes']; + $expected[ $attribute ] = null; + $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, $actual ); + $this->assertNotSame( $value, $actual[ $attribute ] ); + $this->assertNull( $actual[ $attribute ] ); + + // Clean up. + remove_filter( $hook, array( $attributes, 'replace' ), 10 ); + } + } + + /** + * Test beans_replace_attribute() should replace all values when an empty value is given as the new value. + */ + public function test_should_replace_all_values_when_empty_given() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $value = current( $markup['attributes'] ); + $attribute = key( $markup['attributes'] ); + + $attributes = beans_replace_attribute( $beans_id, $attribute, null, '' ); + $hook = $beans_id . '_attributes'; + + // Set up the WordPress simulator. + Monkey\Filters\expectApplied( $hook ) + ->once() + ->with( $markup['attributes'] ) + ->andReturn( $attributes->replace( $markup['attributes'] ) ); + + // Run the tests. + $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); + $expected = $markup['attributes']; + $expected[ $attribute ] = ''; + $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, $actual ); + $this->assertNotSame( $value, $actual[ $attribute ] ); + $this->assertSame( '', $actual[ $attribute ] ); + + // Clean up. + remove_filter( $hook, array( $attributes, 'replace' ), 10 ); + } + } } From 33ec16fbbcc3e7caf750da98c70650ac01370e71 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Feb 2018 14:01:07 -0600 Subject: [PATCH 054/800] Improved documentation. --- lib/api/actions/functions.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index f608a86f..3a6a2bae 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -481,12 +481,10 @@ function _beans_get_action( $id, $status ) { function _beans_set_action( $id, $action, $status, $overwrite = false ) { $id = _beans_unique_action_id( $id ); - // If not overwriting, let's check if an action is already registered for that id. + // If not overwriting, return the registered action (if it's registered). if ( ! $overwrite ) { - // Get the action, if it's already registered. $registered_action = _beans_get_action( $id, $status ); - // If yes, return the registered action. if ( ! empty( $registered_action ) ) { return $registered_action; } @@ -559,7 +557,7 @@ function _beans_merge_action( $id, array $action, $status ) { * Get the current action, meaning get from the "added" and/or "modified" statuses. * * @since 1.0.0 - * @since 1.5.0 Bails out if there is not "added" action. + * @since 1.5.0 Bails out if there is no "added" action registered. * @ignore * @access private * @@ -576,7 +574,7 @@ function _beans_get_current_action( $id ) { $added = _beans_get_action( $id, 'added' ); - // If there is not "added" action registered, bail out. + // If there is no "added" action registered, bail out. if ( empty( $added ) ) { return false; } From 4e9192e508343fcac62440f243bd15ce9ef43171 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 11:08:31 -0600 Subject: [PATCH 055/800] Made beans_get_images_dir() wpcs compliant & tested. --- lib/api/image/functions.php | 91 ++++---- .../api/image/beansGetImagesDir.php | 49 +++++ .../integration/api/image/fixtures/image1.jpg | Bin 0 -> 31016 bytes .../integration/api/image/fixtures/image2.jpg | Bin 0 -> 31429 bytes .../image/includes/class-image-test-case.php | 167 +++++++++++++++ .../unit/api/image/beansGetImagesDir.php | 45 ++++ .../unit/api/image/fixtures/image1.jpg | Bin 0 -> 31016 bytes .../unit/api/image/fixtures/image2.jpg | Bin 0 -> 31429 bytes .../image/includes/class-image-test-case.php | 202 ++++++++++++++++++ 9 files changed, 510 insertions(+), 44 deletions(-) create mode 100644 tests/phpunit/integration/api/image/beansGetImagesDir.php create mode 100644 tests/phpunit/integration/api/image/fixtures/image1.jpg create mode 100644 tests/phpunit/integration/api/image/fixtures/image2.jpg create mode 100644 tests/phpunit/integration/api/image/includes/class-image-test-case.php create mode 100644 tests/phpunit/unit/api/image/beansGetImagesDir.php create mode 100644 tests/phpunit/unit/api/image/fixtures/image1.jpg create mode 100644 tests/phpunit/unit/api/image/fixtures/image2.jpg create mode 100644 tests/phpunit/unit/api/image/includes/class-image-test-case.php diff --git a/lib/api/image/functions.php b/lib/api/image/functions.php index dc29e451..d5734763 100644 --- a/lib/api/image/functions.php +++ b/lib/api/image/functions.php @@ -16,22 +16,24 @@ * * @since 1.0.0 * - * @param string $src The image source. - * @param array $args { - * Associative array of arguments used by the image editor. - * - * @type array $resize Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize - * function arguments. - * @type array $crop Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop - * function arguments. - * @type array $rotate Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate - * function arguments. - * @type array $flip Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip - * function arguments. - * @type array $set_quality Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality - * function arguments. + * @param string $src The image source. + * @param array $args { + * Associative array of arguments used by the image editor. + * + * @type array $resize Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize function arguments. + * @type array $crop Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop function arguments. + * @type array $rotate Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate function arguments. + * @type array $flip Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip function arguments. + * @type array $set_quality Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality function + * arguments. * } - * @param string $output Optional. Returned format. Accepts STRING, OBJECT, ARRAY_A, or ARRAY_N. + * + * @param string $output Optional. Returned format. Accepts STRING, OBJECT, ARRAY_A, or ARRAY_N. * Default STRING. * * @return string|array Image source if output set the STRING, image data otherwise. @@ -61,18 +63,18 @@ function beans_edit_image( $src, array $args, $output = 'STRING' ) { */ function beans_get_post_attachment( $post_id, $size = 'full' ) { - $id = get_post_thumbnail_id( $post_id ); + $id = get_post_thumbnail_id( $post_id ); $post = get_post( $id ); - $src = wp_get_attachment_image_src( $id, $size ); - - $obj = new stdClass(); - $obj->id = $id; - $obj->src = $src[0]; - $obj->width = $src[1]; - $obj->height = $src[2]; - $obj->alt = trim( strip_tags( get_post_meta( $id, '_wp_attachment_image_alt', true ) ) ); - $obj->title = $post->post_title; - $obj->caption = $post->post_excerpt; + $src = wp_get_attachment_image_src( $id, $size ); + + $obj = new stdClass(); + $obj->id = $id; + $obj->src = $src[0]; + $obj->width = $src[1]; + $obj->height = $src[2]; + $obj->alt = trim( strip_tags( get_post_meta( $id, '_wp_attachment_image_alt', true ) ) ); + $obj->title = $post->post_title; + $obj->caption = $post->post_excerpt; $obj->description = $post->post_content; return $obj; @@ -86,20 +88,21 @@ function beans_get_post_attachment( $post_id, $size = 'full' ) { * * @since 1.0.0 * - * @param string $post_id The post id. - * @param array $args { - * Array of arguments used by the image editor. - * - * @type array $resize Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize - * function arguments. - * @type array $crop Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop - * function arguments. - * @type array $rotate Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate - * function arguments. - * @type array $flip Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip - * function arguments. - * @type array $set_quality Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality - * function arguments. + * @param string $post_id The post id. + * @param array $args { + * Array of arguments used by the image editor. + * + * @type array $resize Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize function arguments. + * @type array $crop Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop function arguments. + * @type array $rotate Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate function arguments. + * @type array $flip Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip function arguments. + * @type array $set_quality Numeric array matching the + * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality function + * arguments. * } * * @return object Edited post attachment data. @@ -122,23 +125,23 @@ function beans_edit_post_attachment( $post_id, $args = array() ) { } /** - * Get edited images directory. + * Get the "edited images" storage directory, i.e. where the "edited images" are/will be stored. * * @since 1.0.0 * - * @return string Edited images directory. + * @return string */ function beans_get_images_dir() { - $wp_upload_dir = wp_upload_dir(); /** * Filter the edited images directory. * * @since 1.0.0 + * + * @param string Default path to the Beans' edited images storage directory. */ $dir = apply_filters( 'beans_images_dir', trailingslashit( $wp_upload_dir['basedir'] ) . 'beans/images/' ); return wp_normalize_path( trailingslashit( $dir ) ); - } diff --git a/tests/phpunit/integration/api/image/beansGetImagesDir.php b/tests/phpunit/integration/api/image/beansGetImagesDir.php new file mode 100644 index 00000000..3fd52d36 --- /dev/null +++ b/tests/phpunit/integration/api/image/beansGetImagesDir.php @@ -0,0 +1,49 @@ +assertStringEndsWith( 'uploads/beans/images/', beans_get_images_dir() ); + } + + /** + * Test beans_get_images_dir() should return the filtered images' directory. + */ + public function test_should_return_filtered_images_dir() { + Monkey\Functions\expect( 'test_filter_beans_images_dir' ) + ->once() + ->with( vfsStream::url( 'uploads/beans/images/' ) ) + ->andReturn( 'foo' ); + + add_filter( 'beans_images_dir', 'test_filter_beans_images_dir' ); + + $this->assertSame( 'foo/', beans_get_images_dir() ); + + remove_filter( 'beans_images_dir', 'test_filter_beans_images_dir' ); + } +} diff --git a/tests/phpunit/integration/api/image/fixtures/image1.jpg b/tests/phpunit/integration/api/image/fixtures/image1.jp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>>@ybx8BfS)uLdfGnamVNov&l&g!A1TEzK2jY{TH<+s z6Y8~!EvaKDL3cv0^K;pn!|)IXzU{z}j?pgiuB>Bt-Uz2RuIp>{92FMIP^h05)|}1I z=sGi!QFqn$VgXuB2#v1cg#GEc(l)?8)>dh~1{PQ*I`!#VyawOb_okb=xxI8cZ;`fm zJyAqDJxxMEBTRep9~=JFqL_%r9s+6r9*< zPZVXo(fW2T%B!L{s#Fldz-hKc%U$fe=*<>7u32T2nl?>!Pjq=Z%FQj{93&z; zuv8pOFbK8At^A}1%gyB%$1)->Jn}=)ds~HtUn;lH4BxNaS+*N=GOs)*@HxZjN^I5Q zxSU(xuPm%Ch9$HS372IXq~vTiNYe7>J0JegfOkACn;9Jwv_PW&5KzczfmqncLG6GG z$LkVj3>SN{yW2dq^-+hu%grw>l77NV^|HM%-`2FX{Me ztL19vHR7cS3%c4M@UOh*y53@5rdh?JqZPVJry&8ILT#RZ9o7)uWY3nkwsH^pE?-1G zysCDgevkT{hi?(xf;9~boQFu7ddWSqku5{wyuTR7O49YD*(b{c#ioNuI>?Tn@Qm*r=f(Z{8+q&Nf!%p)y>^H;g39xUs>)4*6{%i0q%@hB1kUier_pUzon6cf%_u#d>`=Gyp+?}JuZv@%n?RWLL t$As+x{;odvkgPpI-__?H6SfEVyY+Jq$=W0I-Trou3EKnw|7ZOa{14D277PFY literal 0 HcmV?d00001 diff --git a/tests/phpunit/integration/api/image/includes/class-image-test-case.php b/tests/phpunit/integration/api/image/includes/class-image-test-case.php new file mode 100644 index 00000000..510a4567 --- /dev/null +++ b/tests/phpunit/integration/api/image/includes/class-image-test-case.php @@ -0,0 +1,167 @@ +set_up_virtual_filesystem(); + $this->images_dir = vfsStream::url( 'uploads/beans/images' ); + + // Set the Uploads directory to our virtual filesystem. + add_filter( 'upload_dir', function( array $uploads_dir ) { + $virtual_dir = vfsStream::url( 'uploads' ); + $uploads_dir['path'] = $virtual_dir . $uploads_dir['subdir']; + $uploads_dir['basedir'] = $virtual_dir; + return $uploads_dir; + } ); + } + + /** + * Set up the virtual filesystem. + */ + private function set_up_virtual_filesystem() { + $structure = array( + 'beans' => array( + 'images' => array( + 'index.php' => '', + ), + ), + ); + + // Set up the "beans" directory's virtual filesystem. + $this->mock_filesystem = vfsStream::setup( 'uploads', 0755, $structure ); + } + + /** + * Get reflective access to the private method. + * + * @since 1.5.0 + * + * @param string $method_name Method name for which to gain access. + * + * @return \ReflectionMethod + */ + protected function get_reflective_method( $method_name ) { + $class = new \ReflectionClass( '_Beans_Image_Editor' ); + $method = $class->getMethod( $method_name ); + $method->setAccessible( true ); + + return $method; + } + + /** + * Get reflective access to the private property. + * + * @since 1.5.0 + * + * @param string $property Optional. Property name for which to gain access. + * + * @return \ReflectionProperty|string + */ + protected function get_reflective_property( $property = 'rebuilt_path' ) { + $class = new \ReflectionClass( '_Beans_Image_Editor' ); + $property = $class->getProperty( $property ); + $property->setAccessible( true ); + + return $property; + } + + /** + * Initialize the virtual "edited" image. + * + * @since 1.5.0 + * + * @param \ReflectionProperty $rebuilt_path Instance of the editor's "rebuilt path" property. + * @param _Beans_Image_Editor $editor Instance of the editor. + * @param string|null $path Optional. The image's "rebuilt path". + * + * @return string + */ + protected function init_virtual_image( $rebuilt_path, $editor, $path = null ) { + + if ( is_null( $path ) ) { + $path = $rebuilt_path->getValue( $editor ); + } + + $path = $this->fix_virtual_dir( $path ); + $rebuilt_path->setValue( $editor, $path ); + return $rebuilt_path->getValue( $editor ); + } + + /** + * Fix the virtual directory. Modify the root, as wp_normalize_path changes it. + * + * @since 1.5.0 + * + * @param string $path The path to fix. + * + * @return string + */ + protected function fix_virtual_dir( $path ) { + + if ( substr( $path, 0, 6 ) === 'vfs://' ) { + return $path; + } + + return str_replace( 'vfs:/', 'vfs://', $path ); + } + + /** + * Removes the vfsStream's root, i.e. vfs:// or vfs:/. + * + * @since 1.5.0 + * + * @param string $path The path to fix. + * + * @return string + */ + protected function remove_virtual_dir_root( $path ) { + $pattern = substr( $path, 0, 6 ) === 'vfs://' + ? 'vfs://' + : 'vfs:/'; + + return str_replace( $pattern, '', $path ); + } +} diff --git a/tests/phpunit/unit/api/image/beansGetImagesDir.php b/tests/phpunit/unit/api/image/beansGetImagesDir.php new file mode 100644 index 00000000..5e201567 --- /dev/null +++ b/tests/phpunit/unit/api/image/beansGetImagesDir.php @@ -0,0 +1,45 @@ +assertStringEndsWith( '/uploads/beans/images/', beans_get_images_dir() ); + } + + /** + * Test beans_get_images_dir() should return the filtered images' directory. + */ + public function test_should_return_filtered_images_dir() { + Monkey\Filters\expectApplied( 'beans_images_dir' ) + ->once() + ->with( vfsStream::url( 'uploads/beans/images/' ) ) + ->andReturn( 'foo' ); + + $this->assertSame( 'foo/', beans_get_images_dir() ); + } +} diff --git a/tests/phpunit/unit/api/image/fixtures/image1.jpg b/tests/phpunit/unit/api/image/fixtures/image1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..598e9db3b4d55c59b616e655be84098ae0c59dd0 GIT binary patch literal 31016 zcmeFYd0dm%x<8uMs87PcTLUi zAPiBEgd`A(7y?AV0f+(tLkIyvKtYBC0wQymZo1Dt=X}mT_w=6g*>`{L=l1#I9g_E5 z&$GVoTI(6t?%?kG13!ci2sdrb%y4+qYuCdAgG^E3VP-McZkhp2&zb@39b;}@Lt%pm z-v$N+hvFRc7C5bX--cdy&_jY@XJI$b2Ze-Qh>Hw@$GLf;;;<;2>w1omZ|!4jW5RBR z1re@&8xwW|hqsM!(EEGiw#w_@em2wl_V14nunu~E{f+ClS71MUdp1Hb(T=_$EIUPs$rc5?X#FXf$s z-ak4O9UW~N4KfXn3^oJW*w~nzH8(RiH&H%ef{(=!uEm((@cRGWf>RJ46&ZSy5E_pA z_O}+V1%^iv9Q5?elpM_d!Q!{e|L7a!-(~pY{09PmAn*qQe<1J&0)HUz|04wc(>e;m zDNUkirR}pT2b}pKB%BbA4++2dEy(mN!1~#{pmo#-1@ns zT`}M`;Pd~WJ<6*+Unq}zzS#T4Z?t#c-oMknef#%+xq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)y>^H;g39xUs>)4*6{%i0q%@hB1kUier_pUzon6cf%_u#d>`=Gyp+?}JuZv@%n?RWLL t$As+x{;odvkgPpI-__?H6SfEVyY+Jq$=W0I-Trou3EKnw|7ZOa{14D277PFY literal 0 HcmV?d00001 diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php new file mode 100644 index 00000000..191f0d95 --- /dev/null +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -0,0 +1,202 @@ +set_up_virtual_filesystem(); + $this->images_dir = vfsStream::url( 'uploads/beans/images' ); + $this->images_url = 'http:://example.com/uploads/beans/images/'; + + Monkey\Functions\expect( 'wp_upload_dir' )->andReturn( array( + 'path' => '', + 'url' => '', + 'subdir' => '', + 'basedir' => vfsStream::url( 'uploads' ), + 'baseurl' => $this->images_url, + 'error' => false, + ) ); + + Monkey\Functions\expect( 'site_url' )->andReturn( 'http:://example.com' ); + } + + /** + * Set up the virtual filesystem. + */ + private function set_up_virtual_filesystem() { + $structure = array( + 'beans' => array( + 'images' => array( + 'index.php' => '', + ), + ), + ); + + // Set up the "beans" directory's virtual filesystem. + $this->mock_filesystem = vfsStream::setup( 'uploads', 0755, $structure ); + } + + /** + * Get reflective access to the private method. + * + * @since 1.5.0 + * + * @param string $method_name Method name for which to gain access. + * + * @return \ReflectionMethod + */ + protected function get_reflective_method( $method_name ) { + $class = new \ReflectionClass( '_Beans_Image_Editor' ); + $method = $class->getMethod( $method_name ); + $method->setAccessible( true ); + + return $method; + } + + /** + * Get reflective access to the private property. + * + * @since 1.5.0 + * + * @param string $property Optional. Property name for which to gain access. + * + * @return \ReflectionProperty|string + */ + protected function get_reflective_property( $property = 'rebuilt_path' ) { + $class = new \ReflectionClass( '_Beans_Image_Editor' ); + $property = $class->getProperty( $property ); + $property->setAccessible( true ); + + return $property; + } + + /** + * Initialize the virtual "edited" image. + * + * @since 1.5.0 + * + * @param \ReflectionProperty $rebuilt_path Instance of the editor's "rebuilt path" property. + * @param _Beans_Image_Editor $editor Instance of the editor. + * @param string|null $path Optional. The image's "rebuilt path". + * + * @return string + */ + protected function init_virtual_image( $rebuilt_path, $editor, $path = null ) { + + if ( is_null( $path ) ) { + $path = $rebuilt_path->getValue( $editor ); + } + + $path = $this->fix_virtual_dir( $path ); + $rebuilt_path->setValue( $editor, $path ); + return $rebuilt_path->getValue( $editor ); + } + + /** + * Fix the virtual directory. Modify the root, as wp_normalize_path changes it. + * + * @since 1.5.0 + * + * @param string $path The path to fix. + * + * @return string + */ + protected function fix_virtual_dir( $path ) { + + if ( substr( $path, 0, 6 ) === 'vfs://' ) { + return $path; + } + + return str_replace( 'vfs:/', 'vfs://', $path ); + } + + /** + * Removes the vfsStream's root, i.e. vfs:// or vfs:/. + * + * @since 1.5.0 + * + * @param string $path The path to fix. + * + * @return string + */ + protected function remove_virtual_dir_root( $path ) { + $pattern = substr( $path, 0, 6 ) === 'vfs://' + ? 'vfs://' + : 'vfs:/'; + + return str_replace( $pattern, '', $path ); + } +} From e98fecc86daa5f9e1e07a1a6463a038fc3a72eec Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 12:06:54 -0600 Subject: [PATCH 056/800] Made _Beans_Image_Editor wpcs compliant. Added tests. --- lib/api/image/class-beans-image-editor.php | 177 ++++++++ lib/api/image/class-images.php | 166 -------- lib/api/image/functions.php | 37 +- .../beans-image-editor/createEditedImage.php | 87 ++++ .../api/image/beans-image-editor/run.php | 340 +++++++++++++++ .../beans-image-editor/createEditedImage.php | 102 +++++ .../unit/api/image/beans-image-editor/run.php | 399 ++++++++++++++++++ 7 files changed, 1116 insertions(+), 192 deletions(-) create mode 100644 lib/api/image/class-beans-image-editor.php delete mode 100644 lib/api/image/class-images.php create mode 100644 tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php create mode 100644 tests/phpunit/integration/api/image/beans-image-editor/run.php create mode 100644 tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php create mode 100644 tests/phpunit/unit/api/image/beans-image-editor/run.php diff --git a/lib/api/image/class-beans-image-editor.php b/lib/api/image/class-beans-image-editor.php new file mode 100644 index 00000000..d6348d40 --- /dev/null +++ b/lib/api/image/class-beans-image-editor.php @@ -0,0 +1,177 @@ +src ); + $this->src = file_exists( $local_source ) ? $local_source : $src; + $this->args = $args; + $this->output = $output; + $this->rebuilt_path = $this->rebuild_image_path(); + } + + /** + * Run the editor. + * + * @since 1.0.0 + * + * @return array|object|string + */ + public function run() { + // Try to create image if it doesn't exist. + if ( ! file_exists( $this->rebuilt_path ) ) { + + // Return original image source if it can't be edited. + if ( ! $this->create_edited_image() ) { + + $array = array( + 'src' => $this->src, + 'width' => null, + 'height' => null, + ); + + switch ( $this->output ) { + + case 'STRING': + return $this->src; + + case 'ARRAY_N': + return array_values( $array ); + + case 'OBJECT': + return (object) $array; + } + } + } + + $src = beans_path_to_url( $this->rebuilt_path ); + + // Simply return the source if dimensions are not requested. + if ( 'STRING' === $this->output ) { + return $src; + } + + // Get the new image dimensions. + list( $width, $height ) = @getimagesize( $this->rebuilt_path ); + + $array = array( + 'src' => $src, + 'width' => $width, + 'height' => $height, + ); + + if ( 'ARRAY_N' === $this->output ) { + return array_values( $array ); + } + + if ( 'OBJECT' === $this->output ) { + return (object) $array; + } + + return $array; + } + + /** + * Edit the image and then store in rebuilt path. + * + * @since 1.0.0 + * + * @return bool Returns true when successful; else false is returned. + */ + private function create_edited_image() { + $wp_editor = wp_get_image_editor( $this->src ); + + // If an error occurred, bail out. + if ( is_wp_error( $wp_editor ) ) { + return false; + } + + // Fire the editing task. + foreach ( $this->args as $method => $args ) { + + if ( is_callable( array( $wp_editor, $method ) ) ) { + call_user_func_array( array( $wp_editor, $method ), (array) $args ); + } + } + + // Save the "edited" image as a new image. + $wp_editor->save( $this->rebuilt_path ); + + return ! is_wp_error( $wp_editor ); + } + + /** + * Rebuild the image's path. + * + * @since 1.0.0 + * + * @return string + */ + private function rebuild_image_path() { + $upload_dir = beans_get_images_dir(); + $info = pathinfo( preg_replace( '#\?.*#', '', $this->src ) ); + $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $extension = $info['extension']; + $filename = str_replace( '.' . $extension, '', $info['basename'] ); + + return "{$upload_dir}{$filename}-{$query}.{$extension}"; + } +} diff --git a/lib/api/image/class-images.php b/lib/api/image/class-images.php deleted file mode 100644 index f3647bac..00000000 --- a/lib/api/image/class-images.php +++ /dev/null @@ -1,166 +0,0 @@ -src = $src; - $this->args = $args; - $this->output = $output; - $local_source = beans_url_to_path( $this->src ); - - // Treat internal files as such if possible. - if ( file_exists( $local_source ) ) { - $this->src = $local_source; - } - - } - - /** - * Initialize the editing. - */ - public function init() { - - $this->setup(); - - // Try to create image if it doesn't exist. - if ( ! file_exists( $this->rebuilt_path ) ) { - - // Return orginial image source if it can't be edited. - if ( ! $this->edit() ) { - - $array = array( - 'src' => $this->src, - 'width' => null, - 'height' => null, - ); - - switch ( $this->output ) { - - case 'STRING': - return $this->src; - break; - - case 'ARRAY_N': - return array_values( $array ); - break; - - case 'OBJECT': - return (object) $array; - break; - - } - } - } - - $src = beans_path_to_url( $this->rebuilt_path ); - - // Simply return the source if dimensions are not requested - if ( 'STRING' == $this->output ) { - return $src; - } - - // Get the new image dimensions - list( $width, $height ) = @getimagesize( $this->rebuilt_path ); - - $array = array( - 'src' => $src, - 'width' => $width, - 'height' => $height, - ); - - if ( 'ARRAY_N' == $this->output ) { - return array_values( $array ); - } elseif ( 'OBJECT' == $this->output ) { - return (object) $array; - } - - return $array; - - } - - /** - * Setup image data. - */ - private function setup() { - - $upload_dir = beans_get_images_dir(); - $info = pathinfo( preg_replace( '#\?.*#', '', $this->src ) ); - $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); - $extension = $info['extension']; - $filename = str_replace( '.' . $extension, '', $info['basename'] ); - $this->rebuilt_path = "{$upload_dir}{$filename}-{$query}.{$extension}"; - - } - - /** - * Edit image. - */ - private function edit() { - - // Prepare editor. - $editor = wp_get_image_editor( $this->src ); - - // Stop here if there was an error. - if ( is_wp_error( $editor ) ) { - return false; - } - - // Fire image edit. - foreach ( $this->args as $function => $arguments ) { - - // Make sure it is callable - if ( is_callable( array( $editor, $function ) ) ) { - call_user_func_array( array( $editor, $function ), (array) $arguments ); - } - } - - // Save new image. - $editor->save( $this->rebuilt_path ); - - // Stop here if there was an error. - if ( is_wp_error( $editor ) ) { - return false; - } - - return true; - - } -} diff --git a/lib/api/image/functions.php b/lib/api/image/functions.php index d5734763..caac6458 100644 --- a/lib/api/image/functions.php +++ b/lib/api/image/functions.php @@ -2,10 +2,10 @@ /** * The Beans Image component contains a set of functions to edit images on the fly. * - * Edited images are duplicates of the orinigals. All modified images are stored in a shared folder, + * Edited images are duplicates of the originals. All modified images are stored in a shared folder, * which makes it easy to delete them without impacting the originals. * - * @package API\Image + * @package Beans\Framework\API\Image */ /** @@ -17,35 +17,20 @@ * @since 1.0.0 * * @param string $src The image source. - * @param array $args { - * Associative array of arguments used by the image editor. - * - * @type array $resize Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize function arguments. - * @type array $crop Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop function arguments. - * @type array $rotate Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate function arguments. - * @type array $flip Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip function arguments. - * @type array $set_quality Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality function - * arguments. - * } - * + * @param array $args An array of editor arguments, where the key is the {@see WP_Image_Editor} method name + * and the value is a numeric array of arguments for the method. Make sure that you + * specify all of the arguments the editor's method requires. Refer to + * {@link https://codex.wordpress.org/Class_Reference/WP_Image_Editor#Methods} for more + * information on the available methods and each method's arguments. * @param string $output Optional. Returned format. Accepts STRING, OBJECT, ARRAY_A, or ARRAY_N. - * Default STRING. + * Default is STRING. * * @return string|array Image source if output set the STRING, image data otherwise. */ function beans_edit_image( $src, array $args, $output = 'STRING' ) { - - require_once( BEANS_API_PATH . 'image/class-images.php' ); - - $instance = new _Beans_Image_Editor( $src, $args, $output ); - - return $instance->init(); - + require_once BEANS_API_PATH . 'image/class-beans-images-editor.php'; + $editor = new _Beans_Image_Editor( $src, $args, $output ); + return $editor->run(); } /** diff --git a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php new file mode 100644 index 00000000..6d8e08ce --- /dev/null +++ b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php @@ -0,0 +1,87 @@ +get_reflective_method( 'create_edited_image' ); + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $this->assertTrue( $get_image_info->invoke( $editor ) ); + $this->assertFileExists( $edited_image_src ); + + list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $this->assertEquals( 800, $width ); + $this->assertEquals( 420, $height ); + } + } + + /** + * Test get_image_info() should return false when the image does not exist. + */ + public function test_should_return_false_when_no_image() { + $get_image_info = $this->get_reflective_method( 'create_edited_image' ); + $rebuilt_path = $this->get_reflective_property(); + $src = 'path/does/not/exist/image.jpg'; + + $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ) ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertFalse( $get_image_info->invoke( $editor ) ); + $this->assertFileNotExists( $edited_image_src ); + } +} diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php new file mode 100644 index 00000000..6f32a4f9 --- /dev/null +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -0,0 +1,340 @@ +get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $image_info = $editor->run(); + $this->assertFileExists( $edited_image_src ); + $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info ); + + // Check the edited image's dimensions. + list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $this->assertEquals( 800, $width ); + $this->assertEquals( 420, $height ); + } + } + + /** + * Test init() should return original src when the image does not exist. + */ + public function test_should_return_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ) ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( $src, $editor->run() ); + } + + /** + * Test run() should return the URL when the edited image exists, meaning that it has already been edited and + * stored. + */ + public function test_should_return_url_when_edited_image_exists() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run it once to create the "edited image". + $editor->run(); + + // Run the tests. + $this->assertFileExists( $edited_image_src ); + $this->assertSame( beans_path_to_url( $edited_image_src ), $editor->run() ); + } + } + + /** + * Test run() should edit the existing image, store it in the "rebuilt path", and then return an index array of its + * image info. + */ + public function test_should_edit_store_and_return_indexed_array() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $image_info = $editor->run(); + $this->assertFileExists( $edited_image_src ); + $this->assertSame( array( beans_path_to_url( $edited_image_src ), 800, 420 ), $image_info ); + + // Check the edited image's dimensions. + list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $this->assertEquals( 800, $width ); + $this->assertEquals( 420, $height ); + } + } + + /** + * Test beans_edit_image() should return an indexed array with the original src when the image does not exist. + */ + public function test_should_return_indexed_array_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( array( $src, null, null ), $editor->run() ); + } + + /** + * Test run() should return return an indexed array when the edited image exists, meaning that it has already been + * edited and stored. + */ + public function test_should_return_index_array_when_edited_image_exists() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run it once to create the "edited image". + $editor->run(); + + // Run the tests. + $this->assertFileExists( $edited_image_src ); + $this->assertSame( array( beans_path_to_url( $edited_image_src ), 800, 420 ), $editor->run() ); + } + } + + /** + * Test run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an + * object. + */ + public function test_should_edit_store_and_return_object() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 400, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, OBJECT ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $image_info = $editor->run(); + $this->assertFileExists( $edited_image_src ); + $this->assertInstanceOf( 'stdClass', $image_info ); + $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info->src ); + $this->assertSame( 400, $image_info->width ); + $this->assertSame( 210, $image_info->height ); + + // Check the edited image's dimensions. + list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $this->assertEquals( 400, $width ); + $this->assertEquals( 210, $height ); + } + } + + /** + * Test beans_edit_image() should return an object with the original src when the image does not exist. + */ + public function test_should_return_object_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), OBJECT ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $image_info = $editor->run(); + $this->assertInstanceOf( 'stdClass', $image_info ); + $this->assertSame( $src, $image_info->src ); + $this->assertNull( $image_info->width ); + $this->assertNull( $image_info->height ); + } + + /** + * Test run() should return return an object when the edited image exists, meaning that it has already been + * edited and stored. + */ + public function test_should_return_object_when_edited_image_exists() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 400, false ) ); + + // Run the tests. + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, OBJECT ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run it once to create the "edited image". + $editor->run(); + + // Run the tests. + $this->assertFileExists( $edited_image_src ); + $image_info = $editor->run(); + $this->assertInstanceOf( 'stdClass', $image_info ); + $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info->src ); + $this->assertSame( 400, $image_info->width ); + $this->assertSame( 210, $image_info->height ); + } + } + + /** + * Test run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an + * associative array. + */ + public function test_should_edit_image_and_return_associative_array() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 600, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, ARRAY_A ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $image_info = $editor->run(); + $this->assertFileExists( $edited_image_src ); + $this->assertSame( + array( + 'src' => beans_path_to_url( $edited_image_src ), + 'width' => 600, + 'height' => 315, + ), + $image_info + ); + + // Check the edited image's dimensions. + list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $this->assertEquals( 600, $width ); + $this->assertEquals( 315, $height ); + } + } + + /** + * Test beans_edit_image() should return an array with the original src when the image does not exist. + */ + public function test_should_return_associative_array_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( + array( + 'src' => $src, + 'width' => null, + 'height' => null, + ), + $editor->run() + ); + } + + /** + * Test run() should return return an associative array when the edited image exists, meaning that it has already + * been edited and stored. + */ + public function test_should_return_associatve_array_when_edited_image_exists() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 600, false ) ); + + // Run the tests. + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, ARRAY_A ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Run it once to create the "edited image". + $editor->run(); + + // Run the tests. + $this->assertFileExists( $edited_image_src ); + $this->assertSame( + array( + 'src' => beans_path_to_url( $edited_image_src ), + 'width' => 600, + 'height' => 315, + ), + $editor->run() + ); + } + } +} diff --git a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php new file mode 100644 index 00000000..b92a1d7b --- /dev/null +++ b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php @@ -0,0 +1,102 @@ +get_reflective_method( 'create_edited_image' ); + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Simulate the WordPress' Editor. + $wp_editor = Mockery::mock( 'WP_Image_Editor' ); + $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); + $wp_editor->shouldReceive( 'save' ) + ->once() + ->with( $edited_image_src ) + ->andReturnUsing( function( $edited_image_src ) use ( $src ) { + imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + } ); + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); + Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $this->assertTrue( $get_image_info->invoke( $editor ) ); + $this->assertFileExists( $edited_image_src ); + } + } + + /** + * Test get_image_info() should return false when the image does not exist. + */ + public function test_should_return_false_when_no_image() { + $get_image_info = $this->get_reflective_method( 'create_edited_image' ); + $rebuilt_path = $this->get_reflective_property(); + $src = 'path/does/not/exist/image.jpg'; + $args = array( 'resize' => array( 800, false ) ); + + $editor = new _Beans_Image_Editor( $src, $args ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Simulate the WordPress' Editor. + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertFalse( $get_image_info->invoke( $editor ) ); + $this->assertFileNotExists( $edited_image_src ); + } +} diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php new file mode 100644 index 00000000..22414700 --- /dev/null +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -0,0 +1,399 @@ +justReturn( true ); + } + + /** + * Test run() should edit the existing image, store it in the "rebuilt path", and then return it's URL. + */ + public function test_should_edit_store_and_return_its_url() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Simulate the WordPress' Editor. + $wp_editor = Mockery::mock( 'WP_Image_Editor' ); + $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); + $wp_editor->shouldReceive( 'save' ) + ->once() + ->with( $edited_image_src ) + ->andReturnUsing( function( $edited_image_src ) use ( $src ) { + imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + } ); + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); + Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $image_info = $editor->run(); + $this->assertFileExists( $edited_image_src ); + $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info ); + } + } + + /** + * Test init() should return original src when the image does not exist. + */ + public function test_should_return_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ) ); + + // Simulate the WordPress' Editor. + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( $src, $editor->run() ); + } + + /** + * Test run() should return the URL when the edited image exists, meaning that it has already been edited and + * stored. + */ + public function test_should_return_url_when_edited_image_exists() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $src ); + + // Check that the WordPress Editor does not get called. + Monkey\Functions\expect( 'wp_get_image_editor' )->never(); + Monkey\Functions\expect( 'is_wp_error' )->never(); + + // Run the tests. + $this->assertFileExists( $edited_image_src ); + $this->assertSame( beans_path_to_url( $edited_image_src ), $editor->run() ); + } + } + + /** + * Test run() should edit the existing image, store it in the "rebuilt path", and then return an index array of its + * image info. + */ + public function test_should_edit_store_and_return_indexed_array() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Simulate the WordPress' Editor. + $wp_editor = Mockery::mock( 'WP_Image_Editor' ); + $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); + $wp_editor->shouldReceive( 'save' ) + ->once() + ->with( $edited_image_src ) + ->andReturnUsing( function( $edited_image_src ) use ( $src ) { + imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + } ); + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); + Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $image_info = $editor->run(); + $this->assertFileExists( $edited_image_src ); + $this->assertSame( array( beans_path_to_url( $edited_image_src ), 1200, 630 ), $image_info ); + } + } + + /** + * Test beans_edit_image() should return an indexed array with the original src when the image does not exist. + */ + public function test_should_return_indexed_array_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ); + + // Simulate the WordPress' Editor. + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( array( $src, null, null ), $editor->run() ); + } + + /** + * Test run() should return return an indexed array when the edited image exists, meaning that it has already been + * edited and stored. + */ + public function test_should_return_index_array_when_edited_image_exists() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 800, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $src ); + + // Check that the WordPress Editor does not get called. + Monkey\Functions\expect( 'wp_get_image_editor' )->never(); + Monkey\Functions\expect( 'is_wp_error' )->never(); + + // Run the tests. + $this->assertFileExists( $edited_image_src ); + $this->assertSame( array( beans_path_to_url( $edited_image_src ), 1200, 630 ), $editor->run() ); + } + } + + /** + * Test run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an + * object. + */ + public function test_should_edit_store_and_return_object() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 400, false ) ); + + // Run the tests. + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, OBJECT ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Simulate the WordPress' Editor. + $wp_editor = Mockery::mock( 'WP_Image_Editor' ); + $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); + $wp_editor->shouldReceive( 'save' ) + ->once() + ->with( $edited_image_src ) + ->andReturnUsing( function( $edited_image_src ) use ( $src ) { + imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + } ); + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); + Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $image_info = $editor->run(); + $this->assertInstanceOf( 'stdClass', $image_info ); + $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info->src ); + $this->assertSame( 1200, $image_info->width ); + $this->assertSame( 630, $image_info->height ); + $this->assertFileExists( $edited_image_src ); + } + } + + /** + * Test beans_edit_image() should return an object with the original src when the image does not exist. + */ + public function test_should_return_object_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), OBJECT ); + + // Simulate the WordPress' Editor. + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $image_info = $editor->run(); + $this->assertInstanceOf( 'stdClass', $image_info ); + $this->assertSame( $src, $image_info->src ); + $this->assertNull( $image_info->width ); + $this->assertNull( $image_info->height ); + } + + /** + * Test run() should return return an object when the edited image exists, meaning that it has already been + * edited and stored. + */ + public function test_should_return_object_when_edited_image_exists() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 400, false ) ); + + // Run the tests. + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, OBJECT ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $src ); + + // Check that the WordPress Editor does not get called. + Monkey\Functions\expect( 'wp_get_image_editor' )->never(); + Monkey\Functions\expect( 'is_wp_error' )->never(); + + // Run the tests. + $this->assertFileExists( $edited_image_src ); + $actual = $editor->run(); + $this->assertInstanceOf( 'stdClass', $actual ); + $this->assertSame( beans_path_to_url( $edited_image_src ), $actual->src ); + $this->assertSame( 1200, $actual->width ); + $this->assertSame( 630, $actual->height ); + } + } + + /** + * Test run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an + * associative array. + */ + public function test_should_edit_image_and_return_associative_array() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 600, false ) ); + + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, ARRAY_A ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); + + // Simulate the WordPress' Editor. + $wp_editor = Mockery::mock( 'WP_Image_Editor' ); + $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); + $wp_editor->shouldReceive( 'save' ) + ->once() + ->with( $edited_image_src ) + ->andReturnUsing( function( $edited_image_src ) use ( $src ) { + imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + } ); + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); + Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); + + // Run the tests. + $this->assertFileNotExists( $edited_image_src ); + $image_info = $editor->run(); + $this->assertFileExists( $edited_image_src ); + $this->assertSame( + array( + 'src' => beans_path_to_url( $edited_image_src ), + 'width' => 1200, + 'height' => 630, + ), + $image_info + ); + } + } + + /** + * Test beans_edit_image() should return an associative array with the original src when the image does not exist. + */ + public function test_should_return_associative_array_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ); + + // Simulate the WordPress' Editor. + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( + array( + 'src' => $src, + 'width' => null, + 'height' => null, + ), + $editor->run() + ); + } + + /** + * Test run() should return return an associative array when the edited image exists, meaning that it has already + * been edited and stored. + */ + public function test_should_return_associatve_array_when_edited_image_exists() { + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( + static::$fixtures_dir . '/image1.jpg', + static::$fixtures_dir . '/image2.jpg', + ); + $args = array( 'resize' => array( 600, false ) ); + + // Run the tests. + foreach ( $image_sources as $src ) { + $editor = new _Beans_Image_Editor( $src, $args, ARRAY_A ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $src ); + + // Check that the WordPress Editor does not get called. + Monkey\Functions\expect( 'wp_get_image_editor' )->never(); + Monkey\Functions\expect( 'is_wp_error' )->never(); + + // Run the tests. + $this->assertFileExists( $edited_image_src ); + $this->assertSame( + array( + 'src' => beans_path_to_url( $edited_image_src ), + 'width' => 1200, + 'height' => 630, + ), + $editor->run() + ); + } + } +} From 9e29719834af369d7bba6e4a83ad662e83ba2980 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 12:08:00 -0600 Subject: [PATCH 057/800] Fixed #115. --- lib/api/image/class-beans-image-editor.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/api/image/class-beans-image-editor.php b/lib/api/image/class-beans-image-editor.php index d6348d40..69d0515d 100644 --- a/lib/api/image/class-beans-image-editor.php +++ b/lib/api/image/class-beans-image-editor.php @@ -96,6 +96,9 @@ public function run() { case 'ARRAY_N': return array_values( $array ); + case 'ARRAY_A': + return $array; + case 'OBJECT': return (object) $array; } From d231c887c0865b0d46bd40948dc1c89371412fa6 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 12:17:02 -0600 Subject: [PATCH 058/800] Refactored run(). Removed redundant code by creating the get_image_info() method. Code is now more readable and maintainable. --- lib/api/image/class-beans-image-editor.php | 107 +++++++++--------- .../api/image/beans-image-editor/run.php | 1 - 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/lib/api/image/class-beans-image-editor.php b/lib/api/image/class-beans-image-editor.php index 69d0515d..48b9f3e0 100644 --- a/lib/api/image/class-beans-image-editor.php +++ b/lib/api/image/class-beans-image-editor.php @@ -72,64 +72,18 @@ public function __construct( $src, array $args, $output = 'STRING' ) { * Run the editor. * * @since 1.0.0 + * @since 1.5.0 Refactored. * * @return array|object|string */ public function run() { - // Try to create image if it doesn't exist. - if ( ! file_exists( $this->rebuilt_path ) ) { - // Return original image source if it can't be edited. - if ( ! $this->create_edited_image() ) { - - $array = array( - 'src' => $this->src, - 'width' => null, - 'height' => null, - ); - - switch ( $this->output ) { - - case 'STRING': - return $this->src; - - case 'ARRAY_N': - return array_values( $array ); - - case 'ARRAY_A': - return $array; - - case 'OBJECT': - return (object) $array; - } - } - } - - $src = beans_path_to_url( $this->rebuilt_path ); - - // Simply return the source if dimensions are not requested. - if ( 'STRING' === $this->output ) { - return $src; - } - - // Get the new image dimensions. - list( $width, $height ) = @getimagesize( $this->rebuilt_path ); - - $array = array( - 'src' => $src, - 'width' => $width, - 'height' => $height, - ); - - if ( 'ARRAY_N' === $this->output ) { - return array_values( $array ); + // Return the edited image's info packet when the file already exists or we successfully create it. + if ( $this->edited_image_exists() || $this->create_edited_image() ) { + return $this->get_image_info( beans_path_to_url( $this->rebuilt_path ), true ); } - if ( 'OBJECT' === $this->output ) { - return (object) $array; - } - - return $array; + return $this->get_image_info( $this->src ); } /** @@ -161,6 +115,46 @@ private function create_edited_image() { return ! is_wp_error( $wp_editor ); } + /** + * Returns the image's information in the configured output format. + * + * @since 1.5.0 + * + * @param string $src Image's path or URL. + * @param bool $edited_image_exists When true, include the dimensions. + * + * @return array|object + */ + private function get_image_info( $src, $edited_image_exists = false ) { + + if ( 'STRING' === $this->output ) { + return $src; + } + + if ( $edited_image_exists ) { + list( $width, $height ) = @getimagesize( $this->rebuilt_path ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + } else { + $width = null; + $height = null; + } + + if ( 'ARRAY_N' === $this->output ) { + return array( $src, $width, $height ); + } + + $image_info = array( + 'src' => $src, + 'width' => $width, + 'height' => $height, + ); + + if ( 'OBJECT' === $this->output ) { + return (object) $image_info; + } + + return $image_info; + } + /** * Rebuild the image's path. * @@ -177,4 +171,15 @@ private function rebuild_image_path() { return "{$upload_dir}{$filename}-{$query}.{$extension}"; } + + /** + * Checks if the edited image exists. + * + * @since 1.5.0 + * + * @return bool + */ + private function edited_image_exists() { + return file_exists( $this->rebuilt_path ); + } } diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php index 6f32a4f9..b118dfe1 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -11,7 +11,6 @@ use _Beans_Image_Editor; use Beans\Framework\Tests\Integration\API\Image\Includes\Image_Test_Case; -use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-image-test-case.php'; require_once BEANS_API_PATH . 'image/class-beans-image-editor.php'; From 7f6e86cbfbe01e4703a038b02b6dcd8eaad0d9cc Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 12:33:13 -0600 Subject: [PATCH 059/800] Tested beans_edit_image(). --- lib/api/image/functions.php | 2 +- .../integration/api/image/beansEditImage.php | 98 +++++++++++++++ .../phpunit/unit/api/image/beansEditImage.php | 119 ++++++++++++++++++ 3 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/integration/api/image/beansEditImage.php create mode 100644 tests/phpunit/unit/api/image/beansEditImage.php diff --git a/lib/api/image/functions.php b/lib/api/image/functions.php index caac6458..0d56ad17 100644 --- a/lib/api/image/functions.php +++ b/lib/api/image/functions.php @@ -28,7 +28,7 @@ * @return string|array Image source if output set the STRING, image data otherwise. */ function beans_edit_image( $src, array $args, $output = 'STRING' ) { - require_once BEANS_API_PATH . 'image/class-beans-images-editor.php'; + require_once BEANS_API_PATH . 'image/class-beans-image-editor.php'; $editor = new _Beans_Image_Editor( $src, $args, $output ); return $editor->run(); } diff --git a/tests/phpunit/integration/api/image/beansEditImage.php b/tests/phpunit/integration/api/image/beansEditImage.php new file mode 100644 index 00000000..77e17cd8 --- /dev/null +++ b/tests/phpunit/integration/api/image/beansEditImage.php @@ -0,0 +1,98 @@ +assertFileNotExists( $src ); + $this->assertSame( $src, beans_edit_image( $src, array( 'resize' => array( 800, false ) ) ) ); + } + + /** + * Test beans_edit_image() should return an indexed array with the original src when the image does not exist. + */ + public function test_should_return_indexed_array_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( + array( $src, null, null ), + beans_edit_image( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ) + ); + } + + /** + * Test beans_edit_image() should return an object with the original src when the image does not exist. + */ + public function test_should_return_object_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + + // Run the tests. + $this->assertFileNotExists( $src ); + $image_info = beans_edit_image( $src, array( 'resize' => array( 800, false ) ), OBJECT ); + $this->assertInstanceOf( 'stdClass', $image_info ); + $this->assertSame( $src, $image_info->src ); + $this->assertNull( $image_info->width ); + $this->assertNull( $image_info->height ); + } + + /** + * Test beans_edit_image() should return an associative array with the original src when the image does not exist. + */ + public function test_should_return_associative_array_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( + array( + 'src' => $src, + 'width' => null, + 'height' => null, + ), + beans_edit_image( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ) + ); + } +} diff --git a/tests/phpunit/unit/api/image/beansEditImage.php b/tests/phpunit/unit/api/image/beansEditImage.php new file mode 100644 index 00000000..4e430009 --- /dev/null +++ b/tests/phpunit/unit/api/image/beansEditImage.php @@ -0,0 +1,119 @@ +with( $src )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( $src, beans_edit_image( $src, array( 'resize' => array( 800, false ) ) ) ); + } + + /** + * Test beans_edit_image() should return an indexed array with the original src when the image does not exist. + */ + public function test_should_return_indexed_array_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + + // Simulate the WordPress' Editor. + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( + array( $src, null, null ), + beans_edit_image( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ) + ); + } + + /** + * Test beans_edit_image() should return an object with the original src when the image does not exist. + */ + public function test_should_return_object_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + + // Simulate the WordPress' Editor. + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $image_info = beans_edit_image( $src, array( 'resize' => array( 800, false ) ), OBJECT ); + $this->assertInstanceOf( 'stdClass', $image_info ); + $this->assertSame( $src, $image_info->src ); + $this->assertNull( $image_info->width ); + $this->assertNull( $image_info->height ); + } + + /** + * Test beans_edit_image() should return an associative array with the original src when the image does not exist. + */ + public function test_should_return_associative_array_with_original_src_when_no_image() { + $src = 'path/does/not/exist/image.jpg'; + + // Simulate the WordPress' Editor. + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the tests. + $this->assertFileNotExists( $src ); + $this->assertSame( + array( + 'src' => $src, + 'width' => null, + 'height' => null, + ), + beans_edit_image( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ) + ); + } +} From 5b7de92739a91041d0dbb99dd0c290ab2bcdddee Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 12:45:22 -0600 Subject: [PATCH 060/800] Made functions.php WPCS compliant. --- lib/api/image/functions.php | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/lib/api/image/functions.php b/lib/api/image/functions.php index 0d56ad17..82f8a469 100644 --- a/lib/api/image/functions.php +++ b/lib/api/image/functions.php @@ -47,7 +47,6 @@ function beans_edit_image( $src, array $args, $output = 'STRING' ) { * @return object Post attachment data. */ function beans_get_post_attachment( $post_id, $size = 'full' ) { - $id = get_post_thumbnail_id( $post_id ); $post = get_post( $id ); $src = wp_get_attachment_image_src( $id, $size ); @@ -63,32 +62,21 @@ function beans_get_post_attachment( $post_id, $size = 'full' ) { $obj->description = $post->post_content; return $obj; - } /** * Edit post attachment. * - * This function is shortuct of {@see beans_edit_image()}. It should be used to edit a post attachment. + * This function is shortcut of {@see beans_edit_image()}. It should be used to edit a post attachment. * * @since 1.0.0 * * @param string $post_id The post id. - * @param array $args { - * Array of arguments used by the image editor. - * - * @type array $resize Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize function arguments. - * @type array $crop Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop function arguments. - * @type array $rotate Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate function arguments. - * @type array $flip Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip function arguments. - * @type array $set_quality Numeric array matching the - * {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality function - * arguments. - * } + * @param array $args An array of editor arguments, where the key is the {@see WP_Image_Editor} method name + * and the value is a numeric array of arguments for the method. Make sure that you + * specify all of the arguments the editor's method requires. Refer to + * {@link https://codex.wordpress.org/Class_Reference/WP_Image_Editor#Methods} for more + * information on the available methods and each method's arguments. * * @return object Edited post attachment data. */ @@ -99,14 +87,14 @@ function beans_edit_post_attachment( $post_id, $args = array() ) { } // Get full size image. - $attachement = beans_get_post_attachment( $post_id, 'full' ); + $attachment = beans_get_post_attachment( $post_id, 'full' ); + $edited = beans_edit_image( $attachment->src, $args, 'ARRAY_A' ); - if ( ! $edited = beans_edit_image( $attachement->src, $args, 'ARRAY_A' ) ) { - return $attachement; + if ( ! $edited ) { + return $attachment; } - return (object) array_merge( (array) $attachement, $edited ); - + return (object) array_merge( (array) $attachment, $edited ); } /** From a55dae23653ab7a15a38321fb246542c0d4c6bca Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 13:53:46 -0600 Subject: [PATCH 061/800] Fixed formatting. --- lib/api/image/functions.php | 2 ++ tests/phpunit/unit/api/image/beansEditImage.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/api/image/functions.php b/lib/api/image/functions.php index 82f8a469..3fb968a3 100644 --- a/lib/api/image/functions.php +++ b/lib/api/image/functions.php @@ -47,6 +47,7 @@ function beans_edit_image( $src, array $args, $output = 'STRING' ) { * @return object Post attachment data. */ function beans_get_post_attachment( $post_id, $size = 'full' ) { + $id = get_post_thumbnail_id( $post_id ); $post = get_post( $id ); $src = wp_get_attachment_image_src( $id, $size ); @@ -62,6 +63,7 @@ function beans_get_post_attachment( $post_id, $size = 'full' ) { $obj->description = $post->post_content; return $obj; + } /** diff --git a/tests/phpunit/unit/api/image/beansEditImage.php b/tests/phpunit/unit/api/image/beansEditImage.php index 4e430009..c100d2cf 100644 --- a/tests/phpunit/unit/api/image/beansEditImage.php +++ b/tests/phpunit/unit/api/image/beansEditImage.php @@ -47,7 +47,7 @@ public static function setUpBeforeClass() { * Test init() should return original src when the image does not exist. */ public function test_should_return_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; + $src = 'path/does/not/exist/image.jpg'; // Simulate the WordPress' Editor. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); From 0b4ee52f57201a10f98b329ac224b32b4909a68c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 15:30:25 -0600 Subject: [PATCH 062/800] Improved documentation. --- lib/api/html/class-beans-attribute.php | 17 ++++--------- lib/api/html/functions.php | 25 +++++++++++-------- .../html/includes/class-html-test-case.php | 2 +- .../html/includes/class-html-test-case.php | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/lib/api/html/class-beans-attribute.php b/lib/api/html/class-beans-attribute.php index d47d0dc1..869718ef 100644 --- a/lib/api/html/class-beans-attribute.php +++ b/lib/api/html/class-beans-attribute.php @@ -2,7 +2,7 @@ /** * This class provides the means to add, replace, and remove a HTML attribute and its value(s). * - * @package Beans\Framework\API\Actions + * @package Beans\Framework\API\HTML * * @since 1.5.0 */ @@ -34,20 +34,14 @@ final class _Beans_Attribute { private $attribute; /** - * Value of the HTML attribute. - * - * If set to '' will display the attribute value as empty (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not display anything. + * Value of the HTML attribute (i.e. value to be replaced or removed). * * @var string */ private $value; /** - * Attribute replacement value. - * - * If set to '' will display the attribute value as empty (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not display anything. + * Replacement (new) value of the HTML attribute. * * @var string */ @@ -60,9 +54,8 @@ final class _Beans_Attribute { * * @param string $id The markup ID. * @param string $attribute Name of the HTML attribute. - * @param string|null $value Optional. Value of the HTML attribute. - * @param string|null $new_value Optional. Attribute replacement value, which is a query string or an array of - * attributes. + * @param string|null $value Optional. Value of the HTML attribute (i.e. value to be replaced or removed). + * @param string|null $new_value Optional. Replacement (new) value of the HTML attribute. */ public function __construct( $id, $attribute, $value = null, $new_value = null ) { $this->id = $id; diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 20ac9381..4a3f14fe 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -3,7 +3,9 @@ * The Beans HTML component contains a powerful set of functions to create flexible and easy overwritable HTML markup, * attributes and content. * - * @package API\HTML + * @package Beans\Framework\API\HTML + * + * @since 1.5.0 */ /** @@ -565,12 +567,14 @@ function beans_add_attribute( $id, $attribute, $value ) { * @since 1.0.0 * @since 1.5.0 Return the object. Allows replacement of all values. * - * @param string $id The markup ID. - * @param string $attribute Name of the HTML attribute to target. - * @param string $value Value which should be replaced. When empty ('', false, or null), it replaces all of the values for this attribute. - * @param string $new_value Optional. Replacement value. If set to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display the attribute name - * (e.g. data-example). Setting it to 'null' will not display anything. + * @param string $id The markup ID. + * @param string $attribute Name of the HTML attribute to target. + * @param string $value Value of the HTML attribute to be replaced. Setting it to an empty (i.e. empty string, + * false, or null) replaces all of the values for this attribute. + * @param string|null $new_value Optional. Replacement (new) value of the HTML attribute. Setting it to an empty string + * ('') or null will remove the $value (e.g. class=""). Setting it to 'false', the + * browser will display only the attribute name + * (e.g. data-example). * * @return _Beans_Attribute */ @@ -591,9 +595,10 @@ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { * @since 1.0.0 * @since 1.5.0 Return the object. * - * @param string $id The markup ID. - * @param string $attribute Name of the HTML attribute to target. - * @param string $value Optional. The attribute value to remove. Set it to 'false' or null to completely remove the attribute. + * @param string $id The markup ID. + * @param string $attribute Name of the HTML attribute to target. + * @param string|null $value Optional. The attribute value to remove. Set it to 'false' or null to completely + * remove the attribute. * * @return _Beans_Attribute */ diff --git a/tests/phpunit/integration/api/html/includes/class-html-test-case.php b/tests/phpunit/integration/api/html/includes/class-html-test-case.php index 51777d7a..392aa82f 100644 --- a/tests/phpunit/integration/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/integration/api/html/includes/class-html-test-case.php @@ -1,6 +1,6 @@ Date: Fri, 16 Feb 2018 16:08:49 -0600 Subject: [PATCH 063/800] Made beans_get_default_layout() compliant & tested. --- lib/api/layout/functions.php | 69 +++++++++++-------- .../api/layout/beansGetDefaultLayout.php | 52 ++++++++++++++ .../unit/api/layout/beansGetDefaultLayout.php | 64 +++++++++++++++++ 3 files changed, 155 insertions(+), 30 deletions(-) create mode 100644 tests/phpunit/integration/api/layout/beansGetDefaultLayout.php create mode 100644 tests/phpunit/unit/api/layout/beansGetDefaultLayout.php diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index c85a7b6d..65642c46 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -2,7 +2,19 @@ /** * The Beans Layout API controls what and how Beans main section elements are displayed. * - * @package API\Layout + * Layouts are: + * - "c" - content only + * - "c_sp" - content + sidebar primary + * - "sp_c" - sidebar primary + content + * - "c_ss" - content + sidebar secondary + * - "c_sp_ss" - content + sidebar primary + sidebar secondary + * - "ss_c" - sidebar secondary + content + * - "sp_ss_c" - sidebar primary + sidebar secondary + content + * - "sp_c_ss" - sidebar primary + content + sidebar secondary + * + * @package Beans\Framework\API\Layout + * + * @since 1.5.0 */ /** @@ -10,24 +22,21 @@ * * @since 1.0.0 * - * @return string The defautl layout. + * @return string */ function beans_get_default_layout() { - $default_layout = beans_has_widget_area( 'sidebar_primary' ) ? 'c_sp' : 'c'; /** - * Filter the default layout id. + * Filter the default layout. * - * The default id is set to "c_sp" (content with sidebar primary). If the sidebar primary is deregistered, it fallback - * to "c" (content only). + * The default layout is set to "c_sp" (content + sidebar primary). If the sidebar primary is unregistered, the default layout is "c" (content only). * * @since 1.0.0 * - * @param string $layout The default layout id. + * @param string $layout The default layout. */ return apply_filters( 'beans_default_layout', $default_layout ); - } /** @@ -86,13 +95,13 @@ function beans_get_layout_class( $id ) { * * @since 1.0.0 * - * @param array $args { - * An array of arguments. + * @param array $args { + * An array of arguments. * - * @type int $grid Total number of columns the grid contains. Default 4. - * @type int $sidebar_primary The number of columns the sidebar primary takes. Default 1. - * @type int $sidebar_secondary The number of columns the sidebar secondary takes. Default 1. - * @type string $breakpoint The UIkit grid breakpoint which may be set to 'small', 'medium' or 'large'. Default 'medium'. + * @type int $grid Total number of columns the grid contains. Default 4. + * @type int $sidebar_primary The number of columns the sidebar primary takes. Default 1. + * @type int $sidebar_secondary The number of columns the sidebar secondary takes. Default 1. + * @type string $breakpoint The UIkit grid breakpoint which may be set to 'small', 'medium' or 'large'. Default 'medium'. * } */ $args = apply_filters( 'beans_layout_grid_settings', array( @@ -102,10 +111,10 @@ function beans_get_layout_class( $id ) { 'breakpoint' => 'medium', ) ); - $g = beans_get( 'grid', $args ); // $g stands for grid. - $c = $g; // $c stands for content. Same value as grid by default - $sp = beans_get( 'sidebar_primary', $args ); // $sp stands for sidebar primary. - $ss = beans_get( 'sidebar_secondary', $args ); // $ss stands for 'sidebar secondary. + $g = beans_get( 'grid', $args ); // $g stands for grid. + $c = $g; // $c stands for content. Same value as grid by default + $sp = beans_get( 'sidebar_primary', $args ); // $sp stands for sidebar primary. + $ss = beans_get( 'sidebar_secondary', $args ); // $ss stands for 'sidebar secondary. $prefix = 'uk-width-' . beans_get( 'breakpoint', $args, 'medium' ); $classes = array(); @@ -133,7 +142,7 @@ function beans_get_layout_class( $id ) { $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g"; + $classes['content'] = "$prefix-$c-$g"; $classes['sidebar_primary'] = "$prefix-$sp-$g"; break; @@ -142,7 +151,7 @@ function beans_get_layout_class( $id ) { $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; + $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; break; @@ -159,7 +168,7 @@ function beans_get_layout_class( $id ) { $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g"; + $classes['content'] = "$prefix-$c-$g"; $classes['sidebar_secondary'] = "$prefix-$sp-$g"; break; @@ -168,8 +177,8 @@ function beans_get_layout_class( $id ) { $c = $g - ( $sp + $ss ); - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g"; + $classes['content'] = "$prefix-$c-$g"; + $classes['sidebar_primary'] = "$prefix-$sp-$g"; $classes['sidebar_secondary'] = "$prefix-$ss-$g"; break; @@ -178,18 +187,18 @@ function beans_get_layout_class( $id ) { $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; + $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; $classes['sidebar_secondary'] = "$prefix-$sp-$g uk-pull-$c-$g"; break; case 'sp_ss_c': - $c = $g - ( $sp + $ss ); + $c = $g - ( $sp + $ss ); $push_content = $sp + $ss; - $classes['content'] = "$prefix-$c-$g uk-push-$push_content-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + $classes['content'] = "$prefix-$c-$g uk-push-$push_content-$g"; + $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; $classes['sidebar_secondary'] = "$prefix-$ss-$g uk-pull-$c-$g"; break; @@ -198,8 +207,8 @@ function beans_get_layout_class( $id ) { $c = $g - ( $sp + $ss ); - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; + $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; $classes['sidebar_secondary'] = "$prefix-$ss-$g"; break; @@ -273,7 +282,7 @@ function beans_get_layouts_for_options( $add_default = false ) { if ( $add_default ) { $layouts = array_merge( array( 'default_fallback' => sprintf( - __( 'Use Default Layout (%s)', 'tm-beans' ), + __( 'Use Default Layout (%s)', 'tm-beans' ), '' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '' ), ), $layouts ); diff --git a/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php b/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php new file mode 100644 index 00000000..cf6b4da0 --- /dev/null +++ b/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php @@ -0,0 +1,52 @@ +assertFalse( beans_has_widget_area( 'sidebar_primary' ) ); + $this->assertSame( 'c', beans_get_default_layout() ); + } + + /** + * Test beans_get_default_layout() should return "c_sp" when there is a primary sidebar. + */ + public function test_should_return_c_sp_when_has_primary_sidebar() { + $this->assertTrue( beans_has_widget_area( 'sidebar_primary' ) ); + $this->assertSame( 'c_sp', beans_get_default_layout() ); + } +} diff --git a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php new file mode 100644 index 00000000..09724618 --- /dev/null +++ b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php @@ -0,0 +1,64 @@ +once() + ->with( 'sidebar_primary' ) + ->andReturn( false ); + Monkey\Filters\expectApplied( 'beans_default_layout' ) + ->once() + ->with( 'c' ) + ->andReturn( 'c' ); + + $this->assertSame( 'c', beans_get_default_layout() ); + } + + /** + * Test beans_get_default_layout() should return "c_sp" when there is a primary sidebar. + */ + public function test_should_return_c_sp_when_has_primary_sidebar() { + Monkey\Functions\expect( 'beans_has_widget_area' ) + ->once() + ->with( 'sidebar_primary' ) + ->andReturn( true ); + Monkey\Filters\expectApplied( 'beans_default_layout' ) + ->once() + ->with( 'c_sp' ) + ->andReturn( 'c_sp' ); + + $this->assertSame( 'c_sp', beans_get_default_layout() ); + } +} From 5b569f215f6b37cef026b5adaf57cb78d6c8f547 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 17:33:37 -0600 Subject: [PATCH 064/800] Made beans_get_layout() compliant & tested. --- lib/api/layout/functions.php | 28 +-- .../integration/api/layout/beansGetLayout.php | 177 ++++++++++++++++ .../unit/api/layout/beansGetLayout.php | 192 ++++++++++++++++++ 3 files changed, 383 insertions(+), 14 deletions(-) create mode 100644 tests/phpunit/integration/api/layout/beansGetLayout.php create mode 100644 tests/phpunit/unit/api/layout/beansGetLayout.php diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index 65642c46..1400dc22 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -18,7 +18,7 @@ */ /** - * Get the default layout. + * Get the default layout ID. * * @since 1.0.0 * @@ -28,50 +28,50 @@ function beans_get_default_layout() { $default_layout = beans_has_widget_area( 'sidebar_primary' ) ? 'c_sp' : 'c'; /** - * Filter the default layout. + * Filter the default layout ID. * - * The default layout is set to "c_sp" (content + sidebar primary). If the sidebar primary is unregistered, the default layout is "c" (content only). + * The default layout ID is set to "c_sp" (content + sidebar primary). If the sidebar primary is unregistered, then it is set to "c" (content only). * * @since 1.0.0 * - * @param string $layout The default layout. + * @param string $layout The default layout ID. */ return apply_filters( 'beans_default_layout', $default_layout ); } /** - * Get the current layout. - * - * This function return the current layout according the the view it is called from. + * Get the current web page's layout ID. * * @since 1.0.0 * - * @return bool Layout, false if no layout found. + * @return string */ function beans_get_layout() { if ( is_singular() ) { $layout = beans_get_post_meta( 'beans_layout' ); - } elseif ( is_home() && ( 0 != ( $posts_page = get_option( 'page_for_posts' ) ) ) ) { - $layout = beans_get_post_meta( 'beans_layout', false, $posts_page ); + } elseif ( is_home() ) { + $posts_page = (int) get_option( 'page_for_posts' ); + if ( 0 !== $posts_page ) { + $layout = beans_get_post_meta( 'beans_layout', false, $posts_page ); + } } elseif ( is_category() || is_tag() || is_tax() ) { $layout = beans_get_term_meta( 'beans_layout' ); } - // Fallback onto the global theme layout option if value is false or default_fallback. + // When the layout is not found or is set to "default_fallback", use the theme's default layout. if ( ! isset( $layout ) || ! $layout || 'default_fallback' === $layout ) { $layout = get_theme_mod( 'beans_layout', beans_get_default_layout() ); } /** - * Filter the layout id. + * Filter the web page's layout ID. * * @since 1.0.0 * - * @param string $layout The layout id. + * @param string $layout The layout ID. */ return apply_filters( 'beans_layout', $layout ); - } /** diff --git a/tests/phpunit/integration/api/layout/beansGetLayout.php b/tests/phpunit/integration/api/layout/beansGetLayout.php new file mode 100644 index 00000000..320ce061 --- /dev/null +++ b/tests/phpunit/integration/api/layout/beansGetLayout.php @@ -0,0 +1,177 @@ +post->create(); + + // Run our tests for when the layout is set. + update_post_meta( $post_id, 'beans_layout', 'c_sp_ss' ); + $this->go_to( get_permalink( $post_id ) ); + $this->assertQueryTrue( 'is_singular', 'is_single' ); + $this->assertTrue( is_singular() ); + $this->assertSame( 'c_sp_ss', beans_get_layout() ); + + // Run our tests for when the layout is not set. + delete_post_meta( $post_id, 'beans_layout' ); + $this->go_to( get_permalink( $post_id ) ); + $this->assertSame( 'c_sp', beans_get_layout() ); + + // Run our tests for when the layout is set to fallback to the default. + update_post_meta( $post_id, 'beans_layout', 'default_fallback' ); + $this->go_to( get_permalink( $post_id ) ); + $this->assertSame( 'c_sp', beans_get_layout() ); + } + + /** + * Test beans_get_layout() should return the layout for the static posts page. + */ + public function test_should_return_layout_for_static_posts_page() { + // Configure the Posts Page for our static page. + $posts_page_id = self::factory()->post->create( [ + 'post_type' => 'page', + ] ); + update_option( 'show_on_front', 'page' ); + update_option( 'page_for_posts', $posts_page_id ); + + // Run our tests for when the layout is set. + update_post_meta( $posts_page_id, 'beans_layout', 'ss_c' ); + $this->go_to( get_permalink( $posts_page_id ) ); + $this->assertQueryTrue( 'is_home', 'is_posts_page' ); + $this->assertTrue( is_home() ); + $this->assertSame( 'ss_c', beans_get_layout() ); + + // Run our tests for when the layout is not set. + delete_post_meta( $posts_page_id, 'beans_layout' ); + $this->go_to( get_permalink( $posts_page_id ) ); + $this->assertSame( 'c_sp', beans_get_layout() ); + + // Run our tests for when the layout is set to fallback to the default. + update_post_meta( $posts_page_id, 'beans_layout', 'default_fallback' ); + $this->go_to( get_permalink( $posts_page_id ) ); + $this->assertSame( 'c_sp', beans_get_layout() ); + } + + /** + * Test beans_get_layout() should return the theme's default layout when a the static page is not configured for + * the Posts Page. + */ + public function test_should_return_default_layout_when_no_static_posts_page() { + // Run our tests without changing the default. + $this->go_to( get_permalink( '/' ) ); + $this->assertQueryTrue( 'is_home', 'is_front_page' ); + $this->assertTrue( is_home() ); + $this->assertSame( 'c_sp', beans_get_layout() ); + + // Run our tests when the theme's mod is set. + set_theme_mod( 'beans_layout', 'sp_ss_c' ); + $this->go_to( get_permalink( '/' ) ); + $this->assertSame( 'sp_ss_c', beans_get_layout() ); + } + + /** + * Test beans_get_layout() should return layout for a category. + */ + public function test_should_return_layout_for_category() { + $post_id = self::factory()->post->create(); + $category_id = self::factory()->category->create( array( 'slug' => 'test-cat' ) ); + wp_set_object_terms( $post_id, $category_id, 'category' ); + $meta_key = "beans_term_{$category_id}_beans_layout"; + + // Run our tests for when the layout is not set. + $this->go_to( "/?cat={$category_id}" ); + $this->assertQueryTrue( 'is_category', 'is_archive' ); + $this->assertTrue( is_category() ); + $this->assertSame( 'c_sp', beans_get_layout() ); + + // Run our tests for when the layout is set. + update_option( $meta_key, 'sp_c' ); + $this->go_to( "/?cat={$category_id}" ); + $this->assertSame( 'sp_c', beans_get_layout() ); + + // Run our tests for when the layout is set to fallback to the default. + update_option( $meta_key, 'default_fallback' ); + $this->go_to( "/?cat={$category_id}" ); + $this->assertSame( 'c_sp', beans_get_layout() ); + } + + /** + * Test beans_get_layout() should return layout for a tag. + */ + public function test_should_return_layout_for_tag() { + $post_id = self::factory()->post->create(); + $tag_id = self::factory()->tag->create( array( 'slug' => 'test-tag' ) ); + wp_set_object_terms( $post_id, $tag_id, 'post_tag' ); + $meta_key = "beans_term_{$tag_id}_beans_layout"; + + // Run our tests for when the layout is not set. + $this->go_to( '/?tag=test-tag' ); + $this->assertQueryTrue( 'is_tag', 'is_archive' ); + $this->assertTrue( is_tag() ); + $this->assertSame( 'c_sp', beans_get_layout() ); + + // Run our tests for when the layout is set. + update_option( $meta_key, 'sp_c' ); + $this->go_to( '/?tag=test-tag' ); + $this->assertSame( 'sp_c', beans_get_layout() ); + + // Run our tests for when the layout is set to fallback to the default. + update_option( $meta_key, 'default_fallback' ); + $this->go_to( '/?tag=test-tag' ); + $this->assertSame( 'c_sp', beans_get_layout() ); + } + + /** + * Test beans_get_layout() should return layout for a custom taxonomy. + */ + public function test_should_return_layout_for_custom_tax() { + register_taxonomy( 'test_tax', 'post', array( 'public' => true ) ); + $post_id = self::factory()->post->create(); + $term_id = self::factory()->term->create( array( + 'taxonomy' => 'test_tax', + 'slug' => 'custom-term', + ) ); + wp_set_object_terms( $post_id, $term_id, 'test_tax' ); + $meta_key = "beans_term_{$term_id}_beans_layout"; + + // Run our tests for when the layout is not set. + $this->go_to( '/?test_tax=custom-term' ); + $this->assertQueryTrue( 'is_tax', 'is_archive' ); + $this->assertTrue( is_tax() ); + $this->assertSame( 'c_sp', beans_get_layout() ); + + // Run our tests for when the layout is set. + update_option( $meta_key, 'sp_c' ); + $this->go_to( '/?test_tax=custom-term' ); + $this->assertSame( 'sp_c', beans_get_layout() ); + + // Run our tests for when the layout is set to fallback to the default. + update_option( $meta_key, 'default_fallback' ); + $this->go_to( '/?test_tax=custom-term' ); + $this->assertSame( 'c_sp', beans_get_layout() ); + + // Clean up. + _unregister_taxonomy( 'test_tax' ); + } +} diff --git a/tests/phpunit/unit/api/layout/beansGetLayout.php b/tests/phpunit/unit/api/layout/beansGetLayout.php new file mode 100644 index 00000000..e859c931 --- /dev/null +++ b/tests/phpunit/unit/api/layout/beansGetLayout.php @@ -0,0 +1,192 @@ +times( 3 ) + ->andReturn( true ); + + foreach ( array( 'c', 'c_sp', 'sp_c_ss' ) as $layout ) { + + Monkey\Functions\expect( 'beans_get_post_meta' ) + ->once() + ->with( 'beans_layout' ) + ->andReturn( $layout ); + + Monkey\Filters\expectApplied( 'beans_layout' ) + ->once() + ->with( $layout ) + ->andReturn( $layout ); + + $this->assertSame( $layout, beans_get_layout() ); + } + } + + /** + * Test beans_get_layout() should return the layout for the static posts page. + */ + public function test_should_return_layout_for_static_posts_page() { + Monkey\Functions\expect( 'is_singular' ) + ->times( 3 ) + ->andReturn( false ); + + Monkey\Functions\expect( 'is_home' ) + ->times( 3 ) + ->andReturn( true ); + + Monkey\Functions\expect( 'get_option' ) + ->times( 3 ) + ->with( 'page_for_posts' ) + ->andReturn( 1 ); + + foreach ( array( 'c', 'c_sp', 'sp_c_ss' ) as $layout ) { + + Monkey\Functions\expect( 'beans_get_post_meta' ) + ->once() + ->with( 'beans_layout', false, 1 ) + ->andReturn( $layout ); + + Monkey\Filters\expectApplied( 'beans_layout' ) + ->once() + ->with( $layout ) + ->andReturn( $layout ); + + $this->assertSame( $layout, beans_get_layout() ); + } + } + + /** + * Test beans_get_layout() should return layout for category, tag, or taxonomy archive web page. + */ + public function test_should_return_layout_for_cat_tag_tax() { + Monkey\Functions\expect( 'is_singular' ) + ->times( 3 ) + ->andReturn( false ); + Monkey\Functions\expect( 'is_home' ) + ->times( 3 ) + ->andReturn( false ); + + Monkey\Functions\expect( 'is_category' ) + ->times( 3 ) + ->andReturn( true ); + + foreach ( array( 'c', 'c_sp', 'sp_c_ss' ) as $layout ) { + + Monkey\Functions\expect( 'beans_get_term_meta' ) + ->once() + ->with( 'beans_layout' ) + ->andReturn( $layout ); + + Monkey\Filters\expectApplied( 'beans_layout' ) + ->once() + ->with( $layout ) + ->andReturn( $layout ); + + $this->assertSame( $layout, beans_get_layout() ); + } + } + + /** + * Test beans_get_layout() should return default layout when layout is not set. + */ + public function test_should_return_default_layout_when_layout_is_not_set() { + Monkey\Functions\when( 'is_singular' )->justReturn( false ); + Monkey\Functions\when( 'is_home' )->justReturn( false ); + Monkey\Functions\when( 'is_category' )->justReturn( false ); + Monkey\Functions\when( 'is_tag' )->justReturn( false ); + Monkey\Functions\when( 'is_tax' )->justReturn( false ); + Monkey\Functions\when( 'beans_has_widget_area' )->justReturn( true ); + + Monkey\Functions\expect( 'get_theme_mod' ) + ->once() + ->with( 'beans_layout', 'c_sp' ) + ->andReturn( 'c_sp' ); + + Monkey\Filters\expectApplied( 'beans_layout' ) + ->once() + ->with( 'c_sp' ) + ->andReturn( 'c_sp' ); + + $this->assertSame( 'c_sp', beans_get_layout() ); + } + + /** + * Test beans_get_layout() should return default layout when layout is `false`. + */ + public function test_should_return_default_layout_when_layout_is_false() { + Monkey\Functions\when( 'is_singular' )->justReturn( true ); + Monkey\Functions\expect( 'beans_get_post_meta' ) + ->once() + ->with( 'beans_layout' ) + ->andReturn( false ); + Monkey\Functions\when( 'beans_has_widget_area' )->justReturn( true ); + + Monkey\Functions\expect( 'get_theme_mod' ) + ->once() + ->with( 'beans_layout', 'c_sp' ) + ->andReturn( 'c_sp' ); + + Monkey\Filters\expectApplied( 'beans_layout' ) + ->once() + ->with( 'c_sp' ) + ->andReturn( 'c_sp' ); + + $this->assertSame( 'c_sp', beans_get_layout() ); + } + + /** + * Test beans_get_layout() should return default layout when layout is set to "default_fallback". + */ + public function test_should_return_default_layout_when_layout_is_default_fallback() { + Monkey\Functions\when( 'is_singular' )->justReturn( true ); + Monkey\Functions\expect( 'beans_get_post_meta' ) + ->once() + ->with( 'beans_layout' ) + ->andReturn( 'default_fallback' ); + Monkey\Functions\when( 'beans_has_widget_area' )->justReturn( true ); + + Monkey\Functions\expect( 'get_theme_mod' ) + ->once() + ->with( 'beans_layout', 'c_sp' ) + ->andReturn( 'c_sp' ); + + Monkey\Filters\expectApplied( 'beans_layout' ) + ->once() + ->with( 'c_sp' ) + ->andReturn( 'c_sp' ); + + $this->assertSame( 'c_sp', beans_get_layout() ); + } +} From 4d80001662889e156a16255fe1be4a4a395c9eb9 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 19:29:50 -0600 Subject: [PATCH 065/800] Added unit tests for beans_get_layout_class(). --- lib/api/layout/functions.php | 49 +-- .../unit/api/layout/beansGetLayoutClass.php | 370 ++++++++++++++++++ 2 files changed, 382 insertions(+), 37 deletions(-) create mode 100644 tests/phpunit/unit/api/layout/beansGetLayoutClass.php diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index 1400dc22..7da889e9 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -75,7 +75,7 @@ function beans_get_layout() { } /** - * Get the current layout. + * Get the current web page's layout class. * * This function generate the layout class base on the current layout. * @@ -86,7 +86,6 @@ function beans_get_layout() { * @return bool Layout class, false if no layout class found. */ function beans_get_layout_class( $id ) { - /** * Filter the arguments used to define the layout grid. * @@ -117,45 +116,36 @@ function beans_get_layout_class( $id ) { $ss = beans_get( 'sidebar_secondary', $args ); // $ss stands for 'sidebar secondary. $prefix = 'uk-width-' . beans_get( 'breakpoint', $args, 'medium' ); - $classes = array(); + $classes = array(); + $layout = beans_get_layout(); + $has_primary = beans_has_widget_area( 'sidebar_primary' ); - switch ( $layout = beans_get_layout() ) { + switch ( $layout ) { case 'c': - $classes['content'] = "$prefix-$c-$g"; - break; default: - $classes['content'] = "$prefix-$c-$g"; - } // Add sidebar primary layouts if the primary widget area is registered. - if ( $has_primary = beans_has_widget_area( 'sidebar_primary' ) ) { + if ( $has_primary ) { switch ( $layout ) { case 'c_sp': - - $c = $g - $sp; - + $c = $g - $sp; $classes['content'] = "$prefix-$c-$g"; $classes['sidebar_primary'] = "$prefix-$sp-$g"; - break; case 'sp_c': - - $c = $g - $sp; - + $c = $g - $sp; $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; - break; - } } @@ -165,54 +155,40 @@ function beans_get_layout_class( $id ) { switch ( $layout ) { case 'c_ss': - - $c = $g - $sp; - + $c = $g - $sp; $classes['content'] = "$prefix-$c-$g"; $classes['sidebar_secondary'] = "$prefix-$sp-$g"; - break; case 'c_sp_ss': - - $c = $g - ( $sp + $ss ); - + $c = $g - ( $sp + $ss ); $classes['content'] = "$prefix-$c-$g"; $classes['sidebar_primary'] = "$prefix-$sp-$g"; $classes['sidebar_secondary'] = "$prefix-$ss-$g"; - break; case 'ss_c': - $c = $g - $sp; $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; $classes['sidebar_secondary'] = "$prefix-$sp-$g uk-pull-$c-$g"; - break; case 'sp_ss_c': - $c = $g - ( $sp + $ss ); $push_content = $sp + $ss; $classes['content'] = "$prefix-$c-$g uk-push-$push_content-$g"; $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; $classes['sidebar_secondary'] = "$prefix-$ss-$g uk-pull-$c-$g"; - break; case 'sp_c_ss': - - $c = $g - ( $sp + $ss ); - + $c = $g - ( $sp + $ss ); $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; $classes['sidebar_secondary'] = "$prefix-$ss-$g"; - break; - } } @@ -225,8 +201,7 @@ function beans_get_layout_class( $id ) { * * @param string $layout The layout class. */ - return apply_filters( "beans_layout_class_$id", beans_get( $id, $classes ) ); - + return apply_filters( "beans_layout_class_{$id}", beans_get( $id, $classes ) ); } /** diff --git a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php new file mode 100644 index 00000000..bc7b4f05 --- /dev/null +++ b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php @@ -0,0 +1,370 @@ +justReturn( true ); + Monkey\Functions\when( 'beans_get_post_meta' )->justReturn( $layout_id ); + + foreach ( $test_parameters as $parameters ) { + foreach ( $parameters['expected'] as $id => $expected ) { + Monkey\Functions\expect( 'beans_has_widget_area' ) + ->with( 'sidebar_primary' ) + ->once() + ->andReturn( $parameters['sidebar_primary'] ); + + if ( true === $parameters['sidebar_primary'] ) { + Monkey\Functions\expect( 'beans_has_widget_area' ) + ->with( 'sidebar_secondary' ) + ->once() + ->andReturn( $parameters['sidebar_secondary'] ); + } + + Monkey\Filters\expectApplied( 'beans_layout_class_' . $id ) + ->with( $expected ) + ->once() + ->andReturn( $expected ); + + $this->assertSame( $expected, beans_get_layout_class( $id ) ); + } + } + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "c". + */ + public function test_should_return_classes_when_layout_is_c() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'c' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "c_sp". + */ + public function test_should_return_classes_when_layout_is_c_sp() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4', + 'sidebar_primary' => 'uk-width-medium-1-4', + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4', + 'sidebar_primary' => 'uk-width-medium-1-4', + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'c_sp' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "sp_c". + */ + public function test_should_return_classes_when_layout_is_sp_c() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'sp_c' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "c_ss". + */ + public function test_should_return_classes_when_layout_is_c_ss() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => 'uk-width-medium-1-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'c_ss' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "c_sp_ss". + */ + public function test_should_return_classes_when_layout_is_c_sp_ss() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + // @TONYA - Is this right? The page is set to display "c_sp_ss". + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-2-4', + 'sidebar_primary' => 'uk-width-medium-1-4', + 'sidebar_secondary' => 'uk-width-medium-1-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'c_sp_ss' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "ss_c". + */ + public function test_should_return_classes_when_layout_is_ss_c() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-3-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'ss_c' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "sp_ss_c". + */ + public function test_should_return_classes_when_layout_is_sp_ss_c() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + // @TONYA - This isn't right. + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-2-4 uk-push-2-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', + 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-2-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'sp_ss_c' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "sp_c_ss". + */ + public function test_should_return_classes_when_layout_is_sp_c_ss() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + // @TONYA - This isn't right. + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-2-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', + 'sidebar_secondary' => 'uk-width-medium-1-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'sp_c_ss' ); + } +} From b185c27ad40ed481c79df366e1c814673b235092 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 19:50:24 -0600 Subject: [PATCH 066/800] Added integration tests for beans_get_layout_class. --- .../api/layout/beansGetLayoutClass.php | 384 ++++++++++++++++++ 1 file changed, 384 insertions(+) create mode 100644 tests/phpunit/integration/api/layout/beansGetLayoutClass.php diff --git a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php new file mode 100644 index 00000000..e280baaa --- /dev/null +++ b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php @@ -0,0 +1,384 @@ +post_id = self::factory()->post->create(); + } + + /** + * Cleans up the test environment after each test. + */ + public function tearDown() { + parent::tearDown(); + + // Reset the Beans' sidebars. + beans_do_register_widget_areas(); + } + + /** + * Run the tests for the given set of test parameters. + * + * @since 1.5.0 + * + * @param array $test_parameters Array of test parameters. + * @param string $layout_id The layout's ID for this test. + * + * @return void + */ + protected function run_the_tests( array $test_parameters, $layout_id ) { + // Go to the post's web page, i.e. to set up is_singular(). + update_post_meta( $this->post_id, 'beans_layout', $layout_id ); + $this->go_to( get_permalink( $this->post_id ) ); + $this->assertTrue( is_singular() ); + + foreach ( $test_parameters as $parameters ) { + + // Unregister the sidebar primary. + if ( ! $parameters['sidebar_primary'] ) { + unregister_sidebar( 'sidebar_primary' ); + } + + // Unregister the sidebar secondary. + if ( ! $parameters['sidebar_secondary'] ) { + unregister_sidebar( 'sidebar_secondary' ); + } + + foreach ( $parameters['expected'] as $id => $expected ) { + $this->assertSame( $expected, beans_get_layout_class( $id ) ); + } + + // Reset the sidebars. + beans_do_register_widget_areas(); + } + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "c". + */ + public function test_should_return_classes_when_layout_is_c() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'c' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "c_sp". + */ + public function test_should_return_classes_when_layout_is_c_sp() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4', + 'sidebar_primary' => 'uk-width-medium-1-4', + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4', + 'sidebar_primary' => 'uk-width-medium-1-4', + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'c_sp' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "sp_c". + */ + public function test_should_return_classes_when_layout_is_sp_c() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'sp_c' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "c_ss". + */ + public function test_should_return_classes_when_layout_is_c_ss() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => 'uk-width-medium-1-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'c_ss' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "c_sp_ss". + */ + public function test_should_return_classes_when_layout_is_c_sp_ss() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + // @TONYA - Is this right? The page is set to display "c_sp_ss". + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-2-4', + 'sidebar_primary' => 'uk-width-medium-1-4', + 'sidebar_secondary' => 'uk-width-medium-1-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'c_sp_ss' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "ss_c". + */ + public function test_should_return_classes_when_layout_is_ss_c() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-3-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'ss_c' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "sp_ss_c". + */ + public function test_should_return_classes_when_layout_is_sp_ss_c() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + // @TONYA - This isn't right. + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-2-4 uk-push-2-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', + 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-2-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'sp_ss_c' ); + } + + /** + * Test beans_get_default_layout() should return classes when the layout is "sp_c_ss". + */ + public function test_should_return_classes_when_layout_is_sp_c_ss() { + $test_parameters = array( + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => false, + 'sidebar_secondary' => false, + ), + // @TONYA - This isn't right. + array( + 'expected' => array( + 'content' => 'uk-width-medium-4-4', + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => false, + ), + array( + 'expected' => array( + 'content' => 'uk-width-medium-2-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', + 'sidebar_secondary' => 'uk-width-medium-1-4', + ), + 'sidebar_primary' => true, + 'sidebar_secondary' => true, + ), + ); + + $this->run_the_tests( $test_parameters, 'sp_c_ss' ); + } +} From 5a50b38bce1ccb2347e0f32191552e5653e75165 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 20:00:28 -0600 Subject: [PATCH 067/800] Refactored to remove 1st switch. --- lib/api/layout/functions.php | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index 7da889e9..0cc2b805 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -116,19 +116,14 @@ function beans_get_layout_class( $id ) { $ss = beans_get( 'sidebar_secondary', $args ); // $ss stands for 'sidebar secondary. $prefix = 'uk-width-' . beans_get( 'breakpoint', $args, 'medium' ); - $classes = array(); - $layout = beans_get_layout(); - $has_primary = beans_has_widget_area( 'sidebar_primary' ); - - switch ( $layout ) { - - case 'c': - $classes['content'] = "$prefix-$c-$g"; - break; - - default: - $classes['content'] = "$prefix-$c-$g"; - } + $classes = array( + 'content' => "$prefix-$c-$g", + 'sidebar_primary' => null, + 'sidebar_secondary' => null, + ); + $layout = beans_get_layout(); + $has_primary = beans_has_widget_area( 'sidebar_primary' ); + $has_both_sidebars = $has_primary && beans_has_widget_area( 'sidebar_secondary' ); // Add sidebar primary layouts if the primary widget area is registered. if ( $has_primary ) { @@ -150,7 +145,7 @@ function beans_get_layout_class( $id ) { } // Add sidebar secondary layouts if the primary and secondary widget area are registered. - if ( $has_primary && beans_has_widget_area( 'sidebar_secondary' ) ) { + if ( $has_both_sidebars ) { switch ( $layout ) { From ba9b7641ba51739e8d43ffabfb97568dd29c7193 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 20:45:00 -0600 Subject: [PATCH 068/800] Fixed #117. Refactored the function, pulling out the computation and class building tasks. This allows us to bail out without having to wrap the code in separate IF blocks. Then conditional code is added in the associated case block to adjust for the given sidebar conditions. --- lib/api/layout/functions.php | 150 +++++++++++------- .../api/layout/beansGetLayoutClass.php | 15 +- .../unit/api/layout/beansGetLayoutClass.php | 15 +- 3 files changed, 101 insertions(+), 79 deletions(-) diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index 0cc2b805..382b65cc 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -110,93 +110,121 @@ function beans_get_layout_class( $id ) { 'breakpoint' => 'medium', ) ); + + /** + * Filter the layout class. + * + * The dynamic portion of the hook name refers to the searched layout section ID. + * + * @since 1.0.0 + * + * @param string $layout The layout class. + */ + return apply_filters( "beans_layout_class_{$id}", beans_get( $id, _beans_get_layout_classes( $args ) ) ); +} + +/** + * Get the layout's class attribute values. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @param array $args Grid configuration. + * + * @return array + */ +function _beans_get_layout_classes( array $args ) { $g = beans_get( 'grid', $args ); // $g stands for grid. $c = $g; // $c stands for content. Same value as grid by default $sp = beans_get( 'sidebar_primary', $args ); // $sp stands for sidebar primary. $ss = beans_get( 'sidebar_secondary', $args ); // $ss stands for 'sidebar secondary. $prefix = 'uk-width-' . beans_get( 'breakpoint', $args, 'medium' ); - $classes = array( - 'content' => "$prefix-$c-$g", - 'sidebar_primary' => null, - 'sidebar_secondary' => null, + $classes = array( + 'content' => "$prefix-$c-$g", ); + + if ( ! beans_has_widget_area( 'sidebar_primary' ) ) { + return $classes; + } + $layout = beans_get_layout(); - $has_primary = beans_has_widget_area( 'sidebar_primary' ); - $has_both_sidebars = $has_primary && beans_has_widget_area( 'sidebar_secondary' ); + $has_secondary = beans_has_widget_area( 'sidebar_secondary' ); - // Add sidebar primary layouts if the primary widget area is registered. - if ( $has_primary ) { + switch ( $layout ) { - switch ( $layout ) { + case 'c_sp': + $c = $g - $sp; + $classes['content'] = "$prefix-$c-$g"; + $classes['sidebar_primary'] = "$prefix-$sp-$g"; + break; - case 'c_sp': - $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g"; - break; + case 'sp_c': + $c = $g - $sp; + $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; + $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + break; - case 'sp_c': - $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; - break; - } - } + case 'c_ss': - // Add sidebar secondary layouts if the primary and secondary widget area are registered. - if ( $has_both_sidebars ) { + if ( ! $has_secondary ) { + return $classes; + } - switch ( $layout ) { + $c = $g - $sp; + $classes['content'] = "$prefix-$c-$g"; + $classes['sidebar_secondary'] = "$prefix-$sp-$g"; + break; - case 'c_ss': - $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_secondary'] = "$prefix-$sp-$g"; - break; + case 'c_sp_ss': + $c = $has_secondary ? $g - ( $sp + $ss ) : $g - $sp; + $classes['content'] = "$prefix-$c-$g"; + $classes['sidebar_primary'] = "$prefix-$sp-$g"; - case 'c_sp_ss': - $c = $g - ( $sp + $ss ); - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g"; + if ( $has_secondary ) { $classes['sidebar_secondary'] = "$prefix-$ss-$g"; - break; + } + break; - case 'ss_c': - $c = $g - $sp; + case 'ss_c': - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_secondary'] = "$prefix-$sp-$g uk-pull-$c-$g"; - break; + if ( ! $has_secondary ) { + return $classes; + } - case 'sp_ss_c': - $c = $g - ( $sp + $ss ); - $push_content = $sp + $ss; + $c = $g - $sp; + $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; + $classes['sidebar_secondary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + break; - $classes['content'] = "$prefix-$c-$g uk-push-$push_content-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; - $classes['sidebar_secondary'] = "$prefix-$ss-$g uk-pull-$c-$g"; - break; + case 'sp_ss_c': - case 'sp_c_ss': + if ( $has_secondary ) { $c = $g - ( $sp + $ss ); - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + $push_content = $sp + $ss; + $classes['sidebar_secondary'] = "$prefix-$ss-$g uk-pull-$c-$g"; + } else { + $c = $g - $sp; + $push_content = $sp; + } + + $classes['content'] = "{$prefix}-{$c}-{$g} uk-push-{$push_content}-{$g}"; + $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + + break; + + case 'sp_c_ss': + $c = $has_secondary ? $g - ( $sp + $ss ) : $g - $sp; + $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; + $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + + if ( $has_secondary ) { $classes['sidebar_secondary'] = "$prefix-$ss-$g"; - break; - } + } } - /** - * Filter the layout class. - * - * The dynamic portion of the hook name refers to the searched layout section ID. - * - * @since 1.0.0 - * - * @param string $layout The layout class. - */ - return apply_filters( "beans_layout_class_{$id}", beans_get( $id, $classes ) ); + return $classes; } /** diff --git a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php index e280baaa..528811e1 100644 --- a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php @@ -245,11 +245,10 @@ public function test_should_return_classes_when_layout_is_c_sp_ss() { 'sidebar_primary' => false, 'sidebar_secondary' => false, ), - // @TONYA - Is this right? The page is set to display "c_sp_ss". array( 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, + 'content' => 'uk-width-medium-3-4', + 'sidebar_primary' => 'uk-width-medium-1-4', 'sidebar_secondary' => null, ), 'sidebar_primary' => true, @@ -320,11 +319,10 @@ public function test_should_return_classes_when_layout_is_sp_ss_c() { 'sidebar_primary' => false, 'sidebar_secondary' => false, ), - // @TONYA - This isn't right. array( 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', 'sidebar_secondary' => null, ), 'sidebar_primary' => true, @@ -358,11 +356,10 @@ public function test_should_return_classes_when_layout_is_sp_c_ss() { 'sidebar_primary' => false, 'sidebar_secondary' => false, ), - // @TONYA - This isn't right. array( 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', 'sidebar_secondary' => null, ), 'sidebar_primary' => true, diff --git a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php index bc7b4f05..5ce3e5d9 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php @@ -231,11 +231,10 @@ public function test_should_return_classes_when_layout_is_c_sp_ss() { 'sidebar_primary' => false, 'sidebar_secondary' => false, ), - // @TONYA - Is this right? The page is set to display "c_sp_ss". array( 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, + 'content' => 'uk-width-medium-3-4', + 'sidebar_primary' => 'uk-width-medium-1-4', 'sidebar_secondary' => null, ), 'sidebar_primary' => true, @@ -306,11 +305,10 @@ public function test_should_return_classes_when_layout_is_sp_ss_c() { 'sidebar_primary' => false, 'sidebar_secondary' => false, ), - // @TONYA - This isn't right. array( 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', 'sidebar_secondary' => null, ), 'sidebar_primary' => true, @@ -344,11 +342,10 @@ public function test_should_return_classes_when_layout_is_sp_c_ss() { 'sidebar_primary' => false, 'sidebar_secondary' => false, ), - // @TONYA - This isn't right. array( 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, + 'content' => 'uk-width-medium-3-4 uk-push-1-4', + 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', 'sidebar_secondary' => null, ), 'sidebar_primary' => true, From 2e8aa86b074561437cd1d108b34d3f6e01f60727 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 21:25:43 -0600 Subject: [PATCH 069/800] Refactored to reduce redundancy. --- lib/api/layout/functions.php | 69 +++++++++++++++--------------------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index 382b65cc..92c77cf1 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -135,14 +135,14 @@ function beans_get_layout_class( $id ) { * @return array */ function _beans_get_layout_classes( array $args ) { - $g = beans_get( 'grid', $args ); // $g stands for grid. - $c = $g; // $c stands for content. Same value as grid by default - $sp = beans_get( 'sidebar_primary', $args ); // $sp stands for sidebar primary. - $ss = beans_get( 'sidebar_secondary', $args ); // $ss stands for 'sidebar secondary. + $grid = beans_get( 'grid', $args ); + $c = $grid; // $c stands for "content". + $sp = beans_get( 'sidebar_primary', $args ); + $ss = beans_get( 'sidebar_secondary', $args ); $prefix = 'uk-width-' . beans_get( 'breakpoint', $args, 'medium' ); $classes = array( - 'content' => "$prefix-$c-$g", + 'content' => "{$prefix}-{$c}-{$grid}", ); if ( ! beans_has_widget_area( 'sidebar_primary' ) ) { @@ -151,40 +151,39 @@ function _beans_get_layout_classes( array $args ) { $layout = beans_get_layout(); $has_secondary = beans_has_widget_area( 'sidebar_secondary' ); + $c = $has_secondary && strlen( trim( $layout ) ) > 4 ? $grid - ( $sp + $ss ) : $grid - $sp; switch ( $layout ) { case 'c_sp': - $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g"; + case 'c_sp_ss': + $classes['content'] = "{$prefix}-{$c}-{$grid}"; + $classes['sidebar_primary'] = "{$prefix}-{$sp}-{$grid}"; + + if ( $has_secondary && 'c_sp_ss' === $layout ) { + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid}"; + } break; case 'sp_c': - $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + case 'sp_c_ss': + $classes['content'] = "{$prefix}-{$c}-{$grid} uk-push-{$sp}-{$grid}"; + $classes['sidebar_primary'] = "{$prefix}-{$sp}-{$grid} uk-pull-{$c}-{$grid}"; + + if ( $has_secondary && 'sp_c_ss' === $layout ) { + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid}"; + } break; + case 'c_ss': if ( ! $has_secondary ) { return $classes; } - $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_secondary'] = "$prefix-$sp-$g"; - break; - - case 'c_sp_ss': - $c = $has_secondary ? $g - ( $sp + $ss ) : $g - $sp; - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g"; - - if ( $has_secondary ) { - $classes['sidebar_secondary'] = "$prefix-$ss-$g"; - } + $classes['content'] = "{$prefix}-{$c}-{$grid}"; + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid}"; break; case 'ss_c': @@ -193,35 +192,23 @@ function _beans_get_layout_classes( array $args ) { return $classes; } - $c = $g - $sp; - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_secondary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + $classes['content'] = "{$prefix}-{$c}-{$grid} uk-push-{$ss}-{$grid}"; + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid} uk-pull-{$c}-{$grid}"; break; case 'sp_ss_c': if ( $has_secondary ) { - $c = $g - ( $sp + $ss ); $push_content = $sp + $ss; - $classes['sidebar_secondary'] = "$prefix-$ss-$g uk-pull-$c-$g"; + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid} uk-pull-{$c}-{$grid}"; } else { - $c = $g - $sp; $push_content = $sp; } - $classes['content'] = "{$prefix}-{$c}-{$g} uk-push-{$push_content}-{$g}"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; + $classes['content'] = "{$prefix}-{$c}-{$grid} uk-push-{$push_content}-{$grid}"; + $classes['sidebar_primary'] = "{$prefix}-{$sp}-{$grid} uk-pull-{$c}-{$grid}"; break; - - case 'sp_c_ss': - $c = $has_secondary ? $g - ( $sp + $ss ) : $g - $sp; - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; - - if ( $has_secondary ) { - $classes['sidebar_secondary'] = "$prefix-$ss-$g"; - } } return $classes; From 8ac42f2ce82c1ea5b4b75d844d771e0f5e4741fa Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 21:37:40 -0600 Subject: [PATCH 070/800] Made beans_get_layouts_for_options compliant. --- lib/api/layout/functions.php | 43 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index 92c77cf1..5f8cbc51 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -110,7 +110,6 @@ function beans_get_layout_class( $id ) { 'breakpoint' => 'medium', ) ); - /** * Filter the layout class. * @@ -175,9 +174,8 @@ function _beans_get_layout_classes( array $args ) { } break; - case 'c_ss': - + // If we don't have a secondary sidebar, bail out. if ( ! $has_secondary ) { return $classes; } @@ -187,7 +185,7 @@ function _beans_get_layout_classes( array $args ) { break; case 'ss_c': - + // If we don't have a secondary sidebar, bail out. if ( ! $has_secondary ) { return $classes; } @@ -197,17 +195,14 @@ function _beans_get_layout_classes( array $args ) { break; case 'sp_ss_c': + $push_content = $has_secondary ? $sp + $ss : $sp; + $classes['content'] = "{$prefix}-{$c}-{$grid} uk-push-{$push_content}-{$grid}"; + $classes['sidebar_primary'] = "{$prefix}-{$sp}-{$grid} uk-pull-{$c}-{$grid}"; if ( $has_secondary ) { - $push_content = $sp + $ss; $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid} uk-pull-{$c}-{$grid}"; - } else { - $push_content = $sp; } - $classes['content'] = "{$prefix}-{$c}-{$grid} uk-push-{$push_content}-{$grid}"; - $classes['sidebar_primary'] = "{$prefix}-{$sp}-{$grid} uk-pull-{$c}-{$grid}"; - break; } @@ -227,28 +222,24 @@ function _beans_get_layout_classes( array $args ) { * @return array Layouts ready for Beans 'imageradio' option type. */ function beans_get_layouts_for_options( $add_default = false ) { - - $base = BEANS_ADMIN_ASSETS_URL . 'images/layouts/'; - + $base = BEANS_ADMIN_ASSETS_URL . 'images/layouts/'; $layouts = array( 'c' => $base . 'c.png', ); // Add sidebar primary layouts if the primary widget area is registered. - if ( $has_primary = beans_has_widget_area( 'sidebar_primary' ) ) { + $has_primary = beans_has_widget_area( 'sidebar_primary' ); + if ( $has_primary ) { $layouts['c_sp'] = $base . 'cs.png'; $layouts['sp_c'] = $base . 'sc.png'; - } // Add sidebar secondary layouts if the primary and secondary widget area are registered. if ( $has_primary && beans_has_widget_area( 'sidebar_secondary' ) ) { - $layouts['c_sp_ss'] = $base . 'css.png'; $layouts['sp_ss_c'] = $base . 'ssc.png'; $layouts['sp_c_ss'] = $base . 'scs.png'; - } /** @@ -264,15 +255,17 @@ function beans_get_layouts_for_options( $add_default = false ) { */ $layouts = apply_filters( 'beans_layouts', $layouts ); - if ( $add_default ) { - $layouts = array_merge( array( - 'default_fallback' => sprintf( - __( 'Use Default Layout (%s)', 'tm-beans' ), - '' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '' - ), - ), $layouts ); + if ( ! $add_default ) { + return $layouts; } - return $layouts; + $layouts = array_merge( array( + 'default_fallback' => sprintf( + // translators: The (%s) placeholder is for the "Modify" hyperlink. + __( 'Use Default Layout (%s)', 'tm-beans' ), + '' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '' + ), + ), $layouts ); + return $layouts; } From d4ced1399bc7830de8367e922ad98a115c5afab3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 22:12:26 -0600 Subject: [PATCH 071/800] Fixed comments & names. --- lib/api/image/class-beans-image-editor.php | 8 +++--- lib/api/image/functions.php | 8 +++--- .../beans-image-editor/createEditedImage.php | 27 ++++++++++--------- .../api/image/beans-image-editor/run.php | 14 +++++----- .../integration/api/image/beansEditImage.php | 4 +-- .../beans-image-editor/createEditedImage.php | 16 +++++------ .../unit/api/image/beans-image-editor/run.php | 14 +++++----- .../phpunit/unit/api/image/beansEditImage.php | 4 +-- 8 files changed, 48 insertions(+), 47 deletions(-) diff --git a/lib/api/image/class-beans-image-editor.php b/lib/api/image/class-beans-image-editor.php index 48b9f3e0..d9ab5e9d 100644 --- a/lib/api/image/class-beans-image-editor.php +++ b/lib/api/image/class-beans-image-editor.php @@ -1,6 +1,6 @@ get_reflective_method( 'create_edited_image' ); - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( + $created_edited_image = $this->get_reflective_method( 'create_edited_image' ); + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', ); - $args = array( 'resize' => array( 800, false ) ); + $args = array( 'resize' => array( 800, false ) ); foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args ); @@ -59,7 +60,7 @@ public function test_should_edit_create_and_store_image() { // Run the tests. $this->assertFileNotExists( $edited_image_src ); - $this->assertTrue( $get_image_info->invoke( $editor ) ); + $this->assertTrue( $created_edited_image->invoke( $editor ) ); $this->assertFileExists( $edited_image_src ); list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. @@ -69,19 +70,19 @@ public function test_should_edit_create_and_store_image() { } /** - * Test get_image_info() should return false when the image does not exist. + * Test create_edited_image() should return false when the image does not exist. */ public function test_should_return_false_when_no_image() { - $get_image_info = $this->get_reflective_method( 'create_edited_image' ); - $rebuilt_path = $this->get_reflective_property(); - $src = 'path/does/not/exist/image.jpg'; + $created_edited_image = $this->get_reflective_method( 'create_edited_image' ); + $rebuilt_path = $this->get_reflective_property(); + $src = 'path/does/not/exist/image.jpg'; $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ) ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); // Run the tests. $this->assertFileNotExists( $src ); - $this->assertFalse( $get_image_info->invoke( $editor ) ); + $this->assertFalse( $created_edited_image->invoke( $editor ) ); $this->assertFileNotExists( $edited_image_src ); } } diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php index b118dfe1..df8fcf83 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -41,7 +41,7 @@ public static function setUpBeforeClass() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return it's URL. + * Test run() should edit the existing image, store it in the "rebuilt path", and then return its URL. */ public function test_should_edit_store_and_return_its_url() { $rebuilt_path = $this->get_reflective_property(); @@ -106,7 +106,7 @@ public function test_should_return_url_when_edited_image_exists() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return an index array of its + * Test run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of its * image info. */ public function test_should_edit_store_and_return_indexed_array() { @@ -135,7 +135,7 @@ public function test_should_edit_store_and_return_indexed_array() { } /** - * Test beans_edit_image() should return an indexed array with the original src when the image does not exist. + * Test run() should return an indexed array with the original src when the image does not exist. */ public function test_should_return_indexed_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -204,7 +204,7 @@ public function test_should_edit_store_and_return_object() { } /** - * Test beans_edit_image() should return an object with the original src when the image does not exist. + * Test run() should return an object with the original src when the image does not exist. */ public function test_should_return_object_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -220,7 +220,7 @@ public function test_should_return_object_with_original_src_when_no_image() { } /** - * Test run() should return return an object when the edited image exists, meaning that it has already been + * Test run() should return an object when the edited image exists, meaning that it has already been * edited and stored. */ public function test_should_return_object_when_edited_image_exists() { @@ -286,7 +286,7 @@ public function test_should_edit_image_and_return_associative_array() { } /** - * Test beans_edit_image() should return an array with the original src when the image does not exist. + * Test run() should return an array with the original src when the image does not exist. */ public function test_should_return_associative_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -305,7 +305,7 @@ public function test_should_return_associative_array_with_original_src_when_no_i } /** - * Test run() should return return an associative array when the edited image exists, meaning that it has already + * Test run() should return an associative array when the edited image exists, meaning that it has already * been edited and stored. */ public function test_should_return_associatve_array_when_edited_image_exists() { diff --git a/tests/phpunit/integration/api/image/beansEditImage.php b/tests/phpunit/integration/api/image/beansEditImage.php index 77e17cd8..462782d4 100644 --- a/tests/phpunit/integration/api/image/beansEditImage.php +++ b/tests/phpunit/integration/api/image/beansEditImage.php @@ -20,7 +20,7 @@ * @group integration-tests * @group api */ -class Tests_Beans_Edit_Image extends Image_Test_Case { +class Tests_BeansEditImage extends Image_Test_Case { /** * Path of the fixtures directory. @@ -39,7 +39,7 @@ public static function setUpBeforeClass() { } /** - * Test init() should return original src when the image does not exist. + * Test beans_edit_image() should return original src when the image does not exist. */ public function test_should_return_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; diff --git a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php index b92a1d7b..a43c98f1 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php @@ -1,6 +1,6 @@ get_reflective_method( 'create_edited_image' ); + $create_edited_image = $this->get_reflective_method( 'create_edited_image' ); $rebuilt_path = $this->get_reflective_property(); $image_sources = array( static::$fixtures_dir . '/image1.jpg', @@ -73,16 +73,16 @@ public function test_should_edit_create_and_store_image() { // Run the tests. $this->assertFileNotExists( $edited_image_src ); - $this->assertTrue( $get_image_info->invoke( $editor ) ); + $this->assertTrue( $create_edited_image->invoke( $editor ) ); $this->assertFileExists( $edited_image_src ); } } /** - * Test get_image_info() should return false when the image does not exist. + * Test create_edited_image() should return false when the image does not exist. */ public function test_should_return_false_when_no_image() { - $get_image_info = $this->get_reflective_method( 'create_edited_image' ); + $create_edited_image = $this->get_reflective_method( 'create_edited_image' ); $rebuilt_path = $this->get_reflective_property(); $src = 'path/does/not/exist/image.jpg'; $args = array( 'resize' => array( 800, false ) ); @@ -96,7 +96,7 @@ public function test_should_return_false_when_no_image() { // Run the tests. $this->assertFileNotExists( $src ); - $this->assertFalse( $get_image_info->invoke( $editor ) ); + $this->assertFalse( $create_edited_image->invoke( $editor ) ); $this->assertFileNotExists( $edited_image_src ); } } diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php index 22414700..2c02ec73 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -52,7 +52,7 @@ protected function setUp() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return it's URL. + * Test run() should edit the existing image, store it in the "rebuilt path", and then return its URL. */ public function test_should_edit_store_and_return_its_url() { $rebuilt_path = $this->get_reflective_property(); @@ -129,7 +129,7 @@ public function test_should_return_url_when_edited_image_exists() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return an index array of its + * Test run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of its * image info. */ public function test_should_edit_store_and_return_indexed_array() { @@ -165,7 +165,7 @@ public function test_should_edit_store_and_return_indexed_array() { } /** - * Test beans_edit_image() should return an indexed array with the original src when the image does not exist. + * Test run() should return an indexed array with the original src when the image does not exist. */ public function test_should_return_indexed_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -247,7 +247,7 @@ public function test_should_edit_store_and_return_object() { } /** - * Test beans_edit_image() should return an object with the original src when the image does not exist. + * Test run() should return an object with the original src when the image does not exist. */ public function test_should_return_object_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -267,7 +267,7 @@ public function test_should_return_object_with_original_src_when_no_image() { } /** - * Test run() should return return an object when the edited image exists, meaning that it has already been + * Test run() should return an object when the edited image exists, meaning that it has already been * edited and stored. */ public function test_should_return_object_when_edited_image_exists() { @@ -341,7 +341,7 @@ public function test_should_edit_image_and_return_associative_array() { } /** - * Test beans_edit_image() should return an associative array with the original src when the image does not exist. + * Test run() should return an associative array with the original src when the image does not exist. */ public function test_should_return_associative_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -364,7 +364,7 @@ public function test_should_return_associative_array_with_original_src_when_no_i } /** - * Test run() should return return an associative array when the edited image exists, meaning that it has already + * Test run() should return an associative array when the edited image exists, meaning that it has already * been edited and stored. */ public function test_should_return_associatve_array_when_edited_image_exists() { diff --git a/tests/phpunit/unit/api/image/beansEditImage.php b/tests/phpunit/unit/api/image/beansEditImage.php index c100d2cf..537fc49e 100644 --- a/tests/phpunit/unit/api/image/beansEditImage.php +++ b/tests/phpunit/unit/api/image/beansEditImage.php @@ -21,7 +21,7 @@ * @group unit-tests * @group api */ -class Tests_Beans_Edit_Image extends Image_Test_Case { +class Tests_BeansEditImage extends Image_Test_Case { /** * Path of the fixtures directory. @@ -44,7 +44,7 @@ public static function setUpBeforeClass() { } /** - * Test init() should return original src when the image does not exist. + * Test beans_edit_image() should return original src when the image does not exist. */ public function test_should_return_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; From 4c2c85c20e5a4d582f4626f374bd01af9a48631f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 16 Feb 2018 22:21:06 -0600 Subject: [PATCH 072/800] Fixed formatting. --- .../beans-image-editor/createEditedImage.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php index a43c98f1..0b1e527a 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php @@ -43,17 +43,18 @@ public static function setUpBeforeClass() { } /** - * Test create_edited_image() should edit the given image and then create a new "edited image", which is stored in the + * Test create_edited_image() should edit the given image and then create a new "edited image", which is stored in + * the * "rebuilt path". */ public function test_should_edit_create_and_store_image() { $create_edited_image = $this->get_reflective_method( 'create_edited_image' ); - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( + $rebuilt_path = $this->get_reflective_property(); + $image_sources = array( static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', ); - $args = array( 'resize' => array( 800, false ) ); + $args = array( 'resize' => array( 800, false ) ); foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args ); @@ -83,9 +84,9 @@ public function test_should_edit_create_and_store_image() { */ public function test_should_return_false_when_no_image() { $create_edited_image = $this->get_reflective_method( 'create_edited_image' ); - $rebuilt_path = $this->get_reflective_property(); - $src = 'path/does/not/exist/image.jpg'; - $args = array( 'resize' => array( 800, false ) ); + $rebuilt_path = $this->get_reflective_property(); + $src = 'path/does/not/exist/image.jpg'; + $args = array( 'resize' => array( 800, false ) ); $editor = new _Beans_Image_Editor( $src, $args ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); From 11769f296c1edcc1b6b57f79f81121f14d96db24 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Feb 2018 12:03:59 -0600 Subject: [PATCH 073/800] Made WPCS compliant. Improved documentation. --- lib/api/template/functions.php | 115 +++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/lib/api/template/functions.php b/lib/api/template/functions.php index 1b0334d8..10b992bc 100644 --- a/lib/api/template/functions.php +++ b/lib/api/template/functions.php @@ -2,20 +2,27 @@ /** * The Beans Templates API allows to load Beans template files as well as loading the entire document. * - * @package API\Templates + * @package Beans\Framework\API\Actions + * + * @since 1.0.0 */ /** - * Load the entire document. + * Load and render the entire document (web page). This function is the root of the Beans' framework hierarchy. + * Therefore, when calling it, Beans runs, building the web page's HTML markup and rendering it out to the + * browser. * - * This function is the root of Beans's framework hierarchy. It must be called from a primary template file - * (e.g. page.php) and must be the last function to be called. All modifications must be done before calling - * this function. This includes modifying markup, attributes, fragments, etc. + * Here are some guidelines for calling this function: + * + * - Called it from a primary template file, e.g. single.php, page.php, home.php, archive.php, etc. + * - Do all modifications and customizations before calling this function. + * - Put this function on the last line of code in the template file. * * @since 1.0.0 + * + * @return void */ function beans_load_document() { - /** * Fires before the document is loaded. * @@ -23,14 +30,14 @@ function beans_load_document() { */ do_action( 'beans_before_load_document' ); - /** - * Fires when the document loads. - * - * This hook is the root of Beans's framework hierarchy. It all starts here! - * - * @since 1.0.0 - */ - do_action( 'beans_load_document' ); + /** + * Fires when the document loads. + * + * This hook is the root of Beans's framework hierarchy. It all starts here! + * + * @since 1.0.0 + */ + do_action( 'beans_load_document' ); /** * Fires after the document is loaded. @@ -38,11 +45,10 @@ function beans_load_document() { * @since 1.0.0 */ do_action( 'beans_after_load_document' ); - } /** - * Load Beans secondary template file. + * Loads a secondary template file. * * This function loads Beans's default template file. It must be called from a secondary template file * (e.g. comments.php) and must be the last function to be called. All modifications must be done before calling @@ -55,84 +61,93 @@ function beans_load_document() { * * @param string $file The filename of the secondary template files. __FILE__ is usually to argument to pass. * - * @return bool False if file isn't found. + * @return bool True on success, false on failure. */ function beans_load_default_template( $file ) { - $file = BEANS_STRUCTURE_PATH . basename( $file ); if ( ! file_exists( $file ) ) { return false; } - require_once( $file ); + require_once $file; + return true; } /** - * Load fragment file. + * Load the fragment file. * - * This function can be short-circuited. + * This function can be short-circuited using the filter event "beans_pre_load_fragment_". * * @since 1.0.0 * - * @param string $slug The file name to include without extension. + * @param string $fragment The fragment to load. This is its filename without the extension. * * @return bool True on success, false on failure. */ -function beans_load_fragment_file( $slug ) { +function beans_load_fragment_file( $fragment ) { /** - * Filter whether to load a fragment or not. + * Filter to allow the child theme or plugin to short-circuit this function by passing back a `true` or + * truthy value. * - * The dynamic portion of the hook name, $slug, refers to the file name without extension. Passing a truthy - * value to the filter will short-circuit loading the fragment. + * The hook's name is "beans_pre_load_fragment_" + the fragment's filename (without its extension). For example, + * the header fragment's hook name is "beans_pre_load_fragment_header". * * @since 1.0.0 * - * @param bool $pre True to short-circuit, False to let the function run. + * @param bool Set to `true` to short-circuit this function. The default is `false`. */ - if ( apply_filters( 'beans_pre_load_fragment_' . $slug, false ) ) { + if ( apply_filters( 'beans_pre_load_fragment_' . $fragment, false ) ) { return false; } - // Stop here if fragment file doesn't exists. - if ( ! file_exists( BEANS_FRAGMENTS_PATH . $slug . '.php' ) ) { + // If fragment file does not exist, bail out. + if ( ! file_exists( BEANS_FRAGMENTS_PATH . $fragment . '.php' ) ) { return false; } - require_once( BEANS_FRAGMENTS_PATH . $slug . '.php' ); + require_once BEANS_FRAGMENTS_PATH . $fragment . '.php'; return true; - } /** - * wp_list_comments callback function. + * Render the current comment's HTML markup. * - * This function adds the hooks to which the comment template part is attached to. - * are attached. + * This function is a callback that is registered to {@see wp_list_comments()}. It adds the args and depth to the + * global comment, renders the opening

  • tag, and fires the "beans_comment" event to render the comment. * * @since 1.0.0 + * + * @see wp_list_comments() + * + * @param WP_Comment $comment Instance of the current comment, i.e. which is also the global comment. + * @param array $args Array of arguments. + * @param int $depth Depth of the comment in reference to its parents. + * + * @return void */ -function beans_comment_callback( $comment, $args, $depth ) { - +function beans_comment_callback( $comment, array $args, $depth ) { + // To give us access, add the args and depth as public properties on the comment's global instance. global $comment; - - // Add args and depth to comment global. - $comment->args = $args; + $comment->args = $args; $comment->depth = $depth; - // Don't allow overwrite. - ?>
  • > tag. + $comment_class = empty( $args['has_children'] ) ? '' : 'parent'; + printf( '
  • ', + (int) get_comment_ID(), + comment_class( $comment_class, $comment, null, false ) + ); - // Don't close
  • tag. + /** + * Render the comment's HTML markup. + * + * @since 1.0.0 + */ + do_action( 'beans_comment' ); + // The tag is intentionally omitted. } From de67f5d125cbab28d94141efdbba6a4b79e58ae0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Feb 2018 16:45:02 -0600 Subject: [PATCH 074/800] Added unit tests. --- phpunit.xml.dist | 1 + .../api/template/beansLoadDefaultTemplate.php | 58 +++++++++ .../api/template/beansLoadFragmentFile.php | 71 +++++++++++ .../includes/class-template-test-case.php | 116 ++++++++++++++++++ 4 files changed, 246 insertions(+) create mode 100644 tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php create mode 100644 tests/phpunit/unit/api/template/beansLoadFragmentFile.php create mode 100644 tests/phpunit/unit/api/template/includes/class-template-test-case.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 30a69a2e..b2e10ba9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,6 +22,7 @@ . + ./tests/TestCase.php diff --git a/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php new file mode 100644 index 00000000..28b0a30b --- /dev/null +++ b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php @@ -0,0 +1,58 @@ +assertFileNotExists( $file ); + $this->assertFileNotExists( BEANS_STRUCTURE_PATH . 'does-not-exist.php' ); + $this->assertFalse( beans_load_default_template( $file ) ); + + $this->assertFileNotExists( BEANS_STRUCTURE_PATH . basename( __FILE__ ) ); + $this->assertFalse( beans_load_default_template( __FILE__ ) ); + } + + /** + * Test beans_load_default_template() should load the template when the given structure has an invalid path. + */ + public function test_should_return_true_after_template_loads() { + // Check with an invalid path/to the structure. + $file = '/path/to/structure/content.php'; + $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); + ob_start(); + $this->assertTrue( beans_load_default_template( $file ) ); + $this->assertSame( $this->mock_filesystem->getChild( 'structure/content.php' )->getContent(), ob_get_clean() ); + + // Check with an absolute path to the structure. + $file = __DIR__ . 'fixtures/structure/header.php'; + $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); + ob_start(); + $this->assertTrue( beans_load_default_template( $file ) ); + $this->assertSame( $this->mock_filesystem->getChild( 'structure/header.php' )->getContent(), ob_get_clean() ); + } +} diff --git a/tests/phpunit/unit/api/template/beansLoadFragmentFile.php b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php new file mode 100644 index 00000000..5107631c --- /dev/null +++ b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php @@ -0,0 +1,71 @@ +with( false ) + ->once() + ->andReturn( true ); + + $this->assertFalse( beans_load_fragment_file( $fragment ) ); + } + } + + /** + * Test beans_load_fragment_file() should return false when the fragment does not exist. + */ + public function test_should_return_false_when_fragment_does_not_exist() { + Monkey\Filters\expectApplied( 'beans_pre_load_fragment_does-not-exist' ) + ->with( false ) + ->once() + ->andReturn( false ); + + $this->assertFileNotExists( BEANS_FRAGMENTS_PATH . 'does-not-exist.php' ); + $this->assertFalse( beans_load_fragment_file( 'does-not-exist' ) ); + } + + /** + * Test beans_load_fragment_file() should return true when after loading the fragment. + */ + public function test_should_return_true_after_loading_the_fragment() { + + foreach ( array( 'branding', 'post-body' ) as $fragment ) { + Monkey\Filters\expectApplied( "beans_pre_load_fragment_{$fragment}" ) + ->with( false ) + ->once() + ->andReturn( false ); + + $this->assertFileExists( BEANS_FRAGMENTS_PATH . "{$fragment}.php" ); + ob_start(); + $this->assertTrue( beans_load_fragment_file( $fragment ) ); + $this->assertSame( $this->mock_filesystem->getChild( "fragments/{$fragment}.php" )->getContent(), ob_get_clean() ); + } + } +} diff --git a/tests/phpunit/unit/api/template/includes/class-template-test-case.php b/tests/phpunit/unit/api/template/includes/class-template-test-case.php new file mode 100644 index 00000000..dc1d3a81 --- /dev/null +++ b/tests/phpunit/unit/api/template/includes/class-template-test-case.php @@ -0,0 +1,116 @@ +set_up_virtual_filesystem(); + + if ( ! defined( 'BEANS_STRUCTURE_PATH' ) ) { + define( 'BEANS_STRUCTURE_PATH', vfsStream::url( 'templates/structure/' ) ); + } + + if ( ! defined( 'BEANS_FRAGMENTS_PATH' ) ) { + define( 'BEANS_FRAGMENTS_PATH', vfsStream::url( 'templates/fragments/' ) ); + } + } + + /** + * Set up the virtual filesystem. + */ + private function set_up_virtual_filesystem() { + // Create the file structure and load each file's content. + $file_structure = array( + 'fragments' => array( + 'branding.php' => '', + 'post-body.php' => '

    Nulla in orci condimentum, facilisis ex et, blandit augue.

    ', + ), + 'structure' => array( + 'content.php' => '', + 'header.php' => '', + ), + ); + $file_structure['structure']['content.php'] = '
    ' . $file_structure['fragments']['post-body.php'] . '
    '; + $file_structure['structure']['header.php'] = '
    ' . $file_structure['fragments']['branding.php'] . '
    '; + + // Set up the "templates" directory's virtual filesystem. + $this->mock_filesystem = vfsStream::setup( 'templates', 0755, $file_structure ); + } + + /** + * Load the fragment into the virtual filesystem. Loads from the fixtures/fragments/ folder. + * + * @since 1.0.0 + * + * @param string $fragment Fragment's path or filename. + * + * @return void + */ + protected function load_fragment_into_virtual_filesystem( $fragment ) { + $structure['fragments'][ $fragment ] = file_get_contents( BEANS_THEME_DIR . '/lib/templates/fragments/' . basename( $fragment ) ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - valid edge case. + } + + /** + * Load the structure into the virtual filesystem. Loads from the fixtures/structure/ folder. + * + * @since 1.0.0 + * + * @param string $structure Structure's path or filename. + * + * @return void + */ + protected function load_structure_into_virtual_filesystem( $structure ) { + $structure['structure'][ $structure ] = file_get_contents( BEANS_THEME_DIR . '/lib/templates/structure/' . basename( $structure ) ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - valid edge case. + } +} From b8854016170166deec4b67c9388ec560206e46b4 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Feb 2018 16:49:01 -0600 Subject: [PATCH 075/800] Exclude fixtures from test suite autoloader. --- phpunit.xml.dist | 1 + tests/phpunit/integration/phpunit.xml.dist | 1 + 2 files changed, 2 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 30a69a2e..9628669b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,6 +16,7 @@ ./tests/phpunit/unit/ + ./tests/phpunit/unit/*/*/fixtures/ diff --git a/tests/phpunit/integration/phpunit.xml.dist b/tests/phpunit/integration/phpunit.xml.dist index 9a29b2d0..1eefa14a 100644 --- a/tests/phpunit/integration/phpunit.xml.dist +++ b/tests/phpunit/integration/phpunit.xml.dist @@ -16,6 +16,7 @@ . + ./*/*/fixtures/ From 571a75ff79c44c6943a66441a718385ac2aafe71 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Feb 2018 16:49:36 -0600 Subject: [PATCH 076/800] Removed sample integration test. --- .../phpunit/integration/integrationSample.php | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 tests/phpunit/integration/integrationSample.php diff --git a/tests/phpunit/integration/integrationSample.php b/tests/phpunit/integration/integrationSample.php deleted file mode 100644 index 2e375e66..00000000 --- a/tests/phpunit/integration/integrationSample.php +++ /dev/null @@ -1,30 +0,0 @@ -assertTrue( true ); - } -} From 04d5b3c902e39ec80e1adafb7af863e0ea2ed842 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Feb 2018 16:51:30 -0600 Subject: [PATCH 077/800] Changed "Tests Case" to "Test Case". --- .../api/actions/includes/class-actions-test-case.php | 2 +- .../api/actions/includes/class-replace-action-test-case.php | 2 +- .../api/filters/includes/class-filters-test-case.php | 2 +- .../unit/api/actions/includes/class-actions-test-case.php | 2 +- .../api/actions/includes/class-replace-action-test-case.php | 2 +- .../unit/api/filters/includes/class-filters-test-case.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index 6a1b3ce0..6ff3ad3c 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -1,6 +1,6 @@ Date: Sat, 17 Feb 2018 17:16:36 -0600 Subject: [PATCH 078/800] Added integration tests. Fixed formatting. --- .../api/template/beansLoadDefaultTemplate.php | 52 ++++++++++++++++ .../api/template/beansLoadFragmentFile.php | 61 +++++++++++++++++++ .../api/template/beansLoadDefaultTemplate.php | 6 +- .../api/template/beansLoadFragmentFile.php | 2 +- .../includes/class-template-test-case.php | 35 +---------- 5 files changed, 118 insertions(+), 38 deletions(-) create mode 100644 tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php create mode 100644 tests/phpunit/integration/api/template/beansLoadFragmentFile.php diff --git a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php new file mode 100644 index 00000000..141b60f3 --- /dev/null +++ b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php @@ -0,0 +1,52 @@ +assertFileNotExists( BEANS_STRUCTURE_PATH . 'does-not-exist.php' ); + $this->assertFalse( beans_load_default_template( 'path/to/does-not-exist.php' ) ); + + $this->assertFileNotExists( BEANS_STRUCTURE_PATH . basename( __FILE__ ) ); + $this->assertFalse( beans_load_default_template( __FILE__ ) ); + } + + /** + * Test beans_load_default_template() should return true after loading the given structure. + */ + public function test_should_return_true_after_loading_structure() { + // Check with an invalid path/to the structure. + $file = '/path/to/structure/content.php'; + $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); + ob_start(); + $this->assertTrue( beans_load_default_template( $file ) ); + $this->assertStringStartsWith( '
    assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); + ob_start(); + $this->assertTrue( beans_load_default_template( $file ) ); + $this->assertStringStartsWith( '', ob_get_clean() ); + } +} diff --git a/tests/phpunit/integration/api/template/beansLoadFragmentFile.php b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php new file mode 100644 index 00000000..4d7300ff --- /dev/null +++ b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php @@ -0,0 +1,61 @@ +with( false ) + ->once() + ->andReturn( true ); + + add_filter( "beans_pre_load_fragment_{$fragment}", 'beans_test_fragment_short_circuit' ); + $this->assertFalse( beans_load_fragment_file( $fragment ) ); + remove_filter( "beans_pre_load_fragment_{$fragment}", 'beans_test_fragment_short_circuit' ); + } + } + + /** + * Test beans_load_fragment_file() should return false when the fragment does not exist. + */ + public function test_should_return_false_when_fragment_does_not_exist() { + $this->assertFileNotExists( BEANS_FRAGMENTS_PATH . 'does-not-exist.php' ); + $this->assertFalse( beans_load_fragment_file( 'does-not-exist' ) ); + } + + /** + * Test beans_load_fragment_file() should return true when after loading the fragment. + */ + public function test_should_return_true_after_loading_fragment() { + $this->assertFileExists( BEANS_FRAGMENTS_PATH . 'header.php' ); + $this->assertTrue( beans_load_fragment_file( 'header' ) ); + $this->assertTrue( function_exists( 'beans_head_meta' ) ); + + $this->assertFileExists( BEANS_FRAGMENTS_PATH . 'post.php' ); + $this->assertTrue( beans_load_fragment_file( 'post' ) ); + $this->assertTrue( function_exists( 'beans_post_title' ) ); + } +} diff --git a/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php index 28b0a30b..507234f2 100644 --- a/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php @@ -24,7 +24,7 @@ class Tests_BeansLoadDefaultTemplate extends Template_Test_Case { /** - * Test beans_load_default_template() should return false when structure template does not exist. + * Test beans_load_default_template() should return false when the template does not exist. */ public function test_should_return_false_when_template_does_not_exist() { $file = vfsStream::url( 'templates/structure/does-not-exist.php' ); @@ -38,9 +38,9 @@ public function test_should_return_false_when_template_does_not_exist() { } /** - * Test beans_load_default_template() should load the template when the given structure has an invalid path. + * Test beans_load_default_template() should return true after loading the given structure. */ - public function test_should_return_true_after_template_loads() { + public function test_should_return_true_after_loading_structure() { // Check with an invalid path/to the structure. $file = '/path/to/structure/content.php'; $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); diff --git a/tests/phpunit/unit/api/template/beansLoadFragmentFile.php b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php index 5107631c..1da97b9c 100644 --- a/tests/phpunit/unit/api/template/beansLoadFragmentFile.php +++ b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php @@ -54,7 +54,7 @@ public function test_should_return_false_when_fragment_does_not_exist() { /** * Test beans_load_fragment_file() should return true when after loading the fragment. */ - public function test_should_return_true_after_loading_the_fragment() { + public function test_should_return_true_after_loading_fragment() { foreach ( array( 'branding', 'post-body' ) as $fragment ) { Monkey\Filters\expectApplied( "beans_pre_load_fragment_{$fragment}" ) diff --git a/tests/phpunit/unit/api/template/includes/class-template-test-case.php b/tests/phpunit/unit/api/template/includes/class-template-test-case.php index dc1d3a81..02dd609b 100644 --- a/tests/phpunit/unit/api/template/includes/class-template-test-case.php +++ b/tests/phpunit/unit/api/template/includes/class-template-test-case.php @@ -33,13 +33,6 @@ abstract class Template_Test_Case extends Test_Case { */ protected $mock_filesystem; - /** - * Flag is in admin area (back-end). - * - * @var bool - */ - protected $is_admin = false; - /** * Set up the test before we run the test setups. */ @@ -71,7 +64,7 @@ protected function setUp() { */ private function set_up_virtual_filesystem() { // Create the file structure and load each file's content. - $file_structure = array( + $file_structure = array( 'fragments' => array( 'branding.php' => '', 'post-body.php' => '

    Nulla in orci condimentum, facilisis ex et, blandit augue.

    ', @@ -87,30 +80,4 @@ private function set_up_virtual_filesystem() { // Set up the "templates" directory's virtual filesystem. $this->mock_filesystem = vfsStream::setup( 'templates', 0755, $file_structure ); } - - /** - * Load the fragment into the virtual filesystem. Loads from the fixtures/fragments/ folder. - * - * @since 1.0.0 - * - * @param string $fragment Fragment's path or filename. - * - * @return void - */ - protected function load_fragment_into_virtual_filesystem( $fragment ) { - $structure['fragments'][ $fragment ] = file_get_contents( BEANS_THEME_DIR . '/lib/templates/fragments/' . basename( $fragment ) ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - valid edge case. - } - - /** - * Load the structure into the virtual filesystem. Loads from the fixtures/structure/ folder. - * - * @since 1.0.0 - * - * @param string $structure Structure's path or filename. - * - * @return void - */ - protected function load_structure_into_virtual_filesystem( $structure ) { - $structure['structure'][ $structure ] = file_get_contents( BEANS_THEME_DIR . '/lib/templates/structure/' . basename( $structure ) ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - valid edge case. - } } From e1ce6f84b15155d273d7298337463f9d041829b7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Feb 2018 17:26:24 -0600 Subject: [PATCH 079/800] Fixed comments. --- lib/api/layout/functions.php | 2 +- tests/phpunit/integration/api/layout/beansGetLayout.php | 2 +- tests/phpunit/unit/api/layout/beansGetLayout.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index 5f8cbc51..a913827c 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -77,7 +77,7 @@ function beans_get_layout() { /** * Get the current web page's layout class. * - * This function generate the layout class base on the current layout. + * This function generates the layout class(es) based on the current layout. * * @since 1.0.0 * diff --git a/tests/phpunit/integration/api/layout/beansGetLayout.php b/tests/phpunit/integration/api/layout/beansGetLayout.php index 320ce061..ae918a24 100644 --- a/tests/phpunit/integration/api/layout/beansGetLayout.php +++ b/tests/phpunit/integration/api/layout/beansGetLayout.php @@ -21,7 +21,7 @@ class Tests_BeansGetLayout extends WP_UnitTestCase { /** - * Test beans_get_layout() should return a single post or page's layout. + * Test beans_get_layout() should return the layout for a single post or page. */ public function test_should_return_layout_for_singular() { $post_id = self::factory()->post->create(); diff --git a/tests/phpunit/unit/api/layout/beansGetLayout.php b/tests/phpunit/unit/api/layout/beansGetLayout.php index e859c931..b301b0b5 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetLayout.php @@ -31,7 +31,7 @@ protected function setUp() { } /** - * Test beans_get_layout() should return a single post or page's layout. + * Test beans_get_layout() should return the layout for a single post or page. */ public function test_should_return_layout_for_singular() { Monkey\Functions\expect( 'is_singular' ) From cddd8a9ad8a5edfcfe1b4515d78b5618962006d8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Feb 2018 19:05:54 -0600 Subject: [PATCH 080/800] Fixed comments. --- lib/api/template/functions.php | 2 +- .../integration/api/template/beansLoadDefaultTemplate.php | 2 +- .../phpunit/integration/api/template/beansLoadFragmentFile.php | 2 +- tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php | 2 +- tests/phpunit/unit/api/template/beansLoadFragmentFile.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/api/template/functions.php b/lib/api/template/functions.php index 10b992bc..17e006b5 100644 --- a/lib/api/template/functions.php +++ b/lib/api/template/functions.php @@ -14,7 +14,7 @@ * * Here are some guidelines for calling this function: * - * - Called it from a primary template file, e.g. single.php, page.php, home.php, archive.php, etc. + * - Call it from a primary template file, e.g. single.php, page.php, home.php, archive.php, etc. * - Do all modifications and customizations before calling this function. * - Put this function on the last line of code in the template file. * diff --git a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php index 141b60f3..b88716ab 100644 --- a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php @@ -35,7 +35,7 @@ public function test_should_return_false_when_template_does_not_exist() { * Test beans_load_default_template() should return true after loading the given structure. */ public function test_should_return_true_after_loading_structure() { - // Check with an invalid path/to the structure. + // Check with an invalid path to the structure. $file = '/path/to/structure/content.php'; $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); ob_start(); diff --git a/tests/phpunit/integration/api/template/beansLoadFragmentFile.php b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php index 4d7300ff..040a39dd 100644 --- a/tests/phpunit/integration/api/template/beansLoadFragmentFile.php +++ b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php @@ -47,7 +47,7 @@ public function test_should_return_false_when_fragment_does_not_exist() { } /** - * Test beans_load_fragment_file() should return true when after loading the fragment. + * Test beans_load_fragment_file() should return true after loading the fragment. */ public function test_should_return_true_after_loading_fragment() { $this->assertFileExists( BEANS_FRAGMENTS_PATH . 'header.php' ); diff --git a/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php index 507234f2..84afa161 100644 --- a/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php @@ -41,7 +41,7 @@ public function test_should_return_false_when_template_does_not_exist() { * Test beans_load_default_template() should return true after loading the given structure. */ public function test_should_return_true_after_loading_structure() { - // Check with an invalid path/to the structure. + // Check with an invalid path to the structure. $file = '/path/to/structure/content.php'; $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); ob_start(); diff --git a/tests/phpunit/unit/api/template/beansLoadFragmentFile.php b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php index 1da97b9c..6024d3e5 100644 --- a/tests/phpunit/unit/api/template/beansLoadFragmentFile.php +++ b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php @@ -52,7 +52,7 @@ public function test_should_return_false_when_fragment_does_not_exist() { } /** - * Test beans_load_fragment_file() should return true when after loading the fragment. + * Test beans_load_fragment_file() should return true after loading the fragment. */ public function test_should_return_true_after_loading_fragment() { From cf0376986011702f7d77f08eb38f98f8981c9594 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 08:19:59 -0600 Subject: [PATCH 081/800] Made beans_register_fields compliant + tests. --- .../{class.php => class-beans-fields.php} | 219 +++++++++++------- lib/api/fields/functions.php | 55 ++--- .../api/fields/beansRegisterFields.php | 62 +++++ .../api/fields/fixtures/test-fields.php | 29 +++ .../includes/class-fields-test-case.php | 163 +++++++++++++ .../unit/api/fields/beansRegisterFields.php | 54 +++++ .../unit/api/fields/fixtures/test-fields.php | 29 +++ .../includes/class-fields-test-case.php | 195 ++++++++++++++++ 8 files changed, 691 insertions(+), 115 deletions(-) rename lib/api/fields/{class.php => class-beans-fields.php} (52%) create mode 100644 tests/phpunit/integration/api/fields/beansRegisterFields.php create mode 100644 tests/phpunit/integration/api/fields/fixtures/test-fields.php create mode 100644 tests/phpunit/integration/api/fields/includes/class-fields-test-case.php create mode 100644 tests/phpunit/unit/api/fields/beansRegisterFields.php create mode 100644 tests/phpunit/unit/api/fields/fixtures/test-fields.php create mode 100644 tests/phpunit/unit/api/fields/includes/class-fields-test-case.php diff --git a/lib/api/fields/class.php b/lib/api/fields/class-beans-fields.php similarity index 52% rename from lib/api/fields/class.php rename to lib/api/fields/class-beans-fields.php index 9645ad27..513a5887 100644 --- a/lib/api/fields/class.php +++ b/lib/api/fields/class-beans-fields.php @@ -1,59 +1,69 @@ array(), @@ -63,11 +73,20 @@ final class _Beans_Fields { ); /** - * Register fields. + * Register the given fields. + * + * @since 1.0.0 + * + * @param array $fields Array of fields to register. + * @param string $context The context in which the fields are used. 'option' for options/settings pages, + * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for + * WP customizer fields. + * @param string $section A section ID to define the group of fields. + * + * @return bool */ - public function register( $fields, $context, $section ) { - - $this->fields = $fields; + public function register( array $fields, $context, $section ) { + $this->fields = $fields; $this->context = $context; $this->section = $section; @@ -79,13 +98,17 @@ public function register( $fields, $context, $section ) { add_action( 'admin_enqueue_scripts', array( $this, 'load_fields_assets_hook' ) ); add_action( 'customize_controls_enqueue_scripts', array( $this, 'load_fields_assets_hook' ) ); + return true; } /** - * Register field. + * Register the field. + * + * @since 1.0.0 + * + * @return void */ private function add() { - $fields = array(); foreach ( $this->fields as $field ) { @@ -94,28 +117,29 @@ private function add() { // Register fields. self::$registered[ $this->context ][ $this->section ] = $fields; - } /** - * Standadrize field to beans format. + * Standardize the field to the Beans' format. + * + * @since 1.0.0 + * + * @param array $field The given field to be standardized. + * + * @return array */ private function standardize_field( $field ) { - - // Set defaults. - $defaults = array( + $field = array_merge( array( 'label' => false, 'description' => false, 'default' => false, 'context' => $this->context, 'attributes' => array(), 'db_group' => false, - ); - - $field = array_merge( $defaults, $field ); + ), $field ); - // Set field name. - $field['name'] = 'wp_customize' == $this->context ? $field['id'] : 'beans_fields[' . $field['id'] . ']'; + // Set the field's name. + $field['name'] = 'wp_customize' === $this->context ? $field['id'] : 'beans_fields[' . $field['id'] . ']'; if ( 'group' === $field['type'] ) { @@ -126,13 +150,10 @@ private function standardize_field( $field ) { } $field['fields'][ $index ] = $this->standardize_field( $_field ); - } } else { - // Add value after the standardizing the field. $field['value'] = $this->get_field_value( $field['id'], $field['context'], $field['default'] ); - } // Add required attributes for wp_customizer. @@ -144,22 +165,27 @@ private function standardize_field( $field ) { } return $field; - } /** - * Set the fields types used. + * Set the type for the field(s). + * + * @since 1.0.0 + * + * @return void */ private function set_types() { foreach ( $this->fields as $field ) { - if ( 'group' == $field['type'] ) { - foreach ( $field['fields'] as $_field ) { - $this->field_types[ $_field['type'] ] = $_field['type']; - } - } else { + // Set the single field's type. + if ( 'group' !== $field['type'] ) { $this->field_types[ $field['type'] ] = $field['type']; + continue; + } + + foreach ( $field['fields'] as $_field ) { + $this->field_types[ $_field['type'] ] = $_field['type']; } } @@ -167,26 +193,33 @@ private function set_types() { /** * Trigger actions only once. + * + * @since 1.0.0 + * + * @return void */ private function do_once() { - static $once = false; - if ( ! $once ) { - - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_global_assets' ) ); - add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_global_assets' ) ); - - require_once( BEANS_API_PATH . 'fields/types/field.php' ); + if ( $once ) { + return; + } - $once = true; + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_global_assets' ) ); + add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_global_assets' ) ); - } + // Load the field label and description handler. + require_once BEANS_API_PATH . 'fields/types/field.php'; + $once = true; } /** - * Load the required core fields php files. + * Load the field type PHP file for each of the fields. + * + * @since 1.0.0 + * + * @return void */ private function load_fields() { @@ -200,18 +233,20 @@ private function load_fields() { $path = BEANS_API_PATH . "fields/types/{$type}.php"; if ( file_exists( $path ) ) { - require_once( $path ); + require_once $path; } // Set flag that field is loaded. self::$field_types_loaded[ $type ] = $type; - } - } /** * Load the fields assets hooks. This hook can then be used to load custom fields assets. + * + * @since 1.0.0 + * + * @return void */ public function load_fields_assets_hook() { @@ -226,28 +261,37 @@ public function load_fields_assets_hook() { // Set flag that field is loaded. self::$field_assets_hook_loaded[ $type ] = $type; - } - } /** - * Enqueue default fields assets. + * Enqueue the default fields assets. + * + * @since 1.0.0 + * + * @return void */ public function enqueue_global_assets() { - $css = BEANS_API_URL . 'fields/assets/css/fields' . BEANS_MIN_CSS . '.css'; - $js = BEANS_API_URL . 'fields/assets/js/fields' . BEANS_MIN_CSS . '.js'; + $js = BEANS_API_URL . 'fields/assets/js/fields' . BEANS_MIN_CSS . '.js'; wp_enqueue_style( 'beans-fields', $css, false, BEANS_VERSION ); wp_enqueue_script( 'beans-fields', $js, array( 'jquery' ), BEANS_VERSION ); do_action( 'beans_field_enqueue_scripts' ); - } /** * Get the field value. + * + * @since 1.0.0 + * @since 1.5.0 Return the default when the context is not pre-defined. + * + * @param string $field_id Field's ID. + * @param string $context The field's context, i.e. "option", "post_meta", "term_meta", or "wp_customize". + * @param mixed $default The field's default value. + * + * @return mixed|string|void */ private function get_field_value( $field_id, $context, $default ) { @@ -255,73 +299,78 @@ private function get_field_value( $field_id, $context, $default ) { case 'option': return get_option( $field_id, $default ); - break; case 'post_meta': return beans_get_post_meta( $field_id, $default ); - break; case 'term_meta': return beans_get_term_meta( $field_id, $default ); - break; case 'wp_customize': return get_theme_mod( $field_id, $default ); - break; - } - } /** - * Display the field content. + * Render the field content. + * + * @since 1.0.0 + * + * @param array $field The given field to be rendered. + * + * @return void */ public function field_content( $field ) { - beans_open_markup_e( 'beans_field_wrap', 'div', array( 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], ), $field ); - // Set fields loop to cater for groups. - if ( 'group' === $field['type'] ) { - $fields = $field['fields']; - } else { - $fields = array( $field ); - } - - beans_open_markup_e( 'beans_field_inside', 'div', array( - 'class' => 'bs-field-inside', - ), $fields ); - - // Loop through fields. - foreach ( $fields as $single_field ) { - - beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array( - 'class' => 'bs-field bs-' . $single_field['type'], - ), $single_field ); + // Set fields loop to cater for groups. + if ( 'group' === $field['type'] ) { + $fields = $field['fields']; + } else { + $fields = array( $field ); + } - do_action( 'beans_field_' . $single_field['type'], $single_field ); + beans_open_markup_e( 'beans_field_inside', 'div', array( + 'class' => 'bs-field-inside', + ), $fields ); - beans_close_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', $single_field ); + // Loop through fields. + foreach ( $fields as $single_field ) { + beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array( + 'class' => 'bs-field bs-' . $single_field['type'], + ), $single_field ); - } + do_action( 'beans_field_' . $single_field['type'], $single_field ); - beans_close_markup_e( 'beans_field_inside', 'div', $fields ); + beans_close_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', $single_field ); + } + beans_close_markup_e( 'beans_field_inside', 'div', $fields ); beans_close_markup_e( 'beans_field_wrap', 'div', $field ); - } /** * Get the registered fields. + * + * @since 1.0.0 + * + * @param string $context The context in which the fields are used. 'option' for options/settings pages, + * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP + * customizer fields. + * @param string $section Optional. A section ID to define a group of fields. This is mostly used for meta boxes + * and WP Customizer sections. + * + * @return array|bool Array of register fields on success, false on failure. */ public function get_fields( $context, $section ) { + $fields = beans_get( $section, self::$registered[ $context ] ); - if ( ! $fields = beans_get( $section, self::$registered[ $context ] ) ) { + if ( ! $fields ) { return false; } return $fields; - } } diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 46c44335..28e926e8 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -2,42 +2,40 @@ /** * The Beans Fields component offers a range of fields which can be used in the WordPress admin. * - * Fields can be used as Options, Post Meta, Term Meta or WP - * Customizer Options. Custom fields can easily be added too. + * Fields can be used as Options, Post Meta, Term Meta or WP Customizer Options. Custom fields can easily be added too. * - * @package API\Fields + * @package Beans\Framework\API\Options */ /** - * Register fields. + * Register the given fields. * * This function should only be invoked through the 'admin_init' action. * * @since 1.0.0 * - * @param array $fields { - * Array of fields to register. + * @param array $fields { + * Array of fields to register. * - * @type string $id A unique id used for the field. This id will also be used to save the value in - * the database. - * @type string $type The type of field to use. Please refer to the Beans core field types for more - * information. Custom field types are accepted here. - * @type string $label The field label. Default false. - * @type string $description The field description. The description can be truncated using - * as a delimiter. Default false. - * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. - * @type mixed $default The default field value. Default false. - * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the - * {@see beans_register_fields()} $fields arguments. - * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * @type string $id A unique id used for the field. This id will also be used to save the value in the + * database. + * @type string $type The type of field to use. Please refer to the Beans core field types for more + * information. Custom field types are accepted here. + * @type string $label The field label. Default false. + * @type string $description The field description. The description can be truncated using as a delimiter. + * Default false. + * @type array $attributes An array of attributes to add to the field. The array key defines the attribute name and + * the array value defines the attribute value. Default array. + * @type mixed $default The default field value. Default false. + * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the + * {@see beans_register_fields()} $fields arguments. + * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields + * registered should be saved as a group in the database or as individual entries. Default false. * } - * @param string $context The context in which the fields are used. 'option' for options/settings pages, 'post_meta' - * for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP customizer - * fields. - * @param string $section A section id to define the group of fields. + * @param string $context The context in which the fields are used. 'option' for options/settings pages, + * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP + * customizer fields. + * @param string $section A section ID to define the group of fields. * * @return bool True on success, false on failure. */ @@ -48,13 +46,10 @@ function beans_register_fields( array $fields, $context, $section ) { } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'fields/class.php' ); + require_once BEANS_API_PATH . 'fields/class-beans-fields.php'; $class = new _Beans_Fields(); - $class->register( $fields, $context, $section ); - - return true; - + return $class->register( $fields, $context, $section ); } /** diff --git a/tests/phpunit/integration/api/fields/beansRegisterFields.php b/tests/phpunit/integration/api/fields/beansRegisterFields.php new file mode 100644 index 00000000..b0a0f880 --- /dev/null +++ b/tests/phpunit/integration/api/fields/beansRegisterFields.php @@ -0,0 +1,62 @@ +assertFalse( beans_register_fields( array(), '', '' ) ); + $this->assertFalse( beans_register_fields( array(), 'post_meta', 'tm-beans' ) ); + } + + /** + * Test beans_register_fields() should register the fields. + */ + public function test_should_register_fields() { + + foreach ( static::$test_data as $test_data ) { + $this->assertTrue( beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ) ); + + // Check what was registered. + $registered = $this->get_reflective_property_value( 'registered' ); + $this->assertArrayHasKey( 'beans_tests', $registered ); + $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); + + foreach ( $test_data['fields'] as $index => $field ) { + $expected = array_merge( array( + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => 'beans_tests', + 'attributes' => array(), + 'db_group' => false, + ), $field ); + $expected['name'] = 'beans_fields[' . $field['id'] . ']'; + $expected['value'] = $field['default']; + + $this->assertSame( $expected, $registered['beans_tests'][ $test_data['section'] ][ $index ] ); + } + } + } +} diff --git a/tests/phpunit/integration/api/fields/fixtures/test-fields.php b/tests/phpunit/integration/api/fields/fixtures/test-fields.php new file mode 100644 index 00000000..5a449bee --- /dev/null +++ b/tests/phpunit/integration/api/fields/fixtures/test-fields.php @@ -0,0 +1,29 @@ + array( + array( + 'id' => 'beans_layout', + 'label' => 'Layout', + 'type' => 'radio', + 'default' => 'default_fallback', + 'options' => array( + 'default_fallback' => 'Use Default Layout', + 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', + 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', + 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', + ), + ), + ), + 'context' => 'post_meta', + 'section' => 'tm-beans', + ), +); diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php new file mode 100644 index 00000000..5973d3b8 --- /dev/null +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -0,0 +1,163 @@ +get_reflective_property( 'registered' ); + $registered->setValue( new \_Beans_Fields(), array( + 'option' => array(), + 'post_meta' => array(), + 'term_meta' => array(), + 'wp_customize' => array(), + ) ); + + // Reset the other static properties. + foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { + $property = $this->get_reflective_property( $property_name ); + $property->setValue( new \_Beans_Fields(), array() ); + } + } + + /** + * Get reflective access to the private method. + * + * @since 1.5.0 + * + * @param string $method_name Method name for which to gain access. + * + * @return \ReflectionMethod + */ + protected function get_reflective_method( $method_name ) { + $class = new \ReflectionClass( '_Beans_Fields' ); + $method = $class->getMethod( $method_name ); + $method->setAccessible( true ); + + return $method; + } + + /** + * Get reflective access to the private property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * + * @return \ReflectionProperty|string + */ + protected function get_reflective_property( $property ) { + $class = new \ReflectionClass( '_Beans_Fields' ); + $property = $class->getProperty( $property ); + $property->setAccessible( true ); + + return $property; + } + + /** + * Get the value of the private or protected property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * + * @return mixed + */ + protected function get_reflective_property_value( $property ) { + $reflective = $this->get_reflective_property( $property ); + return $reflective->getValue( new \_Beans_Fields() ); + } + + /** + * Merge the given field with the default structure. + * + * @since 1.5.0 + * + * @param array $field The given field to merge. + * @param bool $set_value Optional. When true, sets the "value" to the "default". + * + * @return array + */ + protected function merge_field_with_default( array $field, $set_value = true ) { + $merged_field = array_merge( array( + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => 'beans_tests', + 'attributes' => array(), + 'db_group' => false, + ), $field ); + $merged_field['name'] = 'beans_fields[' . $field['id'] . ']'; + + if ( $set_value ) { + $merged_field['value'] = $field['default']; + } + + return $merged_field; + } + + /** + * Format the HTML by stripping out the whitespace between the HTML tags and then putting each tag on a separate + * line. + * + * Why? We can then compare the actual vs. expected HTML patterns without worrying about tabs, new lines, and extra + * spaces.z + * + * @since 1.0.0 + * + * @param string $html HTML to strip. + * + * @return string + */ + protected function format_the_html( $html ) { + $html = trim( $html ); + + // Strip whitespace between the tags. + $html = preg_replace( '/(\>)\s*(\<)/m', '$1$2', $html ); + + // Strip whitespace at the end of a tag. + $html = preg_replace( '/(\>)\s*/m', '$1$2', $html ); + + // Strip whitespace at the start of a tag. + $html = preg_replace( '/\s*(\<)/m', '$1$2', $html ); + + return str_replace( '>', ">\n", $html ); + } +} diff --git a/tests/phpunit/unit/api/fields/beansRegisterFields.php b/tests/phpunit/unit/api/fields/beansRegisterFields.php new file mode 100644 index 00000000..eb0e4012 --- /dev/null +++ b/tests/phpunit/unit/api/fields/beansRegisterFields.php @@ -0,0 +1,54 @@ +assertFalse( beans_register_fields( array(), '', '' ) ); + $this->assertFalse( beans_register_fields( array(), 'post_meta', 'tm-beans' ) ); + } + + /** + * Test beans_register_fields() should register the fields. + */ + public function test_should_register_fields() { + + foreach ( static::$test_data as $test_data ) { + $this->assertTrue( beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ) ); + + // Check what was registered. + $registered = $this->get_reflective_property_value( 'registered' ); + $this->assertArrayHasKey( 'beans_tests', $registered ); + $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); + + foreach ( $test_data['fields'] as $index => $field ) { + $this->assertSame( + $this->merge_field_with_default( $field ), + $registered['beans_tests'][ $test_data['section'] ][ $index ] + ); + } + } + } +} diff --git a/tests/phpunit/unit/api/fields/fixtures/test-fields.php b/tests/phpunit/unit/api/fields/fixtures/test-fields.php new file mode 100644 index 00000000..0e95c301 --- /dev/null +++ b/tests/phpunit/unit/api/fields/fixtures/test-fields.php @@ -0,0 +1,29 @@ + array( + array( + 'id' => 'beans_layout', + 'label' => 'Layout', + 'type' => 'radio', + 'default' => 'default_fallback', + 'options' => array( + 'default_fallback' => 'Use Default Layout', + 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', + 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', + 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', + ), + ), + ), + 'context' => 'post_meta', + 'section' => 'tm-beans', + ), +); diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php new file mode 100644 index 00000000..b8a3988a --- /dev/null +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -0,0 +1,195 @@ +returnArg(); + } + Monkey\Functions\when( 'checked' )->alias( function( $actual, $value ) { + if ( $actual !== $value ) { + return; + } + + echo " checked='checked'"; + } ); + Monkey\Functions\when( 'selected' )->alias( function( $actual, $value ) { + if ( $actual !== $value ) { + return; + } + + echo " selected='selected'"; + } ); + Monkey\Functions\when( '_n' )->alias( function( $single, $plural, $number ) { + return $number > 1 ? $plural : $single; + } ); + } + + /** + * Cleans up the test environment after each test. + */ + protected function tearDown() { + parent::tearDown(); + + // Reset the "registered" container. + $registered = $this->get_reflective_property( 'registered' ); + $registered->setValue( new \_Beans_Fields(), array( + 'option' => array(), + 'post_meta' => array(), + 'term_meta' => array(), + 'wp_customize' => array(), + ) ); + + // Reset the other static properties. + foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { + $property = $this->get_reflective_property( $property_name ); + $property->setValue( new \_Beans_Fields(), array() ); + } + } + + /** + * Get reflective access to the private method. + * + * @since 1.5.0 + * + * @param string $method_name Method name for which to gain access. + * + * @return \ReflectionMethod + */ + protected function get_reflective_method( $method_name ) { + $class = new \ReflectionClass( '_Beans_Fields' ); + $method = $class->getMethod( $method_name ); + $method->setAccessible( true ); + + return $method; + } + + /** + * Get reflective access to the private property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * + * @return \ReflectionProperty|string + */ + protected function get_reflective_property( $property ) { + $class = new \ReflectionClass( '_Beans_Fields' ); + $property = $class->getProperty( $property ); + $property->setAccessible( true ); + + return $property; + } + + /** + * Get the value of the private or protected property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * + * @return mixed + */ + protected function get_reflective_property_value( $property ) { + $reflective = $this->get_reflective_property( $property ); + return $reflective->getValue( new \_Beans_Fields() ); + } + + /** + * Merge the given field with the default structure. + * + * @since 1.5.0 + * + * @param array $field The given field to merge. + * @param bool $set_value Optional. When true, sets the "value" to the "default". + * + * @return array + */ + protected function merge_field_with_default( array $field, $set_value = true ) { + $merged_field = array_merge( array( + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => 'beans_tests', + 'attributes' => array(), + 'db_group' => false, + ), $field ); + $merged_field['name'] = 'beans_fields[' . $field['id'] . ']'; + + if ( $set_value ) { + $merged_field['value'] = $field['default']; + } + + return $merged_field; + } + + /** + * Format the HTML by stripping out the whitespace between the HTML tags and then putting each tag on a separate + * line. + * + * Why? We can then compare the actual vs. expected HTML patterns without worrying about tabs, new lines, and extra + * spaces.z + * + * @since 1.0.0 + * + * @param string $html HTML to strip. + * + * @return string + */ + protected function format_the_html( $html ) { + $html = trim( $html ); + + // Strip whitespace between the tags. + $html = preg_replace( '/(\>)\s*(\<)/m', '$1$2', $html ); + + // Strip whitespace at the end of a tag. + $html = preg_replace( '/(\>)\s*/m', '$1$2', $html ); + + // Strip whitespace at the start of a tag. + $html = preg_replace( '/\s*(\<)/m', '$1$2', $html ); + + return str_replace( '>', ">\n", $html ); + } +} From 5db77fa3292b23ff9be9103957831623dc588b97 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 08:23:01 -0600 Subject: [PATCH 082/800] Returned default as fallback for get_field_value. --- lib/api/fields/class-beans-fields.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index 513a5887..c68a3a31 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -309,6 +309,8 @@ private function get_field_value( $field_id, $context, $default ) { case 'wp_customize': return get_theme_mod( $field_id, $default ); } + + return $default; } /** From 8f6687ef4160d3abf03f53056c37d5d3cc4e074a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 08:25:04 -0600 Subject: [PATCH 083/800] Made beans_get_fields compliant + tested. --- lib/api/fields/functions.php | 7 ++- .../integration/api/fields/beansGetFields.php | 44 +++++++++++++++++++ .../unit/api/fields/beansGetFields.php | 44 +++++++++++++++++++ 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/integration/api/fields/beansGetFields.php create mode 100644 tests/phpunit/unit/api/fields/beansGetFields.php diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 28e926e8..f72ef8a4 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -53,7 +53,7 @@ function beans_register_fields( array $fields, $context, $section ) { } /** - * Get registered fields. + * Get the registered fields. * * This function is used to get the previously registered fields in order to display them using * {@see beans_field()}. @@ -63,8 +63,8 @@ function beans_register_fields( array $fields, $context, $section ) { * @param string $context The context in which the fields are used. 'option' for options/settings pages, 'post_meta' * for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP customizer * fields. - * @param string $section Optional. A section id to define a group of fields. This is mostly used for metaboxes - * and WP Customizer sections. + * @param string $section Optional. A section ID to define a group of fields. This is mostly used for metaboxes and WP + * Customizer sections. * * @return array|bool Array of register fields on success, false on failure. */ @@ -76,7 +76,6 @@ function beans_get_fields( $context, $section = false ) { $class = new _Beans_Fields(); return $class->get_fields( $context, $section ); - } /** diff --git a/tests/phpunit/integration/api/fields/beansGetFields.php b/tests/phpunit/integration/api/fields/beansGetFields.php new file mode 100644 index 00000000..46ec066d --- /dev/null +++ b/tests/phpunit/integration/api/fields/beansGetFields.php @@ -0,0 +1,44 @@ + array( + $test_data['section'] => $test_data['fields'], + ), + ); + + // Register the fields first. + $registered = $this->get_reflective_property( 'registered' ); + $registered->setValue( new \_Beans_Fields(), $data_set ); + + $this->assertSame( $data_set['beans_tests'][ $test_data['section'] ], beans_get_fields( 'beans_tests', $test_data['section'] ) ); + } + } +} diff --git a/tests/phpunit/unit/api/fields/beansGetFields.php b/tests/phpunit/unit/api/fields/beansGetFields.php new file mode 100644 index 00000000..2e85c909 --- /dev/null +++ b/tests/phpunit/unit/api/fields/beansGetFields.php @@ -0,0 +1,44 @@ + array( + $test_data['section'] => $test_data['fields'], + ), + ); + + // Register the fields first. + $registered = $this->get_reflective_property( 'registered' ); + $registered->setValue( new \_Beans_Fields(), $data_set ); + + $this->assertSame( $data_set['beans_tests'][ $test_data['section'] ], beans_get_fields( 'beans_tests', $test_data['section'] ) ); + } + } +} From 612a05965f536839415c74d3359ed7db2deef430 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 11:31:31 -0600 Subject: [PATCH 084/800] Made _beans_pre_standardize_fields compliant + tested. --- lib/api/fields/functions.php | 13 +++-- .../api/fields/_beansPreStandardizeFields.php | 55 +++++++++++++++++++ .../api/fields/beansRegisterFields.php | 33 ++++------- .../api/fields/fixtures/test-fields.php | 55 ++++++++++++++++++- .../api/fields/_beansPreStandardizeFields.php | 55 +++++++++++++++++++ .../unit/api/fields/beansRegisterFields.php | 33 ++++++----- .../unit/api/fields/fixtures/test-fields.php | 55 ++++++++++++++++++- 7 files changed, 251 insertions(+), 48 deletions(-) create mode 100644 tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php create mode 100644 tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index f72ef8a4..60895666 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -100,16 +100,20 @@ function beans_field( $field ) { } /** - * Standardize fields. + * Pre-standardize the fields by keying each field by its ID. * + * @since 1.0.0 * @ignore + * @access private + * + * @param array $fields An array of fields to be standardized. + * + * @return array */ -function _beans_pre_standardize_fields( $fields ) { - +function _beans_pre_standardize_fields( array $fields ) { $_fields = array(); foreach ( $fields as $field ) { - $_fields[ $field['id'] ] = $field; if ( 'group' === beans_get( 'type', $field ) ) { @@ -118,5 +122,4 @@ function _beans_pre_standardize_fields( $fields ) { } return $_fields; - } diff --git a/tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php b/tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php new file mode 100644 index 00000000..5e805407 --- /dev/null +++ b/tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php @@ -0,0 +1,55 @@ +assertArrayHasKey( $field['id'], $fields ); + $this->assertSame( $field, $fields[ $field['id'] ] ); + } + } + + /** + * Test _beans_pre_standardize_fields() should pre-standardize a group of fields. + */ + public function test_should_pre_standardize_group_of_fields() { + $actual = _beans_pre_standardize_fields( static::$test_data['group']['fields'] ); + + foreach ( static::$test_data['group']['fields'] as $group ) { + $this->assertArrayHasKey( $group['id'], $actual ); + + $actual_fields = $actual[ $group['id'] ]['fields']; + + // Check each of the grouped fields. + foreach ( $group['fields'] as $field ) { + $this->assertArrayHasKey( $field['id'], $actual_fields ); + $this->assertSame( $field, $actual_fields[ $field['id'] ] ); + } + } + } +} diff --git a/tests/phpunit/integration/api/fields/beansRegisterFields.php b/tests/phpunit/integration/api/fields/beansRegisterFields.php index b0a0f880..bdd74926 100644 --- a/tests/phpunit/integration/api/fields/beansRegisterFields.php +++ b/tests/phpunit/integration/api/fields/beansRegisterFields.php @@ -34,29 +34,18 @@ public function test_should_return_false_when_no_fields() { * Test beans_register_fields() should register the fields. */ public function test_should_register_fields() { + $test_data = static::$test_data['single_fields']; - foreach ( static::$test_data as $test_data ) { - $this->assertTrue( beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ) ); - - // Check what was registered. - $registered = $this->get_reflective_property_value( 'registered' ); - $this->assertArrayHasKey( 'beans_tests', $registered ); - $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); - - foreach ( $test_data['fields'] as $index => $field ) { - $expected = array_merge( array( - 'label' => false, - 'description' => false, - 'default' => false, - 'context' => 'beans_tests', - 'attributes' => array(), - 'db_group' => false, - ), $field ); - $expected['name'] = 'beans_fields[' . $field['id'] . ']'; - $expected['value'] = $field['default']; - - $this->assertSame( $expected, $registered['beans_tests'][ $test_data['section'] ][ $index ] ); - } + $this->assertTrue( beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ) ); + + // Check what was registered. + $registered = $this->get_reflective_property_value( 'registered' ); + $this->assertArrayHasKey( 'beans_tests', $registered ); + $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); + + foreach ( $test_data['fields'] as $index => $field ) { + $expected = $this->merge_field_with_default( $field ); + $this->assertSame( $expected, $registered['beans_tests'][ $test_data['section'] ][ $index ] ); } } } diff --git a/tests/phpunit/integration/api/fields/fixtures/test-fields.php b/tests/phpunit/integration/api/fields/fixtures/test-fields.php index 5a449bee..acc418ad 100644 --- a/tests/phpunit/integration/api/fields/fixtures/test-fields.php +++ b/tests/phpunit/integration/api/fields/fixtures/test-fields.php @@ -8,7 +8,8 @@ */ return array( - array( + // Single fields. + 'single_fields' => array( 'fields' => array( array( 'id' => 'beans_layout', @@ -22,8 +23,58 @@ 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', ), ), + array( + 'id' => 'beans_checkbox_test', + 'label' => false, + 'checkbox_label' => 'Enable the checkbox test', + 'type' => 'checkbox', + 'default' => false, + ), + array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => 'Testing the text field.', + ), + ), + 'context' => 'tests', + 'section' => 'tm-beans', + ), + + // Group of fields. + 'group' => array( + 'fields' => array( + array( + 'id' => 'beans_group_test', + 'label' => 'Group of fields', + 'description' => 'This is a group of fields.', + 'type' => 'group', + 'fields' => array( + array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ), + array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), + 'options' => array( + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ), + ), + array( + 'id' => 'beans_checkbox_test', + 'label' => false, + 'checkbox_label' => 'Enable the checkbox test', + 'type' => 'checkbox', + 'default' => false, + ), + ), + ), ), - 'context' => 'post_meta', + 'context' => 'group_tests', 'section' => 'tm-beans', ), ); diff --git a/tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php b/tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php new file mode 100644 index 00000000..a1355895 --- /dev/null +++ b/tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php @@ -0,0 +1,55 @@ +assertArrayHasKey( $field['id'], $fields ); + $this->assertSame( $field, $fields[ $field['id'] ] ); + } + } + + /** + * Test _beans_pre_standardize_fields() should pre-standardize a group of fields. + */ + public function test_should_pre_standardize_group_of_fields() { + $actual = _beans_pre_standardize_fields( static::$test_data['group']['fields'] ); + + foreach ( static::$test_data['group']['fields'] as $group ) { + $this->assertArrayHasKey( $group['id'], $actual ); + + $actual_fields = $actual[ $group['id'] ]['fields']; + + // Check each of the grouped fields. + foreach ( $group['fields'] as $field ) { + $this->assertArrayHasKey( $field['id'], $actual_fields ); + $this->assertSame( $field, $actual_fields[ $field['id'] ] ); + } + } + } +} diff --git a/tests/phpunit/unit/api/fields/beansRegisterFields.php b/tests/phpunit/unit/api/fields/beansRegisterFields.php index eb0e4012..04c352b3 100644 --- a/tests/phpunit/unit/api/fields/beansRegisterFields.php +++ b/tests/phpunit/unit/api/fields/beansRegisterFields.php @@ -31,24 +31,23 @@ public function test_should_return_false_when_no_fields() { } /** - * Test beans_register_fields() should register the fields. + * Test beans_register_fields() should register the single fields. */ - public function test_should_register_fields() { - - foreach ( static::$test_data as $test_data ) { - $this->assertTrue( beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ) ); - - // Check what was registered. - $registered = $this->get_reflective_property_value( 'registered' ); - $this->assertArrayHasKey( 'beans_tests', $registered ); - $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); - - foreach ( $test_data['fields'] as $index => $field ) { - $this->assertSame( - $this->merge_field_with_default( $field ), - $registered['beans_tests'][ $test_data['section'] ][ $index ] - ); - } + public function test_should_register_single_fields() { + $test_data = static::$test_data['single_fields']; + + $this->assertTrue( beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ) ); + + // Check what was registered. + $registered = $this->get_reflective_property_value( 'registered' ); + $this->assertArrayHasKey( 'beans_tests', $registered ); + $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); + + foreach ( $test_data['fields'] as $index => $field ) { + $this->assertSame( + $this->merge_field_with_default( $field ), + $registered['beans_tests'][ $test_data['section'] ][ $index ] + ); } } } diff --git a/tests/phpunit/unit/api/fields/fixtures/test-fields.php b/tests/phpunit/unit/api/fields/fixtures/test-fields.php index 0e95c301..17469fad 100644 --- a/tests/phpunit/unit/api/fields/fixtures/test-fields.php +++ b/tests/phpunit/unit/api/fields/fixtures/test-fields.php @@ -8,7 +8,8 @@ */ return array( - array( + // Single fields. + 'single_fields' => array( 'fields' => array( array( 'id' => 'beans_layout', @@ -22,8 +23,58 @@ 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', ), ), + array( + 'id' => 'beans_checkbox_test', + 'label' => false, + 'checkbox_label' => 'Enable the checkbox test', + 'type' => 'checkbox', + 'default' => false, + ), + array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => 'Testing the text field.', + ), + ), + 'context' => 'tests', + 'section' => 'tm-beans', + ), + + // Group of fields. + 'group' => array( + 'fields' => array( + array( + 'id' => 'beans_group_test', + 'label' => 'Group of fields', + 'description' => 'This is a group of fields.', + 'type' => 'group', + 'fields' => array( + array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ), + array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), + 'options' => array( + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ), + ), + array( + 'id' => 'beans_checkbox_test', + 'label' => false, + 'checkbox_label' => 'Enable the checkbox test', + 'type' => 'checkbox', + 'default' => false, + ), + ), + ), ), - 'context' => 'post_meta', + 'context' => 'group_tests', 'section' => 'tm-beans', ), ); From 5c73099fbede6a34a3c2a1a25b1f2e84ed6cce3f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 11:34:26 -0600 Subject: [PATCH 085/800] Made text type compliant + tested. --- lib/api/fields/types/text.php | 26 +++--- .../api/fields/types/beansFieldText.php | 85 +++++++++++++++++++ .../unit/api/fields/types/beansFieldText.php | 85 +++++++++++++++++++ 3 files changed, 184 insertions(+), 12 deletions(-) create mode 100644 tests/phpunit/integration/api/fields/types/beansFieldText.php create mode 100644 tests/phpunit/unit/api/fields/types/beansFieldText.php diff --git a/lib/api/fields/types/text.php b/lib/api/fields/types/text.php index e9b50757..78ba6d63 100644 --- a/lib/api/fields/types/text.php +++ b/lib/api/fields/types/text.php @@ -1,6 +1,8 @@ - > - ', + esc_attr( $field['name'] ), + esc_attr( $field['value'] ), + beans_esc_attributes( $field['attributes'] ) // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - Escaping is handled in the function. + ); } diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php new file mode 100644 index 00000000..6987ad58 --- /dev/null +++ b/tests/phpunit/integration/api/fields/types/beansFieldText.php @@ -0,0 +1,85 @@ +merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + ) ); + $field['value'] = 'Testing the text field.'; + + ob_start(); + beans_field_text( $field ); + $html = ob_get_clean(); + + // Run the test. + $this->assertSame( '', $html ); + } + + /** + * Test beans_field_text() should render the text field with attributes when given. + */ + public function test_should_render_text_field_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + $field['value'] = 'Testing the text field with attributes.'; + + ob_start(); + beans_field_text( $field ); + $html = ob_get_clean(); + + // Run the test. + $this->assertSame( '', $html ); + + } +} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php new file mode 100644 index 00000000..9eb11b74 --- /dev/null +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -0,0 +1,85 @@ +merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + ) ); + $field['value'] = 'Testing the text field.'; + + ob_start(); + beans_field_text( $field ); + $html = ob_get_clean(); + + // Run the test. + $this->assertSame( '', $html ); + } + + /** + * Test beans_field_text() should render the text field with attributes when given. + */ + public function test_should_render_text_field_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + $field['value'] = 'Testing the text field with attributes.'; + + ob_start(); + beans_field_text( $field ); + $html = ob_get_clean(); + + // Run the test. + $this->assertSame( '', $html ); + + } +} From cf7e2ab113231728d5d66b9679afecb9283e9fb0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 11:35:52 -0600 Subject: [PATCH 086/800] Made textarea field compliant & tested. --- lib/api/fields/types/textarea.php | 28 ++++--- .../api/fields/types/beansFieldTextarea.php | 84 +++++++++++++++++++ .../api/fields/types/beansFieldTextarea.php | 84 +++++++++++++++++++ 3 files changed, 183 insertions(+), 13 deletions(-) create mode 100644 tests/phpunit/integration/api/fields/types/beansFieldTextarea.php create mode 100644 tests/phpunit/unit/api/fields/types/beansFieldTextarea.php diff --git a/lib/api/fields/types/textarea.php b/lib/api/fields/types/textarea.php index d7d4baad..47252b80 100644 --- a/lib/api/fields/types/textarea.php +++ b/lib/api/fields/types/textarea.php @@ -1,28 +1,30 @@ - - %s', + esc_attr( $field['name'] ), + beans_esc_attributes( $field['attributes'] ), // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - Escaping is handled in the function. + esc_textarea( $field['value'] ) + ); } diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php new file mode 100644 index 00000000..ed272fe0 --- /dev/null +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -0,0 +1,84 @@ +merge_field_with_default( array( + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + ) ); + $field['value'] = 'Testing the textarea field.'; + + ob_start(); + beans_field_textarea( $field ); + $html = ob_get_clean(); + + // Run the test. + $this->assertSame( '', $html ); + } + + /** + * Test beans_field_textarea() should render the textarea field with attributes when given. + */ + public function test_should_render_text_field_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + $field['value'] = 'Testing the textarea field with attributes.'; + + ob_start(); + beans_field_textarea( $field ); + $html = ob_get_clean(); + + // Run the test. + $this->assertSame( '', $html ); + } +} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php new file mode 100644 index 00000000..1e65b379 --- /dev/null +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -0,0 +1,84 @@ +merge_field_with_default( array( + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + ) ); + $field['value'] = 'Testing the textarea field.'; + + ob_start(); + beans_field_textarea( $field ); + $html = ob_get_clean(); + + // Run the test. + $this->assertSame( '', $html ); + } + + /** + * Test beans_field_textarea() should render the textarea field with attributes when given. + */ + public function test_should_render_text_field_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + $field['value'] = 'Testing the textarea field with attributes.'; + + ob_start(); + beans_field_textarea( $field ); + $html = ob_get_clean(); + + // Run the test. + $this->assertSame( '', $html ); + } +} From 0b23eed0877188f9331c36c876db34986602431c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 11:38:19 -0600 Subject: [PATCH 087/800] Made activation field compliant & tested. --- lib/api/fields/types/activation.php | 26 +++--- .../api/fields/types/beansFieldActivation.php | 90 +++++++++++++++++++ .../api/fields/types/beansFieldActivation.php | 90 +++++++++++++++++++ 3 files changed, 193 insertions(+), 13 deletions(-) create mode 100644 tests/phpunit/integration/api/fields/types/beansFieldActivation.php create mode 100644 tests/phpunit/unit/api/fields/types/beansFieldActivation.php diff --git a/lib/api/fields/types/activation.php b/lib/api/fields/types/activation.php index a3ce930f..443de06c 100644 --- a/lib/api/fields/types/activation.php +++ b/lib/api/fields/types/activation.php @@ -1,6 +1,8 @@ - * as a delimiter. Default false. - * @type mixed $value The field value. - * @type string $name The field name value. - * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. - * @type mixed $default The default value. Default false. + * @type string $description The field description. The description can be truncated using as a delimiter. + * Default false. + * @type mixed $value The field value. + * @type string $name The field name value. + * @type array $attributes An array of attributes to add to the field. The array key defines the attribute name and + * the array value defines the attribute value. Default array. + * @type mixed $default The default value. Default false. * } */ -function beans_field_activation( $field ) { - +function beans_field_activation( array $field ) { ?> - /> + /> merge_field_with_default( array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ) ); + + ob_start(); + beans_field_activation( $field ); + $html = ob_get_clean(); + + $expected = << + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_activation() should render the activation field with attributes when given. + */ + public function test_should_render_activation_field_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + + ob_start(); + beans_field_activation( $field ); + $html = ob_get_clean(); + + $expected = << + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php new file mode 100644 index 00000000..166d0584 --- /dev/null +++ b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php @@ -0,0 +1,90 @@ +merge_field_with_default( array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ) ); + + ob_start(); + beans_field_activation( $field ); + $html = ob_get_clean(); + + $expected = << + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_activation() should render the activation field with attributes when given. + */ + public function test_should_render_activation_field_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + + ob_start(); + beans_field_activation( $field ); + $html = ob_get_clean(); + + $expected = << + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} From 68def871658c65f310cd3074157b83f8b65b3640 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 11:39:26 -0600 Subject: [PATCH 088/800] Separated concerns in activation field. --- lib/api/fields/types/activation.php | 5 +---- lib/api/fields/types/views/activation.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 lib/api/fields/types/views/activation.php diff --git a/lib/api/fields/types/activation.php b/lib/api/fields/types/activation.php index 443de06c..1aebd8a8 100644 --- a/lib/api/fields/types/activation.php +++ b/lib/api/fields/types/activation.php @@ -24,8 +24,5 @@ * } */ function beans_field_activation( array $field ) { - ?> - - /> - + + + /> From ac55fc6f3d2a15c61506b21dd63b245f080500b8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 11:43:17 -0600 Subject: [PATCH 089/800] Made checkbox field compliant + tested. --- lib/api/fields/types/checkbox.php | 32 ++--- .../api/fields/types/beansFieldCheckbox.php | 118 ++++++++++++++++++ .../api/fields/types/beansFieldCheckbox.php | 118 ++++++++++++++++++ 3 files changed, 253 insertions(+), 15 deletions(-) create mode 100644 tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php create mode 100644 tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php diff --git a/lib/api/fields/types/checkbox.php b/lib/api/fields/types/checkbox.php index 93e89bf6..982dccf5 100644 --- a/lib/api/fields/types/checkbox.php +++ b/lib/api/fields/types/checkbox.php @@ -1,6 +1,8 @@ - - /> - - + + /> + + merge_field_with_default( array( + 'id' => 'beans_compile_all_styles', + 'label' => false, + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + ) ); + + ob_start(); + beans_field_checkbox( $field ); + $html = ob_get_clean(); + + $expected = << + +Compile all WordPress styles +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_checkbox() should render the checkbox with the default label when none is given. + */ + public function test_should_render_a_checkbox_with_default_label_when_none_is_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_compile_all_styles', + 'type' => 'checkbox', + 'default' => false, + ) ); + + ob_start(); + beans_field_checkbox( $field ); + $html = ob_get_clean(); + + $expected = << + +Enable +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_checkbox() should render the checkbox with attributes when given. + */ + public function test_should_render_a_checkbox_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_compile_all_styles', + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + + ob_start(); + beans_field_checkbox( $field ); + $html = ob_get_clean(); + + $expected = << + +Compile all WordPress styles +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php new file mode 100644 index 00000000..06253ef5 --- /dev/null +++ b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php @@ -0,0 +1,118 @@ +merge_field_with_default( array( + 'id' => 'beans_compile_all_styles', + 'label' => false, + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + ) ); + + ob_start(); + beans_field_checkbox( $field ); + $html = ob_get_clean(); + + $expected = << + +Compile all WordPress styles +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_checkbox() should render the checkbox with the default label when none is given. + */ + public function test_should_render_a_checkbox_with_default_label_when_none_is_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_compile_all_styles', + 'type' => 'checkbox', + 'default' => false, + ) ); + + ob_start(); + beans_field_checkbox( $field ); + $html = ob_get_clean(); + + $expected = << + +Enable +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_checkbox() should render the checkbox with attributes when given. + */ + public function test_should_render_a_checkbox_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_compile_all_styles', + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + + ob_start(); + beans_field_checkbox( $field ); + $html = ob_get_clean(); + + $expected = << + +Compile all WordPress styles +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} From c820f7dd07055cc35a331782c9ff99f4e5b350f1 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 11:44:13 -0600 Subject: [PATCH 090/800] Separated concerns in checkbox field. --- lib/api/fields/types/checkbox.php | 7 +------ lib/api/fields/types/views/checkbox.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 lib/api/fields/types/views/checkbox.php diff --git a/lib/api/fields/types/checkbox.php b/lib/api/fields/types/checkbox.php index 982dccf5..cb1bb5de 100644 --- a/lib/api/fields/types/checkbox.php +++ b/lib/api/fields/types/checkbox.php @@ -25,10 +25,5 @@ function beans_field_checkbox( array $field ) { $checkbox_label = beans_get( 'checkbox_label', $field, __( 'Enable', 'tm-beans' ) ); - ?> - - /> - - - + + + /> + + + + Date: Wed, 21 Feb 2018 11:48:37 -0600 Subject: [PATCH 091/800] Made image field compliant & tested. --- lib/api/fields/types/image.php | 43 +++-- .../api/fields/types/beansFieldImage.php | 160 ++++++++++++++++++ .../unit/api/fields/types/beansFieldImage.php | 153 +++++++++++++++++ 3 files changed, 333 insertions(+), 23 deletions(-) create mode 100644 tests/phpunit/integration/api/fields/types/beansFieldImage.php create mode 100644 tests/phpunit/unit/api/fields/types/beansFieldImage.php diff --git a/lib/api/fields/types/image.php b/lib/api/fields/types/image.php index 67067836..1a8ad623 100644 --- a/lib/api/fields/types/image.php +++ b/lib/api/fields/types/image.php @@ -1,6 +1,8 @@ - > + > -
    +
    'image-id', 'type' => 'hidden', - 'name' => $multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple. + 'name' => $is_multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple. 'value' => $id, ), $field['attributes'] ); @@ -76,10 +74,10 @@ function beans_field_image( $field ) { ?>
    - /> + />
    - + @@ -90,5 +88,4 @@ function beans_field_image( $field ) {
    post->create(); + $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, array( + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ) ); + + $field = $this->merge_field_with_default( array( + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => $image_id, + ), false ); + + ob_start(); + beans_field_image( $field ); + $html = ob_get_clean(); + + $expected = <<
    +0 +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_slider() should render the slider field with unit when given. + */ + public function test_should_render_slider_field_with_unit_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 10, + 'max' => 100, + 'interval' => 5, + 'unit' => 'Number of beans', + ) ); + + ob_start(); + beans_field_slider( $field ); + $html = ob_get_clean(); + + $expected = << + +
    +0 +Number of beans +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_slider() should render the slider with the current value. + */ + public function test_should_render_slider_with_current_value() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 10, + 'max' => 100, + 'interval' => 5, + ) ); + $field['value'] = 15; + + ob_start(); + beans_field_slider( $field ); + $html = ob_get_clean(); + + $expected = << + +
    +15 +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_slider() should render the slider field with unit when given. + */ + public function test_should_render_slider_field_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 1, + 'min' => 1, + 'max' => 20, + 'interval' => 1, + 'unit' => 'Number of beans', + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + + ob_start(); + beans_field_slider( $field ); + $html = ob_get_clean(); + + $expected = << + +
    +1 +Number of beans +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php new file mode 100644 index 00000000..b70952b8 --- /dev/null +++ b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php @@ -0,0 +1,168 @@ +merge_field_with_default( array( + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 0, + 'max' => 100, + 'interval' => 1, + ) ); + + ob_start(); + beans_field_slider( $field ); + $html = ob_get_clean(); + + $expected = << + + +0 +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_slider() should render the slider field with unit when given. + */ + public function test_should_render_slider_field_with_unit_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 10, + 'max' => 100, + 'interval' => 5, + 'unit' => 'Number of beans', + ) ); + + ob_start(); + beans_field_slider( $field ); + $html = ob_get_clean(); + + $expected = << + + +0 +Number of beans +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_slider() should render the slider with the current value. + */ + public function test_should_render_slider_with_current_value() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 10, + 'max' => 100, + 'interval' => 5, + ) ); + $field['value'] = 15; + + ob_start(); + beans_field_slider( $field ); + $html = ob_get_clean(); + + $expected = << + + +15 +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test beans_field_slider() should render the slider field with unit when given. + */ + public function test_should_render_slider_field_with_attributes_when_given() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 1, + 'min' => 1, + 'max' => 20, + 'interval' => 1, + 'unit' => 'Number of beans', + 'attributes' => array( + 'data-test' => 'foo', + ), + ) ); + + ob_start(); + beans_field_slider( $field ); + $html = ob_get_clean(); + + $expected = << + + +1 +Number of beans +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} From 6c90fbc9a25cbeabf15e4b5eaddbf7ecfbec31fe Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 12:15:58 -0600 Subject: [PATCH 099/800] Separated concerns for slider field. --- lib/api/fields/types/slider.php | 14 +------------- lib/api/fields/types/views/slider.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 lib/api/fields/types/views/slider.php diff --git a/lib/api/fields/types/slider.php b/lib/api/fields/types/slider.php index cd81a60d..61fe5c1a 100644 --- a/lib/api/fields/types/slider.php +++ b/lib/api/fields/types/slider.php @@ -45,17 +45,5 @@ function beans_field_slider( $field ) { $field = array_merge( $defaults, $field ); - ?> -
    - - - /> - -
    - - - - - + +
    + /> +
    + + + + + Date: Wed, 21 Feb 2018 12:36:54 -0600 Subject: [PATCH 100/800] Made field label and description compliant & tested. --- lib/api/fields/types/field.php | 56 +++++---- .../fields/types/beansFieldDescription.php | 108 ++++++++++++++++++ .../api/fields/types/beansFieldLabel.php | 82 +++++++++++++ 3 files changed, 217 insertions(+), 29 deletions(-) create mode 100644 tests/phpunit/integration/api/fields/types/beansFieldDescription.php create mode 100644 tests/phpunit/integration/api/fields/types/beansFieldLabel.php diff --git a/lib/api/fields/types/field.php b/lib/api/fields/types/field.php index dca07e66..04caf052 100644 --- a/lib/api/fields/types/field.php +++ b/lib/api/fields/types/field.php @@ -1,32 +1,32 @@ - * as a delimiter. Default false. + * @type string $description The field description. The description can be truncated using as a delimiter. + * Default false. * } */ -function beans_field_description( $field ) { +function beans_field_description( array $field ) { + $description = beans_get( 'description', $field ); - if ( ! $description = beans_get( 'description', $field ) ) { + if ( ! $description ) { return; } + // Escape the description here. + $description = wp_kses_post( $description ); - beans_open_markup_e( 'beans_field_description[_' . $field['id'] . ']', 'div', array( 'class' => 'bs-field-description' ) ); - - if ( preg_match( '##', $description, $matches ) ) { - list( $description, $extended ) = explode( $matches[0], $description, 2 ); - } - - echo $description; - - if ( isset( $extended ) ) { + if ( preg_match( '##', $description, $matches ) ) { + list( $description, $extended ) = explode( $matches[0], $description, 2 ); + } - ?> -
    -
    - 'bs-field-description' ) ); + echo wp_kses_post( $description ); - } + if ( isset( $extended ) ) : ?> +
    +
    + merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + ) ); + + $this->assertNull( beans_field_description( $field ) ); + + $field['description'] = ''; + $this->assertNull( beans_field_description( $field ) ); + } + + /** + * Test beans_field_description() should render the field's description. + */ + public function test_should_render_field_description() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'description' => 'Testing the text field.', + 'default' => '', + ) ); + + ob_start(); + beans_field_description( $field ); + $html = ob_get_clean(); + + $expected = <<Testing the text field. +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + + /** + * Test beans_field_description() should render the field's extended description. + */ + public function test_should_render_extended_description() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'description' => 'Testing the text field.This is the extended part of the description.', + 'default' => '', + ) ); + + ob_start(); + beans_field_description( $field ); + $html = ob_get_clean(); + + $expected = <<Testing the text field.
    + More... +
    This is the extended part of the description.
    + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php new file mode 100644 index 00000000..8d5cb587 --- /dev/null +++ b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php @@ -0,0 +1,82 @@ +merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + ) ); + + $this->assertNull( beans_field_label( $field ) ); + + $field['label'] = ''; + $this->assertNull( beans_field_label( $field ) ); + } + + /** + * Test beans_field_label() should render the field's label. + */ + public function test_should_render_field_label() { + $field = $this->merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'label' => 'Testing the text field.', + 'default' => '', + ) ); + + ob_start(); + beans_field_label( $field ); + $html = ob_get_clean(); + + $expected = <<Testing the text field. +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} From 7763cc9a42237cdee2c6d775ede75e9817422931 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 12:38:27 -0600 Subject: [PATCH 101/800] Separated concerns in the field description. --- lib/api/fields/types/field.php | 10 ++++------ lib/api/fields/types/views/field-description.php | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 lib/api/fields/types/views/field-description.php diff --git a/lib/api/fields/types/field.php b/lib/api/fields/types/field.php index 04caf052..35fe6735 100644 --- a/lib/api/fields/types/field.php +++ b/lib/api/fields/types/field.php @@ -56,13 +56,11 @@ function beans_field_description( array $field ) { } beans_open_markup_e( 'beans_field_description[_' . $field['id'] . ']', 'div', array( 'class' => 'bs-field-description' ) ); - echo wp_kses_post( $description ); + echo wp_kses_post( $description ); - if ( isset( $extended ) ) : ?> -
    -
    - + +
    +
    From 3726d269084f0c29094f5064c474411c37eb7e84 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 12:56:18 -0600 Subject: [PATCH 102/800] Changed get_fields() to static. Why? It is using a static variable with no relationship to the object itself. --- lib/api/fields/class-beans-fields.php | 2 +- lib/api/fields/functions.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index c68a3a31..ec34c2dd 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -366,7 +366,7 @@ public function field_content( $field ) { * * @return array|bool Array of register fields on success, false on failure. */ - public function get_fields( $context, $section ) { + public static function get_fields( $context, $section ) { $fields = beans_get( $section, self::$registered[ $context ] ); if ( ! $fields ) { diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 60895666..f0b357b2 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -32,6 +32,7 @@ * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields * registered should be saved as a group in the database or as individual entries. Default false. * } + * * @param string $context The context in which the fields are used. 'option' for options/settings pages, * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP * customizer fields. @@ -74,8 +75,7 @@ function beans_get_fields( $context, $section = false ) { return; } - $class = new _Beans_Fields(); - return $class->get_fields( $context, $section ); + return _Beans_Fields::get_fields( $context, $section ); } /** From e2e006458393b45cfff36bf3b793afb9eb868f31 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 13:09:38 -0600 Subject: [PATCH 103/800] Fixed formatting. --- lib/api/fields/class-beans-fields.php | 8 +- lib/api/fields/functions.php | 5 +- lib/api/fields/types/field.php | 8 +- lib/api/fields/types/slider.php | 6 +- .../integration/api/fields/beansField.php | 93 +++++++++++++++++++ .../fields/types/beansFieldDescription.php | 16 ++-- .../api/fields/types/beansFieldSelect.php | 16 ++-- .../api/fields/types/beansFieldText.php | 19 ++-- .../api/fields/types/beansFieldTextarea.php | 18 ++-- .../api/fields/types/beansFieldSelect.php | 16 ++-- .../unit/api/fields/types/beansFieldText.php | 19 ++-- .../api/fields/types/beansFieldTextarea.php | 18 ++-- 12 files changed, 167 insertions(+), 75 deletions(-) create mode 100644 tests/phpunit/integration/api/fields/beansField.php diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index ec34c2dd..4f933ed5 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -157,7 +157,7 @@ private function standardize_field( $field ) { } // Add required attributes for wp_customizer. - if ( 'wp_customize' == $this->context ) { + if ( 'wp_customize' === $this->context ) { $field['attributes'] = array_merge( $field['attributes'], array( 'data-customize-setting-link' => $field['name'] ) @@ -188,7 +188,6 @@ private function set_types() { $this->field_types[ $_field['type'] ] = $_field['type']; } } - } /** @@ -226,7 +225,7 @@ private function load_fields() { foreach ( $this->field_types as $type ) { // Stop here if the field type has already been loaded. - if ( in_array( $type, self::$field_types_loaded ) ) { + if ( in_array( $type, self::$field_types_loaded, true ) ) { continue; } @@ -253,7 +252,7 @@ public function load_fields_assets_hook() { foreach ( $this->field_types as $type ) { // Stop here if the field type has already been loaded. - if ( in_array( $type, self::$field_assets_hook_loaded ) ) { + if ( in_array( $type, self::$field_assets_hook_loaded, true ) ) { continue; } @@ -357,6 +356,7 @@ public function field_content( $field ) { * Get the registered fields. * * @since 1.0.0 + * @since 1.5.0 Changed to static method. * * @param string $context The context in which the fields are used. 'option' for options/settings pages, * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index f0b357b2..64c777be 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -79,7 +79,7 @@ function beans_get_fields( $context, $section = false ) { } /** - * Echo a field. + * Render (echo) a field. * * This function echos the field content. Must be used in the loop of fields obtained using * {@see beans_get_fields()}. @@ -87,6 +87,8 @@ function beans_get_fields( $context, $section = false ) { * @since 1.0.0 * * @param array $field Array of data obtained using {@see beans_get_fields()}. + * + * @return void */ function beans_field( $field ) { @@ -96,7 +98,6 @@ function beans_field( $field ) { $class = new _Beans_Fields(); $class->field_content( $field ); - } /** diff --git a/lib/api/fields/types/field.php b/lib/api/fields/types/field.php index 35fe6735..8af5d192 100644 --- a/lib/api/fields/types/field.php +++ b/lib/api/fields/types/field.php @@ -12,7 +12,7 @@ * @since 1.0.0 * * @param array $field { - * Array of data. + * Array of data. * * @type string $label The field label. Default false. * } @@ -25,7 +25,7 @@ function beans_field_label( array $field ) { } beans_open_markup_e( 'beans_field_label[_' . $field['id'] . ']', 'label' ); - echo esc_html( $field['label'] ); + echo esc_html( $field['label'] ); beans_close_markup_e( 'beans_field_label[_' . $field['id'] . ']', 'label' ); } @@ -36,7 +36,7 @@ function beans_field_label( array $field ) { * @since 1.0.0 * * @param array $field { - * Array of data. + * Array of data. * * @type string $description The field description. The description can be truncated using as a delimiter. * Default false. @@ -56,7 +56,7 @@ function beans_field_description( array $field ) { } beans_open_markup_e( 'beans_field_description[_' . $field['id'] . ']', 'div', array( 'class' => 'bs-field-description' ) ); - echo wp_kses_post( $description ); + echo wp_kses_post( $description ); // @codingStandardsIgnoreStart - Generic.WhiteSpace.ScopeIndent.IncorrectExact - the indent is intentional to indicate HTML structure. if ( isset( $extended ) ) { include dirname( __FILE__ ) . '/views/field-description.php'; diff --git a/lib/api/fields/types/slider.php b/lib/api/fields/types/slider.php index 61fe5c1a..d21e1c7b 100644 --- a/lib/api/fields/types/slider.php +++ b/lib/api/fields/types/slider.php @@ -21,8 +21,8 @@ function beans_field_slider_assets() { * * @since 1.0.0 * - * @param array $field { - * For best practices, pass the array of data obtained using {@see beans_get_fields()}. + * @param array $field { + * For best practices, pass the array of data obtained using {@see beans_get_fields()}. * * @type mixed $value The field's current value. * @type string $name The field's "name" value. @@ -35,7 +35,7 @@ function beans_field_slider_assets() { * @type string $unit The slider's units, which is displayed after the current value. Default null. * } */ -function beans_field_slider( $field ) { +function beans_field_slider( array $field ) { $defaults = array( 'min' => 0, 'max' => 100, diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php new file mode 100644 index 00000000..1a067b18 --- /dev/null +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -0,0 +1,93 @@ +merge_field_with_default( array( + 'id' => 'beans_compile_all_styles', + 'label' => false, + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + ) ); + Monkey\Actions\expectDone( 'beans_field_checkbox' )->once()->with( $field ); + + ob_start(); + beans_field( $field ); + $html = ob_get_clean(); + + $expected = << +
    +
    + + + Compile all WordPress styles +
    +
    + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php index ad57e4fc..7454107f 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php @@ -63,10 +63,10 @@ public function test_should_not_render_field_description_when_none_given() { */ public function test_should_render_field_description() { $field = $this->merge_field_with_default( array( - 'id' => 'beans_text_test', - 'type' => 'text', - 'description' => 'Testing the text field.', - 'default' => '', + 'id' => 'beans_text_test', + 'type' => 'text', + 'description' => 'Testing the text field.', + 'default' => '', ) ); ob_start(); @@ -86,10 +86,10 @@ public function test_should_render_field_description() { */ public function test_should_render_extended_description() { $field = $this->merge_field_with_default( array( - 'id' => 'beans_text_test', - 'type' => 'text', - 'description' => 'Testing the text field.This is the extended part of the description.', - 'default' => '', + 'id' => 'beans_text_test', + 'type' => 'text', + 'description' => 'Testing the text field.This is the extended part of the description.', + 'default' => '', ) ); ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php index 6ff065da..cd96fbb2 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php @@ -46,10 +46,10 @@ public function tearDown() { */ public function test_should_render_select_field() { $field = $this->merge_field_with_default( array( - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'options' => array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'options' => array( 'aggressive' => 'Aggressive', 'standard' => 'Standard', ), @@ -74,14 +74,14 @@ public function test_should_render_select_field() { */ public function test_should_render_select_field_with_attributes_when_given() { $field = $this->merge_field_with_default( array( - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'standard', + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'standard', 'options' => array( 'aggressive' => 'Aggressive', 'standard' => 'Standard', ), - 'attributes' => array( + 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;', ), ) ); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php index 6987ad58..558829d5 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldText.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldText.php @@ -45,10 +45,10 @@ public function tearDown() { * Test beans_field_text() should render the text field. */ public function test_should_render_text_field() { - $field = $this->merge_field_with_default( array( - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', + $field = $this->merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', ) ); $field['value'] = 'Testing the text field.'; @@ -64,11 +64,11 @@ public function test_should_render_text_field() { * Test beans_field_text() should render the text field with attributes when given. */ public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - 'attributes' => array( + $field = $this->merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + 'attributes' => array( 'data-test' => 'foo', ), ) ); @@ -80,6 +80,5 @@ public function test_should_render_text_field_with_attributes_when_given() { // Run the test. $this->assertSame( '', $html ); - } } diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php index ed272fe0..d4473a8b 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -45,10 +45,10 @@ public function tearDown() { * Test beans_field_textarea() should render the textarea field. */ public function test_should_render_text_field() { - $field = $this->merge_field_with_default( array( - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', + $field = $this->merge_field_with_default( array( + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', ) ); $field['value'] = 'Testing the textarea field.'; @@ -64,11 +64,11 @@ public function test_should_render_text_field() { * Test beans_field_textarea() should render the textarea field with attributes when given. */ public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - 'attributes' => array( + $field = $this->merge_field_with_default( array( + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + 'attributes' => array( 'data-test' => 'foo', ), ) ); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index ea315bed..f6d48aae 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -46,10 +46,10 @@ public function tearDown() { */ public function test_should_render_select_field() { $field = $this->merge_field_with_default( array( - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'options' => array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'options' => array( 'aggressive' => 'Aggressive', 'standard' => 'Standard', ), @@ -74,14 +74,14 @@ public function test_should_render_select_field() { */ public function test_should_render_select_field_with_attributes_when_given() { $field = $this->merge_field_with_default( array( - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'standard', + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'standard', 'options' => array( 'aggressive' => 'Aggressive', 'standard' => 'Standard', ), - 'attributes' => array( + 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;', ), ) ); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index 9eb11b74..473e5c3c 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -45,10 +45,10 @@ public function tearDown() { * Test beans_field_text() should render the text field. */ public function test_should_render_text_field() { - $field = $this->merge_field_with_default( array( - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', + $field = $this->merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', ) ); $field['value'] = 'Testing the text field.'; @@ -64,11 +64,11 @@ public function test_should_render_text_field() { * Test beans_field_text() should render the text field with attributes when given. */ public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - 'attributes' => array( + $field = $this->merge_field_with_default( array( + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + 'attributes' => array( 'data-test' => 'foo', ), ) ); @@ -80,6 +80,5 @@ public function test_should_render_text_field_with_attributes_when_given() { // Run the test. $this->assertSame( '', $html ); - } } diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index 1e65b379..66300406 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -45,10 +45,10 @@ public function tearDown() { * Test beans_field_textarea() should render the textarea field. */ public function test_should_render_text_field() { - $field = $this->merge_field_with_default( array( - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', + $field = $this->merge_field_with_default( array( + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', ) ); $field['value'] = 'Testing the textarea field.'; @@ -64,11 +64,11 @@ public function test_should_render_text_field() { * Test beans_field_textarea() should render the textarea field with attributes when given. */ public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - 'attributes' => array( + $field = $this->merge_field_with_default( array( + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + 'attributes' => array( 'data-test' => 'foo', ), ) ); From a3bd7a2bfb43d8850da698703008f07bfef8dbe2 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 18:23:47 -0600 Subject: [PATCH 104/800] Improved documentation. --- lib/api/fields/types/activation.php | 22 ++++++------ lib/api/fields/types/checkbox.php | 17 +++++----- lib/api/fields/types/field.php | 14 ++++---- lib/api/fields/types/image.php | 27 ++++++++------- lib/api/fields/types/radio.php | 34 +++++++++++++------ lib/api/fields/types/select.php | 11 +++--- lib/api/fields/types/slider.php | 13 +++---- lib/api/fields/types/text.php | 18 +++++----- lib/api/fields/types/textarea.php | 16 ++++----- .../integration/api/fields/beansField.php | 2 ++ .../api/fields/types/_beansIsRadioImage.php | 16 ++++----- .../types/_beansStandardizeRadioImage.php | 18 +++++----- .../api/fields/types/beansFieldCheckbox.php | 6 ++-- .../api/fields/types/beansFieldImage.php | 6 ++-- .../api/fields/types/beansFieldRadio.php | 9 +++-- .../api/fields/types/beansFieldTextarea.php | 4 +-- .../api/fields/types/_beansIsRadioImage.php | 16 ++++----- .../types/_beansStandardizeRadioImage.php | 18 +++++----- .../api/fields/types/beansFieldCheckbox.php | 6 ++-- .../unit/api/fields/types/beansFieldImage.php | 7 ++-- .../unit/api/fields/types/beansFieldRadio.php | 9 +++-- .../api/fields/types/beansFieldSelect.php | 4 +-- .../api/fields/types/beansFieldTextarea.php | 4 +-- 23 files changed, 157 insertions(+), 140 deletions(-) diff --git a/lib/api/fields/types/activation.php b/lib/api/fields/types/activation.php index 1aebd8a8..4993bb0b 100644 --- a/lib/api/fields/types/activation.php +++ b/lib/api/fields/types/activation.php @@ -1,27 +1,25 @@ as a delimiter. - * Default false. - * @type mixed $value The field value. - * @type string $name The field name value. - * @type array $attributes An array of attributes to add to the field. The array key defines the attribute name and - * the array value defines the attribute value. Default array. - * @type mixed $default The default value. Default false. - * } + * @type mixed $value The field's current value. + * @type string $name The field's "name" value. + * @type array $attributes An array of attributes to add to the field. The array's key defines the attribute name + * and the array's value defines the attribute value. Default is an empty array. + * @type int $default The default value. */ function beans_field_activation( array $field ) { include dirname( __FILE__ ) . '/views/activation.php'; diff --git a/lib/api/fields/types/checkbox.php b/lib/api/fields/types/checkbox.php index cb1bb5de..e0d54911 100644 --- a/lib/api/fields/types/checkbox.php +++ b/lib/api/fields/types/checkbox.php @@ -1,25 +1,26 @@ as a delimiter. - * Default false. + * Default false. * } */ function beans_field_description( array $field ) { @@ -51,6 +52,7 @@ function beans_field_description( array $field ) { // Escape the description here. $description = wp_kses_post( $description ); + // If the description has , split it. if ( preg_match( '##', $description, $matches ) ) { list( $description, $extended ) = explode( $matches[0], $description, 2 ); } diff --git a/lib/api/fields/types/image.php b/lib/api/fields/types/image.php index 96f125a6..5fa814cd 100644 --- a/lib/api/fields/types/image.php +++ b/lib/api/fields/types/image.php @@ -1,15 +1,17 @@ '', ), $radio ); - if ( ! $radio['screen_reader_text'] && ! $radio['alt'] ) { - $radio['alt'] = "Option for {$value}"; - $radio['screen_reader_text'] = "Option for {$value}"; + if ( isset( $GLOBALS['tonya'] ) ) { + var_dump( $radio ); } + if ( $radio['screen_reader_text'] && $radio['alt'] ) { + return $radio; + } + + // Use the "alt" attribute when the "screen_reader_text" is not set. if ( ! $radio['screen_reader_text'] && $radio['alt'] ) { $radio['screen_reader_text'] = $radio['alt']; + return $radio; } + // Use the "screen_reader_text" attribute when the "alt" is not set. if ( ! $radio['alt'] && $radio['screen_reader_text'] ) { $radio['alt'] = $radio['screen_reader_text']; + return $radio; } + // Set the default accessibility values. + $radio['alt'] = "Option for {$value}"; + $radio['screen_reader_text'] = "Option for {$value}"; return $radio; } diff --git a/lib/api/fields/types/select.php b/lib/api/fields/types/select.php index 94c6b9c3..cf11def8 100644 --- a/lib/api/fields/types/select.php +++ b/lib/api/fields/types/select.php @@ -1,6 +1,6 @@ ', esc_attr( $field['name'] ), esc_attr( $field['value'] ), diff --git a/lib/api/fields/types/textarea.php b/lib/api/fields/types/textarea.php index 47252b80..6ea4bf5c 100644 --- a/lib/api/fields/types/textarea.php +++ b/lib/api/fields/types/textarea.php @@ -1,27 +1,27 @@ %s', esc_attr( $field['name'] ), beans_esc_attributes( $field['attributes'] ), // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - Escaping is handled in the function. diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 1a067b18..febe8409 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -45,6 +45,7 @@ public static function setUpBeforeClass() { */ public function setUp() { parent::setUp(); + Monkey\setUp(); // Make sure the radio is hooked into Beans. beans_add_smart_action( 'beans_field_checkbox', 'beans_field_checkbox' ); @@ -54,6 +55,7 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { + Monkey\tearDown(); parent::tearDown(); beans_remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); diff --git a/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php b/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php index 84d8c741..36236de3 100644 --- a/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php +++ b/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php @@ -33,13 +33,13 @@ public static function setUpBeforeClass() { } /** - * Test _beans_is_radio_image() should return true when an array configuration is given. + * Test _beans_is_radio_image() should return true when image source is given. */ public function test_should_return_true_when_image_src_given() { $test_data = array( - 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', - 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', - 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', + 'c' => 'http://example.com/images/layouts/c.png', + 'c_sp' => 'http://example.com/images/layouts/c_sp.png', + 'sp_c' => 'http://example.com/images/layouts/sp_c.png', ); foreach ( $test_data as $src ) { @@ -64,21 +64,21 @@ public function test_should_return_false_when_non_image_src_given() { } /** - * Test _beans_is_radio_image() should return true when an array configuration is given. + * Test _beans_is_radio_image() should return true when an array is given, an array that configures the image. */ public function test_should_return_true_when_array_is_given() { $test_data = array( 'c' => array( - 'src' => 'images/layouts/c.png', + 'src' => 'http://example.com/images/layouts/c.png', 'screen_reader_text' => 'Content Only Layout', ), 'c_sp' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', ), 'sp_c' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', ), ); diff --git a/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php b/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php index 77bbe54a..c91eac03 100644 --- a/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php +++ b/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php @@ -37,9 +37,9 @@ public static function setUpBeforeClass() { */ public function test_should_standardize_when_only_src_given() { $test_data = array( - 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', - 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', - 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', + 'c' => 'http://example.com/images/layouts/c.png', + 'c_sp' => 'http://example.com/images/layouts/c_sp.png', + 'sp_c' => 'http://example.com/images/layouts/sp_c.png', ); foreach ( $test_data as $value => $radio ) { @@ -58,15 +58,15 @@ public function test_should_standardize_when_only_src_given() { public function test_should_standardize_when_alt_is_not_given() { $test_data = array( 'c' => array( - 'src' => 'images/layouts/c.png', + 'src' => 'http://example.com/images/layouts/c.png', 'screen_reader_text' => 'Content Only Layout', ), 'c_sp' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Content + Sidebar Primary Layout', ), 'sp_c' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Sidebar Primary + Content Layout', ), ); @@ -87,15 +87,15 @@ public function test_should_standardize_when_alt_is_not_given() { public function test_should_standardize_when_screen_reader_text_is_not_given() { $test_data = array( 'c' => array( - 'src' => 'images/layouts/c.png', + 'src' => 'http://example.com/images/layouts/c.png', 'alt' => 'Content Only Layout', ), 'c_sp' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', ), 'sp_c' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', ), ); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php index c2c61fa0..f5c4e6e1 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php @@ -44,7 +44,7 @@ public function tearDown() { /** * Test beans_field_checkbox() should render the checkbox with the label when given. */ - public function test_should_render_a_checkbox_with_label_when_given() { + public function test_should_render_checkbox_with_label_when_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_compile_all_styles', 'label' => false, @@ -69,7 +69,7 @@ public function test_should_render_a_checkbox_with_label_when_given() { /** * Test beans_field_checkbox() should render the checkbox with the default label when none is given. */ - public function test_should_render_a_checkbox_with_default_label_when_none_is_given() { + public function test_should_render_checkbox_with_default_label_when_none_is_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_compile_all_styles', 'type' => 'checkbox', @@ -92,7 +92,7 @@ public function test_should_render_a_checkbox_with_default_label_when_none_is_gi /** * Test beans_field_checkbox() should render the checkbox with attributes when given. */ - public function test_should_render_a_checkbox_with_attributes_when_given() { + public function test_should_render_checkbox_with_attributes_when_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_compile_all_styles', 'checkbox_label' => 'Compile all WordPress styles', diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index 9bedb8d2..c1cf820c 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -1,6 +1,6 @@ post->create(); @@ -92,7 +92,7 @@ public function test_should_render_single_image_field() { } /** - * Test beans_field_image_assets() should render multiple images field. + * Test beans_field_image() should render multiple images field. */ public function test_should_render_multiple_images_field() { $images = array(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php index b1167f56..888d01a8 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php @@ -42,9 +42,9 @@ public function tearDown() { } /** - * Test beans_field_radio() should render a radio field with image options. + * Test beans_field_radio() should render the radio field with image options. */ - public function test_should_render_a_radio_field_with_image_options() { + public function test_should_render_radio_field_with_image_options() { $field = $this->merge_field_with_default( array( 'id' => 'beans_layout', 'label' => 'Layout', @@ -90,10 +90,9 @@ public function test_should_render_a_radio_field_with_image_options() { } /** - * Test beans_field_Radio() should render the accessible images when accessible parameters are not - * given. + * Test beans_field_radio() should render the accessible images when accessible parameters are given. */ - public function test_should_render_when_accessible_parameters_given() { + public function test_should_render_accessible_images_when_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_layout', 'label' => 'Layout', diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php index d4473a8b..af663878 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -44,7 +44,7 @@ public function tearDown() { /** * Test beans_field_textarea() should render the textarea field. */ - public function test_should_render_text_field() { + public function test_should_render_textarea_field() { $field = $this->merge_field_with_default( array( 'id' => 'beans_textarea_test', 'type' => 'textarea', @@ -63,7 +63,7 @@ public function test_should_render_text_field() { /** * Test beans_field_textarea() should render the textarea field with attributes when given. */ - public function test_should_render_text_field_with_attributes_when_given() { + public function test_should_render_textarea_field_with_attributes_when_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_textarea_test', 'type' => 'textarea', diff --git a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php index 2b8d8472..38b7a4ab 100644 --- a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php @@ -33,13 +33,13 @@ public static function setUpBeforeClass() { } /** - * Test _beans_is_radio_image() should return true when an array configuration is given. + * Test _beans_is_radio_image() should return true when image source is given. */ public function test_should_return_true_when_image_src_given() { $test_data = array( - 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', - 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', - 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', + 'c' => 'http://example.com/images/layouts/c.png', + 'c_sp' => 'http://example.com/images/layouts/c_sp.png', + 'sp_c' => 'http://example.com/images/layouts/sp_c.png', ); foreach ( $test_data as $src ) { @@ -64,21 +64,21 @@ public function test_should_return_false_when_non_image_src_given() { } /** - * Test _beans_is_radio_image() should return true when an array configuration is given. + * Test _beans_is_radio_image() should return true when an array is given, an array that configures the image. */ public function test_should_return_true_when_array_is_given() { $test_data = array( 'c' => array( - 'src' => 'images/layouts/c.png', + 'src' => 'http://example.com/images/layouts/c.png', 'screen_reader_text' => 'Content Only Layout', ), 'c_sp' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', ), 'sp_c' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', ), ); diff --git a/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php b/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php index a05fbd44..43062068 100644 --- a/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php @@ -37,9 +37,9 @@ public static function setUpBeforeClass() { */ public function test_should_standardize_when_only_src_given() { $test_data = array( - 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', - 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', - 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', + 'c' => 'http://example.com/images/layouts/c.png', + 'c_sp' => 'http://example.com/images/layouts/c_sp.png', + 'sp_c' => 'http://example.com/images/layouts/sp_c.png', ); foreach ( $test_data as $value => $radio ) { @@ -58,15 +58,15 @@ public function test_should_standardize_when_only_src_given() { public function test_should_standardize_when_alt_is_not_given() { $test_data = array( 'c' => array( - 'src' => 'images/layouts/c.png', + 'src' => 'http://example.com/images/layouts/c.png', 'screen_reader_text' => 'Content Only Layout', ), 'c_sp' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Content + Sidebar Primary Layout', ), 'sp_c' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Sidebar Primary + Content Layout', ), ); @@ -87,15 +87,15 @@ public function test_should_standardize_when_alt_is_not_given() { public function test_should_standardize_when_screen_reader_text_is_not_given() { $test_data = array( 'c' => array( - 'src' => 'images/layouts/c.png', + 'src' => 'http://example.com/images/layouts/c.png', 'alt' => 'Content Only Layout', ), 'c_sp' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', ), 'sp_c' => array( - 'src' => 'images/layouts/c_sp.png', + 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', ), ); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php index 06253ef5..9753ef72 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php @@ -44,7 +44,7 @@ public function tearDown() { /** * Test beans_field_checkbox() should render the checkbox with the label when given. */ - public function test_should_render_a_checkbox_with_label_when_given() { + public function test_should_render_checkbox_with_label_when_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_compile_all_styles', 'label' => false, @@ -69,7 +69,7 @@ public function test_should_render_a_checkbox_with_label_when_given() { /** * Test beans_field_checkbox() should render the checkbox with the default label when none is given. */ - public function test_should_render_a_checkbox_with_default_label_when_none_is_given() { + public function test_should_render_checkbox_with_default_label_when_none_is_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_compile_all_styles', 'type' => 'checkbox', @@ -92,7 +92,7 @@ public function test_should_render_a_checkbox_with_default_label_when_none_is_gi /** * Test beans_field_checkbox() should render the checkbox with attributes when given. */ - public function test_should_render_a_checkbox_with_attributes_when_given() { + public function test_should_render_checkbox_with_attributes_when_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_compile_all_styles', 'checkbox_label' => 'Compile all WordPress styles', diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index f113a5d6..db615c4e 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -1,6 +1,6 @@ with( 1, 'thumbnail' )->once() @@ -89,7 +89,7 @@ public function test_should_render_single_image_field() { } /** - * Test beans_field_image_assets() should render multiple images field. + * Test beans_field_image() should render multiple images field. */ public function test_should_render_multiple_images_field() { Monkey\Functions\expect( 'wp_get_attachment_image_src' ) @@ -146,7 +146,6 @@ public function test_should_render_multiple_images_field() { EOB; - // Run the test. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); } diff --git a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php index 54401f18..470cbb22 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php @@ -42,9 +42,9 @@ public function tearDown() { } /** - * Test beans_field() should render a radio field with image options. + * Test beans_field_radio() should render the radio field with image options. */ - public function test_should_render_a_radio_field_with_image_options() { + public function test_should_render_radio_field_with_image_options() { $field = $this->merge_field_with_default( array( 'id' => 'beans_layout', 'label' => 'Layout', @@ -90,10 +90,9 @@ public function test_should_render_a_radio_field_with_image_options() { } /** - * Test beans_field() should render the accessible images when accessible parameters are not - * given. + * Test beans_field_radio() should render the accessible images when accessible parameters are given. */ - public function test_should_render_when_accessible_parameters_given() { + public function test_should_render_accessible_images_when_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_layout', 'label' => 'Layout', diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index f6d48aae..9cd077be 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -14,7 +14,7 @@ require_once dirname( __DIR__ ) . '/includes/class-fields-test-case.php'; /** - * Class Tests_BeansFieldSelect + * Class Tests_BeansFieldSelectV * * @package Beans\Framework\Tests\Unit\API\Fields * @group unit-tests @@ -70,7 +70,7 @@ public function test_should_render_select_field() { } /** - * Test beans_field_checkbox() should render the select field with attributes when given. + * Test beans_field_select() should render the select field with attributes when given. */ public function test_should_render_select_field_with_attributes_when_given() { $field = $this->merge_field_with_default( array( diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index 66300406..021c966d 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -44,7 +44,7 @@ public function tearDown() { /** * Test beans_field_textarea() should render the textarea field. */ - public function test_should_render_text_field() { + public function test_should_render_textarea_field() { $field = $this->merge_field_with_default( array( 'id' => 'beans_textarea_test', 'type' => 'textarea', @@ -63,7 +63,7 @@ public function test_should_render_text_field() { /** * Test beans_field_textarea() should render the textarea field with attributes when given. */ - public function test_should_render_text_field_with_attributes_when_given() { + public function test_should_render_textarea_field_with_attributes_when_given() { $field = $this->merge_field_with_default( array( 'id' => 'beans_textarea_test', 'type' => 'textarea', From 33c12fea2f7a897ea73f631f2814f89ec2000efa Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 18:28:49 -0600 Subject: [PATCH 105/800] Moved rendering code from _Beans_Fields into beans_field. Why? The rendering code has no tie to the object. It does not relate to the rest of the tasks within _Beans_Fields. Therefore, we can avoid instantiating and invoking the method by moving the code directly into the beans_field function. adl --- lib/api/fields/class-beans-fields.php | 40 ------------------- lib/api/fields/functions.php | 35 ++++++++++++++-- .../integration/api/fields/beansField.php | 6 +-- 3 files changed, 33 insertions(+), 48 deletions(-) diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index 4f933ed5..6c0f03ce 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -312,46 +312,6 @@ private function get_field_value( $field_id, $context, $default ) { return $default; } - /** - * Render the field content. - * - * @since 1.0.0 - * - * @param array $field The given field to be rendered. - * - * @return void - */ - public function field_content( $field ) { - beans_open_markup_e( 'beans_field_wrap', 'div', array( - 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], - ), $field ); - - // Set fields loop to cater for groups. - if ( 'group' === $field['type'] ) { - $fields = $field['fields']; - } else { - $fields = array( $field ); - } - - beans_open_markup_e( 'beans_field_inside', 'div', array( - 'class' => 'bs-field-inside', - ), $fields ); - - // Loop through fields. - foreach ( $fields as $single_field ) { - beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array( - 'class' => 'bs-field bs-' . $single_field['type'], - ), $single_field ); - - do_action( 'beans_field_' . $single_field['type'], $single_field ); - - beans_close_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', $single_field ); - } - - beans_close_markup_e( 'beans_field_inside', 'div', $fields ); - beans_close_markup_e( 'beans_field_wrap', 'div', $field ); - } - /** * Get the registered fields. * diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 64c777be..063a67ab 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -85,19 +85,46 @@ function beans_get_fields( $context, $section = false ) { * {@see beans_get_fields()}. * * @since 1.0.0 + * @since 1.5.0 Moved rendering code out of _Beans_Fields. * - * @param array $field Array of data obtained using {@see beans_get_fields()}. + * @param array $field The given field to render, obtained using {@see beans_get_fields()}. * * @return void */ -function beans_field( $field ) { +function beans_field( array $field ) { if ( ! class_exists( '_Beans_Fields' ) ) { return; } - $class = new _Beans_Fields(); - $class->field_content( $field ); + beans_open_markup_e( 'beans_field_wrap', 'div', array( + 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], + ), $field ); + + // Set fields loop to cater for groups. + if ( 'group' === $field['type'] ) { + $fields = $field['fields']; + } else { + $fields = array( $field ); + } + + beans_open_markup_e( 'beans_field_inside', 'div', array( + 'class' => 'bs-field-inside', + ), $fields ); + + // Loop through fields. + foreach ( $fields as $single_field ) { + beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array( + 'class' => 'bs-field bs-' . $single_field['type'], + ), $single_field ); + + do_action( 'beans_field_' . $single_field['type'], $single_field ); + + beans_close_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', $single_field ); + } + + beans_close_markup_e( 'beans_field_inside', 'div', $fields ); + beans_close_markup_e( 'beans_field_wrap', 'div', $field ); } /** diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index febe8409..672044de 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -45,7 +45,6 @@ public static function setUpBeforeClass() { */ public function setUp() { parent::setUp(); - Monkey\setUp(); // Make sure the radio is hooked into Beans. beans_add_smart_action( 'beans_field_checkbox', 'beans_field_checkbox' ); @@ -55,16 +54,15 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - Monkey\tearDown(); parent::tearDown(); beans_remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); } /** - * Test beans_field() should render a checkbox field. + * Test beans_field() should render the checkbox field. */ - public function test_should_render_a_checkbox_field() { + public function test_should_render_checkbox_field() { $field = $this->merge_field_with_default( array( 'id' => 'beans_compile_all_styles', 'label' => false, From e8ee1631aa0c2a73d66e666471baf7c6072404bd Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Feb 2018 20:34:41 -0600 Subject: [PATCH 106/800] Added "alt" for accessibility to Image Field. --- lib/api/fields/types/image.php | 36 +++++++++- lib/api/fields/types/views/image.php | 3 +- .../api/fields/types/beansFieldImage.php | 62 ++++++++++++++-- .../unit/api/fields/types/beansFieldImage.php | 72 +++++++++++++++++-- 4 files changed, 159 insertions(+), 14 deletions(-) diff --git a/lib/api/fields/types/image.php b/lib/api/fields/types/image.php index 5fa814cd..6a59251f 100644 --- a/lib/api/fields/types/image.php +++ b/lib/api/fields/types/image.php @@ -27,7 +27,7 @@ function beans_field_image_assets() { * @since 1.5.0 Moved the HTML to a view file. * * @param array $field { - * For best practices, pass the array of data obtained using {@see beans_get_fields()}. + * For best practices, pass the array of data obtained using {@see beans_get_fields()}. * * @type mixed $value The image's or images' ID. * @type string $name The field's "name" value. @@ -82,3 +82,37 @@ function _beans_get_image_id_attributes( $id, array $field, $is_multiple ) { return $attributes; } + +/** + * Get the image's URL and alt values. + * + * @since 1.5.0 + * + * @param mixed $image_id The image's attachment ID. + * + * @return array|void + */ +function _beans_get_image_url_and_alt( $image_id ) { + $image_id = (int) $image_id; + + // If this is not a valid image ID, bail out. + if ( $image_id < 1 ) { + return; + } + + $image_url = beans_get( 0, wp_get_attachment_image_src( $image_id, 'thumbnail' ) ); + + // If no URL is retrieved, bail out. + if ( ! $image_url ) { + return; + } + + $image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true ); + + // If no alt value is given, set a default. + if ( ! $image_alt ) { + $image_alt = __( 'Sorry, no alt was given for this image.', 'tm-beans' ); + } + + return array( $image_url, $image_alt ); +} diff --git a/lib/api/fields/types/views/image.php b/lib/api/fields/types/views/image.php index 2ed3ed4a..f2ab0341 100644 --- a/lib/api/fields/types/views/image.php +++ b/lib/api/fields/types/views/image.php @@ -23,10 +23,11 @@ } $attributes = _beans_get_image_id_attributes( $id, $field, $is_multiple ); // @codingStandardsIgnoreLine. WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound - Called from within a function and not within global scope. + list( $image_url, $image_alt ) = _beans_get_image_url_and_alt( $id ); ?>
    /> - + <?php echo $image_alt ? esc_attr( $image_alt ) : ''; ?>
    diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index c1cf820c..2a6300bb 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -51,6 +51,7 @@ public function test_should_render_single_image_field() { 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', ) ); + update_post_meta( $image_id, '_wp_attachment_image_alt', 'This is the alt value.', true ); $field = $this->merge_field_with_default( array( 'id' => 'beans_image_test', @@ -69,7 +70,7 @@ public function test_should_render_single_image_field() {
    - + This is the alt value.
    @@ -77,7 +78,7 @@ public function test_should_render_single_image_field() {
    - +
    @@ -101,10 +102,12 @@ public function test_should_render_multiple_images_field() { 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', ) ); + update_post_meta( $images[0], '_wp_attachment_image_alt', 'Image 1 alt.', true ); $images[] = self::factory()->attachment->create_object( 'image-2.png', $post_id, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', ) ); + update_post_meta( $images[1], '_wp_attachment_image_alt', 'Image 2 alt.', true ); $field = $this->merge_field_with_default( array( 'id' => 'beans_image_test', @@ -124,7 +127,7 @@ public function test_should_render_multiple_images_field() {
    - + Image 1 alt.
    @@ -133,7 +136,7 @@ public function test_should_render_multiple_images_field() {
    - + Image 2 alt.
    @@ -142,7 +145,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -157,4 +160,53 @@ public function test_should_render_multiple_images_field() { // Run the test. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); } + + /** + * Test beans_field_image() should render a single image field with the default alt when none exists. + */ + public function test_should_render_single_image_field_with_default_alt_when_none_exists() { + $post_id = self::factory()->post->create(); + $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, array( + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ) ); + + $field = $this->merge_field_with_default( array( + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => $image_id, + ), false ); + + ob_start(); + beans_field_image( $field ); + $html = ob_get_clean(); + + $expected = <<
    0 Number of beans @@ -124,7 +124,7 @@ public function test_should_render_slider_with_current_value() { $expected = << - +
    15 EOB; @@ -157,7 +157,7 @@ public function test_should_render_slider_field_with_attributes_when_given() { $expected = << - +
    1 Number of beans diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index 473e5c3c..5957ab14 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -56,8 +56,11 @@ public function test_should_render_text_field() { beans_field_text( $field ); $html = ob_get_clean(); + $expected = << +EOB; // Run the test. - $this->assertSame( '', $html ); + $this->assertSame( $expected, $html ); } /** @@ -78,7 +81,10 @@ public function test_should_render_text_field_with_attributes_when_given() { beans_field_text( $field ); $html = ob_get_clean(); + $expected = << +EOB; // Run the test. - $this->assertSame( '', $html ); + $this->assertSame( $expected, $html ); } } diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index 021c966d..7b0dbbc2 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -56,8 +56,12 @@ public function test_should_render_textarea_field() { beans_field_textarea( $field ); $html = ob_get_clean(); + + $expected = <<Testing the textarea field. +EOB; // Run the test. - $this->assertSame( '', $html ); + $this->assertSame( $expected, $html ); } /** @@ -78,7 +82,10 @@ public function test_should_render_textarea_field_with_attributes_when_given() { beans_field_textarea( $field ); $html = ob_get_clean(); + $expected = <<Testing the textarea field with attributes. +EOB; // Run the test. - $this->assertSame( '', $html ); + $this->assertSame( $expected, $html ); } } From 9a86b30da87db5928e0c9cab0f6139105a017161 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Feb 2018 14:06:16 -0600 Subject: [PATCH 118/800] Added ID to image field. --- lib/api/fields/types/views/image.php | 2 +- .../integration/api/fields/types/beansFieldImage.php | 6 +++--- tests/phpunit/unit/api/fields/types/beansFieldImage.php | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/api/fields/types/views/image.php b/lib/api/fields/types/views/image.php index a7b4abb9..eefbf2b1 100644 --- a/lib/api/fields/types/views/image.php +++ b/lib/api/fields/types/views/image.php @@ -11,7 +11,7 @@ ?> - +
    Add Image - +
    @@ -123,7 +123,7 @@ public function test_should_render_multiple_images_field() { $expected = <<
    @@ -129,27 +129,27 @@ public function test_should_render_multiple_images_field() { This is the image alt value.
    - - - + + +
    This is the image alt value.
    - - - + + +
    - - - + + +
    @@ -189,21 +189,20 @@ public function test_should_render_single_image_field_with_default_alt_when_none Sorry, no alt was given for this image.
    - - + +
    - - + +
    EOB; - // Run the test. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); } From 876b92fb822b5f8d369429f723924e4e35ce2705 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Feb 2018 17:20:22 -0600 Subject: [PATCH 125/800] Fixed formatting. --- lib/api/fields/class-beans-fields.php | 4 ++-- lib/api/fields/types/radio.php | 4 ---- tests/phpunit/integration/api/fields/beansRegisterFields.php | 2 +- .../integration/api/fields/types/beansFieldActivation.php | 2 ++ .../integration/api/fields/types/beansFieldCheckbox.php | 3 +++ .../integration/api/fields/types/beansFieldDescription.php | 2 ++ .../phpunit/integration/api/fields/types/beansFieldImage.php | 3 +++ .../phpunit/integration/api/fields/types/beansFieldLabel.php | 3 +++ .../phpunit/integration/api/fields/types/beansFieldRadio.php | 2 ++ .../phpunit/integration/api/fields/types/beansFieldSelect.php | 2 ++ .../phpunit/integration/api/fields/types/beansFieldSlider.php | 4 ++++ tests/phpunit/integration/api/fields/types/beansFieldText.php | 2 ++ .../integration/api/fields/types/beansFieldTextarea.php | 2 ++ tests/phpunit/unit/api/fields/types/beansFieldActivation.php | 2 ++ tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php | 3 +++ tests/phpunit/unit/api/fields/types/beansFieldImage.php | 3 +++ tests/phpunit/unit/api/fields/types/beansFieldRadio.php | 2 ++ tests/phpunit/unit/api/fields/types/beansFieldSelect.php | 2 ++ tests/phpunit/unit/api/fields/types/beansFieldSlider.php | 4 ++++ tests/phpunit/unit/api/fields/types/beansFieldText.php | 2 ++ tests/phpunit/unit/api/fields/types/beansFieldTextarea.php | 3 ++- 21 files changed, 48 insertions(+), 8 deletions(-) diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index c1cff232..6c0f03ce 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -139,14 +139,14 @@ private function standardize_field( $field ) { ), $field ); // Set the field's name. - $field['name'] = 'wp_customize' === $this->context ? $field['id'] : 'beans_fields[' . $field['id'] . ']'; + $field['name'] = 'wp_customize' === $this->context ? $field['id'] : 'beans_fields[' . $field['id'] . ']'; if ( 'group' === $field['type'] ) { foreach ( $field['fields'] as $index => $_field ) { if ( $field['db_group'] ) { - $_field['name'] = $field['name'] . '[' . $_field['id'] . ']'; + $_field['name'] = $field['name'] . '[' . $_field['id'] . ']'; } $field['fields'][ $index ] = $this->standardize_field( $_field ); diff --git a/lib/api/fields/types/radio.php b/lib/api/fields/types/radio.php index 29865f4d..898f2448 100644 --- a/lib/api/fields/types/radio.php +++ b/lib/api/fields/types/radio.php @@ -90,10 +90,6 @@ function _beans_standardize_radio_image( $value, $radio ) { 'screen_reader_text' => '', ), $radio ); - if ( isset( $GLOBALS['tonya'] ) ) { - var_dump( $radio ); - } - if ( $radio['screen_reader_text'] && $radio['alt'] ) { return $radio; } diff --git a/tests/phpunit/integration/api/fields/beansRegisterFields.php b/tests/phpunit/integration/api/fields/beansRegisterFields.php index 0abf0152..bdd74926 100644 --- a/tests/phpunit/integration/api/fields/beansRegisterFields.php +++ b/tests/phpunit/integration/api/fields/beansRegisterFields.php @@ -44,7 +44,7 @@ public function test_should_register_fields() { $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); foreach ( $test_data['fields'] as $index => $field ) { - $expected = $this->merge_field_with_default( $field ); + $expected = $this->merge_field_with_default( $field ); $this->assertSame( $expected, $registered['beans_tests'][ $test_data['section'] ][ $index ] ); } } diff --git a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php index c30f6feb..a6cdecb3 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php @@ -51,6 +51,7 @@ public function test_should_render_activation_field() { 'default' => false, ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_activation( $field ); $html = ob_get_clean(); @@ -76,6 +77,7 @@ public function test_should_render_activation_field_with_attributes_when_given() ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_activation( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php index 3d0e7dbe..d2e0782e 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php @@ -53,6 +53,7 @@ public function test_should_render_checkbox_with_label_when_given() { 'default' => false, ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_checkbox( $field ); $html = ob_get_clean(); @@ -76,6 +77,7 @@ public function test_should_render_checkbox_with_default_label_when_none_is_give 'default' => false, ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_checkbox( $field ); $html = ob_get_clean(); @@ -103,6 +105,7 @@ public function test_should_render_checkbox_with_attributes_when_given() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_checkbox( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php index 7454107f..96e6b325 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php @@ -69,6 +69,7 @@ public function test_should_render_field_description() { 'default' => '', ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_description( $field ); $html = ob_get_clean(); @@ -92,6 +93,7 @@ public function test_should_render_extended_description() { 'default' => '', ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_description( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index 714bc93b..90820c3e 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -60,6 +60,7 @@ public function test_should_render_single_image_field() { 'value' => $image_id, ), false ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_image( $field ); $html = ob_get_clean(); @@ -117,6 +118,7 @@ public function test_should_render_multiple_images_field() { 'multiple' => true, ), false ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_image( $field ); $html = ob_get_clean(); @@ -178,6 +180,7 @@ public function test_should_render_single_image_field_with_default_alt_when_none 'value' => $image_id, ), false ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_image( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php index e9bd385b..20674065 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php @@ -69,6 +69,7 @@ public function test_should_render_field_label() { 'default' => '', ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_label( $field ); $html = ob_get_clean(); @@ -108,6 +109,7 @@ public function test_should_render_radio_group_header() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_label( $field ); $html = ob_get_clean(); @@ -156,6 +158,7 @@ public function test_should_render_group_header() { ), ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_label( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php index b9f0a9f6..43a8a743 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php @@ -59,6 +59,7 @@ public function test_should_render_radio_field_with_image_options() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_radio( $field ); $html = ob_get_clean(); @@ -118,6 +119,7 @@ public function test_should_render_accessible_images_when_given() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_radio( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php index 393e1cc4..56422fcd 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php @@ -55,6 +55,7 @@ public function test_should_render_select_field() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_select( $field ); $html = ob_get_clean(); @@ -86,6 +87,7 @@ public function test_should_render_select_field_with_attributes_when_given() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_select( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php index ac01e90b..84d96c9a 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php @@ -57,6 +57,7 @@ public function test_should_render_slider_field() { 'interval' => 1, ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_slider( $field ); $html = ob_get_clean(); @@ -87,6 +88,7 @@ public function test_should_render_slider_field_with_unit_when_given() { 'unit' => 'Number of beans', ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_slider( $field ); $html = ob_get_clean(); @@ -118,6 +120,7 @@ public function test_should_render_slider_with_current_value() { ) ); $field['value'] = 15; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_slider( $field ); $html = ob_get_clean(); @@ -151,6 +154,7 @@ public function test_should_render_slider_field_with_attributes_when_given() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_slider( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php index 100fcce0..a900d6a2 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldText.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldText.php @@ -52,6 +52,7 @@ public function test_should_render_text_field() { ) ); $field['value'] = 'Testing the text field.'; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_text( $field ); $html = ob_get_clean(); @@ -77,6 +78,7 @@ public function test_should_render_text_field_with_attributes_when_given() { ) ); $field['value'] = 'Testing the text field with attributes.'; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_text( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php index 25730862..3f3ea14f 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -52,6 +52,7 @@ public function test_should_render_textarea_field() { ) ); $field['value'] = 'Testing the textarea field.'; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_textarea( $field ); $html = ob_get_clean(); @@ -77,6 +78,7 @@ public function test_should_render_textarea_field_with_attributes_when_given() { ) ); $field['value'] = 'Testing the textarea field with attributes.'; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_textarea( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php index 0e34f4a8..f376b6d8 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php @@ -51,6 +51,7 @@ public function test_should_render_activation_field() { 'default' => false, ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_activation( $field ); $html = ob_get_clean(); @@ -76,6 +77,7 @@ public function test_should_render_activation_field_with_attributes_when_given() ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_activation( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php index 723871c9..c397f138 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php @@ -53,6 +53,7 @@ public function test_should_render_checkbox_with_label_when_given() { 'default' => false, ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_checkbox( $field ); $html = ob_get_clean(); @@ -76,6 +77,7 @@ public function test_should_render_checkbox_with_default_label_when_none_is_give 'default' => false, ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_checkbox( $field ); $html = ob_get_clean(); @@ -103,6 +105,7 @@ public function test_should_render_checkbox_with_attributes_when_given() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_checkbox( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index e20bd7d0..7c71c098 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -62,6 +62,7 @@ public function test_should_render_single_image_field() { 'value' => 1, // attachment ID. ), false ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_image( $field ); $html = ob_get_clean(); @@ -117,6 +118,7 @@ public function test_should_render_multiple_images_field() { 'multiple' => true, ), false ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_image( $field ); $html = ob_get_clean(); @@ -177,6 +179,7 @@ public function test_should_render_single_image_field_with_default_alt_when_none 'value' => 1, // attachment ID. ), false ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_image( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php index e9409153..3f9a7506 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php @@ -59,6 +59,7 @@ public function test_should_render_radio_field_with_image_options() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_radio( $field ); $html = ob_get_clean(); @@ -118,6 +119,7 @@ public function test_should_render_accessible_images_when_given() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_radio( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index 62b250b0..9b7c4c1c 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -55,6 +55,7 @@ public function test_should_render_select_field() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_select( $field ); $html = ob_get_clean(); @@ -86,6 +87,7 @@ public function test_should_render_select_field_with_attributes_when_given() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_select( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php index 029681c5..ffa15f31 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php @@ -57,6 +57,7 @@ public function test_should_render_slider_field() { 'interval' => 1, ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_slider( $field ); $html = ob_get_clean(); @@ -87,6 +88,7 @@ public function test_should_render_slider_field_with_unit_when_given() { 'unit' => 'Number of beans', ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_slider( $field ); $html = ob_get_clean(); @@ -118,6 +120,7 @@ public function test_should_render_slider_with_current_value() { ) ); $field['value'] = 15; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_slider( $field ); $html = ob_get_clean(); @@ -151,6 +154,7 @@ public function test_should_render_slider_field_with_attributes_when_given() { ), ) ); + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_slider( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index 5957ab14..db23556c 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -52,6 +52,7 @@ public function test_should_render_text_field() { ) ); $field['value'] = 'Testing the text field.'; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_text( $field ); $html = ob_get_clean(); @@ -77,6 +78,7 @@ public function test_should_render_text_field_with_attributes_when_given() { ) ); $field['value'] = 'Testing the text field with attributes.'; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_text( $field ); $html = ob_get_clean(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index 7b0dbbc2..b553de9e 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -52,11 +52,11 @@ public function test_should_render_textarea_field() { ) ); $field['value'] = 'Testing the textarea field.'; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_textarea( $field ); $html = ob_get_clean(); - $expected = <<Testing the textarea field. EOB; @@ -78,6 +78,7 @@ public function test_should_render_textarea_field_with_attributes_when_given() { ) ); $field['value'] = 'Testing the textarea field with attributes.'; + // Run the function and grab the HTML out of the buffer. ob_start(); beans_field_textarea( $field ); $html = ob_get_clean(); From 6d9fef496e3a2549944cfe154650fd999a7575b4 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Feb 2018 17:23:42 -0600 Subject: [PATCH 126/800] Optimized by removing extra loop with set_types(). --- lib/api/fields/class-beans-fields.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index 6c0f03ce..3229c964 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -91,7 +91,6 @@ public function register( array $fields, $context, $section ) { $this->section = $section; $this->add(); - $this->set_types(); $this->do_once(); $this->load_fields(); @@ -113,6 +112,7 @@ private function add() { foreach ( $this->fields as $field ) { $fields[] = $this->standardize_field( $field ); + $this->set_type( $field ); } // Register fields. @@ -168,25 +168,24 @@ private function standardize_field( $field ) { } /** - * Set the type for the field(s). + * Set the type for the given field. * - * @since 1.0.0 + * @since 1.5.0 + * + * @param array $field The given field. * * @return void */ - private function set_types() { + private function set_type( array $field ) { - foreach ( $this->fields as $field ) { - - // Set the single field's type. - if ( 'group' !== $field['type'] ) { - $this->field_types[ $field['type'] ] = $field['type']; - continue; - } + // Set the single field's type. + if ( 'group' !== $field['type'] ) { + $this->field_types[ $field['type'] ] = $field['type']; + return; + } - foreach ( $field['fields'] as $_field ) { - $this->field_types[ $_field['type'] ] = $_field['type']; - } + foreach ( $field['fields'] as $_field ) { + $this->field_types[ $_field['type'] ] = $_field['type']; } } From 98571a7c322c3834a2308d700d9de4f8b9969cac Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Feb 2018 17:38:08 -0600 Subject: [PATCH 127/800] Fixed the field description. 1. Hide the extended content by default. 2. Escape the description before checking the extended, i.e. to optimize. --- lib/api/fields/types/field.php | 4 +++- lib/api/fields/types/views/field-description.php | 2 +- .../integration/api/fields/types/beansFieldDescription.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/api/fields/types/field.php b/lib/api/fields/types/field.php index cc3367bf..6ba59296 100644 --- a/lib/api/fields/types/field.php +++ b/lib/api/fields/types/field.php @@ -69,8 +69,10 @@ function beans_field_description( array $field ) { list( $description, $extended ) = explode( $matches[0], $description, 2 ); } + beans_open_markup_e( 'beans_field_description[_' . $field['id'] . ']', 'div', array( 'class' => 'bs-field-description' ) ); - echo wp_kses_post( $description ); // @codingStandardsIgnoreStart - Generic.WhiteSpace.ScopeIndent.IncorrectExact - the indent is intentional to indicate HTML structure. + + echo $description; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - To optimize, escaping is handled above. if ( isset( $extended ) ) { include dirname( __FILE__ ) . '/views/field-description.php'; diff --git a/lib/api/fields/types/views/field-description.php b/lib/api/fields/types/views/field-description.php index b286ce2b..485708ed 100644 --- a/lib/api/fields/types/views/field-description.php +++ b/lib/api/fields/types/views/field-description.php @@ -11,4 +11,4 @@ ?>
    -
    + diff --git a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php index 96e6b325..47e53e0a 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php @@ -101,7 +101,7 @@ public function test_should_render_extended_description() { $expected = <<Testing the text field.
    More... -
    This is the extended part of the description.
    +
    EOB; // Run the test. From a142f19f8e56ee14975edb77199f025b3a58faa3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Feb 2018 17:39:05 -0600 Subject: [PATCH 128/800] Fixed format. --- lib/api/fields/types/field.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/api/fields/types/field.php b/lib/api/fields/types/field.php index 6ba59296..4c8dee96 100644 --- a/lib/api/fields/types/field.php +++ b/lib/api/fields/types/field.php @@ -69,10 +69,9 @@ function beans_field_description( array $field ) { list( $description, $extended ) = explode( $matches[0], $description, 2 ); } - beans_open_markup_e( 'beans_field_description[_' . $field['id'] . ']', 'div', array( 'class' => 'bs-field-description' ) ); - echo $description; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - To optimize, escaping is handled above. + echo $description; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - To optimize, escaping is handled above. if ( isset( $extended ) ) { include dirname( __FILE__ ) . '/views/field-description.php'; From 1456fe76d63faa1a28f7eaa2386b8e620edf4617 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 23 Feb 2018 20:11:06 -0500 Subject: [PATCH 129/800] Image Field: Corrected css classes. Adjusted tests. --- lib/api/fields/assets/css/fields.css | 4 ++- lib/api/fields/assets/css/fields.min.css | 2 +- lib/api/fields/assets/js/media.js | 4 +-- lib/api/fields/assets/js/media.min.js | 2 +- lib/api/fields/types/views/image.php | 6 ++-- .../api/fields/types/beansFieldImage.php | 34 +++++++++---------- .../unit/api/fields/types/beansFieldImage.php | 34 +++++++++---------- 7 files changed, 44 insertions(+), 42 deletions(-) diff --git a/lib/api/fields/assets/css/fields.css b/lib/api/fields/assets/css/fields.css index 30d34001..1d3d3737 100644 --- a/lib/api/fields/assets/css/fields.css +++ b/lib/api/fields/assets/css/fields.css @@ -142,7 +142,9 @@ } .bs-field .bs-button-edit:hover, -.bs-field .bs-button-edit:focus { +.bs-field .bs-button-edit:focus, +.bs-field .bs-add-image:hover, +.bs-field .bs-add-image:focus { background-color: #76b031; } diff --git a/lib/api/fields/assets/css/fields.min.css b/lib/api/fields/assets/css/fields.min.css index 4c60ef78..d34e4868 100644 --- a/lib/api/fields/assets/css/fields.min.css +++ b/lib/api/fields/assets/css/fields.min.css @@ -1 +1 @@ -.bs-field,.bs-field select{width:100%;min-width:200px}.bs-field-wrap{display:inline-block;box-sizing:border-box;width:100%;padding:20px 0;border-top:1px solid #e8e8e8}.bs-field-wrap:first-of-type{padding-top:10px;border-top:0}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field{display:block;position:relative;padding:0}.bs-field input[type=text],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{max-width:280px;margin:0;color:#666}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;padding:10px 0 0;color:#333;font-size:11px}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{float:left}.bs-field.deactivated{opacity:.5}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-field .button{display:inline-block;padding:0 4px 1px;border-radius:4px;color:#555;background-color:#fff;text-align:center;-moz-transition:background-color .1s ease-in 0;-webkit-transition:background-color .1s ease-in 0;transition:background-color .1s ease-in 0}.bs-field .button:focus,.bs-field .button:hover{color:#fff}.bs-field .button.dashicons{width:auto;font-size:0}.bs-field .bs-button-edit:before,.bs-field .bs-button-menu:before,.bs-field .bs-button-trash:before{font-family:dashicons;font-size:22px;text-align:center}.bs-field .bs-button-edit:before{content:"\f464"}.bs-field .bs-button-menu:before{content:"\f333"}.bs-field .bs-button-trash{margin-left:5px}.bs-field .bs-button-trash:before{content:"\f182"}.bs-field .bs-button-edit:focus,.bs-field .bs-button-edit:hover{background-color:#76b031}.bs-field .bs-button-menu:focus,.bs-field .bs-button-menu:hover{background-color:#2991c0;cursor:move}.bs-field .bs-button-trash:focus,.bs-field .bs-button-trash:hover{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-placeholder,.bs-field .bs-image-wrap{display:inline-block;position:relative;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{width:110px;height:110px;border:1px solid #ddd;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;top:0;right:0;bottom:0;left:0;box-sizing:border-box;max-width:100%;max-height:100%;margin:auto;padding:2px}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{position:absolute;right:0;bottom:0;box-sizing:border-box;width:100%;padding:3px 0;background-color:#e6e6e6;text-align:center}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-radio fieldset{margin-left:-15px}.bs-radio fieldset label{padding-left:15px}.bs-radio .bs-has-image{display:inline-block;width:auto;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{display:inline-block;position:relative;top:2px;width:180px;height:10px;margin:2px 0 0;border:1px solid #ccc;border-radius:5px}.bs-field .ui-slider-range{height:10px;border-radius:4px;background:#ddd}.bs-field .ui-slider-handle{display:block;position:absolute;width:16px;height:16px;margin:-13px 0 0 -8px;border-radius:8px;background:#bbb;box-shadow:none;cursor:pointer}.bs-field .ui-slider-handle.ui-state-active{background:#aaa}.bs-field .bs-slider-unit,.bs-field .bs-slider-value{display:inline-block;margin:0;font-size:11px}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{display:block;clear:both;width:100%;margin:20px 0 0;padding:0}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;min-height:100px;margin:0;padding-left:20px}@media (min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type=text],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{margin-bottom:0;padding:0 0 0 5px}#customize-controls .bs-radio .bs-has-image img{width:33px;height:33px;margin-bottom:0;border-width:2px} \ No newline at end of file +.bs-field,.bs-field select{width:100%;min-width:200px}.bs-field-wrap{display:inline-block;box-sizing:border-box;width:100%;padding:20px 0;border-top:1px solid #e8e8e8}.bs-field-wrap:first-of-type{padding-top:10px;border-top:0}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field{display:block;position:relative;padding:0}.bs-field input[type=text],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{max-width:280px;margin:0;color:#666}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;padding:10px 0 0;color:#333;font-size:11px}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{float:left}.bs-field.deactivated{opacity:.5}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-field .button{display:inline-block;padding:0 4px 1px;border-radius:4px;color:#555;background-color:#fff;text-align:center;-moz-transition:background-color .1s ease-in 0;-webkit-transition:background-color .1s ease-in 0;transition:background-color .1s ease-in 0}.bs-field .button:focus,.bs-field .button:hover{color:#fff}.bs-field .button.dashicons{width:auto;font-size:0}.bs-field .bs-button-edit:before,.bs-field .bs-button-menu:before,.bs-field .bs-button-trash:before{font-family:dashicons;font-size:22px;text-align:center}.bs-field .bs-button-edit:before{content:"\f464"}.bs-field .bs-button-menu:before{content:"\f333"}.bs-field .bs-button-trash{margin-left:5px}.bs-field .bs-button-trash:before{content:"\f182"}.bs-field .bs-add-image:focus,.bs-field .bs-add-image:hover,.bs-field .bs-button-edit:focus,.bs-field .bs-button-edit:hover{background-color:#76b031}.bs-field .bs-button-menu:focus,.bs-field .bs-button-menu:hover{background-color:#2991c0;cursor:move}.bs-field .bs-button-trash:focus,.bs-field .bs-button-trash:hover{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-placeholder,.bs-field .bs-image-wrap{display:inline-block;position:relative;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{width:110px;height:110px;border:1px solid #ddd;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;top:0;right:0;bottom:0;left:0;box-sizing:border-box;max-width:100%;max-height:100%;margin:auto;padding:2px}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{position:absolute;right:0;bottom:0;box-sizing:border-box;width:100%;padding:3px 0;background-color:#e6e6e6;text-align:center}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-radio fieldset{margin-left:-15px}.bs-radio fieldset label{padding-left:15px}.bs-radio .bs-has-image{display:inline-block;width:auto;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{display:inline-block;position:relative;top:2px;width:180px;height:10px;margin:2px 0 0;border:1px solid #ccc;border-radius:5px}.bs-field .ui-slider-range{height:10px;border-radius:4px;background:#ddd}.bs-field .ui-slider-handle{display:block;position:absolute;width:16px;height:16px;margin:-13px 0 0 -8px;border-radius:8px;background:#bbb;box-shadow:none;cursor:pointer}.bs-field .ui-slider-handle.ui-state-active{background:#aaa}.bs-field .bs-slider-unit,.bs-field .bs-slider-value{display:inline-block;margin:0;font-size:11px}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{display:block;clear:both;width:100%;margin:20px 0 0;padding:0}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;min-height:100px;margin:0;padding-left:20px}@media (min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type=text],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{margin-bottom:0;padding:0 0 0 5px}#customize-controls .bs-radio .bs-has-image img{width:33px;height:33px;margin-bottom:0;border-width:2px} \ No newline at end of file diff --git a/lib/api/fields/assets/js/media.js b/lib/api/fields/assets/js/media.js index a1b932f8..f762b5fe 100644 --- a/lib/api/fields/assets/js/media.js +++ b/lib/api/fields/assets/js/media.js @@ -172,7 +172,7 @@ }); - this.container.on( 'click', '.dashicon-trash', function( e ) { + this.container.on( 'click', '.dashicons-post-trash', function( e ) { e.preventDefault(); @@ -180,7 +180,7 @@ }); - this.container.on( 'click', '.dashicon-edit', function( e ) { + this.container.on( 'click', '.dashicons-edit', function( e ) { e.preventDefault(); diff --git a/lib/api/fields/assets/js/media.min.js b/lib/api/fields/assets/js/media.min.js index 684a44a5..3bb745ce 100644 --- a/lib/api/fields/assets/js/media.min.js +++ b/lib/api/fields/assets/js/media.min.js @@ -1 +1 @@ -!function(e){"use strict";var t=function(t,i){this.container=e(t),this.isMultiple=this.container.find(".bs-images-wrap").data("multiple"),this.init()};t.prototype={constructor:t,addImage:function(e){var t,i=this,a=e.parents(".bs-field-wrap");(t=wp.media({multiple:i.isMultiple})).on("select",function(){var n=t.state().get("selection");n&&n.each(function(t){var n=a.find(".bs-image-wrap.bs-image-template").clone().removeClass("bs-image-template"),s=i.updateImage(n,t);a.find(".bs-images-wrap").append(s),i.isMultiple||e.hide()})}),t.open()},editImage:function(e){var t,i=this;e.parents(".bs-field-wrap");(t=wp.media({multiple:!1})).on("open",function(){var i=t.state().get("selection"),a=e.parents(".bs-image-wrap").find("input[type=hidden]").val(),n=wp.media.model.Attachment.get(a);n.fetch(),i.add(n?[n]:[])}),t.on("select",function(){var a=t.state().get("selection");a&&a.each(function(t){i.updateImage(e.parents(".bs-image-wrap"),t)})}),t.open()},updateImage:function(e,t){if("thumbnail"in t.attributes.sizes)var i=t.attributes.sizes.thumbnail.url;else i=t.attributes.url;return e.find("input[type=hidden]").attr("value",t.id).removeAttr("disabled"),e.find("img").attr("src",i),e},deleteImage:function(e){e.closest(".bs-image-wrap").remove(),this.isMultiple||this.container.find(".bs-add-image").show()},sortable:function(){if(this.isMultiple){var e=this;this.container.find(".bs-images-wrap").sortable({handle:".bs-toolbar .dashicons-menu",placeholder:"bs-image-placeholder",cursor:"move",start:function(t,i){i.placeholder.height(e.container.find(".bs-image-wrap").outerHeight()-6),i.placeholder.width(e.container.find(" .bs-image-wrap").outerWidth()-6)}})}},init:function(){this.sortable(),this.listen()},listen:function(){var t=this;this.container.on("click",".bs-add-image",function(){t.addImage(e(this))}),this.container.on("click",".dashicon-trash",function(i){i.preventDefault(),t.deleteImage(e(this))}),this.container.on("click",".dashicon-edit",function(i){i.preventDefault(),t.editImage(e(this))})}},e.fn.beansFieldImage=function(i){return this.each(function(){e.data(this,"plugin_beansFieldImages")||e.data(this,"plugin_beansFieldImage",new t(this,i))})},e(document).ready(function(e){e(".bs-field.bs-image").beansFieldImage()})}(jQuery); +!function(e){"use strict";var t=function(t,i){this.container=e(t),this.isMultiple=this.container.find(".bs-images-wrap").data("multiple"),this.init()};t.prototype={constructor:t,addImage:function(e){var t,i=this,a=e.parents(".bs-field-wrap");(t=wp.media({multiple:i.isMultiple})).on("select",function(){var n=t.state().get("selection");n&&n.each(function(t){var n=a.find(".bs-image-wrap.bs-image-template").clone().removeClass("bs-image-template"),s=i.updateImage(n,t);a.find(".bs-images-wrap").append(s),i.isMultiple||e.hide()})}),t.open()},editImage:function(e){var t,i=this;e.parents(".bs-field-wrap");(t=wp.media({multiple:!1})).on("open",function(){var i=t.state().get("selection"),a=e.parents(".bs-image-wrap").find("input[type=hidden]").val(),n=wp.media.model.Attachment.get(a);n.fetch(),i.add(n?[n]:[])}),t.on("select",function(){var a=t.state().get("selection");a&&a.each(function(t){i.updateImage(e.parents(".bs-image-wrap"),t)})}),t.open()},updateImage:function(e,t){if("thumbnail"in t.attributes.sizes)var i=t.attributes.sizes.thumbnail.url;else i=t.attributes.url;return e.find("input[type=hidden]").attr("value",t.id).removeAttr("disabled"),e.find("img").attr("src",i),e},deleteImage:function(e){e.closest(".bs-image-wrap").remove(),this.isMultiple||this.container.find(".bs-add-image").show()},sortable:function(){if(this.isMultiple){var e=this;this.container.find(".bs-images-wrap").sortable({handle:".bs-toolbar .dashicons-menu",placeholder:"bs-image-placeholder",cursor:"move",start:function(t,i){i.placeholder.height(e.container.find(".bs-image-wrap").outerHeight()-6),i.placeholder.width(e.container.find(" .bs-image-wrap").outerWidth()-6)}})}},init:function(){this.sortable(),this.listen()},listen:function(){var t=this;this.container.on("click",".bs-add-image",function(){t.addImage(e(this))}),this.container.on("click",".dashicons-post-trash",function(i){i.preventDefault(),t.deleteImage(e(this))}),this.container.on("click",".dashicons-edit",function(i){i.preventDefault(),t.editImage(e(this))})}},e.fn.beansFieldImage=function(i){return this.each(function(){e.data(this,"plugin_beansFieldImages")||e.data(this,"plugin_beansFieldImage",new t(this,i))})},e(document).ready(function(e){e(".bs-field.bs-image").beansFieldImage()})}(jQuery); \ No newline at end of file diff --git a/lib/api/fields/types/views/image.php b/lib/api/fields/types/views/image.php index 623bb328..4d45eb8c 100644 --- a/lib/api/fields/types/views/image.php +++ b/lib/api/fields/types/views/image.php @@ -30,10 +30,10 @@ <?php echo $image_alt ? esc_attr( $image_alt ) : ''; ?>
    - + - - + +
    diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index 90820c3e..aeb07881 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -73,16 +73,16 @@ public function test_should_render_single_image_field() { This is the alt value.
    - - + +
    - - + +
    @@ -131,27 +131,27 @@ public function test_should_render_multiple_images_field() { Image 1 alt.
    - - - + + +
    Image 2 alt.
    - - - + + +
    - - - + + +
    @@ -193,16 +193,16 @@ public function test_should_render_single_image_field_with_default_alt_when_none Sorry, no alt was given for this image.
    - - + +
    - - + +
    diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 7c71c098..4fbc9fed 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -75,16 +75,16 @@ public function test_should_render_single_image_field() { This is the image alt value.
    - - + +
    - - + +
    @@ -131,27 +131,27 @@ public function test_should_render_multiple_images_field() { This is the image alt value.
    - - - + + +
    This is the image alt value.
    - - - + + +
    - - - + + +
    @@ -192,16 +192,16 @@ public function test_should_render_single_image_field_with_default_alt_when_none Sorry, no alt was given for this image.
    - - + +
    - - + +
    From e4a0a88fa52771865820d00315c5f2372b4e6ddf Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 23 Feb 2018 22:29:10 -0500 Subject: [PATCH 130/800] Editorial changes to docblocks, comments and function names. --- lib/api/fields/class-beans-fields.php | 22 +++++++++---------- lib/api/fields/functions.php | 12 +++++----- lib/api/fields/types/image.php | 4 ++-- lib/api/fields/types/radio.php | 6 ++--- .../integration/api/fields/beansGetFields.php | 2 +- .../includes/class-fields-test-case.php | 6 ++--- .../api/fields/types/_beansIsRadioImage.php | 6 ++--- .../types/_beansStandardizeRadioImage.php | 2 +- .../api/fields/types/beansFieldActivation.php | 2 +- .../api/fields/types/beansFieldCheckbox.php | 2 +- .../fields/types/beansFieldDescription.php | 2 +- .../api/fields/types/beansFieldImage.php | 2 +- .../api/fields/types/beansFieldLabel.php | 4 ++-- .../api/fields/types/beansFieldRadio.php | 4 ++-- .../api/fields/types/beansFieldSelect.php | 2 +- .../api/fields/types/beansFieldSlider.php | 4 ++-- .../api/fields/types/beansFieldText.php | 2 +- .../api/fields/types/beansFieldTextarea.php | 2 +- .../includes/class-fields-test-case.php | 6 ++--- .../api/fields/types/_beansIsRadioImage.php | 6 ++--- .../types/_beansStandardizeRadioImage.php | 2 +- .../api/fields/types/beansFieldActivation.php | 2 +- .../api/fields/types/beansFieldCheckbox.php | 2 +- .../unit/api/fields/types/beansFieldImage.php | 4 ++-- .../unit/api/fields/types/beansFieldRadio.php | 4 ++-- .../api/fields/types/beansFieldSelect.php | 4 ++-- .../api/fields/types/beansFieldSlider.php | 4 ++-- .../unit/api/fields/types/beansFieldText.php | 2 +- .../api/fields/types/beansFieldTextarea.php | 2 +- 29 files changed, 62 insertions(+), 62 deletions(-) diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index 3229c964..fbf01aa5 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -26,7 +26,7 @@ final class _Beans_Fields { private $fields = array(); /** - * Fields types. + * Field types. * * @var array */ @@ -40,21 +40,21 @@ final class _Beans_Fields { private $context; /** - * Fields section. + * Field section. * * @var string */ private $section; /** - * Fields types loaded. + * Field types loaded. * * @var array */ private static $field_types_loaded = array(); /** - * Fields assets hook loaded. + * Field assets hook loaded. * * @var array */ @@ -120,7 +120,7 @@ private function add() { } /** - * Standardize the field to the Beans' format. + * Standardize the field to the Beans format. * * @since 1.0.0 * @@ -152,7 +152,7 @@ private function standardize_field( $field ) { $field['fields'][ $index ] = $this->standardize_field( $_field ); } } else { - // Add value after the standardizing the field. + // Add value after standardizing the field. $field['value'] = $this->get_field_value( $field['id'], $field['context'], $field['default'] ); } @@ -234,13 +234,13 @@ private function load_fields() { require_once $path; } - // Set flag that field is loaded. + // Set a flag that the field is loaded. self::$field_types_loaded[ $type ] = $type; } } /** - * Load the fields assets hooks. This hook can then be used to load custom fields assets. + * Load the field's assets hook. This hook can then be used to load custom assets for the field. * * @since 1.0.0 * @@ -257,13 +257,13 @@ public function load_fields_assets_hook() { do_action( "beans_field_enqueue_scripts_{$type}" ); - // Set flag that field is loaded. + // Set a flag that the field is loaded. self::$field_assets_hook_loaded[ $type ] = $type; } } /** - * Enqueue the default fields assets. + * Enqueue the default assets for the fields. * * @since 1.0.0 * @@ -323,7 +323,7 @@ private function get_field_value( $field_id, $context, $default ) { * @param string $section Optional. A section ID to define a group of fields. This is mostly used for meta boxes * and WP Customizer sections. * - * @return array|bool Array of register fields on success, false on failure. + * @return array|bool Array of registered fields on success, false on failure. */ public static function get_fields( $context, $section ) { $fields = beans_get( $section, self::$registered[ $context ] ); diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 8bba4745..845c9583 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -2,9 +2,9 @@ /** * The Beans Fields component offers a range of fields which can be used in the WordPress admin. * - * Fields can be used as Options, Post Meta, Term Meta or WP Customizer Options. Custom fields can easily be added too. + * Fields can be used as Options, Post Meta, Term Meta or WP Customizer Options. Custom fields can easily be added, too. * - * @package Beans\Framework\API\Options + * @package Beans\Framework\API\Fields */ /** @@ -27,10 +27,10 @@ * @type array $attributes An array of attributes to add to the field. The array key defines the attribute name and * the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. - * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the + * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the * {@see beans_register_fields()} $fields arguments. - * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields - * registered should be saved as a group in the database or as individual entries. Default false. + * @type bool $db_group Must only be used for the 'group' field type. It defines whether the group of fields + * should be saved as a group or as individual entries in the database. Default false. * } * * @param string $context The context in which the fields are used. 'option' for options/settings pages, @@ -67,7 +67,7 @@ function beans_register_fields( array $fields, $context, $section ) { * @param string $section Optional. A section ID to define a group of fields. This is mostly used for metaboxes and WP * Customizer sections. * - * @return array|bool Array of register fields on success, false on failure. + * @return array|bool Array of registered fields on success, false on failure. */ function beans_get_fields( $context, $section = false ) { diff --git a/lib/api/fields/types/image.php b/lib/api/fields/types/image.php index 6a59251f..f52cec18 100644 --- a/lib/api/fields/types/image.php +++ b/lib/api/fields/types/image.php @@ -21,7 +21,7 @@ function beans_field_image_assets() { beans_add_smart_action( 'beans_field_image', 'beans_field_image' ); /** - * Render the image field, which handles a single ime or a gallery of images. + * Render the image field, which handles a single image or a gallery of images. * * @since 1.0.0 * @since 1.5.0 Moved the HTML to a view file. @@ -111,7 +111,7 @@ function _beans_get_image_url_and_alt( $image_id ) { // If no alt value is given, set a default. if ( ! $image_alt ) { - $image_alt = __( 'Sorry, no alt was given for this image.', 'tm-beans' ); + $image_alt = __( 'Sorry, no description was given for this image.', 'tm-beans' ); } return array( $image_url, $image_alt ); diff --git a/lib/api/fields/types/radio.php b/lib/api/fields/types/radio.php index 898f2448..d9e936fa 100644 --- a/lib/api/fields/types/radio.php +++ b/lib/api/fields/types/radio.php @@ -20,9 +20,9 @@ * @type array $attributes An array of attributes to add to the field. The array's key defines the attribute name * and the array's value defines the attribute value. Default is an empty array. * @type mixed $default The default value. Default false. - * @type array $options An array used to populate the radio options. The array's key defines radio value. The - * and the array's value defines the radio's label, image source (src), or an array to define - * the image's src, alt, and screen text reader value. + * @type array $options An array used to populate the radio options. The array's key defines the radio value. The + * array's value defines the radio's label, image source (src), or an array to define + * the image's src, alt, and screen text reader values. * } */ function beans_field_radio( array $field ) { diff --git a/tests/phpunit/integration/api/fields/beansGetFields.php b/tests/phpunit/integration/api/fields/beansGetFields.php index 46ec066d..53e513c8 100644 --- a/tests/phpunit/integration/api/fields/beansGetFields.php +++ b/tests/phpunit/integration/api/fields/beansGetFields.php @@ -23,7 +23,7 @@ class Tests_BeansGetFields extends Fields_Test_Case { /** - * Test beans_register_fields() should return the registered fields. + * Test beans_get_fields() should return the registered fields. */ public function test_should_return_registered_fields() { diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index cf2252d6..8339b5d4 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -1,6 +1,6 @@ merge_field_with_default( array( diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php index 56422fcd..63c661aa 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php @@ -16,7 +16,7 @@ /** * Class Tests_BeansFieldSelect * - * @package Beans\Framework\Tests\Integration\API\Fields + * @package Beans\Framework\Tests\Integration\API\Fields\Types * @group integration-tests * @group api */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php index 84d96c9a..3780a571 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php @@ -16,7 +16,7 @@ /** * Class Tests_BeansFieldSlider * - * @package Beans\Framework\Tests\Integration\API\Fields + * @package Beans\Framework\Tests\Integration\API\Fields\Types * @group integration-tests * @group api */ @@ -136,7 +136,7 @@ public function test_should_render_slider_with_current_value() { } /** - * Test beans_field_slider() should render the slider field with unit when given. + * Test beans_field_slider() should render the slider field with attributes when given. */ public function test_should_render_slider_field_with_attributes_when_given() { $field = $this->merge_field_with_default( array( diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php index a900d6a2..ae8ed497 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldText.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldText.php @@ -16,7 +16,7 @@ /** * Class Tests_BeansFieldText * - * @package Beans\Framework\Tests\Integration\API\Fields + * @package Beans\Framework\Tests\Integration\API\Fields\Types * @group integration-tests * @group api */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php index 3f3ea14f..ec48c70b 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -16,7 +16,7 @@ /** * Class Tests_BeansFieldTextarea * - * @package Beans\Framework\Tests\Integration\API\Fields + * @package Beans\Framework\Tests\Integration\API\Fields\Types * @group integration-tests * @group api */ diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 5f58816b..89107dc6 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -1,6 +1,6 @@ merge_field_with_default( array( diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index 9b7c4c1c..eec451e6 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -14,9 +14,9 @@ require_once dirname( __DIR__ ) . '/includes/class-fields-test-case.php'; /** - * Class Tests_BeansFieldSelectV + * Class Tests_BeansFieldSelect * - * @package Beans\Framework\Tests\Unit\API\Fields + * @package Beans\Framework\Tests\Unit\API\Fields\Types * @group unit-tests * @group api */ diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php index ffa15f31..2b9c2780 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php @@ -16,7 +16,7 @@ /** * Class Tests_BeansFieldSlider * - * @package Beans\Framework\Tests\Unit\API\Fields + * @package Beans\Framework\Tests\Unit\API\Fields\Types * @group unit-tests * @group api */ @@ -136,7 +136,7 @@ public function test_should_render_slider_with_current_value() { } /** - * Test beans_field_slider() should render the slider field with unit when given. + * Test beans_field_slider() should render the slider field with attributes when given. */ public function test_should_render_slider_field_with_attributes_when_given() { $field = $this->merge_field_with_default( array( diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index db23556c..1e9bfcff 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -16,7 +16,7 @@ /** * Class Tests_BeansFieldText * - * @package Beans\Framework\Tests\Unit\API\Fields + * @package Beans\Framework\Tests\Unit\API\Fields\Types * @group unit-tests * @group api */ diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index b553de9e..c87a77a8 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -16,7 +16,7 @@ /** * Class Tests_BeansFieldTextarea * - * @package Beans\Framework\Tests\Unit\API\Fields + * @package Beans\Framework\Tests\Unit\API\Fields\Types * @group unit-tests * @group api */ From 8d87ee87d4ab4ce9bc59f265e3b25e3235723a8c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 24 Feb 2018 09:20:58 -0600 Subject: [PATCH 131/800] Fixed image field tests. --- lib/api/fields/types/views/image.php | 4 ++-- .../api/fields/types/beansFieldImage.php | 16 ++++++++-------- .../unit/api/fields/types/beansFieldImage.php | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/api/fields/types/views/image.php b/lib/api/fields/types/views/image.php index 4d45eb8c..e59c7cb9 100644 --- a/lib/api/fields/types/views/image.php +++ b/lib/api/fields/types/views/image.php @@ -26,14 +26,14 @@ list( $image_url, $image_alt ) = _beans_get_image_url_and_alt( $id ); ?>
    - /> + /> <?php echo $image_alt ? esc_attr( $image_alt ) : ''; ?>
    - +
    diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index 6ec1624a..42bc4119 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -74,7 +74,7 @@ public function test_should_render_single_image_field() { This is the alt value.
    - +
    @@ -82,7 +82,7 @@ public function test_should_render_single_image_field() {
    - +
    @@ -133,7 +133,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -142,7 +142,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -151,7 +151,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -191,10 +191,10 @@ public function test_should_render_single_image_field_with_default_alt_when_none
    - Sorry, no alt was given for this image. + Sorry, no description was given for this image.
    - +
    @@ -202,7 +202,7 @@ public function test_should_render_single_image_field_with_default_alt_when_none
    - +
    diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 74e508fe..2252fae4 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -76,7 +76,7 @@ public function test_should_render_single_image_field() { This is the image alt value.
    - +
    @@ -84,7 +84,7 @@ public function test_should_render_single_image_field() {
    - +
    @@ -133,7 +133,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -142,7 +142,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -151,7 +151,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -190,10 +190,10 @@ public function test_should_render_single_image_field_with_default_alt_when_none
    - Sorry, no alt was given for this image. + Sorry, no description was given for this image.
    - +
    @@ -201,7 +201,7 @@ public function test_should_render_single_image_field_with_default_alt_when_none
    - +
    From 51bc350f288f56a3d39cf5d181c943bdb9bbbb6b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 24 Feb 2018 09:35:04 -0600 Subject: [PATCH 132/800] Changed dashicons-post-trash to dashicons-trash. --- lib/api/fields/assets/js/media.js | 2 +- lib/api/fields/assets/js/media.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/fields/assets/js/media.js b/lib/api/fields/assets/js/media.js index f762b5fe..f5aa851d 100644 --- a/lib/api/fields/assets/js/media.js +++ b/lib/api/fields/assets/js/media.js @@ -172,7 +172,7 @@ }); - this.container.on( 'click', '.dashicons-post-trash', function( e ) { + this.container.on( 'click', '.dashicons-trash', function( e ) { e.preventDefault(); diff --git a/lib/api/fields/assets/js/media.min.js b/lib/api/fields/assets/js/media.min.js index 3bb745ce..2545ad4a 100644 --- a/lib/api/fields/assets/js/media.min.js +++ b/lib/api/fields/assets/js/media.min.js @@ -1 +1 @@ -!function(e){"use strict";var t=function(t,i){this.container=e(t),this.isMultiple=this.container.find(".bs-images-wrap").data("multiple"),this.init()};t.prototype={constructor:t,addImage:function(e){var t,i=this,a=e.parents(".bs-field-wrap");(t=wp.media({multiple:i.isMultiple})).on("select",function(){var n=t.state().get("selection");n&&n.each(function(t){var n=a.find(".bs-image-wrap.bs-image-template").clone().removeClass("bs-image-template"),s=i.updateImage(n,t);a.find(".bs-images-wrap").append(s),i.isMultiple||e.hide()})}),t.open()},editImage:function(e){var t,i=this;e.parents(".bs-field-wrap");(t=wp.media({multiple:!1})).on("open",function(){var i=t.state().get("selection"),a=e.parents(".bs-image-wrap").find("input[type=hidden]").val(),n=wp.media.model.Attachment.get(a);n.fetch(),i.add(n?[n]:[])}),t.on("select",function(){var a=t.state().get("selection");a&&a.each(function(t){i.updateImage(e.parents(".bs-image-wrap"),t)})}),t.open()},updateImage:function(e,t){if("thumbnail"in t.attributes.sizes)var i=t.attributes.sizes.thumbnail.url;else i=t.attributes.url;return e.find("input[type=hidden]").attr("value",t.id).removeAttr("disabled"),e.find("img").attr("src",i),e},deleteImage:function(e){e.closest(".bs-image-wrap").remove(),this.isMultiple||this.container.find(".bs-add-image").show()},sortable:function(){if(this.isMultiple){var e=this;this.container.find(".bs-images-wrap").sortable({handle:".bs-toolbar .dashicons-menu",placeholder:"bs-image-placeholder",cursor:"move",start:function(t,i){i.placeholder.height(e.container.find(".bs-image-wrap").outerHeight()-6),i.placeholder.width(e.container.find(" .bs-image-wrap").outerWidth()-6)}})}},init:function(){this.sortable(),this.listen()},listen:function(){var t=this;this.container.on("click",".bs-add-image",function(){t.addImage(e(this))}),this.container.on("click",".dashicons-post-trash",function(i){i.preventDefault(),t.deleteImage(e(this))}),this.container.on("click",".dashicons-edit",function(i){i.preventDefault(),t.editImage(e(this))})}},e.fn.beansFieldImage=function(i){return this.each(function(){e.data(this,"plugin_beansFieldImages")||e.data(this,"plugin_beansFieldImage",new t(this,i))})},e(document).ready(function(e){e(".bs-field.bs-image").beansFieldImage()})}(jQuery); \ No newline at end of file +!function(e){"use strict";var t=function(t,i){this.container=e(t),this.isMultiple=this.container.find(".bs-images-wrap").data("multiple"),this.init()};t.prototype={constructor:t,addImage:function(e){var t,i=this,a=e.parents(".bs-field-wrap");(t=wp.media({multiple:i.isMultiple})).on("select",function(){var n=t.state().get("selection");n&&n.each(function(t){var n=a.find(".bs-image-wrap.bs-image-template").clone().removeClass("bs-image-template"),s=i.updateImage(n,t);a.find(".bs-images-wrap").append(s),i.isMultiple||e.hide()})}),t.open()},editImage:function(e){var t,i=this;e.parents(".bs-field-wrap");(t=wp.media({multiple:!1})).on("open",function(){var i=t.state().get("selection"),a=e.parents(".bs-image-wrap").find("input[type=hidden]").val(),n=wp.media.model.Attachment.get(a);n.fetch(),i.add(n?[n]:[])}),t.on("select",function(){var a=t.state().get("selection");a&&a.each(function(t){i.updateImage(e.parents(".bs-image-wrap"),t)})}),t.open()},updateImage:function(e,t){if("thumbnail"in t.attributes.sizes)var i=t.attributes.sizes.thumbnail.url;else i=t.attributes.url;return e.find("input[type=hidden]").attr("value",t.id).removeAttr("disabled"),e.find("img").attr("src",i),e},deleteImage:function(e){e.closest(".bs-image-wrap").remove(),this.isMultiple||this.container.find(".bs-add-image").show()},sortable:function(){if(this.isMultiple){var e=this;this.container.find(".bs-images-wrap").sortable({handle:".bs-toolbar .dashicons-menu",placeholder:"bs-image-placeholder",cursor:"move",start:function(t,i){i.placeholder.height(e.container.find(".bs-image-wrap").outerHeight()-6),i.placeholder.width(e.container.find(" .bs-image-wrap").outerWidth()-6)}})}},init:function(){this.sortable(),this.listen()},listen:function(){var t=this;this.container.on("click",".bs-add-image",function(){t.addImage(e(this))}),this.container.on("click",".dashicons-trash",function(i){i.preventDefault(),t.deleteImage(e(this))}),this.container.on("click",".dashicons-edit",function(i){i.preventDefault(),t.editImage(e(this))})}},e.fn.beansFieldImage=function(i){return this.each(function(){e.data(this,"plugin_beansFieldImages")||e.data(this,"plugin_beansFieldImage",new t(this,i))})},e(document).ready(function(e){e(".bs-field.bs-image").beansFieldImage()})}(jQuery); \ No newline at end of file From 15d5c992bf5727a9e6189f4bccfeb108f8a6bb11 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 24 Feb 2018 09:37:01 -0600 Subject: [PATCH 133/800] Fixed docblock for formatting. --- tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php index 28f06ddc..d62b953b 100644 --- a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php @@ -15,7 +15,7 @@ /** * Class Tests_BeansIsRadioImage - *t + * * @package Beans\Framework\Tests\Unit\API\Fields\Types * @group unit-tests * @group api From e01e351081d855770783a10c8e85d5f055ea7332 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 24 Feb 2018 11:39:35 -0600 Subject: [PATCH 134/800] Deprecated image field dashicons. 1. Added a docblock identifying that the dashicons class attributes are deprecated and will be removed in Beans 2.0. 2. Removed dashicons from media script. 3. Removed empty lines from scripts (formatting). 4. Replaced dashicons-trash with dashicons-post-trash for custom script/styling backwards compatibility. --- lib/api/fields/assets/js/fields.js | 51 ++----------------- lib/api/fields/assets/js/media.js | 34 ++----------- lib/api/fields/assets/js/media.min.js | 2 +- lib/api/fields/types/views/image.php | 14 ++++- .../api/fields/types/beansFieldImage.php | 14 ++--- .../unit/api/fields/types/beansFieldImage.php | 14 ++--- 6 files changed, 34 insertions(+), 95 deletions(-) diff --git a/lib/api/fields/assets/js/fields.js b/lib/api/fields/assets/js/fields.js index 4e6c780a..2a399a38 100644 --- a/lib/api/fields/assets/js/fields.js +++ b/lib/api/fields/assets/js/fields.js @@ -1,34 +1,25 @@ -!(function($) { - +!(function( $ ) { "use strict"; var beansFields = function( element, options ) { - this.container = $( element ); this.init(); this.listen(); - } beansFields.prototype = { - constructor: beansFields, checkboxLabelToggle: function ( selector ) { - selector.parent().find( 'input[type="checkbox"]' ).click(); - }, imageradio: function( selector ) { - selector.closest( 'fieldset' ).find( 'label' ).removeClass( 'selected' ); selector.closest( 'label.bs-has-image' ).addClass( 'selected' ); - }, slider: function( selector ) { - var value = parseInt( selector.find( 'input[type=text]' ).val() ), min = parseInt( selector.attr( 'slider_min' ) ), max = parseInt( selector.attr( 'slider_max' ) ), @@ -41,7 +32,6 @@ max: max, step: interval, slide: function( event, ui ) { - // Update visible output. $(this).parent().find( '.bs-slider-value' ).text( ui.value ); @@ -49,33 +39,23 @@ $(this).find( 'input[type=text]' ) .val( ui.value ) .keyup(); - } }); // Remove href attribute to keep status bar from showing. selector.find( '.ui-slider-handle' ).removeAttr( 'href' ); - }, activation: function( selector ) { if ( selector.is( ':checked' ) ) { - - selector.parent().next() - .removeClass( 'deactivated' ); - + selector.parent().next().removeClass( 'deactivated' ); } else { - - selector.parent().next() - .addClass( 'deactivated' ); - + selector.parent().next().addClass( 'deactivated' ); } - }, readmore: function( selector ) { - selector.parents( '.bs-field-description' ).find( '.bs-extended-content' ).slideToggle( 400, function() { if ( $( this ).is( ':visible' ) ) { @@ -83,29 +63,23 @@ } else { selector.text( 'More...' ); } - }); }, postbox: function( selector ) { - // Close postboxes that should be closed. $( '.if-js-closed' ).removeClass( 'if-js-closed' ).addClass( 'closed' ); postboxes.add_postbox_toggles( selector.data( 'page' ) ); - }, init: function() { - var that = this; // Fire ui slider. this.container.find( '.bs-slider-wrap' ).each( function() { - that.slider( $( this ) ); - }); // Add active imageradio. @@ -113,9 +87,7 @@ // Fire activation toggle. this.container.find( '.bs-field.bs-activation input[type="checkbox"]' ).each( function() { - that.activation( $( this ) ); - }); // Fire the postboxes. @@ -125,44 +97,33 @@ }, listen: function() { - var that = this; // Make checkbox legend toggling checkbox input on click. this.container.on( 'click', '.bs-checkbox-label', function( e ) { - that.checkboxLabelToggle( $( this ) ); - }); // Fire imageradio on click. this.container.on( 'click', '.bs-field.bs-radio label', function( e ) { - that.imageradio( $( this ) ); - }); // Fire activation toggle on click. this.container.on( 'click', '.bs-field.bs-activation input[type="checkbox"]', function() { - that.activation( $( this ) ); - }); // Fire readmore on click. this.container.on( 'click', '.bs-read-more', function( e ) { - e.preventDefault(); that.readmore( $( this ) ); - }); // Reset confirmation. this.container.on( 'click', '[name="beans_reset_options"]', function(e) { - return confirm( 'Are you sure you would like to reset?' ); - }); } @@ -176,26 +137,20 @@ if ( ! $.data( this, 'plugin_beansFields' ) ) { $.data( this, 'plugin_beansFields', new beansFields( this, options ) ); } - }); }; // Fire the plugin. $( document ).ready( function( $ ) { - $( '#edittag, #post-body, .bs-options' ).beansFields(); // Wait for the control to be loaded before initialising. if ( wp.customize !== undefined ) { wp.customize.bind( 'ready', function() { - $( '#customize-controls' ).beansFields(); - } ); - } - }); })( window.jQuery ); diff --git a/lib/api/fields/assets/js/media.js b/lib/api/fields/assets/js/media.js index f5aa851d..e5fd1329 100644 --- a/lib/api/fields/assets/js/media.js +++ b/lib/api/fields/assets/js/media.js @@ -1,17 +1,13 @@ (function($){ - "use strict"; var beansFieldImage = function( element, options ) { - this.container = $( element ); this.isMultiple = this.container.find( '.bs-images-wrap' ).data( 'multiple' ); this.init(); - } beansFieldImage.prototype = { - constructor: beansFieldImage, addImage: function( element ) { @@ -27,7 +23,6 @@ // Run a callback when an image is selected. media_iframe.on( 'select', function() { - var selection = media_iframe.state().get( 'selection' ); if ( ! selection ) { @@ -40,7 +35,6 @@ var newField = field.find( '.bs-image-wrap.bs-image-template' ) .clone() .removeClass( 'bs-image-template' ); - var updatedfield = $this.updateImage( newField, attachment ); // Finally append the field @@ -50,18 +44,14 @@ if ( ! $this.isMultiple ) { element.hide(); } - }); - }); // Open the iframe. media_iframe.open(); - }, editImage: function( element ) { - var $this = this, media_iframe, field = element.parents( '.bs-field-wrap' ); @@ -73,19 +63,16 @@ // Select image on edit. media_iframe.on( 'open', function() { - var selection = media_iframe.state().get( 'selection' ), id = element.parents( '.bs-image-wrap' ).find( 'input[type=hidden]' ).val(), attachment = wp.media.model.Attachment.get( id ); attachment.fetch(); selection.add( attachment ? [ attachment ] : [] ); - }); // Run a callback when an image is selected. media_iframe.on( 'select', function() { - var selection = media_iframe.state().get( 'selection' ); if ( ! selection ) { @@ -93,16 +80,13 @@ } selection.each( function( attachment ) { - $this.updateImage( element.parents( '.bs-image-wrap' ), attachment ); - }); }); // Open the iframe. media_iframe.open(); - }, updateImage: function( field, attachment ) { @@ -144,7 +128,7 @@ var $this = this; this.container.find( '.bs-images-wrap' ).sortable( { - handle: '.bs-toolbar .dashicons-menu', + handle: '.bs-toolbar .bs-button-menu', placeholder: "bs-image-placeholder", cursor: 'move', start: function( e, ui ){ @@ -156,36 +140,27 @@ }, init: function() { - this.sortable(); this.listen(); - }, listen: function() { - var $this = this; this.container.on( 'click', '.bs-add-image', function() { - $this.addImage( $(this) ); - }); - this.container.on( 'click', '.dashicons-trash', function( e ) { - + this.container.on( 'click', '.bs-button-trash', function( e ) { e.preventDefault(); $this.deleteImage( $(this) ); - }); - this.container.on( 'click', '.dashicons-edit', function( e ) { - + this.container.on( 'click', '.bs-button-edit', function( e ) { e.preventDefault(); $this.editImage( $(this) ); - }); } @@ -199,15 +174,12 @@ if ( ! $.data( this, 'plugin_beansFieldImages' ) ) { $.data( this, 'plugin_beansFieldImage', new beansFieldImage( this, options ) ); } - }); }; // Fire the plugin. $( document ).ready( function( $ ) { - $( '.bs-field.bs-image' ).beansFieldImage(); - }); })(jQuery); diff --git a/lib/api/fields/assets/js/media.min.js b/lib/api/fields/assets/js/media.min.js index 2545ad4a..673c1293 100644 --- a/lib/api/fields/assets/js/media.min.js +++ b/lib/api/fields/assets/js/media.min.js @@ -1 +1 @@ -!function(e){"use strict";var t=function(t,i){this.container=e(t),this.isMultiple=this.container.find(".bs-images-wrap").data("multiple"),this.init()};t.prototype={constructor:t,addImage:function(e){var t,i=this,a=e.parents(".bs-field-wrap");(t=wp.media({multiple:i.isMultiple})).on("select",function(){var n=t.state().get("selection");n&&n.each(function(t){var n=a.find(".bs-image-wrap.bs-image-template").clone().removeClass("bs-image-template"),s=i.updateImage(n,t);a.find(".bs-images-wrap").append(s),i.isMultiple||e.hide()})}),t.open()},editImage:function(e){var t,i=this;e.parents(".bs-field-wrap");(t=wp.media({multiple:!1})).on("open",function(){var i=t.state().get("selection"),a=e.parents(".bs-image-wrap").find("input[type=hidden]").val(),n=wp.media.model.Attachment.get(a);n.fetch(),i.add(n?[n]:[])}),t.on("select",function(){var a=t.state().get("selection");a&&a.each(function(t){i.updateImage(e.parents(".bs-image-wrap"),t)})}),t.open()},updateImage:function(e,t){if("thumbnail"in t.attributes.sizes)var i=t.attributes.sizes.thumbnail.url;else i=t.attributes.url;return e.find("input[type=hidden]").attr("value",t.id).removeAttr("disabled"),e.find("img").attr("src",i),e},deleteImage:function(e){e.closest(".bs-image-wrap").remove(),this.isMultiple||this.container.find(".bs-add-image").show()},sortable:function(){if(this.isMultiple){var e=this;this.container.find(".bs-images-wrap").sortable({handle:".bs-toolbar .dashicons-menu",placeholder:"bs-image-placeholder",cursor:"move",start:function(t,i){i.placeholder.height(e.container.find(".bs-image-wrap").outerHeight()-6),i.placeholder.width(e.container.find(" .bs-image-wrap").outerWidth()-6)}})}},init:function(){this.sortable(),this.listen()},listen:function(){var t=this;this.container.on("click",".bs-add-image",function(){t.addImage(e(this))}),this.container.on("click",".dashicons-trash",function(i){i.preventDefault(),t.deleteImage(e(this))}),this.container.on("click",".dashicons-edit",function(i){i.preventDefault(),t.editImage(e(this))})}},e.fn.beansFieldImage=function(i){return this.each(function(){e.data(this,"plugin_beansFieldImages")||e.data(this,"plugin_beansFieldImage",new t(this,i))})},e(document).ready(function(e){e(".bs-field.bs-image").beansFieldImage()})}(jQuery); \ No newline at end of file +!function(e){"use strict";var t=function(t,i){this.container=e(t),this.isMultiple=this.container.find(".bs-images-wrap").data("multiple"),this.init()};t.prototype={constructor:t,addImage:function(e){var t,i=this,a=e.parents(".bs-field-wrap");(t=wp.media({multiple:i.isMultiple})).on("select",function(){var n=t.state().get("selection");n&&n.each(function(t){var n=a.find(".bs-image-wrap.bs-image-template").clone().removeClass("bs-image-template"),s=i.updateImage(n,t);a.find(".bs-images-wrap").append(s),i.isMultiple||e.hide()})}),t.open()},editImage:function(e){var t,i=this;e.parents(".bs-field-wrap");(t=wp.media({multiple:!1})).on("open",function(){var i=t.state().get("selection"),a=e.parents(".bs-image-wrap").find("input[type=hidden]").val(),n=wp.media.model.Attachment.get(a);n.fetch(),i.add(n?[n]:[])}),t.on("select",function(){var a=t.state().get("selection");a&&a.each(function(t){i.updateImage(e.parents(".bs-image-wrap"),t)})}),t.open()},updateImage:function(e,t){if("thumbnail"in t.attributes.sizes)var i=t.attributes.sizes.thumbnail.url;else i=t.attributes.url;return e.find("input[type=hidden]").attr("value",t.id).removeAttr("disabled"),e.find("img").attr("src",i),e},deleteImage:function(e){e.closest(".bs-image-wrap").remove(),this.isMultiple||this.container.find(".bs-add-image").show()},sortable:function(){if(this.isMultiple){var e=this;this.container.find(".bs-images-wrap").sortable({handle:".bs-toolbar .bs-button-menu",placeholder:"bs-image-placeholder",cursor:"move",start:function(t,i){i.placeholder.height(e.container.find(".bs-image-wrap").outerHeight()-6),i.placeholder.width(e.container.find(" .bs-image-wrap").outerWidth()-6)}})}},init:function(){this.sortable(),this.listen()},listen:function(){var t=this;this.container.on("click",".bs-add-image",function(){t.addImage(e(this))}),this.container.on("click",".bs-button-trash",function(i){i.preventDefault(),t.deleteImage(e(this))}),this.container.on("click",".bs-button-edit",function(i){i.preventDefault(),t.editImage(e(this))})}},e.fn.beansFieldImage=function(i){return this.each(function(){e.data(this,"plugin_beansFieldImages")||e.data(this,"plugin_beansFieldImage",new t(this,i))})},e(document).ready(function(e){e(".bs-field.bs-image").beansFieldImage()})}(jQuery); \ No newline at end of file diff --git a/lib/api/fields/types/views/image.php b/lib/api/fields/types/views/image.php index e59c7cb9..ae3192aa 100644 --- a/lib/api/fields/types/views/image.php +++ b/lib/api/fields/types/views/image.php @@ -29,11 +29,23 @@ /> <?php echo $image_alt ? esc_attr( $image_alt ) : ''; ?>
    + - +
    diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index 42bc4119..0e8a6ff5 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -74,7 +74,7 @@ public function test_should_render_single_image_field() { This is the alt value.
    - +
    @@ -82,7 +82,7 @@ public function test_should_render_single_image_field() {
    - +
    @@ -133,7 +133,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -142,7 +142,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -151,7 +151,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -194,7 +194,7 @@ public function test_should_render_single_image_field_with_default_alt_when_none Sorry, no description was given for this image.
    - +
    @@ -202,7 +202,7 @@ public function test_should_render_single_image_field_with_default_alt_when_none
    - +
    diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 2252fae4..3986f635 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -76,7 +76,7 @@ public function test_should_render_single_image_field() { This is the image alt value.
    - +
    @@ -84,7 +84,7 @@ public function test_should_render_single_image_field() {
    - +
    @@ -133,7 +133,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -142,7 +142,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -151,7 +151,7 @@ public function test_should_render_multiple_images_field() {
    - +
    @@ -193,7 +193,7 @@ public function test_should_render_single_image_field_with_default_alt_when_none Sorry, no description was given for this image.
    - +
    @@ -201,7 +201,7 @@ public function test_should_render_single_image_field_with_default_alt_when_none
    - +
    From ac7ab943cfec9a6368acc4276a82c812052981eb Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 24 Feb 2018 16:35:06 -0600 Subject: [PATCH 135/800] Split _beans_get_image_url_and_alt into 2 functions. --- lib/api/fields/types/image.php | 31 ++++++++++++++++++++-------- lib/api/fields/types/views/image.php | 11 +++++----- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/api/fields/types/image.php b/lib/api/fields/types/image.php index f52cec18..6866aa52 100644 --- a/lib/api/fields/types/image.php +++ b/lib/api/fields/types/image.php @@ -84,15 +84,15 @@ function _beans_get_image_id_attributes( $id, array $field, $is_multiple ) { } /** - * Get the image's URL and alt values. + * Get the image's URL. * * @since 1.5.0 * * @param mixed $image_id The image's attachment ID. * - * @return array|void + * @return string|void */ -function _beans_get_image_url_and_alt( $image_id ) { +function _beans_get_image_url( $image_id ) { $image_id = (int) $image_id; // If this is not a valid image ID, bail out. @@ -100,19 +100,32 @@ function _beans_get_image_url_and_alt( $image_id ) { return; } - $image_url = beans_get( 0, wp_get_attachment_image_src( $image_id, 'thumbnail' ) ); + return beans_get( 0, wp_get_attachment_image_src( $image_id, 'thumbnail' ) ); +} + +/** + * Get the image's alt description. + * + * @since 1.5.0 + * + * @param mixed $image_id The image's attachment ID. + * + * @return string|void + */ +function _beans_get_image_alt( $image_id ) { + $image_id = (int) $image_id; - // If no URL is retrieved, bail out. - if ( ! $image_url ) { + // If this is not a valid image ID, bail out. + if ( $image_id < 1 ) { return; } $image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true ); - // If no alt value is given, set a default. + // If this image does not an "alt" defined, return the default. if ( ! $image_alt ) { - $image_alt = __( 'Sorry, no description was given for this image.', 'tm-beans' ); + return __( 'Sorry, no description was given for this image.', 'tm-beans' ); } - return array( $image_url, $image_alt ); + return $image_alt; } diff --git a/lib/api/fields/types/views/image.php b/lib/api/fields/types/views/image.php index ae3192aa..661a0651 100644 --- a/lib/api/fields/types/views/image.php +++ b/lib/api/fields/types/views/image.php @@ -15,17 +15,18 @@
    -
    +
    /> <?php echo $image_alt ? esc_attr( $image_alt ) : ''; ?>
    From ad63929598d203f5b465ed61684babdb61461ebf Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 24 Feb 2018 16:40:36 -0600 Subject: [PATCH 136/800] Improved documentation. Added type hinting. --- lib/api/fields/class-beans-fields.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index fbf01aa5..cedb6e17 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -1,6 +1,6 @@ false, 'description' => false, From d0c68478b2e314ac347f4976a9623c2b99295503 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 25 Feb 2018 10:00:11 -0600 Subject: [PATCH 137/800] Added tests for _beans_get_image_url() and _beans_get_image_alt(). --- .../api/fields/types/_BeansGetImageAlt.php | 74 ++++++++++++++++++ .../api/fields/types/_BeansGetImageUrl.php | 65 ++++++++++++++++ .../api/fields/types/_BeansGetImageAlt.php | 71 +++++++++++++++++ .../api/fields/types/_BeansGetImageUrl.php | 76 +++++++++++++++++++ 4 files changed, 286 insertions(+) create mode 100644 tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php create mode 100644 tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php create mode 100644 tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php create mode 100644 tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php diff --git a/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php b/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php new file mode 100644 index 00000000..d747763d --- /dev/null +++ b/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php @@ -0,0 +1,74 @@ +assertNull( _beans_get_image_alt( 0 ) ); + $this->assertNull( _beans_get_image_alt( - 1 ) ); + $this->assertNull( _beans_get_image_alt( null ) ); + $this->assertNull( _beans_get_image_alt( false ) ); + } + + /** + * Test _beans_get_image_alt() should return the default when the image does not have an "alt" defined. + */ + public function test_should_return_default_alt_when_image_alt_not_defined() { + $post_id = self::factory()->post->create(); + $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, array( + 'post_mime_type' => 'image/png', + 'post_type' => 'attachment', + ) ); + + // Run the test. + $this->assertSame( 'Sorry, no description was given for this image.', _beans_get_image_alt( $image_id ) ); + } + + /** + * Test _beans_get_image_alt() should return the image's alt description. + */ + public function test_should_return_image_alt() { + $post_id = self::factory()->post->create(); + $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, array( + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ) ); + $alt = 'This is the alt value.'; + update_post_meta( $image_id, '_wp_attachment_image_alt', $alt, true ); + + // Run the test. + $this->assertSame( $alt, _beans_get_image_alt( $image_id ) ); + } +} diff --git a/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php b/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php new file mode 100644 index 00000000..d7ad84e6 --- /dev/null +++ b/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php @@ -0,0 +1,65 @@ +assertNull( _beans_get_image_url( 0 ) ); + $this->assertNull( _beans_get_image_url( -1 ) ); + $this->assertNull( _beans_get_image_url( null ) ); + $this->assertNull( _beans_get_image_url( false ) ); + } + + /** + * Test _beans_get_image_url() should return null when the image does not exist. + */ + public function test_should_return_null_when_image_does_not_exist() { + $this->assertNull( _beans_get_image_url( 9999999 ) ); + } + + /** + * Test _beans_get_image_url() should return image's URL. + */ + public function test_should_return_image_url() { + $post_id = self::factory()->post->create(); + $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, array( + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ) ); + + // Run the test. + $this->assertSame( 'http://example.org/wp-content/uploads/image.jpeg', _beans_get_image_url( $image_id ) ); + } +} diff --git a/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php b/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php new file mode 100644 index 00000000..0e26b415 --- /dev/null +++ b/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php @@ -0,0 +1,71 @@ +assertNull( _beans_get_image_alt( 0 ) ); + $this->assertNull( _beans_get_image_alt( - 1 ) ); + $this->assertNull( _beans_get_image_alt( null ) ); + $this->assertNull( _beans_get_image_alt( false ) ); + } + + /** + * Test _beans_get_image_alt() should return the default when the image does not have an "alt" defined. + */ + public function test_should_return_default_alt_when_image_alt_not_defined() { + Monkey\Functions\expect( 'get_post_meta' ) + ->with( 1, '_wp_attachment_image_alt', true ) + ->once() + ->andReturnNull(); + + // Run the test. + $this->assertSame( 'Sorry, no description was given for this image.', _beans_get_image_alt( 1 ) ); + } + + /** + * Test _beans_get_image_alt() should return the image's alt description. + */ + public function test_should_return_image_alt() { + Monkey\Functions\expect( 'get_post_meta' ) + ->with( 1, '_wp_attachment_image_alt', true ) + ->once() + ->andReturn( 'This is the alt value.' ); + + // Run the test. + $this->assertSame( 'This is the alt value.', _beans_get_image_alt( 1 ) ); + } +} diff --git a/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php b/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php new file mode 100644 index 00000000..33355cf6 --- /dev/null +++ b/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php @@ -0,0 +1,76 @@ +assertNull( _beans_get_image_url( 0 ) ); + $this->assertNull( _beans_get_image_url( - 1 ) ); + $this->assertNull( _beans_get_image_url( null ) ); + $this->assertNull( _beans_get_image_url( false ) ); + } + + /** + * Test _beans_get_image_url() should return null when the image does not exist. + */ + public function test_should_return_null_when_image_does_not_exist() { + Monkey\Functions\expect( 'wp_get_attachment_image_src' ) + ->with( 9999999, 'thumbnail' ) + ->once() + ->andReturnNull(); + + $this->assertNull( _beans_get_image_url( 9999999 ) ); + } + + /** + * Test _beans_get_image_url() should return image's URL. + */ + public function test_should_return_image_url() { + Monkey\Functions\expect( 'wp_get_attachment_image_src' ) + ->with( 1, 'thumbnail' ) + ->once() + ->andReturn( + array( + 'http://example.org/wp-content/uploads/image.jpeg', + 300, + 300, + ) + ); + + // Run the test. + $this->assertSame( 'http://example.org/wp-content/uploads/image.jpeg', _beans_get_image_url( 1 ) ); + } +} From a81d8dfdb10624caffc6c4b255f61de990e51b53 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 25 Feb 2018 15:34:20 -0500 Subject: [PATCH 138/800] WPCS compliance - root files --- 404.php | 7 ++++--- comments.php | 10 +++++----- footer.php | 10 +++++----- functions.php | 14 +++++++++++++- header.php | 10 +++++----- index.php | 7 ++++--- page.php | 7 ++++--- search.php | 7 ++++--- sidebar-primary.php | 10 +++++----- sidebar-secondary.php | 10 +++++----- sidebar.php | 5 ++++- single.php | 7 ++++--- 12 files changed, 62 insertions(+), 42 deletions(-) diff --git a/404.php b/404.php index cdf2e4e4..0bff2f0c 100644 --- a/404.php +++ b/404.php @@ -1,12 +1,13 @@ Date: Sun, 25 Feb 2018 15:36:40 -0500 Subject: [PATCH 139/800] Fix typo in 404.php --- 404.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/404.php b/404.php index 0bff2f0c..2cdf219d 100644 --- a/404.php +++ b/404.php @@ -3,7 +3,7 @@ * This core file should only be overwritten via your child theme. * * We strongly recommend to read the Beans documentation to find out more about - * how to customize Beans theme. + * how to customize the Beans theme. * * @author Beans * @link http://www.getbeans.io From 2249c88ff3b2e4b39af1bb901d902f2f7e9ae2a9 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 25 Feb 2018 18:35:57 -0500 Subject: [PATCH 140/800] Made lib\admin WPCS compliant PR #123 * Made files WPCS compliant * Removed empty lines, add @return, editorials * Improved DocBlocks --- lib/admin/options.php | 14 +++++++------ lib/admin/updater.php | 40 ++++++++++++++++++------------------ lib/admin/wp-customize.php | 42 +++++++++++++++++++++++++------------- 3 files changed, 56 insertions(+), 40 deletions(-) diff --git a/lib/admin/options.php b/lib/admin/options.php index 3305830c..052d55f6 100644 --- a/lib/admin/options.php +++ b/lib/admin/options.php @@ -2,7 +2,9 @@ /** * Add Beans admin options. * - * @package Admin + * @package Beans\Framework\Admin + * + * @since 1.0.0 */ beans_add_smart_action( 'admin_init', 'beans_do_register_term_meta' ); @@ -10,9 +12,10 @@ * Add Beans term meta. * * @since 1.0.0 + * + * @return void */ function beans_do_register_term_meta() { - // Get layout option without default for the count. $options = beans_get_layouts_for_options(); @@ -32,7 +35,6 @@ function beans_do_register_term_meta() { ); beans_register_term_meta( $fields, array( 'category', 'post_tag' ), 'tm-beans' ); - } beans_add_smart_action( 'admin_init', 'beans_do_register_post_meta' ); @@ -40,13 +42,14 @@ function beans_do_register_term_meta() { * Add Beans post meta. * * @since 1.0.0 + * + * @return void */ function beans_do_register_post_meta() { - // Get layout option without default for the count. $options = beans_get_layouts_for_options(); - // Stop here if there is less than two layouts options. + // Stop here if there are less than two layout options. if ( count( $options ) < 2 ) { return; } @@ -62,5 +65,4 @@ function beans_do_register_post_meta() { ); beans_register_post_meta( $fields, array( 'post', 'page' ), 'tm-beans', array( 'title' => __( 'Post Options', 'tm-beans' ) ) ); - } diff --git a/lib/admin/updater.php b/lib/admin/updater.php index ed21af1d..b780283a 100644 --- a/lib/admin/updater.php +++ b/lib/admin/updater.php @@ -2,26 +2,34 @@ /** * Handles Beans updates. * - * @package Beans - * @since 1.0.0 + * @package Beans\Framework\Admin + * + * @since 1.0.0 */ add_filter( 'site_transient_update_themes', 'beans_updater' ); /** - * Retrieve product data from Beans REST API. + * Retrieve product data from the Beans REST API. * - * Data are cached in a 24 hours transients and will be returned if found to avoid long loading time. + * Data is cached in a transient for 24 hours. Product data will only be retrieved + * if no transient is found to avoid long loading times. * + * @since 1.0.0 * @ignore + * @access private + * + * @param object $value Update check object. + * + * @return object Modified update check object. */ function beans_updater( $value ) { - // Stop here if the current user is not a super admin user. + // Stop here if the current user is not a super admin. if ( ! is_super_admin() ) { return; } - $data = get_site_transient( 'beans_updater' ); + $data = get_site_transient( 'beans_updater' ); $theme = wp_get_theme( 'tm-beans' ); if ( ! $theme->exists() ) { @@ -30,31 +38,24 @@ function beans_updater( $value ) { $current_version = $theme->get( 'Version' ); - // Query Beans REST API if the transient is expired. + // Query the Beans REST API if the transient is expired. if ( empty( $data ) ) { - $response = wp_remote_get( 'http://www.getbeans.io/rest-api/', array( 'sslverify' => false ) ); // Retrieve data from the body and decode json format. $data = json_decode( wp_remote_retrieve_body( $response ), true ); - // Stop here if the is an error. + // Stop here if there is an error, set a temporary transient and bail out. if ( is_wp_error( $response ) || isset( $data['error'] ) ) { - - // Set temporary transient. set_site_transient( 'beans_updater', array( 'version' => $current_version ), 30 * MINUTE_IN_SECONDS ); - return $value; - } set_site_transient( 'beans_updater', $data, 24 * HOUR_IN_SECONDS ); - } // Return data if Beans is not up to date. if ( version_compare( $current_version, beans_get( 'version', $data ), '<' ) ) { - $value->response[ $data['path'] ] = array( 'slug' => $data['slug'], 'name' => $data['name'], @@ -64,23 +65,22 @@ function beans_updater( $value ) { 'tested' => $data['tested'], 'requires' => $data['requires'], ); - return $value; - } return $value; - } add_action( 'load-update-core.php', 'beans_updater_clear_transient' ); /** * Clear updater transient. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function beans_updater_clear_transient() { - delete_site_transient( 'beans_updater' ); - } diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index 998d1afb..ccd66604 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -2,7 +2,9 @@ /** * Add Beans options to the WordPress Customizer. * - * @package Admin + * @package Beans\Framework\Admin + * + * @since 1.0.0 */ beans_add_smart_action( 'customize_preview_init', 'beans_do_enqueue_wp_customize_assets' ); @@ -10,11 +12,11 @@ * Enqueue Beans assets for the WordPress Customizer. * * @since 1.0.0 + * + * @return void */ function beans_do_enqueue_wp_customize_assets() { - wp_enqueue_script( 'beans-wp-customize-preview', BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', array( 'jquery', 'customize-preview' ), BEANS_VERSION, true ); - } beans_add_smart_action( 'customize_register', 'beans_do_register_wp_customize_options' ); @@ -22,9 +24,10 @@ function beans_do_enqueue_wp_customize_assets() { * Add Beans options to the WordPress Customizer. * * @since 1.0.0 + * + * @return void */ function beans_do_register_wp_customize_options() { - $fields = array( array( 'id' => 'beans_logo_image', @@ -40,19 +43,24 @@ function beans_do_register_wp_customize_options() { // Only show the layout options if more than two layouts are registered. if ( count( $options ) > 2 ) { - $fields = array( array( - 'id' => 'beans_layout', - 'label' => __( 'Default Layout', 'tm-beans' ), - 'type' => 'radio', - 'default' => beans_get_default_layout(), - 'options' => $options, + 'id' => 'beans_layout', + 'label' => __( 'Default Layout', 'tm-beans' ), + 'type' => 'radio', + 'default' => beans_get_default_layout(), + 'options' => $options, ), ); - beans_register_wp_customize_options( $fields, 'beans_layout', array( 'title' => __( 'Default Layout', 'tm-beans' ), 'priority' => 1000 ) ); - + beans_register_wp_customize_options( + $fields, + 'beans_layout', + array( + 'title' => __( 'Default Layout', 'tm-beans' ), + 'priority' => 1000, + ) + ); } $fields = array( @@ -100,6 +108,12 @@ function beans_do_register_wp_customize_options() { ), ); - beans_register_wp_customize_options( $fields, 'beans_preview', array( 'title' => __( 'Preview Tools', 'tm-beans' ), 'priority' => 1010 ) ); - + beans_register_wp_customize_options( + $fields, + 'beans_preview', + array( + 'title' => __( 'Preview Tools', 'tm-beans' ), + 'priority' => 1010, + ) + ); } From e0a892ceb1036fa293a36e2bfe0de872826ea6ee Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 25 Feb 2018 19:41:07 -0500 Subject: [PATCH 141/800] Made lib\api\compiler WPCS compliant PR #124 Covers the two files not included in PR 108. --- lib/api/compiler/class-options.php | 69 ++++++++++++------ lib/api/compiler/class-page-compiler.php | 89 +++++++++++++++--------- 2 files changed, 106 insertions(+), 52 deletions(-) diff --git a/lib/api/compiler/class-options.php b/lib/api/compiler/class-options.php index 7a04f9df..1f5f6748 100644 --- a/lib/api/compiler/class-options.php +++ b/lib/api/compiler/class-options.php @@ -1,10 +1,20 @@ 'beans_compiler_items', @@ -35,7 +46,7 @@ public function register() { ), ); - // Add styles compiler option only if supported + // Add the styles compiler option only if it is supported. if ( beans_get_component_support( 'wp_styles_compiler' ) ) { $fields = array_merge( $fields, array( array( @@ -49,14 +60,14 @@ public function register() { ) ); } - // Add scripts compiler option only if supported + // Add the scripts compiler option only if it is supported. if ( beans_get_component_support( 'wp_scripts_compiler' ) ) { $fields = array_merge( $fields, array( array( - 'id' => 'beans_compile_all_scripts_group', - 'label' => __( 'Compile all WordPress scripts', 'tm-beans' ), - 'type' => 'group', - 'fields' => array( + 'id' => 'beans_compile_all_scripts_group', + 'label' => __( 'Compile all WordPress scripts', 'tm-beans' ), + 'type' => 'group', + 'fields' => array( array( 'id' => 'beans_compile_all_scripts', 'type' => 'activation', @@ -82,11 +93,14 @@ public function register() { 'title' => __( 'Compiler options', 'tm-beans' ), 'context' => 'normal', ) ); - } /** * Flush images for all folders set. + * + * @since 1.0.0 + * + * @return void */ public function flush() { @@ -95,11 +109,14 @@ public function flush() { } beans_remove_dir( beans_get_compiler_dir() ); - } /** * Cache cleaner notice. + * + * @since 1.0.0 + * + * @return void */ public function admin_notice() { @@ -108,13 +125,18 @@ public function admin_notice() { } ?> -

    +

    - +
    - +
    - + compile_enqueued( 'style' ) ) { + $styles = $this->compile_enqueued( 'style' ); + + if ( $styles ) { beans_compile_css_fragments( 'beans', $styles, array( 'version' => null ) ); } - } /** * Enqueue compiled wp scripts. + * + * @since 1.0.0 + * + * @return void */ public function compile_page_scripts() { @@ -51,42 +66,56 @@ public function compile_page_scripts() { return; } - if ( $scripts = $this->compile_enqueued( 'script' ) ) { + $scripts = $this->compile_enqueued( 'script' ); + + if ( $scripts ) { beans_compile_js_fragments( 'beans', $scripts, array( 'in_footer' => ( 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ) ) ? true : false, 'version' => null, ) ); } - } /** * Compile all wp enqueued assets. + * + * @since 1.0.0 + * @ignore + * @access private + * + * @param string $type Type of asset, e.g. style or script. + * @param string $dependencies Optional. Dependencies of the asset. Default is false. + * + * @return array */ - private function compile_enqueued( $type, $depedencies = false ) { + private function compile_enqueued( $type, $dependencies = false ) { + + $assets = beans_get( "wp_{$type}s", $GLOBALS ); - if ( ! $assets = beans_get( "wp_{$type}s", $GLOBALS ) ) { + if ( ! $assets ) { return array(); } - if ( 'script' == $type ) { + if ( 'script' === $type ) { add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 ); } - if ( ! $depedencies ) { - $depedencies = $assets->queue; + if ( ! $dependencies ) { + $dependencies = $assets->queue; } $fragments = array(); - foreach ( $depedencies as $id ) { + foreach ( $dependencies as $id ) { // Don't compile admin bar assets. - if ( in_array( $id, array( 'admin-bar', 'open-sans', 'dashicons' ) ) ) { + if ( in_array( $id, array( 'admin-bar', 'open-sans', 'dashicons' ), true ) ) { continue; } - if ( ! $args = beans_get( $id, $assets->registered ) ) { + $args = beans_get( $id, $assets->registered ); + + if ( ! $args ) { continue; } @@ -100,35 +129,33 @@ private function compile_enqueued( $type, $depedencies = false ) { } } - if ( 'style' == $type ) { + if ( 'style' === $type ) { // Add compiler media query if set. - if ( 'all' != $args->args ) { + if ( 'all' !== $args->args ) { $args->src = add_query_arg( array( 'beans_compiler_media_query' => $args->args ), $args->src ); } $assets->done[] = $id; - - } elseif ( 'script' == $type ) { - + } elseif ( 'script' === $type ) { $this->dequeued_scripts[ $id ] = $args->src; - } $fragments[ $id ] = $args->src; - } return $fragments; - } /** * Dequeue scripts which have been compiled, grab localized * data and add it inline. + * + * @since 1.0.0 + * + * @return void */ public function dequeue_scripts() { - global $wp_scripts; if ( empty( $this->dequeued_scripts ) ) { @@ -140,7 +167,9 @@ public function dequeue_scripts() { // Fetch the localized content and dequeue script. foreach ( $this->dequeued_scripts as $id => $src ) { - if ( ! $args = beans_get( $id, $wp_scripts->registered ) ) { + $args = beans_get( $id, $wp_scripts->registered ); + + if ( ! $args ) { continue; } @@ -149,7 +178,6 @@ public function dequeue_scripts() { } $wp_scripts->done[] = $id; - } // Stop here if there isn't any content to add. @@ -158,8 +186,7 @@ public function dequeue_scripts() { } // Add localized content since it was removed with dequeue scripts. - printf( "\n", $localized ); - + printf( "\n", $localized ); // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped. } } From f498a618f7f5b4a38b99ba5592c59d55010fd019 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 25 Feb 2018 20:16:31 -0500 Subject: [PATCH 142/800] Improved WPCS compliance for lib\api\filters\functions.php PR #125 --- lib/api/filters/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/filters/functions.php b/lib/api/filters/functions.php index 88cd3716..c6ba0d0a 100644 --- a/lib/api/filters/functions.php +++ b/lib/api/filters/functions.php @@ -1,8 +1,8 @@ $id are applied to it. - * @param mixed $var Additional variables passed to the functions hooked to $id. + * @param mixed $var Additional variables passed to the functions hooked to $id. @codingStandardsIgnoreLine - Squiz.Commenting.FunctionComment.ExtraParamComment. * * @return mixed The filtered value after all hooked functions are applied to it. */ From 366b5d73365f9ff92bb12087f470c8ac46f7fd38 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 25 Feb 2018 22:16:43 -0500 Subject: [PATCH 143/800] Made lib\api\options WPCS compliant PR #127 --- lib/api/options/class.php | 108 ++++++++++++++++++++++++---------- lib/api/options/functions.php | 45 +++++++------- 2 files changed, 102 insertions(+), 51 deletions(-) diff --git a/lib/api/options/class.php b/lib/api/options/class.php index de72a922..015ca4e9 100644 --- a/lib/api/options/class.php +++ b/lib/api/options/class.php @@ -1,67 +1,89 @@ __( 'Undefined', 'tm-beans' ), 'context' => 'normal', ); $this->section = $section; - $this->args = array_merge( $defaults, $args ); + $this->args = array_merge( $defaults, $args ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); $this->register_metabox(); - } /** * Enqueue assets. + * + * @since 1.0.0 + * + * @return void */ public function enqueue_assets() { - wp_enqueue_script( 'postbox' ); - } /** * Register the Metabox. + * + * @since 1.0.0 + * @ignore + * @access private + * + * @return void */ private function register_metabox() { - add_meta_box( $this->section, $this->args['title'], @@ -70,32 +92,41 @@ private function register_metabox() { $this->args['context'], 'default' ); - } /** * Metabox content. + * + * @since 1.0.0 + * + * @return void */ public function metabox_content() { foreach ( beans_get_fields( 'option', $this->section ) as $field ) { beans_field( $field ); } - } /** * Page content. + * + * @since 1.0.0 + * + * @param int $page Page ID. + * + * @return void */ public function page( $page ) { - global $wp_meta_boxes; - if ( ! $boxes = beans_get( $page, $wp_meta_boxes ) ) { + $boxes = beans_get( $page, $wp_meta_boxes ); + + if ( ! $boxes ) { return; } - // Only add column class if there is more than 1 metaboxes. + // Only add a column class if there is more than 1 metabox. $column_class = beans_get( 'column', $boxes, array() ) ? ' column' : false; // Set page data which will be used by the postbox. @@ -119,32 +150,34 @@ public function page( $page ) {

    save(); add_action( 'admin_notices', array( $this, 'save_notices' ) ); - } if ( beans_post( 'beans_reset_options' ) ) { - $this->reset(); add_action( 'admin_notices', array( $this, 'reset_notices' ) ); - } - } /** * Save options. + * + * @since 1.0.0 + * + * @return bool */ private function save() { @@ -152,7 +185,9 @@ private function save() { return false; } - if ( ! ( $fields = beans_post( 'beans_fields' ) ) ) { + $fields = beans_post( 'beans_fields' ); + + if ( ! ( $fields ) ) { return false; } @@ -161,11 +196,14 @@ private function save() { } $this->success = true; - } /** * Reset options. + * + * @since 1.0.0 + * + * @return bool */ private function reset() { @@ -173,7 +211,9 @@ private function reset() { return false; } - if ( ! ( $fields = beans_post( 'beans_fields' ) ) ) { + $fields = beans_post( 'beans_fields' ); + + if ( ! ( $fields ) ) { return false; } @@ -182,24 +222,27 @@ private function reset() { } $this->success = true; - } /** * Save notice content. + * + * @since 1.0.0 + * + * @return void */ public function save_notices() { if ( $this->success ) { ?>
    -

    +

    -

    +

    success ) { ?>
    -

    +

    -

    +

    - * as a delimiter. Default false. + * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. + * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the - * {@see beans_register_fields()} $fields arguments. + * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field types. Defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * registered should be saved as a group in the database or as individual + * entries. Default false. * } * @param string $menu_slug The menu slug used by fields. * @param string $section A section id to define the group of fields. * @param array $args { * Optional. Array of arguments used to register the fields. * - * @type string $title The metabox Title. Default 'Undefined'. - * @type string $context Where on the page where the metabox should be shown - * ('normal', 'column'). Default 'normal'. + * @type string $title The metabox Title. Default 'Undefined'. + * @type string $context Where on the page where the metabox should be shown + * ('normal', 'column'). Default 'normal'. * } * * @return bool True on success, false on failure. @@ -78,13 +80,12 @@ function beans_register_options( array $fields, $menu_slug, $section, $args = ar } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'options/class.php' ); + require_once BEANS_API_PATH . 'options/class.php'; $class = new _Beans_Options(); $class->register( $section, $args ); return true; - } /** @@ -95,6 +96,8 @@ function beans_register_options( array $fields, $menu_slug, $section, $args = ar * @since 1.0.0 * * @param array $menu_slug The menu slug used to register the options. + * + * @return bool */ function beans_options( $menu_slug ) { @@ -104,14 +107,17 @@ function beans_options( $menu_slug ) { $class = new _Beans_Options(); $class->page( $menu_slug ); - } add_action( 'wp_loaded', '_beans_options_page_actions' ); /** * Fires the options form actions. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_options_page_actions() { @@ -120,9 +126,8 @@ function _beans_options_page_actions() { } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'options/class.php' ); + require_once BEANS_API_PATH . 'options/class.php'; $class = new _Beans_Options(); $class->actions(); - } From 2516daa8c14f6ed8d65509f2a5f8f3a1106e8b46 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 25 Feb 2018 22:18:41 -0500 Subject: [PATCH 144/800] Made lib\api\post-meta WPCS compliant PR #128 --- lib/api/post-meta/class.php | 73 +++++++++++++++------ lib/api/post-meta/functions-admin.php | 92 +++++++++++++++------------ lib/api/post-meta/functions.php | 10 ++- 3 files changed, 114 insertions(+), 61 deletions(-) diff --git a/lib/api/post-meta/class.php b/lib/api/post-meta/class.php index 60bf31ff..4ea214d6 100644 --- a/lib/api/post-meta/class.php +++ b/lib/api/post-meta/class.php @@ -1,32 +1,44 @@ __( 'Undefined', 'tm-beans' ), 'context' => 'normal', @@ -34,54 +46,65 @@ public function __construct( $section, $args ) { ); $this->section = $section; - $this->args = array_merge( $defaults, $args ); + $this->args = array_merge( $defaults, $args ); $this->do_once(); add_action( 'add_meta_boxes', array( $this, 'register_metabox' ) ); - } /** * Trigger actions only once. + * + * @since 1.0.0 + * + * @return void */ private function do_once() { - static $once = false; if ( ! $once ) { - add_action( 'edit_form_top', array( $this, 'nonce' ) ); add_action( 'save_post', array( $this, 'save' ) ); add_filter( 'attachment_fields_to_save', array( $this, 'save_attachment' ) ); $once = true; - } - } /** * Post meta nonce. + * + * @since 1.0.0 + * + * @return void */ public function nonce() { - ?> section, $this->args['title'], array( $this, 'metabox_content' ), $post_type, $this->args['context'], $this->args['priority'] ); - } /** * Metabox content. + * + * @since 1.0.0 + * + * @param int $post Post ID. + * + * @return void */ public function metabox_content( $post ) { @@ -92,6 +115,12 @@ public function metabox_content( $post ) { /** * Save Post Meta. + * + * @since 1.0.0 + * + * @param int $post_id Post ID. + * + * @return mixed */ public function save( $post_id ) { @@ -103,18 +132,25 @@ public function save( $post_id ) { return $post_id; } - if ( ! $fields = beans_post( 'beans_fields' ) ) { + $fields = beans_post( 'beans_fields' ); + + if ( ! $fields ) { return $post_id; } foreach ( $fields as $field => $value ) { update_post_meta( $post_id, $field, $value ); } - } /** * Save Post Meta for attachment. + * + * @since 1.0.0 + * + * @param int $attachment Attachment ID. + * + * @return mixed */ public function save_attachment( $attachment ) { @@ -126,7 +162,9 @@ public function save_attachment( $attachment ) { return $attachment; } - if ( ! $fields = beans_post( 'beans_fields' ) ) { + $fields = beans_post( 'beans_fields' ); + + if ( ! $fields ) { return $attachment; } @@ -135,6 +173,5 @@ public function save_attachment( $attachment ) { } return $attachment; - } } diff --git a/lib/api/post-meta/functions-admin.php b/lib/api/post-meta/functions-admin.php index a5b0a544..adc17769 100644 --- a/lib/api/post-meta/functions-admin.php +++ b/lib/api/post-meta/functions-admin.php @@ -2,7 +2,9 @@ /** * The Beans Post Meta component extends the Beans Fields and make it easy add fields to any Post Type. * - * @package API\Post_Meta + * @package Beans\Framework\API\Post_Meta + * + * @since 1.0.0 */ /** @@ -12,42 +14,41 @@ * * @since 1.0.0 * - * @param array $fields { - * Array of fields to register. + * @param array $fields { + * Array of fields to register. * - * @type string $id A unique id used for the field. This id will also be used to save the value in - * the database. - * @type string $type The type of field to use. Please refer to the Beans core field types for more - * information. Custom field types are accepted here. - * @type string $label The field label. Default false. + * @type string $id A unique id used for the field. This id will also be used to save the value in + * the database. + * @type string $type The type of field to use. Please refer to the Beans core field types for more + * information. Custom field types are accepted here. + * @type string $label The field label. Default false. * @type string $description The field description. The description can be truncated using - * as a delimiter. Default false. + * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. + * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the - * {@see beans_register_fields()} $fields arguments. + * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field type. Defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * registered should be saved as a group in the database or as individual + * entries. Default false. * } * @param string|array $conditions Array of 'post types id(s)', 'post id(s)' or 'page template slug(s)' for which the post meta should be registered. * 'page template slug(s)' must include '.php' file extention. Set to true to display everywhere. - * @param string $section A section id to define the group of fields. - * @param array $args { - * Optional. Array of arguments used to register the fields. + * @param string $section A section id to define the group of fields. + * @param array $args { + * Optional. Array of arguments used to register the fields. * - * @type string $title The metabox Title. Default 'Undefined'. - * @type string $context Where on the page the metabox should be shown - * ('normal', 'advanced', or 'side'). Default 'normal'. - * @type int $priority The priority within the context where the boxes should show - * ('high', 'core', 'default' or 'low'). Default 'high'. + * @type string $title The metabox Title. Default 'Undefined'. + * @type string $context Where on the page the metabox should be shown + * ('normal', 'advanced', or 'side'). Default 'normal'. + * @type int $priority The priority within the context where the boxes should show + * ('high', 'core', 'default' or 'low'). Default 'high'. * } * * @return bool True on success, false on failure. */ function beans_register_post_meta( array $fields, $conditions, $section, $args = array() ) { - global $_beans_post_meta_conditions; /** @@ -71,6 +72,7 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = * @param string|array $conditions Conditions used to define whether the fields set should be displayed or not. */ $conditions = apply_filters( "beans_post_meta_post_types_{$section}", $conditions ); + $_beans_post_meta_conditions = array_merge( $_beans_post_meta_conditions, (array) $conditions ); // Stop here if the current page isn't concerned. @@ -84,37 +86,46 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'post-meta/class.php' ); + require_once BEANS_API_PATH . 'post-meta/class.php'; new _Beans_Post_Meta( $section, $args ); - } /** * Check the current screen conditions. * + * @since 1.0.0 * @ignore + * @access private + * + * @param array $conditions Conditions to show a Post Meta box. + * + * @return bool */ function _beans_is_post_meta_conditions( $conditions ) { // Check if it is a new post and treat it as such. if ( false !== stripos( $_SERVER['REQUEST_URI'], 'post-new.php' ) ) { + $current_post_type = beans_get( 'post_type' ); - if ( ! $current_post_type = beans_get( 'post_type' ) ) { + if ( ! $current_post_type ) { - if ( in_array( 'post', (array) $conditions ) ) { + if ( in_array( 'post', (array) $conditions, true ) ) { return true; } else { return false; } } } else { - // Try to get id from $_GET. - if ( $id = beans_get( 'post' ) ) { - $post_id = $id; - } elseif ( $id = beans_post( 'post_ID' ) ) { // Try to get id from $_POST. - $post_id = $id; + $id_get = beans_get( 'post' ); + // Try to get id from $_POST. + $id_post = beans_post( 'post_ID' ); + + if ( $id_get ) { + $post_id = $id_get; + } elseif ( $id_post ) { + $post_id = $id_post; } if ( ! isset( $post_id ) ) { @@ -122,33 +133,34 @@ function _beans_is_post_meta_conditions( $conditions ) { } $current_post_type = get_post_type( $post_id ); - } $statements = array( true === $conditions, - in_array( $current_post_type, (array) $conditions ), // Check post type. - isset( $post_id ) && in_array( $post_id, (array) $conditions ), // Check post id. - isset( $post_id ) && in_array( get_post_meta( $post_id, '_wp_page_template', true ), (array) $conditions ), // Check page template. + in_array( $current_post_type, (array) $conditions, true ), // Check post type. + isset( $post_id ) && in_array( $post_id, (array) $conditions, true ), // Check post id. + isset( $post_id ) && in_array( get_post_meta( $post_id, '_wp_page_template', true ), (array) $conditions, true ), // Check page template. ); // Return true if any condition is met, otherwise false. - return in_array( true, $statements ); - + return in_array( true, $statements, true ); } add_action( 'admin_print_footer_scripts', '_beans_post_meta_page_template_reload' ); /** * Reload post edit screen on page template change. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_post_meta_page_template_reload() { - global $_beans_post_meta_conditions, $pagenow; // Stop here if not editing a post object. - if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php' ) ) ) { + if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php' ), true ) ) { return; } @@ -182,13 +194,13 @@ function _beans_post_meta_page_template_reload() { } )( jQuery ); Date: Sun, 25 Feb 2018 22:46:38 -0500 Subject: [PATCH 145/800] Fixed typo in @package PR #129 --- lib/api/template/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/template/functions.php b/lib/api/template/functions.php index 17e006b5..77f871d5 100644 --- a/lib/api/template/functions.php +++ b/lib/api/template/functions.php @@ -2,7 +2,7 @@ /** * The Beans Templates API allows to load Beans template files as well as loading the entire document. * - * @package Beans\Framework\API\Actions + * @package Beans\Framework\API\Template * * @since 1.0.0 */ From 6f4219f527d629fa234dbe8a782abc708c51df0a Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 25 Feb 2018 22:49:51 -0500 Subject: [PATCH 146/800] Made lib\api\term-meta WPCS compliant PR #130 --- lib/api/term-meta/class.php | 93 +++++++++++++++++---------- lib/api/term-meta/functions-admin.php | 44 +++++++------ lib/api/term-meta/functions.php | 11 +++- 3 files changed, 92 insertions(+), 56 deletions(-) diff --git a/lib/api/term-meta/class.php b/lib/api/term-meta/class.php index 88c62575..6ab8e3f3 100644 --- a/lib/api/term-meta/class.php +++ b/lib/api/term-meta/class.php @@ -1,90 +1,108 @@ section = $section; $this->do_once(); - - add_action( beans_get( 'taxonomy' ). '_edit_form_fields', array( $this, 'fields' ) ); - + add_action( beans_get( 'taxonomy' ) . '_edit_form_fields', array( $this, 'fields' ) ); } /** * Trigger actions only once. + * + * @since 1.0.0 + * + * @return void */ private function do_once() { - static $once = false; if ( ! $once ) { - - add_action( beans_get( 'taxonomy' ). '_edit_form', array( $this, 'nonce' ) ); + add_action( beans_get( 'taxonomy' ) . '_edit_form', array( $this, 'nonce' ) ); add_action( 'edit_term', array( $this, 'save' ) ); add_action( 'delete_term', array( $this, 'delete' ), 10, 3 ); $once = true; - } - } /** - * Post meta nonce. + * Term meta nonce. + * + * @since 1.0.0 + * + * @return void */ - public function nonce( $tag ) { - - ?> - + + section ) as $field ) { - ?> - + - + $value ) { update_option( "beans_term_{$term_id}_{$field}", stripslashes_deep( $value ) ); } - } /** * Delete Term Meta. + * + * @since 1.0.0 + * + * @param int $term_id Term ID. + * + * @return void */ - public function delete( $term, $term_id, $taxonomy ) { - + public function delete( $term_id ) { global $wpdb; - $wpdb->query( $wpdb->prepare( - "DELETE FROM $wpdb->options WHERE option_name LIKE %s", - "beans_term_{$term_id}_%" - ) ); - + $wpdb->query( + $wpdb->prepare( + "DELETE FROM $wpdb->options WHERE option_name LIKE %s", + "beans_term_{$term_id}_%" + ) + ); } } diff --git a/lib/api/term-meta/functions-admin.php b/lib/api/term-meta/functions-admin.php index 97c5a3b5..adce51fe 100644 --- a/lib/api/term-meta/functions-admin.php +++ b/lib/api/term-meta/functions-admin.php @@ -1,8 +1,10 @@ - * as a delimiter. Default false. + * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. + * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the - * {@see beans_register_fields()} $fields arguments. + * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field type. Defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * registered should be saved as a group in the database or as individual + * entries. Default false. * } * @param string|array $taxonomies Array of taxonomies for which the term meta should be registered. * @param string $section A section id to define the group of fields. @@ -71,20 +73,25 @@ function beans_register_term_meta( array $fields, $taxonomies, $section ) { } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'term-meta/class.php' ); + require_once BEANS_API_PATH . 'term-meta/class.php'; new _Beans_Term_Meta( $section ); - } /** * Check if the current screen is a given term. * + * @since 1.0.0 * @ignore + * @access private + * + * @param array $taxonomies Array of taxonomies. + * @return bool */ function _beans_is_admin_term( $taxonomies ) { + $taxonomy = beans_get_or_post( 'taxonomy' ); - if ( ! $taxonomy = beans_get_or_post( 'taxonomy' ) ) { + if ( ! $taxonomy ) { return false; } @@ -92,10 +99,9 @@ function _beans_is_admin_term( $taxonomies ) { return true; } - if ( in_array( $taxonomy, (array) $taxonomies ) ) { + if ( in_array( $taxonomy, (array) $taxonomies, true ) ) { return true; } return false; - } diff --git a/lib/api/term-meta/functions.php b/lib/api/term-meta/functions.php index bc961a1e..eb9bc213 100644 --- a/lib/api/term-meta/functions.php +++ b/lib/api/term-meta/functions.php @@ -1,6 +1,10 @@ Date: Sun, 25 Feb 2018 23:09:52 -0500 Subject: [PATCH 147/800] Made lib\api\wp-customize WPCS compliant --- lib/api/wp-customize/class.php | 96 ++++++++++++++++++++++-------- lib/api/wp-customize/functions.php | 41 ++++++------- 2 files changed, 91 insertions(+), 46 deletions(-) diff --git a/lib/api/wp-customize/class.php b/lib/api/wp-customize/class.php index fb40913f..017b854d 100644 --- a/lib/api/wp-customize/class.php +++ b/lib/api/wp-customize/class.php @@ -1,25 +1,44 @@ __( 'Undefined', 'tm-beans' ), 'priority' => 30, @@ -27,24 +46,26 @@ public function __construct( $section, $args ) { ); $this->section = $section; - $this->args = array_merge( $defaults, $args ); + $this->args = array_merge( $defaults, $args ); // Add section, settings and controls. $this->add(); beans_add_attribute( 'beans_field_label', 'class', 'customize-control-title' ); - } /** * Add section, settings and controls. + * + * @since 1.0.0 + * @ignore + * @access private + * + * @return void */ private function add() { - global $wp_customize; - $this->add_section( $wp_customize ); - $fields = beans_get_fields( 'wp_customize', $this->section ); foreach ( $fields as $field ) { @@ -57,13 +78,19 @@ private function add() { $this->add_setting( $wp_customize, $field ); $this->add_control( $wp_customize, $field ); - } - } /** * Add Section. + * + * @since 1.0.0 + * @ignore + * @access private + * + * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. + * + * @return void */ private function add_section( $wp_customize ) { @@ -79,14 +106,21 @@ private function add_section( $wp_customize ) { 'description' => $this->args['description'], ) ); - } /** * Add setting. + * + * @since 1.0.0 + * @ignore + * @access private + * + * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. + * @param array $field Metabox settings. + * + * @return void */ private function add_setting( $wp_customize, $field ) { - $defaults = array( 'db_type' => 'theme_mod', 'capability' => 'edit_theme_options', @@ -105,14 +139,21 @@ private function add_setting( $wp_customize, $field ) { 'sanitize_callback' => array( $this, 'sanitize' ), ) ); - } /** * Add Control. + * + * @since 1.0.0 + * @ignore + * @access private + * + * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. + * @param array $field Metabox settings. + * + * @return void */ private function add_control( $wp_customize, $field ) { - $class = '_Beans_WP_Customize_Control'; if ( $field['type'] !== $class && class_exists( $field['type'] ) ) { @@ -130,32 +171,37 @@ private function add_control( $wp_customize, $field ) { $field ) ); - } /** * Sanatize value. + * + * @since 1.0.0 + * + * @param mixed $value Value. + * + * @return mixed */ public function sanitize( $value ) { - return $value; - } } if ( class_exists( 'WP_Customize_Control' ) ) : - /** * Render Beans fields content for WP Customize. * + * @since 1.0.0 + * * @ignore + * @access private */ class _Beans_WP_Customize_Control extends WP_Customize_Control { /** * Field data. * - * @type string + * @var string */ private $beans_field; @@ -163,22 +209,20 @@ class _Beans_WP_Customize_Control extends WP_Customize_Control { * Constructor. */ public function __construct() { - $args = func_get_args(); - call_user_func_array( array( 'parent', '__construct' ), $args ); - $this->beans_field = end( $args ); - } /** * Field content. + * + * @since 1.0.0 + * + * @return void */ public function render_content() { - beans_field( $this->beans_field ); - } } diff --git a/lib/api/wp-customize/functions.php b/lib/api/wp-customize/functions.php index caa126eb..e77af5bd 100644 --- a/lib/api/wp-customize/functions.php +++ b/lib/api/wp-customize/functions.php @@ -1,9 +1,11 @@ - * as a delimiter. Default false. + * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. + * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for 'group' field type. The array arguments are similary to the - * {@see beans_register_fields()} $fields arguments. + * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * registered should be saved as a group in the database or as individual + * entries. Default false. * } * @param string $section The WP customize section to which the fields should be added. Add a unique id * to create a new section. * @param array $args { * Optional. Array of arguments used to register the fields. * - * @type string $title The visible name of a controller section. - * @type int $priority This controls the order in which this section appears - * in the Theme Customizer sidebar. Default 30. - * @type string $description This optional argument can add additional descriptive - * text to the section. Default false. + * @type string $title The visible name of a controller section. + * @type int $priority This controls the order in which this section appears + * in the Theme Customizer sidebar. Default 30. + * @type string $description This optional argument can add additional descriptive + * text to the section. Default false. * } * * @return bool True on success, false on failure. @@ -70,8 +72,7 @@ function beans_register_wp_customize_options( array $fields, $section, $args = a } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'wp-customize/class.php' ); + require_once BEANS_API_PATH . 'wp-customize/class.php'; new _Beans_WP_Customize( $section, $args ); - } From dcbbb4d042597524e447688d9340e1b0bc77dfbc Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 25 Feb 2018 23:17:33 -0500 Subject: [PATCH 148/800] Ignored one class per file rule --- lib/api/wp-customize/class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/wp-customize/class.php b/lib/api/wp-customize/class.php index 017b854d..73035ee2 100644 --- a/lib/api/wp-customize/class.php +++ b/lib/api/wp-customize/class.php @@ -196,7 +196,7 @@ public function sanitize( $value ) { * @ignore * @access private */ - class _Beans_WP_Customize_Control extends WP_Customize_Control { + class _Beans_WP_Customize_Control extends WP_Customize_Control { // @codingStandardsIgnoreLine - Generic.Files.OneClassPerFile.MultipleFound. /** * Field data. From 591bf0268948b74bdff156ca89cbac070593ab02 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Mon, 26 Feb 2018 00:53:22 -0500 Subject: [PATCH 149/800] Made lib\api\image WPCS compliant PR #126 --- lib/api/image/class-options.php | 49 +++++++++++++++------ lib/api/image/functions.php | 76 +++++++++++++++------------------ 2 files changed, 69 insertions(+), 56 deletions(-) diff --git a/lib/api/image/class-options.php b/lib/api/image/class-options.php index 47dbaa3a..4f17c254 100644 --- a/lib/api/image/class-options.php +++ b/lib/api/image/class-options.php @@ -1,10 +1,20 @@ __( 'Images options', 'tm-beans' ), 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', // Check of other beans boxes. ) ); - } /** * Flush images for all folders set. + * + * @since 1.0.0 + * + * @return void */ public function flush() { @@ -53,11 +67,14 @@ public function flush() { } beans_remove_dir( beans_get_images_dir() ); - } /** * Image editor notice notice. + * + * @since 1.0.0 + * + * @return void */ public function admin_notice() { @@ -66,13 +83,18 @@ public function admin_notice() { } ?> -

    +

    - + init(); - } /** @@ -60,23 +56,21 @@ function beans_edit_image( $src, array $args, $output = 'STRING' ) { * @return object Post attachment data. */ function beans_get_post_attachment( $post_id, $size = 'full' ) { - - $id = get_post_thumbnail_id( $post_id ); + $id = get_post_thumbnail_id( $post_id ); $post = get_post( $id ); - $src = wp_get_attachment_image_src( $id, $size ); - - $obj = new stdClass(); - $obj->id = $id; - $obj->src = $src[0]; - $obj->width = $src[1]; - $obj->height = $src[2]; - $obj->alt = trim( strip_tags( get_post_meta( $id, '_wp_attachment_image_alt', true ) ) ); - $obj->title = $post->post_title; - $obj->caption = $post->post_excerpt; + $src = wp_get_attachment_image_src( $id, $size ); + + $obj = new stdClass(); + $obj->id = $id; + $obj->src = $src[0]; + $obj->width = $src[1]; + $obj->height = $src[2]; + $obj->alt = trim( strip_tags( get_post_meta( $id, '_wp_attachment_image_alt', true ) ) ); + $obj->title = $post->post_title; + $obj->caption = $post->post_excerpt; $obj->description = $post->post_content; return $obj; - } /** @@ -90,16 +84,16 @@ function beans_get_post_attachment( $post_id, $size = 'full' ) { * @param array $args { * Array of arguments used by the image editor. * - * @type array $resize Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize - * function arguments. - * @type array $crop Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop - * function arguments. - * @type array $rotate Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate - * function arguments. - * @type array $flip Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip - * function arguments. - * @type array $set_quality Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality - * function arguments. + * @type array $resize Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize + * function arguments. + * @type array $crop Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop + * function arguments. + * @type array $rotate Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate + * function arguments. + * @type array $flip Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip + * function arguments. + * @type array $set_quality Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality + * function arguments. * } * * @return object Edited post attachment data. @@ -112,13 +106,13 @@ function beans_edit_post_attachment( $post_id, $args = array() ) { // Get full size image. $attachement = beans_get_post_attachment( $post_id, 'full' ); + $edited = beans_edit_image( $attachement->src, $args, 'ARRAY_A' ); - if ( ! $edited = beans_edit_image( $attachement->src, $args, 'ARRAY_A' ) ) { + if ( ! $edited ) { return $attachement; } return (object) array_merge( (array) $attachement, $edited ); - } /** @@ -129,7 +123,6 @@ function beans_edit_post_attachment( $post_id, $args = array() ) { * @return string Edited images directory. */ function beans_get_images_dir() { - $wp_upload_dir = wp_upload_dir(); /** @@ -140,5 +133,4 @@ function beans_get_images_dir() { $dir = apply_filters( 'beans_images_dir', trailingslashit( $wp_upload_dir['basedir'] ) . 'beans/images/' ); return wp_normalize_path( trailingslashit( $dir ) ); - } From 39d1b72bc0932c4f9d141483428a96446ded2fa8 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Mon, 26 Feb 2018 00:58:45 -0500 Subject: [PATCH 150/800] Made lib\api\widget WPCS compliant PR #132 --- lib/api/widget/functions.php | 136 +++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 62 deletions(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 819a0673..18a5ea0b 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -4,7 +4,9 @@ * 'widget_area' as it is more appropriate when using it to define an area which is not besides the main * content (e.g. a mega footer widget area). * - * @package API\Widgets + * @package Beans\Framework\API\Widgets + * + * @since 1.0.0 */ /** @@ -37,12 +39,15 @@ * @type bool $beans_widget_badge_content Optional. The badge content. This may contain widget shortcodes * {@see beans_widget_shortcodes()}. Default 'Hello'. * } + * @param array $widget_control Optional. + * * @return string The widget area ID is added to the $wp_registered_sidebars globals when the widget area is setup. */ function beans_register_widget_area( $args = array(), $widget_control = array() ) { - // Stop here if the id isn't set. - if ( ! $id = beans_get( 'id', $args ) ) { + $id = beans_get( 'id', $args ); + + if ( ! $id ) { return; } @@ -68,7 +73,6 @@ function beans_register_widget_area( $args = array(), $widget_control = array() $args = beans_apply_filters( "beans_widgets_area_args[_{$id}]", array_merge( $defaults, $args ) ); return register_sidebar( $args ); - } /** @@ -81,11 +85,11 @@ function beans_register_widget_area( $args = array(), $widget_control = array() * @since 1.0.0 * * @param string $id The ID of the registered widget area. + * + * @return void */ function beans_deregister_widget_area( $id ) { - unregister_sidebar( $id ); - } /** @@ -101,9 +105,7 @@ function beans_deregister_widget_area( $id ) { * @return bool True if the widget area is in use, false otherwise. */ function beans_is_active_widget_area( $id ) { - return is_active_sidebar( $id ); - } /** @@ -119,7 +121,6 @@ function beans_is_active_widget_area( $id ) { * @return bool True if the widget area is registered, false otherwise. */ function beans_has_widget_area( $id ) { - global $wp_registered_sidebars; if ( isset( $wp_registered_sidebars[ $id ] ) ) { @@ -127,7 +128,6 @@ function beans_has_widget_area( $id ) { } return false; - } /** @@ -177,7 +177,6 @@ function beans_widget_area( $id ) { do_action( 'beans_widget_area_reset' ); return $output; - } /** @@ -190,7 +189,6 @@ function beans_widget_area( $id ) { * @return string The current widget area data, or field data if the needle is specified. False if not found. */ function beans_get_widget_area( $needle = false ) { - global $_beans_widget_area; if ( ! $needle ) { @@ -198,7 +196,6 @@ function beans_get_widget_area( $needle = false ) { } return beans_get( $needle, $_beans_widget_area ); - } /** @@ -222,7 +219,6 @@ function beans_widget_area_shortcodes( $content ) { } return beans_array_shortcodes( $string, $GLOBALS['_beans_widget_area'] ); - } /** @@ -233,7 +229,6 @@ function beans_widget_area_shortcodes( $content ) { * @return bool True if widgets are available, false if end of loop. */ function beans_have_widgets() { - global $_beans_widget_area; if ( ! beans_get( 'widgets', $_beans_widget_area ) ) { @@ -250,7 +245,6 @@ function beans_have_widgets() { _beans_reset_widget(); return false; - } /** @@ -263,13 +257,14 @@ function beans_have_widgets() { * @return bool True on success, false on failure. */ function beans_setup_widget() { - global $_beans_widget_area; $widgets = array_keys( $_beans_widget_area['widgets'] ); // Retrieve widget id if exists. - if ( ! $id = beans_get( $_beans_widget_area['current_widget'], $widgets ) ) { + $id = beans_get( $_beans_widget_area['current_widget'], $widgets ); + + if ( ! $id ) { return false; } @@ -279,7 +274,6 @@ function beans_setup_widget() { _beans_setup_widget( $id ); return true; - } /** @@ -292,7 +286,6 @@ function beans_setup_widget() { * @return string The current widget data, or field data if the needle is specified. False if not found. */ function beans_get_widget( $needle = false ) { - global $_beans_widget; if ( ! $needle ) { @@ -300,7 +293,6 @@ function beans_get_widget( $needle = false ) { } return beans_get( $needle, $_beans_widget ); - } /** @@ -324,16 +316,20 @@ function beans_widget_shortcodes( $content ) { } return beans_array_shortcodes( $content, $GLOBALS['_beans_widget'] ); - } /** * Set up widget area global data. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id Widget area ID. + * + * @return bool */ function _beans_setup_widget_area( $id ) { - global $_beans_widget_area, $wp_registered_sidebars; if ( ! isset( $wp_registered_sidebars[ $id ] ) ) { @@ -341,7 +337,7 @@ function _beans_setup_widget_area( $id ) { } // Add widget area delimiters. This is used to split wp sidebar as well as the widgets title. - $wp_registered_sidebars[ $id ] = array_merge( $wp_registered_sidebars[ $id ], array( + $wp_registered_sidebars[ $id ] = array_merge( $wp_registered_sidebars[ $id ], array( // @codingStandardsIgnoreLine - WordPress.Variables.GlobalVariables.OverrideProhibited. 'before_widget' => '', 'after_widget' => '', 'before_title' => '', @@ -364,29 +360,31 @@ function _beans_setup_widget_area( $id ) { preg_match_all( '##', $sidebar, $counter ); // Continue building widget area global with the splited sidebar elements. - $_beans_widget_area['widgets_count'] = count( $counter[0] ); + $_beans_widget_area['widgets_count'] = count( $counter[0] ); $_beans_widget_area['current_widget'] = 0; // Only add widgets if exists. - if ( 3 == count( $splited_sidebar ) ) { - + if ( 3 === count( $splited_sidebar ) ) { $_beans_widget_area['before_widgets'] = $splited_sidebar[0]; - $_beans_widget_area['widgets'] = _beans_setup_widgets( $splited_sidebar[1] ); - $_beans_widget_area['after_widgets'] = $splited_sidebar[2]; - + $_beans_widget_area['widgets'] = _beans_setup_widgets( $splited_sidebar[1] ); + $_beans_widget_area['after_widgets'] = $splited_sidebar[2]; } return true; - } /** * Setup widget area global widgets data. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $widget_area_content Content of the widget area. + * + * @return array */ function _beans_setup_widgets( $widget_area_content ) { - global $wp_registered_widgets, $_beans_widget_area; $_beans_widgets = array(); @@ -401,7 +399,9 @@ function _beans_setup_widgets( $widget_area_content ) { $id = $matches[1]; // Stop here if the widget can't be found. - if ( ! $data = beans_get( $id, $wp_registered_widgets ) ) { + $data = beans_get( $id, $wp_registered_widgets ); + + if ( ! $data ) { continue; } @@ -410,8 +410,8 @@ function _beans_setup_widgets( $widget_area_content ) { // Set defaults. $widget['options'] = array(); - $widget['type'] = null; - $widget['title'] = ''; + $widget['type'] = null; + $widget['title'] = ''; // Add total count. $widget['count'] = $_beans_widget_area['widgets_count']; @@ -421,15 +421,15 @@ function _beans_setup_widgets( $widget_area_content ) { $widget[ $var ] = isset( $data[ $var ] ) ? $data[ $var ] : null; } - // Add type and options - if ( isset( $data['callback'] ) && is_array( $data['callback'] ) && ( $object = current( $data['callback'] ) ) ) { + // Add type and options. + $object = current( $data['callback'] ); - if ( is_a( $object, 'WP_Widget' ) ) { + if ( isset( $data['callback'] ) && is_array( $data['callback'] ) && $object ) { + if ( is_a( $object, 'WP_Widget' ) ) { $widget['type'] = $object->id_base; if ( isset( $data['params'][0]['number'] ) ) { - $number = $data['params'][0]['number']; $params = get_option( $object->option_name ); @@ -442,10 +442,8 @@ function _beans_setup_widgets( $widget_area_content ) { } } } - } elseif ( 'nav_menu-0' == $id ) { // Widget type fallback. - + } elseif ( 'nav_menu-0' === $id ) { // Widget type fallback. $widget['type'] = 'nav_menu'; - } // Widget fallback name. @@ -454,7 +452,7 @@ function _beans_setup_widgets( $widget_area_content ) { } // Extract and add title. - if ( preg_match( '#(.*)#s' , $content, $matches ) ) { + if ( preg_match( '#(.*)#s', $content, $matches ) ) { $widget['title'] = strip_tags( $matches[1] ); } @@ -472,71 +470,80 @@ function _beans_setup_widgets( $widget_area_content ) { 'badge' => $_beans_widget_area['beans_show_widget_badge'], 'badge_content' => $_beans_widget_area['beans_widget_badge_content'], ) ); - } return $_beans_widgets; - } /** * Setup widget global data. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id Widget ID. + * + * @return void */ function _beans_setup_widget( $id ) { - global $_beans_widget; - - $widgets = beans_get_widget_area( 'widgets' ); - + $widgets = beans_get_widget_area( 'widgets' ); $_beans_widget = $widgets[ $id ]; - } /** * Reset widget area global data. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_reset_widget_area() { - unset( $GLOBALS['_beans_widget_area'] ); - } /** * Reset widget global data. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_reset_widget() { - unset( $GLOBALS['_beans_widget'] ); - } /** * Build widget area subfilters. * + * @since 1.0.0 * @ignore + * @access private + * + * @return array */ function _beans_widget_area_subfilters() { - global $_beans_widget_area; // Add sidebar id. return '[_' . $_beans_widget_area['id'] . ']'; - } /** * Build widget subfilters. * + * @since 1.0.0 * @ignore + * @access private + * + * @return array */ function _beans_widget_subfilters() { - global $_beans_widget_area, $_beans_widget; $subfilters = array( @@ -546,17 +553,23 @@ function _beans_widget_subfilters() { ); return '[_' . implode( '][_', $subfilters ) . ']'; - } add_action( 'the_widget', '_beans_force_the_widget', 10, 3 ); /** * Force atypical widget added using the_widget() to have a correctly registered id. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $widget The widget's PHP class name (see class-wp-widget.php). + * @param array $instance Optional. The widget's instance settings. Default empty array. + * @param array $args Array of arguments to configure the display of the widget. + * + * @return void */ function _beans_force_the_widget( $widget, $instance, $args ) { - global $wp_widget_factory; $widget_obj = $wp_widget_factory->widgets[ $widget ]; @@ -565,11 +578,10 @@ function _beans_force_the_widget( $widget, $instance, $args ) { return; } - // Stop here if the widget correctly contain an id. + // Stop here if the widget correctly contains an id. if ( false !== stripos( $widget_obj->id, beans_get( 'before_widget', $args ) ) ) { return; } - printf( '', $widget_obj->id ); - + printf( '', esc_attr( $widget_obj->id ) ); } From d78e0c09cdba51519fdf71569f5212371535911a Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Mon, 26 Feb 2018 12:48:01 -0500 Subject: [PATCH 151/800] Made lib\api files WPCS compliant PR #134 --- lib/api/admin-menu.php | 49 ++++++++++++++++++++++++++++++------------ lib/api/components.php | 31 ++++++++++---------------- lib/api/init.php | 2 +- 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/lib/api/admin-menu.php b/lib/api/admin-menu.php index 32262410..f741d8bb 100644 --- a/lib/api/admin-menu.php +++ b/lib/api/admin-menu.php @@ -1,8 +1,20 @@
    -

    +

    __( 'Mode options', 'tm-beans' ), - 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', // Check for other beans boxes. - ) ); - + beans_register_options( + $fields, + 'beans_settings', + 'mode_options', + array( + 'title' => __( 'Mode options', 'tm-beans' ), + 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', // Check for other beans boxes. + ) + ); } } diff --git a/lib/api/components.php b/lib/api/components.php index 4a541fc4..252b239f 100644 --- a/lib/api/components.php +++ b/lib/api/components.php @@ -1,18 +1,20 @@ Date: Mon, 26 Feb 2018 12:50:13 -0500 Subject: [PATCH 152/800] Made lib\api\uikit WPCS compliant PR #131 --- lib/api/uikit/class.php | 170 +++++++++++++++++++++++------------- lib/api/uikit/functions.php | 73 ++++++++-------- 2 files changed, 145 insertions(+), 98 deletions(-) diff --git a/lib/api/uikit/class.php b/lib/api/uikit/class.php index 257fb688..460629f8 100644 --- a/lib/api/uikit/class.php +++ b/lib/api/uikit/class.php @@ -1,18 +1,31 @@ array( 'jquery' ), - ) ); + $scripts_args = apply_filters( + 'beans_uikit_euqueued_scripts_args', + array( + 'depedencies' => array( 'jquery' ), + ) + ); // Compile less. if ( $styles ) { @@ -62,14 +78,16 @@ function compile() { if ( $scripts ) { beans_compile_js_fragments( 'uikit', array_unique( $scripts ), $scripts_args ); } - } /** * Register less components. + * + * @since 1.0.0 + * + * @return array */ - function register_less_components() { - + public function register_less_components() { global $_beans_uikit_enqueued_items; $components = array(); @@ -77,13 +95,12 @@ function register_less_components() { foreach ( $_beans_uikit_enqueued_items['components'] as $type => $items ) { // Add core before the components. - if ( 'core' == $type ) { + if ( 'core' === $type ) { $items = array_merge( array( 'variables' ), $items ); } // Fetch components from directories. $components = array_merge( $components, $this->get_components_from_directory( $items, $this->get_less_directories( $type ), 'styles' ) ); - } // Add fixes. @@ -92,14 +109,16 @@ function register_less_components() { } return $components; - } /** - * Register js components. + * Register JavaScript components. + * + * @since 1.0.0 + * + * @return array */ - function register_js_components() { - + public function register_js_components() { global $_beans_uikit_enqueued_items; $components = array(); @@ -107,7 +126,7 @@ function register_js_components() { foreach ( $_beans_uikit_enqueued_items['components'] as $type => $items ) { // Add core before the components. - if ( 'core' == $type ) { + if ( 'core' === $type ) { $items = array_merge( array( 'core', @@ -121,25 +140,29 @@ function register_js_components() { // Fetch components from directories. $components = array_merge( $components, $this->get_components_from_directory( $items, $this->get_js_directories( $type ), 'scripts' ) ); - } return $components; - } /** * Get LESS directories. + * + * @since 1.0.0 + * + * @param string $type Type of the UIkit components. + * + * @return array */ - function get_less_directories( $type ) { + public function get_less_directories( $type ) { - if ( 'add-ons' == $type ) { + if ( 'add-ons' === $type ) { $type = 'components'; } global $_beans_uikit_enqueued_items; - // Define uikit src directory. + // Define the UIkit src directory. $directories = array( BEANS_API_PATH . 'uikit/src/less/' . $type ); // Add the registered theme directories. @@ -148,29 +171,41 @@ function get_less_directories( $type ) { } return $directories; - } /** - * Get JS directories. + * Get JavaScript directories. + * + * @since 1.0.0 + * + * @param string $type Type. + * + * @return array */ - function get_js_directories( $type ) { + public function get_js_directories( $type ) { - if ( 'add-ons' == $type ) { + if ( 'add-ons' === $type ) { $type = 'components'; } - // Define uikit src directory. + // Define the UIkit src directory. return array( BEANS_API_PATH . 'uikit/src/js/' . $type ); - } /** * Get components from directories. + * + * @since 1.0.0 + * + * @param array $components Array of UIkit Components. + * @param array $directories Array of directories containing the UIkit Components. + * @param string $format File format. + * + * @return array */ - function get_components_from_directory( $components, $directories, $format ) { + public function get_components_from_directory( $components, $directories, $format ) { - $extension = ( 'styles' == $format ) ? 'less' : 'min.js'; + $extension = 'styles' === $format ? 'less' : 'min.js'; $return = array(); @@ -178,7 +213,6 @@ function get_components_from_directory( $components, $directories, $format ) { // Fectch components from all directories set. foreach ( $directories as $directory ) { - $file = trailingslashit( $directory ) . $component . '.' . $extension; // Make sure the file exists. @@ -189,14 +223,18 @@ function get_components_from_directory( $components, $directories, $format ) { } return $return; - } /** * Get all components. + * + * @since 1.0.0 + * + * @param string $type Type of UIkit components ('core' or 'add-ons'). + * + * @return array */ - function get_all_components( $type ) { - + public function get_all_components( $type ) { // Fetch all directories. $directories = array_merge( $this->get_less_directories( $type ), $this->get_js_directories( $type ) ); @@ -215,45 +253,48 @@ function get_all_components( $type ) { // Only return the filname and remove empty elements. $components = array_merge( $components, array_filter( array_map( array( $this, 'to_filename' ), $scandir ) ) ); - } return $components; - } /** - * Auto detect components required. + * Auto detect the required components. + * + * @since 1.0.0 + * + * @param array $components Array of components to autoload. + * + * @return array */ - function get_autoload_components( $components ) { - + public function get_autoload_components( $components ) { $autoload = array( 'core' => array(), 'add-ons' => array(), ); - $depedencies = array( - 'panel' => array( + $dependencies = array( + 'panel' => array( 'core' => array( 'badge', ), ), - 'cover' => array( + 'cover' => array( 'core' => array( 'flex', ), ), - 'overlay' => array( + 'overlay' => array( 'core' => array( 'flex', ), ), - 'tab' => array( + 'tab' => array( 'core' => array( 'switcher', ), ), - 'modal' => array( + 'modal' => array( 'core' => array( 'close', ), @@ -263,8 +304,8 @@ function get_autoload_components( $components ) { 'animation', ), ), - 'lightbox' => array( - 'core' => array( + 'lightbox' => array( + 'core' => array( 'animation', 'flex', 'close', @@ -275,13 +316,13 @@ function get_autoload_components( $components ) { 'slidenav', ), ), - 'slider' => array( + 'slider' => array( 'add-ons' => array( 'slidenav', ), ), - 'slideset' => array( - 'core' => array( + 'slideset' => array( + 'core' => array( 'animation', 'flex', ), @@ -291,7 +332,7 @@ function get_autoload_components( $components ) { ), ), 'slideshow' => array( - 'core' => array( + 'core' => array( 'animation', 'flex', ), @@ -300,12 +341,12 @@ function get_autoload_components( $components ) { 'slidenav', ), ), - 'parallax' => array( + 'parallax' => array( 'core' => array( 'flex', ), ), - 'notify' => array( + 'notify' => array( 'core' => array( 'close', ), @@ -314,27 +355,31 @@ function get_autoload_components( $components ) { foreach ( (array) $components as $component ) { - $this_depedencies = beans_get( $component, $depedencies, array() ); + $this_dependencies = beans_get( $component, $dependencies, array() ); - foreach ( $this_depedencies as $depedency ) { - $autoload['core'] = array_merge( $autoload['core'], array_flip( beans_get( 'core', $this_depedencies, array() ) ) ); - $autoload['add-ons'] = array_merge( $autoload['add-ons'], array_flip( beans_get( 'add-ons', $this_depedencies, array() ) ) ); + foreach ( $this_dependencies as $dependency ) { + $autoload['core'] = array_merge( $autoload['core'], array_flip( beans_get( 'core', $this_dependencies, array() ) ) ); + $autoload['add-ons'] = array_merge( $autoload['add-ons'], array_flip( beans_get( 'add-ons', $this_dependencies, array() ) ) ); } } // Format autoload back to associative key value array. - $autoload['core'] = array_flip( $autoload['core'] ); + $autoload['core'] = array_flip( $autoload['core'] ); $autoload['add-ons'] = array_flip( $autoload['add-ons'] ); return $autoload; - } /** * Convert component to a filename. + * + * @since 1.0.0 + * + * @param string $file File name. + * + * @return null|string */ - function to_filename( $file ) { - + public function to_filename( $file ) { $pathinfo = pathinfo( $file ); $ignore = array( @@ -343,12 +388,11 @@ function to_filename( $file ) { ); // Stop here if it isn't a valid file or if it should be ignored. - if ( ! isset( $pathinfo['filename'] ) || in_array( $pathinfo['filename'], $ignore ) ) { + if ( ! isset( $pathinfo['filename'] ) || in_array( $pathinfo['filename'], $ignore, true ) ) { return null; } // Return the filename without the .min to avoid duplicates. return str_replace( '.min', '', $pathinfo['filename'] ); - } } diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index 888c7da0..4bd32ea1 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -2,14 +2,16 @@ /** * The Beans UIkit component integrates the awesome {@link https://getuikit.com/v2/ UIkit 2 framework}. * - * Only the desired components are compiled into a single cached file and may be different on a per page basis. UIkit - * default or custom themes can be enqueued to the UIkit compiler. All UIkit LESS variables are accessible + * Only the selected components are compiled into a single cached file and can be different on a per page basis. + * UIkit default or custom themes can be enqueued to the UIkit compiler. All UIkit LESS variables are accessible * and overwritable via custom themes. * - * When development mode is enabled, files changes will automatically be detected. This makes it very easy + * When development mode is enabled, file changes will automatically be detected. This makes it very easy * to style UIkit themes using LESS. * - * @package API\UIkit + * @package Beans\Framework\API\UIkit + * + * @since 1.0.0 */ /** @@ -18,7 +20,7 @@ * Enqueued components will be compiled into a single file. Refer to * {@link https://getuikit.com/v2/ UIkit 2} to learn more about the available components. * - * When development mode is enabled, files changes will automatically be detected. This makes it very easy + * When development mode is enabled, file changes will automatically be detected. This makes it very easy * to style UIkit themes using LESS. * * This function must be called in the 'beans_uikit_enqueue_scripts' action hook. @@ -30,20 +32,18 @@ * load all components. * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). * @param bool $autoload Optional. Automatically include components dependencies. + * + * @return void */ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload = true ) { - global $_beans_uikit_enqueued_items; // Get all uikit components. if ( true === $components ) { - - $uikit = new _Beans_Uikit; + $uikit = new _Beans_Uikit(); $components = $uikit->get_all_components( $type ); - } elseif ( $autoload ) { - - $uikit = new _Beans_Uikit; + $uikit = new _Beans_Uikit(); $autoloads = $uikit->get_autoload_components( (array) $components ); foreach ( $autoloads as $autotype => $autoload ) { @@ -53,7 +53,6 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload // Add components. $_beans_uikit_enqueued_items['components'][ $type ] = array_merge( (array) $_beans_uikit_enqueued_items['components'][ $type ], (array) $components ); - } /** @@ -62,7 +61,7 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload * Dequeued components are removed from the UIkit compiler. Refer to * {@link https://getuikit.com/v2/ UIkit 2} to learn more about the available components. * - * When development mode is enabled, files changes will automatically be detected. This makes it very easy + * When development mode is enabled, file changes will automatically be detected. This makes it very easy * to style UIkit themes using LESS. * * This function must be called in the 'beans_uikit_enqueue_scripts' action hook. @@ -73,21 +72,19 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload * the UIkit component filename without the extention (e.g. 'grid'). Set to true * exclude all components. * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). + * + * @return void */ function beans_uikit_dequeue_components( $components, $type = 'core' ) { - global $_beans_uikit_enqueued_items; if ( true === $components ) { - - $uikit = new _Beans_Uikit; + $uikit = new _Beans_Uikit(); $components = $uikit->get_all_components( $type ); - } // Remove components. $_beans_uikit_enqueued_items['components'][ $type ] = array_diff( (array) $_beans_uikit_enqueued_items['components'][ $type ], (array) $components ); - } /** @@ -106,7 +103,6 @@ function beans_uikit_dequeue_components( $components, $type = 'core' ) { * @return bool False on error or if already exists, true on success. */ function beans_uikit_register_theme( $id, $path ) { - global $_beans_uikit_registered_items; // Stop here if already registered. @@ -125,7 +121,6 @@ function beans_uikit_register_theme( $id, $path ) { $_beans_uikit_registered_items['themes'][ $id ] = trailingslashit( $path ); return true; - } /** @@ -155,7 +150,6 @@ function beans_uikit_enqueue_theme( $id, $path = false ) { $_beans_uikit_enqueued_items['themes'][ $id ] = _beans_uikit_get_registered_theme( $id ); return true; - } /** @@ -167,20 +161,18 @@ function beans_uikit_enqueue_theme( $id, $path = false ) { * * @param string $id The id of the theme to dequeue. * - * @return bool Will always return true. + * @return void */ function beans_uikit_dequeue_theme( $id ) { - global $_beans_uikit_enqueued_items; - unset( $_beans_uikit_enqueued_items['themes'][ $id ] ); - } /** * Initialize registered UIkit items global. * * @ignore + * @access private */ global $_beans_uikit_registered_items; @@ -199,6 +191,7 @@ function beans_uikit_dequeue_theme( $id ) { * Initialize enqueued UIkit items global. * * @ignore + * @access private */ global $_beans_uikit_enqueued_items; @@ -215,26 +208,36 @@ function beans_uikit_dequeue_theme( $id ) { /** * Get registered theme. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id UIkit theme ID. + * + * @return mixed */ function _beans_uikit_get_registered_theme( $id ) { - global $_beans_uikit_registered_items; - // Stop here if is already registered. - if ( $theme = beans_get( $id, $_beans_uikit_registered_items['themes'] ) ) { + // Stop here if the theme is already registered. + $theme = beans_get( $id, $_beans_uikit_registered_items['themes'] ); + + if ( $theme ) { return $theme; } return false; - } add_action( 'wp_enqueue_scripts', '_beans_uikit_enqueue_assets', 7 ); /** * Enqueue UIkit assets. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_uikit_enqueue_assets() { @@ -250,17 +253,19 @@ function _beans_uikit_enqueue_assets() { do_action( 'beans_uikit_enqueue_scripts' ); // Compile everything. - $uikit = new _Beans_Uikit; - + $uikit = new _Beans_Uikit(); $uikit->compile(); - } add_action( 'admin_enqueue_scripts', '_beans_uikit_enqueue_admin_assets', 7 ); /** * Enqueue UIkit admin assets. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_uikit_enqueue_admin_assets() { @@ -276,8 +281,6 @@ function _beans_uikit_enqueue_admin_assets() { do_action( 'beans_uikit_admin_enqueue_scripts' ); // Compile everything. - $uikit = new _Beans_Uikit; - + $uikit = new _Beans_Uikit(); $uikit->compile(); - } From e05744170bc4b27ac13a1f62333e0b4f9c840baa Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Mon, 26 Feb 2018 13:10:24 -0600 Subject: [PATCH 153/800] Added tests for beans_get_post_meta(). (#135) --- lib/api/post-meta/functions.php | 16 +-- .../api/post-meta/beansGetPostMeta.php | 65 +++++++++++ .../unit/api/post-meta/beansGetPostMeta.php | 105 ++++++++++++++++++ 3 files changed, 178 insertions(+), 8 deletions(-) create mode 100644 tests/phpunit/integration/api/post-meta/beansGetPostMeta.php create mode 100644 tests/phpunit/unit/api/post-meta/beansGetPostMeta.php diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index 66f245fd..5e086dac 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -4,23 +4,23 @@ * * @package Beans\Framework\API\Post_Meta * - * @since 1.0.0 + * @since 1.0.0 */ /** - * Get the current post meta value. + * Get the post's meta value. When no post ID is given, get the current post's meta value. * * This function is a shortcut of {@link http://codex.wordpress.org/Function_Reference/get_post_meta get_post_meta()}. * * @since 1.0.0 * - * @param string $field_id The post meta id searched. - * @param mixed $default Optional. The default value to return of the post meta value doesn't exist. - * @param int $post_id Optional. Overwrite the current post id. + * @param string $meta_key The post meta id searched. + * @param mixed $default Optional. The default value to return of the post meta value doesn't exist. + * @param int|string|false $post_id Optional. Overwrite the current post id. * * @return mixed Saved data if exist, otherwise default value set. */ -function beans_get_post_meta( $field_id, $default = false, $post_id = false ) { +function beans_get_post_meta( $meta_key, $default = false, $post_id = false ) { if ( ! $post_id ) { $id = get_the_id(); @@ -29,8 +29,8 @@ function beans_get_post_meta( $field_id, $default = false, $post_id = false ) { $post_meta = get_post_meta( $post_id ); - if ( isset( $post_meta[ $field_id ] ) ) { - return get_post_meta( $post_id, $field_id, true ); + if ( isset( $post_meta[ $meta_key ] ) ) { + return get_post_meta( $post_id, $meta_key, true ); } return $default; diff --git a/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php b/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php new file mode 100644 index 00000000..00ca1785 --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php @@ -0,0 +1,65 @@ +post->create( array( 'post_title' => 'Hello Beans' ) ); + update_post_meta( $post_id, 'foo', 'foo' ); + + $this->assertFalse( beans_get_post_meta( 'beans_layout', false, $post_id ) ); + $this->assertSame( '', beans_get_post_meta( 'beans_layout', '', $post_id ) ); + $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c', $post_id ) ); + } + + /** + * Test beans_get_post_meta() should get the post ID when none is provided. + */ + public function test_should_get_post_id_when_none_is_provided() { + $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); + $_GET['post'] = $post_id; + $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); + unset( $_GET['post'] ); + + $this->go_to( get_permalink( $post_id ) ); + $this->assertSame( 'c_sp', beans_get_post_meta( 'beans_layout', 'c_sp' ) ); + } + + /** + * Test beans_get_post_meta() should return the post's meta value. + */ + public function test_should_return_post_meta_value() { + $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); + update_post_meta( $post_id, 'beans_layout', 'c_sp' ); + $this->assertSame( 'c_sp', beans_get_post_meta( 'beans_layout', false, $post_id ) ); + + $_GET['post'] = $post_id; + update_post_meta( $post_id, 'beans_layout', 'default_fallback' ); + $this->assertSame( 'default_fallback', beans_get_post_meta( 'beans_layout', 'c' ) ); + unset( $_GET['post'] ); + + update_post_meta( $post_id, 'beans_layout', 'sp_c' ); + $this->go_to( get_permalink( $post_id ) ); + $this->assertSame( 'sp_c', beans_get_post_meta( 'beans_layout' ) ); + } +} diff --git a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php new file mode 100644 index 00000000..0fa4e09e --- /dev/null +++ b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php @@ -0,0 +1,105 @@ +with( 1 )->times( 3 )->andReturn( array() ); + + $this->assertFalse( beans_get_post_meta( 'beans_layout', false, 1 ) ); + $this->assertSame( '', beans_get_post_meta( 'beans_layout', '', 1 ) ); + $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c', 1 ) ); + } + + /** + * Test beans_get_post_meta() should get the post ID when none is provided. + */ + public function test_should_get_post_id_when_none_is_provided() { + Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 47 ); + Monkey\Functions\expect( 'get_post_meta' )->with( 47 )->once()->andReturn( array() ); + $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); + + $_GET['post'] = '18'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; + Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 0 ); + Monkey\Functions\expect( 'get_post_meta' )->with( '18' )->once()->andReturn( array() ); + $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); + unset( $_GET['post'] ); + } + + /** + * Test beans_get_post_meta() should return the post's meta value. + */ + public function test_should_return_post_meta_value() { + Monkey\Functions\expect( 'get_post_meta' ) + ->with( 521 ) + ->once() + ->ordered() + ->andReturn( array( 'beans_layout' => 'c_sp' ) ) + ->andAlsoExpectIt() + ->with( 521, 'beans_layout', true ) + ->once() + ->ordered() + ->andReturn( 'c_sp' ); + $this->assertSame( 'c_sp', beans_get_post_meta( 'beans_layout', false, 521 ) ); + + Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 47 ); + Monkey\Functions\expect( 'get_post_meta' ) + ->with( 47 ) + ->once() + ->ordered() + ->andReturn( array( 'beans_layout' => 'sp_c' ) ) + ->andAlsoExpectIt() + ->with( 47, 'beans_layout', true ) + ->once() + ->ordered() + ->andReturn( 'sp_c' ); + $this->assertSame( 'sp_c', beans_get_post_meta( 'beans_layout' ) ); + + $_GET['post'] = '18'; + require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; + Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 0 ); + Monkey\Functions\expect( 'get_post_meta' ) + ->with( '18' ) + ->once() + ->ordered() + ->andReturn( array( 'beans_layout' => 'default_fallback' ) ) + ->andAlsoExpectIt() + ->with( '18', 'beans_layout', true ) + ->once() + ->ordered() + ->andReturn( 'default_fallback' ); + $this->assertSame( 'default_fallback', beans_get_post_meta( 'beans_layout', 'c' ) ); + unset( $_GET['post'] ); + } +} From 63d44bd420b1a24b7c7d8213e867b7541b261667 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Mon, 26 Feb 2018 15:03:40 -0500 Subject: [PATCH 154/800] Fixed spacing in DocBlock (#136) --- lib/api/wp-customize/class.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/api/wp-customize/class.php b/lib/api/wp-customize/class.php index 73035ee2..a8ab9f22 100644 --- a/lib/api/wp-customize/class.php +++ b/lib/api/wp-customize/class.php @@ -2,17 +2,17 @@ /** * This class handles the Beans WP Customize workflow. * - * @package Beans\Framework\Api\WP_Customize + * @package Beans\Framework\API\WP_Customize * - * @since 1.0.0 + * @since 1.0.0 */ /** * Handle the Beans WP Customize workflow. * - * @since 1.0.0 + * @since 1.0.0 * @ignore - * @access private + * @access private * * @package Beans\Framework\API\WP_Customize */ @@ -59,7 +59,6 @@ public function __construct( $section, $args ) { * * @since 1.0.0 * @ignore - * @access private * * @return void */ @@ -86,7 +85,6 @@ private function add() { * * @since 1.0.0 * @ignore - * @access private * * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. * @@ -113,7 +111,6 @@ private function add_section( $wp_customize ) { * * @since 1.0.0 * @ignore - * @access private * * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. * @param array $field Metabox settings. @@ -146,7 +143,6 @@ private function add_setting( $wp_customize, $field ) { * * @since 1.0.0 * @ignore - * @access private * * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. * @param array $field Metabox settings. @@ -191,10 +187,12 @@ public function sanitize( $value ) { /** * Render Beans fields content for WP Customize. * - * @since 1.0.0 + * @since 1.0.0 * * @ignore - * @access private + * @access private + * + * @package Beans\Framework\API\WP_Customize */ class _Beans_WP_Customize_Control extends WP_Customize_Control { // @codingStandardsIgnoreLine - Generic.Files.OneClassPerFile.MultipleFound. From ffb8208688237fae81b1c4180a51f637d010e6ff Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 28 Feb 2018 00:46:49 -0500 Subject: [PATCH 155/800] Made lib\assets\assets.php WPCS compliant (#141) --- lib/assets/assets.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/assets/assets.php b/lib/assets/assets.php index 5dba1bb5..e0cd9704 100644 --- a/lib/assets/assets.php +++ b/lib/assets/assets.php @@ -2,19 +2,22 @@ /** * Add Beans assets. * - * @package Assets + * @package Beans\Framework\Assets + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_uikit_enqueue_scripts', 'beans_enqueue_uikit_components', 5 ); /** - * Enqueue UIKit components and Beans style. + * Enqueue UIkit components and Beans style. * * Beans style is enqueued with the UIKit components to have access to UIKit LESS variables. * * @since 1.0.0 + * + * @return void */ function beans_enqueue_uikit_components() { - $core = array( 'base', 'block', @@ -42,20 +45,19 @@ function beans_enqueue_uikit_components() { beans_uikit_enqueue_components( $core, 'core', false ); - // Include uikit default theme. + // Include UIkit default theme. beans_uikit_enqueue_theme( 'default' ); - // Enqueue uikit overwrite theme folder. + // Enqueue UIkit overwrite theme folder. beans_uikit_enqueue_theme( 'beans', BEANS_ASSETS_PATH . 'less/uikit-overwrite' ); - // Add the theme style as a uikit fragment to have access to all the variables. + // Add the theme style as a UIkit fragment to have access to all the variables. beans_compiler_add_fragment( 'uikit', BEANS_ASSETS_PATH . 'less/style.less', 'less' ); - // Add the theme default style as a uikit fragment only if the theme supports it. + // Add the theme default style as a UIkit fragment only if the theme supports it. if ( current_theme_supports( 'beans-default-styling' ) ) { beans_compiler_add_fragment( 'uikit', BEANS_ASSETS_PATH . 'less/default.less', 'less' ); } - } beans_add_smart_action( 'wp_enqueue_scripts', 'beans_enqueue_assets', 5 ); @@ -63,13 +65,14 @@ function beans_enqueue_uikit_components() { * Enqueue Beans assets. * * @since 1.0.0 + * + * @return void */ function beans_enqueue_assets() { if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } - } beans_add_smart_action( 'after_setup_theme', 'beans_add_editor_assets' ); @@ -77,9 +80,9 @@ function beans_enqueue_assets() { * Add Beans editor assets. * * @since 1.2.5 + * + * @return void */ function beans_add_editor_assets() { - add_editor_style( BEANS_ASSETS_URL . 'css/editor' . BEANS_MIN_CSS . '.css' ); - } From 518e80362cd80211117eade9df4680459aa15aa4 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Wed, 28 Feb 2018 13:16:21 -0600 Subject: [PATCH 156/800] Upgrade PHPCS/WPCS (#145) 1. Updated composer.json to allow using PHPCS 3.2 version. 2. Replaced all deprecated @coding... inline ignore with the new syntax. 3. Standardized the ignore rule to be: phpcs:ignore Rule.Being.Ignored -- Reason why we are ignoring the rule. Closes #144 --- composer.json | 12 +-- .../actions/class-beans-anonymous-action.php | 2 +- lib/api/compiler/class-page-compiler.php | 2 +- lib/api/init.php | 2 +- lib/api/utilities/functions.php | 10 +-- lib/api/utilities/polyfills.php | 2 +- lib/api/widget/functions.php | 89 ++++++++++--------- lib/api/wp-customize/class.php | 10 +-- .../includes/class-actions-test-case.php | 2 +- .../includes/class-filters-test-case.php | 2 +- tests/phpunit/integration/bootstrap.php | 8 +- .../unit/api/actions/beansRenderAction.php | 2 +- .../api/actions/stubs/class-action-stub.php | 2 +- .../api/utilities/beansRenderFunction.php | 6 +- .../utilities/beansRenderFunctionArray.php | 6 +- tests/phpunit/unit/bootstrap.php | 6 +- tests/phpunit/unit/class-test-case.php | 3 +- 17 files changed, 85 insertions(+), 81 deletions(-) diff --git a/composer.json b/composer.json index bebdc6db..1d0d9e30 100644 --- a/composer.json +++ b/composer.json @@ -41,13 +41,15 @@ "roave/security-advisories": "dev-master" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3", + "php": "^5.6|^7", + "brain/monkey": "^2.2", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "mikey179/vfsStream": "^1.6", + "phpunit/phpunit": "~5.7.9", "sirbrillig/phpcs-variable-analysis": "^2.0", + "squizlabs/php_codesniffer": "^3.2", "wimg/php-compatibility": "^8.0", - "wp-coding-standards/wpcs": "^0.14.0", - "phpunit/phpunit": "~4.8 || ~5.7.9", - "brain/monkey": "^2.0", - "mikey179/vfsStream": "^1.6", + "wp-coding-standards/wpcs": "^0.14.1", "xwp/wp-dev-lib": "^1.0.1" }, "config": { diff --git a/lib/api/actions/class-beans-anonymous-action.php b/lib/api/actions/class-beans-anonymous-action.php index 5c435042..43be47ea 100644 --- a/lib/api/actions/class-beans-anonymous-action.php +++ b/lib/api/actions/class-beans-anonymous-action.php @@ -51,6 +51,6 @@ public function __construct( $hook, array $callback, $priority = 10, $number_arg * @return void */ public function callback() { - echo call_user_func_array( $this->callback[0], $this->callback[1] ); // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: the callback should escape the output. + echo call_user_func_array( $this->callback[0], $this->callback[1] ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- The callback should escape the output. } } diff --git a/lib/api/compiler/class-page-compiler.php b/lib/api/compiler/class-page-compiler.php index ab2980b8..74ec19b1 100644 --- a/lib/api/compiler/class-page-compiler.php +++ b/lib/api/compiler/class-page-compiler.php @@ -186,7 +186,7 @@ public function dequeue_scripts() { } // Add localized content since it was removed with dequeue scripts. - printf( "\n", $localized ); // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped. + printf( "\n", $localized ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Needs review. } } diff --git a/lib/api/init.php b/lib/api/init.php index c64df2aa..8fef4a43 100644 --- a/lib/api/init.php +++ b/lib/api/init.php @@ -18,7 +18,7 @@ // Mode. if ( ! defined( 'SCRIPT_DEBUG' ) ) { - define( 'SCRIPT_DEBUG', false ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound. + define( 'SCRIPT_DEBUG', false ); // @phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Valid use case as we need it defined. } // Assets. diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 378c8572..a0857010 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -86,11 +86,11 @@ function beans_remove_dir( $dir_path ) { if ( is_dir( $path ) ) { beans_remove_dir( $path ); } else { - @unlink( $path ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + @unlink( $path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } - return @rmdir( $dir_path ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + return @rmdir( $dir_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } /** @@ -294,7 +294,7 @@ function beans_sanitize_path( $path ) { function beans_get( $needle, $haystack = false, $default = null ) { if ( false === $haystack ) { - $haystack = $_GET; // @codingStandardsIgnoreLine - WordPress.CSRF.NonceVerification.NoNonceVerification as the nonce verification check should be at the form processing level. + $haystack = $_GET; // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- The nonce verification check should be at the form processing level. } $haystack = (array) $haystack; @@ -317,7 +317,7 @@ function beans_get( $needle, $haystack = false, $default = null ) { * @return string Returns the value if found; else $default is returned. */ function beans_post( $needle, $default = null ) { - return beans_get( $needle, $_POST, $default ); // @codingStandardsIgnoreLine - WordPress.CSRF.NonceVerification.NoNonceVerification as the nonce verification check should be at the form processing level. + return beans_get( $needle, $_POST, $default ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- The nonce verification check should be at the form processing level. } /** @@ -360,7 +360,7 @@ function beans_get_or_post( $needle, $default = null ) { */ function beans_in_multi_array( $needle, $haystack, $strict = false ) { - if ( in_array( $needle, $haystack, $strict ) ) { // @codingStandardsIgnoreLine - WordPress.PHP.StrictInArray.MissingTrueStrict requires 3rd argument to be true or false and not a variable. + if ( in_array( $needle, $haystack, $strict ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- The rule does not account for when we are passing a boolean within a variable as the 3rd argument. return true; } diff --git a/lib/api/utilities/polyfills.php b/lib/api/utilities/polyfills.php index 8d1c3069..8017ad05 100644 --- a/lib/api/utilities/polyfills.php +++ b/lib/api/utilities/polyfills.php @@ -42,7 +42,7 @@ function array_replace_recursive( array $array1, array $array2 ) { $from_base = beans_get( $key, $array1 ); if ( is_array( $value ) && is_array( $from_base ) ) { - $array1[ $key ] = array_replace_recursive( $from_base, $value ); // @codingStandardsIgnoreLine - PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound) - Sniffer is not picking up the polyfill. + $array1[ $key ] = array_replace_recursive( $from_base, $value ); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound -- This polyfill provides the construct for PHP 5.2. } else { $array1[ $key ] = $value; } diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 18a5ea0b..8739b2b2 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -26,18 +26,18 @@ * @since 1.0.0 * * @param array $args { - * Optional. Arguments used by the widget area. - * - * @type string $id Optional. The unique identifier by which the widget area will be called. - * @type string $name Optional. The name or title of the widget area displayed in the - * admin dashboard. - * @type string $description Optional. The widget area description. - * @type string $beans_type Optional. The widget area type. Accepts 'stack', 'grid' or 'offcanvas'. - * Default stack. - * @type bool $beans_show_widget_title Optional. Whether to show the widget title or not. Default true. - * @type bool $beans_show_widget_badge Optional. Whether to show the widget badge or not. Default false. - * @type bool $beans_widget_badge_content Optional. The badge content. This may contain widget shortcodes - * {@see beans_widget_shortcodes()}. Default 'Hello'. + * Optional. Arguments used by the widget area. + * + * @type string $id Optional. The unique identifier by which the widget area will be called. + * @type string $name Optional. The name or title of the widget area displayed in the + * admin dashboard. + * @type string $description Optional. The widget area description. + * @type string $beans_type Optional. The widget area type. Accepts 'stack', 'grid' or 'offcanvas'. + * Default is stack. + * @type bool $beans_show_widget_title Optional. Whether to show the widget title or not. Default true. + * @type bool $beans_show_widget_badge Optional. Whether to show the widget badge or not. Default false. + * @type bool $beans_widget_badge_content Optional. The badge content. This may contain widget shortcodes + * {@see beans_widget_shortcodes()}. Default is 'Hello'. * } * @param array $widget_control Optional. * @@ -111,8 +111,8 @@ function beans_is_active_widget_area( $id ) { /** * Check whether a widget area is registered. * - * While {@see beans_is_active_widget_area()} checks if a widget area contains widgets, this function only checks if a widget - * area is registered. + * While {@see beans_is_active_widget_area()} checks if a widget area contains widgets, this function only checks if a + * widget area is registered. * * @since 1.0.0 * @@ -155,16 +155,16 @@ function beans_widget_area( $id ) { */ do_action( 'beans_widget_area_init' ); - ob_start(); + ob_start(); - /** - * Fires when {@see beans_widget_area()} is called. - * - * @since 1.0.0 - */ - do_action( 'beans_widget_area' ); + /** + * Fires when {@see beans_widget_area()} is called. + * + * @since 1.0.0 + */ + do_action( 'beans_widget_area' ); - $output = ob_get_clean(); + $output = ob_get_clean(); // Reset widget area global to reduce memory usage. _beans_reset_widget_area(); @@ -321,7 +321,7 @@ function beans_widget_shortcodes( $content ) { /** * Set up widget area global data. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * @@ -337,12 +337,15 @@ function _beans_setup_widget_area( $id ) { } // Add widget area delimiters. This is used to split wp sidebar as well as the widgets title. - $wp_registered_sidebars[ $id ] = array_merge( $wp_registered_sidebars[ $id ], array( // @codingStandardsIgnoreLine - WordPress.Variables.GlobalVariables.OverrideProhibited. - 'before_widget' => '', - 'after_widget' => '', - 'before_title' => '', - 'after_title' => '', - ) ); + $wp_registered_sidebars[ $id ] = array_merge( // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case. + $wp_registered_sidebars[ $id ], + array( + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '', + 'after_title' => '', + ) + ); // Start building widget area global before dynamic_sidebar is called. $_beans_widget_area = $wp_registered_sidebars[ $id ]; @@ -359,7 +362,7 @@ function _beans_setup_widget_area( $id ) { // Prepare widgets count. preg_match_all( '##', $sidebar, $counter ); - // Continue building widget area global with the splited sidebar elements. + // Continue building widget area global with the split sidebar elements. $_beans_widget_area['widgets_count'] = count( $counter[0] ); $_beans_widget_area['current_widget'] = 0; @@ -376,7 +379,7 @@ function _beans_setup_widget_area( $id ) { /** * Setup widget area global widgets data. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * @@ -478,7 +481,7 @@ function _beans_setup_widgets( $widget_area_content ) { /** * Setup widget global data. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * @@ -495,7 +498,7 @@ function _beans_setup_widget( $id ) { /** * Reset widget area global data. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * @@ -508,7 +511,7 @@ function _beans_reset_widget_area() { /** * Reset widget global data. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * @@ -519,13 +522,13 @@ function _beans_reset_widget() { } /** - * Build widget area subfilters. + * Build widget area sub-filters. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * - * @return array + * @return string */ function _beans_widget_area_subfilters() { global $_beans_widget_area; @@ -535,13 +538,13 @@ function _beans_widget_area_subfilters() { } /** - * Build widget subfilters. + * Build widget sub-filters. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * - * @return array + * @return string */ function _beans_widget_subfilters() { global $_beans_widget_area, $_beans_widget; @@ -559,13 +562,13 @@ function _beans_widget_subfilters() { /** * Force atypical widget added using the_widget() to have a correctly registered id. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * - * @param string $widget The widget's PHP class name (see class-wp-widget.php). + * @param string $widget The widget's PHP class name (see class-wp-widget.php). * @param array $instance Optional. The widget's instance settings. Default empty array. - * @param array $args Array of arguments to configure the display of the widget. + * @param array $args Array of arguments to configure the display of the widget. * * @return void */ diff --git a/lib/api/wp-customize/class.php b/lib/api/wp-customize/class.php index a8ab9f22..ef828ddc 100644 --- a/lib/api/wp-customize/class.php +++ b/lib/api/wp-customize/class.php @@ -36,7 +36,7 @@ final class _Beans_WP_Customize { * Constructor. * * @param string $section Field section. - * @param array $args Metabox arguments. + * @param array $args Meta box arguments. */ public function __construct( $section, $args ) { $defaults = array( @@ -113,7 +113,7 @@ private function add_section( $wp_customize ) { * @ignore * * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. - * @param array $field Metabox settings. + * @param array $field Meta box settings. * * @return void */ @@ -145,7 +145,7 @@ private function add_setting( $wp_customize, $field ) { * @ignore * * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. - * @param array $field Metabox settings. + * @param array $field Meta box settings. * * @return void */ @@ -170,7 +170,7 @@ private function add_control( $wp_customize, $field ) { } /** - * Sanatize value. + * Sanitize the value. * * @since 1.0.0 * @@ -194,7 +194,7 @@ public function sanitize( $value ) { * * @package Beans\Framework\API\WP_Customize */ - class _Beans_WP_Customize_Control extends WP_Customize_Control { // @codingStandardsIgnoreLine - Generic.Files.OneClassPerFile.MultipleFound. + class _Beans_WP_Customize_Control extends WP_Customize_Control { // phpcs:ignore Generic.Files.OneClassPerFile.MultipleFound, Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- Will be fixed. /** * Field data. diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index 6ff3ad3c..9d859a92 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -209,6 +209,6 @@ protected function go_to_post() { $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); $this->go_to( get_permalink( $post_id ) ); - do_action( 'template_redirect' ); // @codingStandardsIgnoreLine + do_action( 'template_redirect' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Valid use case as we need to fire this action as part of our tests. } } diff --git a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php index a62198e8..6e44a9c5 100644 --- a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php @@ -66,6 +66,6 @@ protected function check_parameters_registered_in_wp( array $filter, $remove_fil protected function go_to_post() { $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); $this->go_to( get_permalink( $post_id ) ); - do_action( 'template_redirect' ); // @codingStandardsIgnoreLine + do_action( 'template_redirect' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Valid use case as we need to fire this action as part of our tests. } } diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index b600ebd2..82bcba24 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -11,15 +11,15 @@ */ if ( ! file_exists( '../../../wp-content' ) ) { - trigger_error( 'Unable to run the integration tests, because the wp-content folder does not exist.', E_USER_ERROR ); // @codingStandardsIgnoreLine. + trigger_error( 'Unable to run the integration tests, because the wp-content folder does not exist.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. } define( 'BEANS_TESTS_DIR', __DIR__ ); define( 'BEANS_THEME_DIR', dirname( dirname( dirname( __DIR__ ) ) ) ); -define( 'WP_CONTENT_DIR', dirname( dirname( dirname( getcwd() ) ) ) . '/wp-content/' ); // @codingStandardsIgnoreLine. +define( 'WP_CONTENT_DIR', dirname( dirname( dirname( getcwd() ) ) ) . '/wp-content/' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Our tests need to define this constant. if ( ! defined( 'WP_PLUGIN_DIR' ) ) { - define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . 'plugins/' ); // @codingStandardsIgnoreLine. + define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . 'plugins/' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- When this constant is not already defined, we define it here. It's a valid use case for our testing suite. } /** @@ -44,7 +44,7 @@ function beans_get_wp_tests_dir() { // Check it again. If it doesn't exist, stop here and post a message as to why we stopped. if ( ! file_exists( $tests_dir . '/includes/' ) ) { - trigger_error( 'Unable to run the integration tests, because the WordPress test suite could not be located.', E_USER_ERROR ); // @codingStandardsIgnoreLine. + trigger_error( 'Unable to run the integration tests, because the WordPress test suite could not be located.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. } // Strip off the trailing directory separator, if it exists. diff --git a/tests/phpunit/unit/api/actions/beansRenderAction.php b/tests/phpunit/unit/api/actions/beansRenderAction.php index ef5ed2c6..cc08c385 100644 --- a/tests/phpunit/unit/api/actions/beansRenderAction.php +++ b/tests/phpunit/unit/api/actions/beansRenderAction.php @@ -61,7 +61,7 @@ public function test_should_return_after_calling_hook_no_subhook() { $this->assertEquals( $expected_args[ $args[0] ], $args[1] ); // Let's echo out to ensure this callback will was called. - echo $args[1][0]; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + echo $args[1][0]; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Not testing escaping functionality. }; add_action( 'beans_stub', $callback ); $this->assertTrue( has_action( 'beans_stub' ) ); diff --git a/tests/phpunit/unit/api/actions/stubs/class-action-stub.php b/tests/phpunit/unit/api/actions/stubs/class-action-stub.php index b44b4c80..626f6e75 100644 --- a/tests/phpunit/unit/api/actions/stubs/class-action-stub.php +++ b/tests/phpunit/unit/api/actions/stubs/class-action-stub.php @@ -36,6 +36,6 @@ public function dummy_method() { * @param string|int $message Message to echo. */ public static function echo_static( $message ) { - echo $message; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + echo $message; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Not testing escaping functionality. } } diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunction.php b/tests/phpunit/unit/api/utilities/beansRenderFunction.php index 85e92ea3..ba7edede 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunction.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunction.php @@ -56,12 +56,12 @@ public function test_should_work_with_arguments() { $this->assertSame( 'foo', beans_render_function( 'callback_for_render_function', 'foo' ) ); $callback = function ( $foo, $bar, $baz ) { - echo "{$foo} {$bar} {$baz}"; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + echo "{$foo} {$bar} {$baz}"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Not testing escaping functionality. }; $this->assertSame( 'foo bar baz', beans_render_function( $callback, 'foo', 'bar', 'baz' ) ); $callback = function ( $array, $baz ) { - echo join( ' ', $array ) . ' ' . $baz; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + echo join( ' ', $array ) . ' ' . $baz; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Not testing escaping functionality. }; $this->assertSame( 'foo bar baz', @@ -70,7 +70,7 @@ public function test_should_work_with_arguments() { $callback = function ( $object ) { $this->assertObjectHasAttribute( 'foo', $object ); - echo $object->foo; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + echo $object->foo; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Not testing escaping functionality. }; $this->assertSame( 'beans', diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php index f87be529..9c728366 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php @@ -51,7 +51,7 @@ public function test_should_work_when_no_arguments() { public function test_should_work_with_arguments() { $callback = function ( $foo, $bar, $baz ) { - echo "{$foo} {$bar} {$baz}"; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + echo "{$foo} {$bar} {$baz}"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Not testing escaping functionality. }; $this->assertSame( 'foo bar baz', @@ -60,7 +60,7 @@ public function test_should_work_with_arguments() { $callback = function ( $array, $baz ) { $this->assertCount( 2, $array ); - echo join( ' ', $array ) . ' ' . $baz; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + echo join( ' ', $array ) . ' ' . $baz; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Not testing escaping functionality. }; $this->assertSame( 'foo bar baz', @@ -72,7 +72,7 @@ public function test_should_work_with_arguments() { $this->assertArrayHasKey( 'bar', $array1 ); $this->assertCount( 1, $array2 ); $this->assertArrayHasKey( 'baz', $array2 ); - echo $array1['foo']; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - reason: we are not testing escaping functionality. + echo $array1['foo']; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Not testing escaping functionality. }; $this->assertSame( 'oof', diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index 00451ab8..8f8ba81e 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -11,7 +11,7 @@ */ if ( version_compare( phpversion(), '5.6.0', '<' ) ) { - trigger_error( 'Beans Unit Tests require PHP 5.6 or higher.', E_USER_ERROR ); // @codingStandardsIgnoreLine. + trigger_error( 'Beans Unit Tests require PHP 5.6 or higher.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. } define( 'BEANS_TESTS_DIR', __DIR__ ); @@ -20,14 +20,14 @@ // Let's define ABSPATH as it is in WordPress, i.e. relative to the filesystem's WordPress root path. if ( ! defined( 'ABSPATH' ) ) { - define( 'ABSPATH', dirname( dirname( dirname( BEANS_THEME_DIR ) ) ) . '/' ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - ABSPATH is required. + define( 'ABSPATH', dirname( dirname( dirname( BEANS_THEME_DIR ) ) ) . '/' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Valid use case for our testing suite. } // Time to load Composer's autoloader. $beans_autoload_path = BEANS_THEME_DIR . 'vendor/'; if ( ! file_exists( $beans_autoload_path . 'autoload.php' ) ) { - trigger_error( 'Whoops, we need Composer before we start running tests. Please type: `composer install`. When done, try running `phpunit` again.', E_USER_ERROR ); // @codingStandardsIgnoreLine. + trigger_error( 'Whoops, we need Composer before we start running tests. Please type: `composer install`. When done, try running `phpunit` again.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. } require_once $beans_autoload_path . 'autoload.php'; unset( $beans_autoload_path ); diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index b92771c8..5a6abf18 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -39,8 +39,7 @@ protected function setUp() { } ); Functions\when( 'wp_json_encode' )->alias( function ( $array ) { - // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.json_encode_json_encode - we are mocking the function here. - return json_encode( $array ); + return json_encode( $array ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode -- Required as part of our mock. } ); } From 4b853321194261756627088e3be4b6e68c9e0622 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Feb 2018 15:41:48 -0600 Subject: [PATCH 157/800] Replaced deprecated phpcs rule ignores. --- tests/phpunit/integration/api/html/beansAddAttribute.php | 4 ++-- .../phpunit/integration/api/html/beansRemoveAttribute.php | 4 ++-- .../integration/api/html/beansReplaceAttribute.php | 8 ++++---- tests/phpunit/unit/api/html/beansAddAttribute.php | 4 ++-- tests/phpunit/unit/api/html/beansRemoveAttribute.php | 4 ++-- tests/phpunit/unit/api/html/beansReplaceAttribute.php | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php index 7d3c95c9..a0d717a1 100644 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -36,7 +36,7 @@ public function test_should_add_empty_value_when_no_value_given() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup_attributes; $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'add' ), 10 ); @@ -62,7 +62,7 @@ public function test_should_add_value_when_attribute_exists() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup['attributes']; $expected['class'] .= ' beans-test'; - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'add' ), 10 ); diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php index 26e9aa3b..0cbebe63 100644 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -37,7 +37,7 @@ public function test_should_remove_attribute_when_null_given() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; unset( $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'remove' ), 10 ); @@ -60,7 +60,7 @@ public function test_should_remove_the_given_value_from_attribute() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'remove' ), 10 ); diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index 521b9040..8f726d70 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -38,7 +38,7 @@ public function test_should_replace_existing_attribute_value() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); @@ -61,7 +61,7 @@ public function test_should_replace_all_attributes_when_no_value_given() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); @@ -84,7 +84,7 @@ public function test_should_replace_all_values_with_null_when_no_value_passed() $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = null; - $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertNull( $actual[ $attribute ] ); @@ -110,7 +110,7 @@ public function test_should_replace_all_values_when_empty_given() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = ''; - $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertSame( '', $actual[ $attribute ] ); diff --git a/tests/phpunit/unit/api/html/beansAddAttribute.php b/tests/phpunit/unit/api/html/beansAddAttribute.php index f6848bc6..1292cfb2 100644 --- a/tests/phpunit/unit/api/html/beansAddAttribute.php +++ b/tests/phpunit/unit/api/html/beansAddAttribute.php @@ -43,7 +43,7 @@ public function test_should_add_empty_value_when_no_value_given() { $this->assertTrue( has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup_attributes; $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'add' ), 10 ); @@ -75,7 +75,7 @@ public function test_should_add_value_when_attribute_exists() { $this->assertTrue( has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup['attributes']; $expected['class'] .= ' beans-test'; - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'add' ), 10 ); diff --git a/tests/phpunit/unit/api/html/beansRemoveAttribute.php b/tests/phpunit/unit/api/html/beansRemoveAttribute.php index 8d991520..8d1a0711 100644 --- a/tests/phpunit/unit/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/unit/api/html/beansRemoveAttribute.php @@ -44,7 +44,7 @@ public function test_should_remove_attribute_when_null_given() { $this->assertTrue( has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; unset( $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'remove' ), 10 ); @@ -73,7 +73,7 @@ public function test_should_remove_the_given_value_from_attribute() { $this->assertTrue( has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'remove' ), 10 ); diff --git a/tests/phpunit/unit/api/html/beansReplaceAttribute.php b/tests/phpunit/unit/api/html/beansReplaceAttribute.php index 51ba6d8b..20b114cd 100644 --- a/tests/phpunit/unit/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/unit/api/html/beansReplaceAttribute.php @@ -45,7 +45,7 @@ public function test_should_replace_existing_attribute_value() { $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); @@ -75,7 +75,7 @@ public function test_should_replace_all_attributes_when_no_value_given() { $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); @@ -104,7 +104,7 @@ public function test_should_replace_all_values_with_null_when_no_value_passed() $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = null; - $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertNull( $actual[ $attribute ] ); @@ -136,7 +136,7 @@ public function test_should_replace_all_values_when_empty_given() { $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = ''; - $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertSame( '', $actual[ $attribute ] ); From 62673b6f355c5889d2a08e9d22b80f618dbf7673 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Feb 2018 15:48:24 -0600 Subject: [PATCH 158/800] Fixed formatting. --- tests/phpunit/integration/api/html/beansReplaceAttribute.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index 8f726d70..e57581be 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -84,7 +84,7 @@ public function test_should_replace_all_values_with_null_when_no_value_passed() $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = null; - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertNull( $actual[ $attribute ] ); @@ -110,7 +110,7 @@ public function test_should_replace_all_values_when_empty_given() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = ''; - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertSame( '', $actual[ $attribute ] ); From 11e56b17429058ed2694cd6d8e12aee55fb79816 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Feb 2018 17:21:33 -0600 Subject: [PATCH 159/800] Replaced deprecated phpcs ignore syntax. --- lib/api/fields/functions.php | 43 +++++++++---------- lib/api/fields/types/text.php | 2 +- lib/api/fields/types/textarea.php | 2 +- lib/api/fields/types/views/activation.php | 2 +- lib/api/fields/types/views/checkbox.php | 2 +- .../fields/types/views/field-description.php | 2 +- lib/api/fields/types/views/image.php | 11 +++-- lib/api/fields/types/views/radio.php | 22 ++++++---- lib/api/fields/types/views/select.php | 4 +- lib/api/fields/types/views/slider.php | 2 +- .../api/html/beansAddAttribute.php | 4 +- .../api/html/beansRemoveAttribute.php | 4 +- .../api/html/beansReplaceAttribute.php | 8 ++-- .../unit/api/html/beansAddAttribute.php | 4 +- .../unit/api/html/beansRemoveAttribute.php | 4 +- .../unit/api/html/beansReplaceAttribute.php | 8 ++-- 16 files changed, 65 insertions(+), 59 deletions(-) diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 845c9583..4c998dbb 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -15,24 +15,23 @@ * @since 1.0.0 * * @param array $fields { - * Array of fields to register. - * - * @type string $id A unique id used for the field. This id will also be used to save the value in the - * database. - * @type string $type The type of field to use. Please refer to the Beans core field types for more - * information. Custom field types are accepted here. - * @type string $label The field label. Default false. - * @type string $description The field description. The description can be truncated using as a delimiter. - * Default false. - * @type array $attributes An array of attributes to add to the field. The array key defines the attribute name and - * the array value defines the attribute value. Default array. - * @type mixed $default The default field value. Default false. - * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the - * {@see beans_register_fields()} $fields arguments. - * @type bool $db_group Must only be used for the 'group' field type. It defines whether the group of fields - * should be saved as a group or as individual entries in the database. Default false. + * Array of fields to register. + * + * @type string $id A unique id used for the field. This id will also be used to save the value in the + * database. + * @type string $type The type of field to use. Please refer to the Beans core field types for more + * information. Custom field types are accepted here. + * @type string $label The field label. Default false. + * @type string $description The field description. The description can be truncated using as a + * delimiter. Default false. + * @type array $attributes An array of attributes to add to the field. The array key defines the attribute name + * and the array value defines the attribute value. Default array. + * @type mixed $default The default field value. Default false. + * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the + * {@see beans_register_fields()} $fields arguments. + * @type bool $db_group Must only be used for the 'group' field type. It defines whether the group of fields + * should be saved as a group or as individual entries in the database. Default false. * } - * * @param string $context The context in which the fields are used. 'option' for options/settings pages, * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP * customizer fields. @@ -61,11 +60,11 @@ function beans_register_fields( array $fields, $context, $section ) { * * @since 1.0.0 * - * @param string $context The context in which the fields are used. 'option' for options/settings pages, 'post_meta' - * for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP customizer - * fields. - * @param string $section Optional. A section ID to define a group of fields. This is mostly used for metaboxes and WP - * Customizer sections. + * @param string $context The context in which the fields are used. 'option' for options/settings pages, + * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP + * customizer fields. + * @param string|bool $section Optional. A section ID to define a group of fields. This is mostly used for metaboxes + * and WP Customizer sections. * * @return array|bool Array of registered fields on success, false on failure. */ diff --git a/lib/api/fields/types/text.php b/lib/api/fields/types/text.php index dc4eda6d..13c71c1b 100644 --- a/lib/api/fields/types/text.php +++ b/lib/api/fields/types/text.php @@ -26,6 +26,6 @@ function beans_field_text( array $field ) { esc_attr( $field['id'] ), esc_attr( $field['name'] ), esc_attr( $field['value'] ), - beans_esc_attributes( $field['attributes'] ) // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - Escaping is handled in the function. + beans_esc_attributes( $field['attributes'] ) // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function. ); } diff --git a/lib/api/fields/types/textarea.php b/lib/api/fields/types/textarea.php index 3926f6a9..b64966e5 100644 --- a/lib/api/fields/types/textarea.php +++ b/lib/api/fields/types/textarea.php @@ -25,7 +25,7 @@ function beans_field_textarea( array $field ) { printf( '', esc_attr( $field['id'] ), esc_attr( $field['name'] ), - beans_esc_attributes( $field['attributes'] ), // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - Escaping is handled in the function. + beans_esc_attributes( $field['attributes'] ), // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function. esc_textarea( $field['value'] ) ); } diff --git a/lib/api/fields/types/views/activation.php b/lib/api/fields/types/views/activation.php index 0a6698bf..3d0ab8af 100644 --- a/lib/api/fields/types/views/activation.php +++ b/lib/api/fields/types/views/activation.php @@ -11,4 +11,4 @@ ?> - /> + /> diff --git a/lib/api/fields/types/views/checkbox.php b/lib/api/fields/types/views/checkbox.php index 4c14b841..89cc2e83 100644 --- a/lib/api/fields/types/views/checkbox.php +++ b/lib/api/fields/types/views/checkbox.php @@ -11,7 +11,7 @@ ?> - /> + /> diff --git a/lib/api/fields/types/views/field-description.php b/lib/api/fields/types/views/field-description.php index 485708ed..711a5e9d 100644 --- a/lib/api/fields/types/views/field-description.php +++ b/lib/api/fields/types/views/field-description.php @@ -11,4 +11,4 @@ ?>
    - + diff --git a/lib/api/fields/types/views/image.php b/lib/api/fields/types/views/image.php index 661a0651..352aac51 100644 --- a/lib/api/fields/types/views/image.php +++ b/lib/api/fields/types/views/image.php @@ -8,6 +8,7 @@ * @since 1.5.0 Moved to view file. */ +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variables are used within a function's scope. ?> @@ -22,12 +23,12 @@ continue; } - $attributes = _beans_get_image_id_attributes( $image_id, $field, $is_multiple ); // @codingStandardsIgnoreLine. WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound - Called from within a function and not within global scope. - $image_url = _beans_get_image_url( $image_id ); // @codingStandardsIgnoreLine. WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound - Called from within a function and not within global scope. - $image_alt = $image_url ? _beans_get_image_alt( $image_id ) : ''; // @codingStandardsIgnoreLine. WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound - Called from within a function and not within global scope. + $attributes = _beans_get_image_id_attributes( $image_id, $field, $is_multiple ); + $image_url = _beans_get_image_url( $image_id ); + $image_alt = $image_url ? _beans_get_image_alt( $image_id ) : ''; ?>
    - /> + /> <?php echo $image_alt ? esc_attr( $image_alt ) : ''; ?>
    +
    @@ -15,27 +16,28 @@ $radio ) : // @codingStandardsIgnoreLine. WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound - Called from within a function and not within global scope. - $is_image = _beans_is_radio_image( $radio ); // @codingStandardsIgnoreLine. WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound - Called from within a function and not within global scope. +foreach ( $field['options'] as $value => $radio ) : + $is_image = _beans_is_radio_image( $radio ); // Clean the value here to avoid calling esc_attr() again and again for the same value. - $clean_value = esc_attr( $value ); // @codingStandardsIgnoreLine. WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound - Called from within a function and not within global scope. - $clean_id = $id_prefix . $clean_value; // @codingStandardsIgnoreLine. WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound - Called from within a function and not within global scope. + $clean_value = esc_attr( $value ); + $clean_id = $id_prefix . $clean_value; ?> -
    + -> + $label ) : // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Called from within a function and not within global scope. ?> diff --git a/lib/api/fields/types/views/slider.php b/lib/api/fields/types/views/slider.php index e7385b8d..44c93525 100644 --- a/lib/api/fields/types/views/slider.php +++ b/lib/api/fields/types/views/slider.php @@ -11,7 +11,7 @@ ?>
    - /> + />
    diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php index 7d3c95c9..a0d717a1 100644 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -36,7 +36,7 @@ public function test_should_add_empty_value_when_no_value_given() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup_attributes; $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'add' ), 10 ); @@ -62,7 +62,7 @@ public function test_should_add_value_when_attribute_exists() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup['attributes']; $expected['class'] .= ' beans-test'; - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'add' ), 10 ); diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php index 26e9aa3b..0cbebe63 100644 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -37,7 +37,7 @@ public function test_should_remove_attribute_when_null_given() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; unset( $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'remove' ), 10 ); @@ -60,7 +60,7 @@ public function test_should_remove_the_given_value_from_attribute() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'remove' ), 10 ); diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index 521b9040..e57581be 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -38,7 +38,7 @@ public function test_should_replace_existing_attribute_value() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); @@ -61,7 +61,7 @@ public function test_should_replace_all_attributes_when_no_value_given() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); @@ -84,7 +84,7 @@ public function test_should_replace_all_values_with_null_when_no_value_passed() $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = null; - $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertNull( $actual[ $attribute ] ); @@ -110,7 +110,7 @@ public function test_should_replace_all_values_when_empty_given() { $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = ''; - $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertSame( '', $actual[ $attribute ] ); diff --git a/tests/phpunit/unit/api/html/beansAddAttribute.php b/tests/phpunit/unit/api/html/beansAddAttribute.php index f6848bc6..1292cfb2 100644 --- a/tests/phpunit/unit/api/html/beansAddAttribute.php +++ b/tests/phpunit/unit/api/html/beansAddAttribute.php @@ -43,7 +43,7 @@ public function test_should_add_empty_value_when_no_value_given() { $this->assertTrue( has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup_attributes; $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'add' ), 10 ); @@ -75,7 +75,7 @@ public function test_should_add_value_when_attribute_exists() { $this->assertTrue( has_filter( $hook, array( $attributes, 'add' ), 10 ) ); $expected = $markup['attributes']; $expected['class'] .= ' beans-test'; - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'add' ), 10 ); diff --git a/tests/phpunit/unit/api/html/beansRemoveAttribute.php b/tests/phpunit/unit/api/html/beansRemoveAttribute.php index 8d991520..8d1a0711 100644 --- a/tests/phpunit/unit/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/unit/api/html/beansRemoveAttribute.php @@ -44,7 +44,7 @@ public function test_should_remove_attribute_when_null_given() { $this->assertTrue( has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; unset( $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'remove' ), 10 ); @@ -73,7 +73,7 @@ public function test_should_remove_the_given_value_from_attribute() { $this->assertTrue( has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'remove' ), 10 ); diff --git a/tests/phpunit/unit/api/html/beansReplaceAttribute.php b/tests/phpunit/unit/api/html/beansReplaceAttribute.php index 51ba6d8b..20b114cd 100644 --- a/tests/phpunit/unit/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/unit/api/html/beansReplaceAttribute.php @@ -45,7 +45,7 @@ public function test_should_replace_existing_attribute_value() { $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); @@ -75,7 +75,7 @@ public function test_should_replace_all_attributes_when_no_value_given() { $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. remove_filter( $hook, array( $attributes, 'replace' ), 10 ); @@ -104,7 +104,7 @@ public function test_should_replace_all_values_with_null_when_no_value_passed() $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = null; - $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertNull( $actual[ $attribute ] ); @@ -136,7 +136,7 @@ public function test_should_replace_all_values_when_empty_given() { $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); $expected = $markup['attributes']; $expected[ $attribute ] = ''; - $actual = apply_filters( $hook, $markup['attributes'] ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound The hook's name is in the value. + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( $expected, $actual ); $this->assertNotSame( $value, $actual[ $attribute ] ); $this->assertSame( '', $actual[ $attribute ] ); From e016cde923c35d83088322213b8c6e6c130594a7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Feb 2018 20:04:44 -0600 Subject: [PATCH 160/800] Improved unit tests. 1. Removed the public API functions unit tests. 2. Added individual method unit tests for _Beans_Attribute. 3. Added unit tests for _beans_is_html_dev_mode(). --- lib/api/html/class-beans-attribute.php | 19 ++- lib/api/html/functions.php | 5 +- .../unit/api/html/beans-attribute/add.php | 68 ++++++++ .../unit/api/html/beans-attribute/init.php | 47 ++++++ .../unit/api/html/beans-attribute/remove.php | 105 +++++++++++++ .../unit/api/html/beans-attribute/replace.php | 122 +++++++++++++++ .../unit/api/html/beansAddAttribute.php | 84 ---------- .../unit/api/html/beansIsHtmlDevMode.php | 52 ++++++ .../unit/api/html/beansRemoveAttribute.php | 82 ---------- .../unit/api/html/beansReplaceAttribute.php | 148 ------------------ 10 files changed, 412 insertions(+), 320 deletions(-) create mode 100644 tests/phpunit/unit/api/html/beans-attribute/add.php create mode 100644 tests/phpunit/unit/api/html/beans-attribute/init.php create mode 100644 tests/phpunit/unit/api/html/beans-attribute/remove.php create mode 100644 tests/phpunit/unit/api/html/beans-attribute/replace.php delete mode 100644 tests/phpunit/unit/api/html/beansAddAttribute.php create mode 100644 tests/phpunit/unit/api/html/beansIsHtmlDevMode.php delete mode 100644 tests/phpunit/unit/api/html/beansRemoveAttribute.php delete mode 100644 tests/phpunit/unit/api/html/beansReplaceAttribute.php diff --git a/lib/api/html/class-beans-attribute.php b/lib/api/html/class-beans-attribute.php index 869718ef..f62ceec9 100644 --- a/lib/api/html/class-beans-attribute.php +++ b/lib/api/html/class-beans-attribute.php @@ -52,10 +52,10 @@ final class _Beans_Attribute { * * @since 1.0.0 * - * @param string $id The markup ID. - * @param string $attribute Name of the HTML attribute. - * @param string|null $value Optional. Value of the HTML attribute (i.e. value to be replaced or removed). - * @param string|null $new_value Optional. Replacement (new) value of the HTML attribute. + * @param string $id The markup ID. + * @param string $attribute Name of the HTML attribute. + * @param string|null $value Optional. Value of the HTML attribute (i.e. value to be replaced or removed). + * @param string|null $new_value Optional. Replacement (new) value of the HTML attribute. */ public function __construct( $id, $attribute, $value = null, $new_value = null ) { $this->id = $id; @@ -72,9 +72,14 @@ public function __construct( $id, $attribute, $value = null, $new_value = null ) * * @param array $method Method to register as the callback for this filter. * - * @return self (for chaining) + * @return void|self (for chaining) */ public function init( $method ) { + + if ( ! method_exists( $this, $method ) ) { + return; + } + beans_add_filter( $this->id . '_attributes', array( $this, $method ) ); return $this; @@ -134,6 +139,10 @@ public function replace( array $attributes ) { */ public function remove( array $attributes ) { + if ( empty( $attributes ) ) { + return $attributes; + } + if ( ! $this->has_attribute( $attributes ) ) { return $attributes; } diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 4a3f14fe..5aa45775 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -611,7 +611,11 @@ function beans_remove_attribute( $id, $attribute, $value = null ) { /** * Check if development mode is enabled taking in consideration legacy constant. * + * @since 1.5.0 * @ignore + * @access private + * + * @return bool */ function _beans_is_html_dev_mode() { @@ -620,5 +624,4 @@ function _beans_is_html_dev_mode() { } return get_option( 'beans_dev_mode', false ); - } diff --git a/tests/phpunit/unit/api/html/beans-attribute/add.php b/tests/phpunit/unit/api/html/beans-attribute/add.php new file mode 100644 index 00000000..3b82a7b4 --- /dev/null +++ b/tests/phpunit/unit/api/html/beans-attribute/add.php @@ -0,0 +1,68 @@ + $markup ) { + $instance = new _Beans_Attribute( $beans_id, 'data-test', 'foo' ); + + // Check that the attribute does not exist before we add it. + $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); + + // Check that the attribute is added with the given value. + $expected = $markup['attributes']; + $expected['data-test'] = 'foo'; + $this->assertSame( $expected, $instance->add( $markup['attributes'] ) ); + } + + // Check it with an empty array. + $instance = new _Beans_Attribute( 'foo', 'data-test', 'test' ); + $actual = $instance->add( array() ); + $this->assertArrayHasKey( 'data-test', $actual ); + $this->assertSame( 'test', $actual['data-test'] ); + } + + /** + * Test add() should add the value to an existing attribute's values. + */ + public function test_should_add_value_to_existing_attribute_values() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $name = key( $markup['attributes'] ); + $instance = new _Beans_Attribute( $beans_id, $name, 'beans-test' ); + + // This test seems silly as we just grabbed the key above. But it's here to make a point that the attribute exists. + $this->assertArrayHasKey( $name, $markup['attributes'] ); + + // Check that the given value is appended to the end of the existing attribute. + $expected = $markup['attributes']; + $expected[ $name ] .= ' beans-test'; + $this->assertSame( $expected, $instance->add( $markup['attributes'] ) ); + } + } +} diff --git a/tests/phpunit/unit/api/html/beans-attribute/init.php b/tests/phpunit/unit/api/html/beans-attribute/init.php new file mode 100644 index 00000000..56d2ae87 --- /dev/null +++ b/tests/phpunit/unit/api/html/beans-attribute/init.php @@ -0,0 +1,47 @@ +assertNull( $instance->init( 'does_not_exist' ) ); + } + + /** + * Test init() should return register the callback when method exists. + */ + public function test_should_register_the_callback_when_method_exists() { + $instance = new _Beans_Attribute( 'foo', 'data-test' ); + + Monkey\Functions\expect( 'beans_add_filter' ) + ->with( 'foo_attributes', array( $instance, 'add' ) ) + ->once(); + + $this->assertSame( $instance, $instance->init( 'add' ) ); + } +} diff --git a/tests/phpunit/unit/api/html/beans-attribute/remove.php b/tests/phpunit/unit/api/html/beans-attribute/remove.php new file mode 100644 index 00000000..15ca3224 --- /dev/null +++ b/tests/phpunit/unit/api/html/beans-attribute/remove.php @@ -0,0 +1,105 @@ + 'http://example.com/image.png', + 'title' => 'Some cool image', + ); + + $instance = new _Beans_Attribute( 'beans_post', 'itemprop' ); + $this->assertArrayNotHasKey( 'itemprop', $attributes ); + $this->assertSame( $attributes, $instance->remove( $attributes ) ); + + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); + $instance = new _Beans_Attribute( 'beans_post', 'data-test', 'uk-panel-box', 'beans-test' ); + $this->assertArrayNotHasKey( 'data-test', $attributes ); + $this->assertSame( $attributes, $instance->remove( $attributes ) ); + } + + /** + * Test remove() should remove the attribute when the given value is null. + */ + public function test_should_remove_attribute_when_value_is_null() { + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); + + foreach ( $attributes as $name => $value ) { + $instance = new _Beans_Attribute( 'beans_post', $name, null ); + $this->assertArrayNotHasKey( $name, $instance->remove( $attributes ) ); + } + } + + /** + * Test remote() should remove the given value from the attribute. + */ + public function test_should_remove_the_given_value_from_attribute() { + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); + + $instance = new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box' ); + + // Check that it removed only that attribute. + $actual = $instance->remove( $attributes ); + $this->assertNotContains( 'uk-panel-box', $actual['class'] ); + $this->assertSame( 'uk-article category-beans', $actual['class'] ); + + // Check that only the class attribute is affected. + $expected = $attributes; + $expected['class'] = 'uk-article category-beans'; + $this->assertSame( $expected, $actual ); + } + + /** + * Test remove() should the empty array. + */ + public function test_should_return_original_empty_array() { + $instance = new _Beans_Attribute( 'beans_post', 'class', 'foo', 'beans-test' ); + $actual = $instance->remove( array() ); + + $this->assertSame( array(), $actual ); + } +} diff --git a/tests/phpunit/unit/api/html/beans-attribute/replace.php b/tests/phpunit/unit/api/html/beans-attribute/replace.php new file mode 100644 index 00000000..75863a5f --- /dev/null +++ b/tests/phpunit/unit/api/html/beans-attribute/replace.php @@ -0,0 +1,122 @@ + 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); + + // Check that the attribute does not contain the new value. + $this->assertNotContains( 'beans-test', $attributes['class'] ); + + // Run the replace. + $actual = $instance->replace( $attributes ); + + // Check that the attribute is added with the given value. + $this->assertContains( 'beans-test', $actual['class'] ); + $this->assertNotContains( 'uk-panel-box', $actual['class'] ); + } + + /** + * Test replace() should replace (overwrite) all attribute's values with the new value when the target value is + * empty (null, empty string, etc.). + */ + public function test_should_overwrite_attribute_values_with_new_value() { + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); + + foreach ( $attributes as $name => $value ) { + // Check when both value and new value are null. + $instance = new _Beans_Attribute( 'beans_post', $name ); + $actual = $instance->replace( $attributes ); + $this->assertNull( $actual[ $name ] ); + + // Check when the value is null. + $instance = new _Beans_Attribute( 'beans_post', $name, null, '' ); + $actual = $instance->replace( $attributes ); + $this->assertSame( '', $actual[ $name ] ); + + // Check when the value is an empty string. + $instance = new _Beans_Attribute( 'beans_post', $name, '', 'foo' ); + $actual = $instance->replace( $attributes ); + $this->assertSame( 'foo', $actual[ $name ] ); + } + } + + /** + * Test replace() should add the attribute when it does not exists in the given attributes. + */ + public function test_should_add_attribute_when_does_not_exist() { + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); + + $instance = new _Beans_Attribute( 'beans_post', 'data-test', 'foo', 'beans-test' ); + + // Check that the attribute does not exist. + $this->assertArrayNotHasKey( 'data-test', $attributes ); + + // Run the replace. + $actual = $instance->replace( $attributes ); + + // Check that the new attribute was added. + $this->assertArrayHasKey( 'data-test', $actual ); + $this->assertSame( 'beans-test', $actual['data-test'] ); + + // Check that only the data-test attribute has affected. + $expected = $attributes; + $expected['data-test'] = 'beans-test'; + $this->assertSame( $expected, $actual ); + } + + /** + * Test replace() should add the attribute when an empty array is given. + */ + public function test_should_add_attribute_when_an_empty_array_given() { + $instance = new _Beans_Attribute( 'beans_post', 'class', 'foo', 'beans-test' ); + $actual = $instance->replace( array() ); + + $this->assertArrayHasKey( 'class', $actual ); + $this->assertSame( 'beans-test', $actual['class'] ); + } +} diff --git a/tests/phpunit/unit/api/html/beansAddAttribute.php b/tests/phpunit/unit/api/html/beansAddAttribute.php deleted file mode 100644 index 1292cfb2..00000000 --- a/tests/phpunit/unit/api/html/beansAddAttribute.php +++ /dev/null @@ -1,84 +0,0 @@ - $markup ) { - $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); - $attributes = beans_add_attribute( $beans_id, 'data-test', '' ); - $hook = $beans_id . '_attributes'; - - // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $hook ) - ->once() - ->with( $markup_attributes ) - ->andReturn( $attributes->add( $markup_attributes ) ); - - // Run the tests. - $this->assertTrue( has_filter( $hook, array( $attributes, 'add' ), 10 ) ); - $expected = $markup_attributes; - $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Clean up. - remove_filter( $hook, array( $attributes, 'add' ), 10 ); - } - } - - /** - * Test beans_add_attribute() should add the value when the attribute exists. - */ - public function test_should_add_value_when_attribute_exists() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - - // Skip if it doesn't have a class attribute. - if ( ! isset( $markup['attributes']['class'] ) ) { - continue; - } - - $attributes = beans_add_attribute( $beans_id, 'class', 'beans-test' ); - $hook = $beans_id . '_attributes'; - - // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $hook ) - ->once() - ->with( $markup['attributes'] ) - ->andReturn( $attributes->add( $markup['attributes'] ) ); - - // Run the tests. - $this->assertTrue( has_filter( $hook, array( $attributes, 'add' ), 10 ) ); - $expected = $markup['attributes']; - $expected['class'] .= ' beans-test'; - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Clean up. - remove_filter( $hook, array( $attributes, 'add' ), 10 ); - } - } -} diff --git a/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php b/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php new file mode 100644 index 00000000..6fb1296a --- /dev/null +++ b/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php @@ -0,0 +1,52 @@ +assertFalse( defined( 'BEANS_HTML_DEV_MODE' ) ); + + Monkey\Functions\expect( 'get_option' ) + ->with( 'beans_dev_mode', false ) + ->once() + ->andReturn( false ); + $this->assertFalse( _beans_is_html_dev_mode() ); + } + + /** + * Test _beans_is_html_dev_mode() should return the option's value. + */ + public function test_should_return_option_value() { + $this->assertFalse( defined( 'BEANS_HTML_DEV_MODE' ) ); + + Monkey\Functions\expect( 'get_option' ) + ->with( 'beans_dev_mode', false ) + ->once() + ->andReturn( true ); + + $this->assertTrue( _beans_is_html_dev_mode() ); + } +} diff --git a/tests/phpunit/unit/api/html/beansRemoveAttribute.php b/tests/phpunit/unit/api/html/beansRemoveAttribute.php deleted file mode 100644 index 8d1a0711..00000000 --- a/tests/phpunit/unit/api/html/beansRemoveAttribute.php +++ /dev/null @@ -1,82 +0,0 @@ - $markup ) { - $attribute = key( $markup['attributes'] ); - - $attributes = beans_remove_attribute( $beans_id, $attribute ); - $hook = $beans_id . '_attributes'; - - // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $hook ) - ->once() - ->with( $markup['attributes'] ) - ->andReturn( $attributes->remove( $markup['attributes'] ) ); - - // Run the tests. - $this->assertTrue( has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); - $expected = $markup['attributes']; - unset( $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Clean up. - remove_filter( $hook, array( $attributes, 'remove' ), 10 ); - } - } - - /** - * Test beans_remove_attribute() should remove the given value from the attribute. - */ - public function test_should_remove_the_given_value_from_attribute() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); - - $attributes = beans_remove_attribute( $beans_id, $attribute, $value ); - $hook = $beans_id . '_attributes'; - - // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $hook ) - ->once() - ->with( $markup['attributes'] ) - ->andReturn( $attributes->remove( $markup['attributes'] ) ); - - // Run the tests. - $this->assertTrue( has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Clean up. - remove_filter( $hook, array( $attributes, 'remove' ), 10 ); - } - } -} diff --git a/tests/phpunit/unit/api/html/beansReplaceAttribute.php b/tests/phpunit/unit/api/html/beansReplaceAttribute.php deleted file mode 100644 index 20b114cd..00000000 --- a/tests/phpunit/unit/api/html/beansReplaceAttribute.php +++ /dev/null @@ -1,148 +0,0 @@ - $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); - - $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); - $hook = $beans_id . '_attributes'; - - // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $hook ) - ->once() - ->with( $markup['attributes'] ) - ->andReturn( $attributes->replace( $markup['attributes'] ) ); - - // Run the tests. - $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Clean up. - remove_filter( $hook, array( $attributes, 'replace' ), 10 ); - } - } - - - /** - * Test beans_replace_attribute() should replace all attribute values with new value when no value given. - */ - public function test_should_replace_all_attributes_when_no_value_given() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); - - $attributes = beans_replace_attribute( $beans_id, $attribute, null, 'beans-test' ); - $hook = $beans_id . '_attributes'; - - // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $hook ) - ->once() - ->with( $markup['attributes'] ) - ->andReturn( $attributes->replace( $markup['attributes'] ) ); - - // Run the tests. - $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Clean up. - remove_filter( $hook, array( $attributes, 'replace' ), 10 ); - } - } - - /** - * Test beans_replace_attribute() should replace all values with null when no value is passed. - */ - public function test_should_replace_all_values_with_null_when_no_value_passed() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); - - $attributes = beans_replace_attribute( $beans_id, $attribute, '' ); - $hook = $beans_id . '_attributes'; - - // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $hook ) - ->once() - ->with( $markup['attributes'] ) - ->andReturn( $attributes->replace( $markup['attributes'] ) ); - - // Run the tests. - $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = null; - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - $this->assertSame( $expected, $actual ); - $this->assertNotSame( $value, $actual[ $attribute ] ); - $this->assertNull( $actual[ $attribute ] ); - - // Clean up. - remove_filter( $hook, array( $attributes, 'replace' ), 10 ); - } - } - - /** - * Test beans_replace_attribute() should replace all values when an empty value is given as the new value. - */ - public function test_should_replace_all_values_when_empty_given() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); - - $attributes = beans_replace_attribute( $beans_id, $attribute, null, '' ); - $hook = $beans_id . '_attributes'; - - // Set up the WordPress simulator. - Monkey\Filters\expectApplied( $hook ) - ->once() - ->with( $markup['attributes'] ) - ->andReturn( $attributes->replace( $markup['attributes'] ) ); - - // Run the tests. - $this->assertTrue( has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = ''; - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - $this->assertSame( $expected, $actual ); - $this->assertNotSame( $value, $actual[ $attribute ] ); - $this->assertSame( '', $actual[ $attribute ] ); - - // Clean up. - remove_filter( $hook, array( $attributes, 'replace' ), 10 ); - } - } -} From 2fd41d1910f10f1fd3adee2d13e8b925c338675b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Feb 2018 20:47:58 -0600 Subject: [PATCH 161/800] Improved integration tests. --- .../api/html/beans-attribute/init.php | 47 +++++ .../api/html/beansAddAttribute.php | 57 +++--- .../api/html/beansRemoveAttribute.php | 106 ++++++++--- .../api/html/beansReplaceAttribute.php | 165 +++++++++++------- .../unit/api/html/beans-attribute/remove.php | 2 +- 5 files changed, 259 insertions(+), 118 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beans-attribute/init.php diff --git a/tests/phpunit/integration/api/html/beans-attribute/init.php b/tests/phpunit/integration/api/html/beans-attribute/init.php new file mode 100644 index 00000000..e2b8dca5 --- /dev/null +++ b/tests/phpunit/integration/api/html/beans-attribute/init.php @@ -0,0 +1,47 @@ +assertNull( $instance->init( 'does_not_exist' ) ); + $this->assertFalse( has_filter( 'foo_attributes', array( $instance, 'does_not_exist' ), 10 ) ); + } + + /** + * Test init() should return register the callback when method exists. + */ + public function test_should_register_the_callback_when_method_exists() { + $instance = new _Beans_Attribute( 'foo', 'data-test' ); + + $this->assertSame( $instance, $instance->init( 'add' ) ); + $this->assertSame( 10, has_filter( 'foo_attributes', array( $instance, 'add' ), 10 ) ); + + // Clean up. + remove_filter( 'foo_attributes', array( $instance, 'add' ) ); + } +} diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php index a0d717a1..91d8ebae 100644 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -23,49 +23,54 @@ class Tests_BeansAddAttribute extends HTML_Test_Case { /** - * Test beans_add_attribute() should add an empty value when no value is given. + * Test beans_add_attribute() should return register the "add" callback to the given ID. */ - public function test_should_add_empty_value_when_no_value_given() { + public function test_should_register_the_add_callback_to_given_id() { + $instance = beans_add_attribute( 'foo', 'data-test', 'test' ); - foreach ( static::$test_markup as $beans_id => $markup ) { - $markup_attributes = isset( $markup['attributes'] ) ? $markup['attributes'] : array(); - $attributes = beans_add_attribute( $beans_id, 'data-test', '' ); - $hook = $beans_id . '_attributes'; + $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); + $this->assertSame( 10, has_filter( 'foo_attributes', array( $instance, 'add' ), 10 ) ); - // Run the tests. - $this->assertSame( 10, has_filter( $hook, array( $attributes, 'add' ), 10 ) ); - $expected = $markup_attributes; - $expected['data-test'] = ''; - $this->assertSame( $expected, apply_filters( $hook, $markup_attributes ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + // Clean up. + remove_filter( 'foo_attributes', array( $instance, 'add' ) ); + } + + /** + * Test beans_add_attribute() should add the attribute when it does not exist in the given attributes. + */ + public function test_should_add_the_attribute_when_does_not_exist() { + + foreach ( static::$test_attributes as $beans_id => $markup ) { + $hook = $beans_id . '_attributes'; + $instance = beans_add_attribute( $beans_id, 'data-test', 'foo' ); + + // Run the full systems test by applying the filter. + $expected = $markup['attributes']; + $expected['data-test'] = 'foo'; + $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. - remove_filter( $hook, array( $attributes, 'add' ), 10 ); + remove_filter( $hook, array( $instance, 'add' ), 10 ); } } /** - * Test beans_add_attribute() should add the value when the attribute exists. + * Test beans_add_attribute() should add the value to an existing attribute's values. */ - public function test_should_add_value_when_attribute_exists() { + public function test_should_add_value_to_existing_attribute_values() { foreach ( static::$test_attributes as $beans_id => $markup ) { + $hook = $beans_id . '_attributes'; + $name = key( $markup['attributes'] ); + $instance = beans_add_attribute( $beans_id, $name, 'beans-test' ); - // Skip if it doesn't have a class attribute. - if ( ! isset( $markup['attributes']['class'] ) ) { - continue; - } - - $attributes = beans_add_attribute( $beans_id, 'class', 'beans-test' ); - $hook = $beans_id . '_attributes'; - - // Run the tests. - $this->assertSame( 10, has_filter( $hook, array( $attributes, 'add' ), 10 ) ); + // Run the full systems test by applying the filter. $expected = $markup['attributes']; - $expected['class'] .= ' beans-test'; + $expected[ $name ] .= ' beans-test'; $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. - remove_filter( $hook, array( $attributes, 'add' ), 10 ); + remove_filter( $hook, array( $instance, 'add' ), 10 ); } } } diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php index 0cbebe63..59ed37d7 100644 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -23,24 +23,60 @@ class Tests_BeansRemoveAttribute extends HTML_Test_Case { /** - * Test beans_remove_attribute() should remove the attribute when null given. + * Test beans_remove_attribute() should return register the "remove" callback to the given ID. */ - public function test_should_remove_attribute_when_null_given() { + public function test_should_register_the_add_callback_to_given_id() { + $instance = beans_remove_attribute( 'foo', 'data-test', 'test' ); - foreach ( static::$test_attributes as $beans_id => $markup ) { - $attribute = key( $markup['attributes'] ); + $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); + $this->assertSame( 10, has_filter( 'foo_attributes', array( $instance, 'remove' ), 10 ) ); - $attributes = beans_remove_attribute( $beans_id, $attribute ); - $hook = $beans_id . '_attributes'; + // Clean up. + remove_filter( 'foo_attributes', array( $instance, 'remove' ) ); + } + + /** + * Test beans_remove_attribute() should return the original attributes when the target attribute does not exist, + * meaning there's nothing to remove in the given attributes. + */ + public function test_should_return_original_attributes_when_target_attribute_does_not_exist() { + $attributes = array( + 'href' => 'http://example.com/image.png', + 'title' => 'Some cool image', + ); + + $instance = beans_remove_attribute( 'beans_post', 'itemprop' ); + + // Check that the new attribute does not exist yet. + $this->assertArrayNotHasKey( 'itemprop', $attributes ); + + // Run the full systems test by applying the filter. + $this->assertSame( $attributes, apply_filters( 'beans_post_attributes', $attributes ) ); + + // Clean up. + remove_filter( 'beans_post_attributes', array( $instance, 'remove' ), 10 ); + } + + /** + * Test beans_remove_attribute() should remove the attribute when the given value is null. + */ + public function test_should_remove_attribute_when_value_is_null() { + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); + + foreach ( $attributes as $name => $value ) { + $instance = beans_remove_attribute( 'beans_test_post', $name, null ); - // Run the tests. - $this->assertSame( 10, has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); - $expected = $markup['attributes']; - unset( $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + // Run the full systems test by applying the filter. + $this->assertArrayNotHasKey( $name, apply_filters( 'beans_test_post_attributes', $attributes ) ); // Clean up. - remove_filter( $hook, array( $attributes, 'remove' ), 10 ); + remove_filter( 'beans_test_post_attributes', array( $instance, 'remove' ), 10 ); } } @@ -48,22 +84,42 @@ public function test_should_remove_attribute_when_null_given() { * Test beans_remove_attribute() should remove the given value from the attribute. */ public function test_should_remove_the_given_value_from_attribute() { + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); - foreach ( static::$test_attributes as $beans_id => $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); + $instance = beans_remove_attribute( 'beans_test', 'class', 'uk-panel-box' ); - $attributes = beans_remove_attribute( $beans_id, $attribute, $value ); - $hook = $beans_id . '_attributes'; + // Run the full systems test by applying the filter. + $actual = apply_filters( 'beans_test_attributes', $attributes ); - // Run the tests. - $this->assertSame( 10, has_filter( $hook, array( $attributes, 'remove' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = str_replace( $value, '', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + // Check that it removed only that attribute. + $this->assertNotContains( 'uk-panel-box', $actual['class'] ); + $this->assertSame( 'uk-article category-beans', $actual['class'] ); - // Clean up. - remove_filter( $hook, array( $attributes, 'remove' ), 10 ); - } + // Check that only the class attribute is affected. + $expected = $attributes; + $expected['class'] = 'uk-article category-beans'; + $this->assertSame( $expected, $actual ); + + // Clean up. + remove_filter( 'beans_test_attributes', array( $instance, 'remove' ), 10 ); + } + + /** + * Test beans_remove_attribute() should the empty array. + */ + public function test_should_return_original_empty_array() { + $instance = beans_remove_attribute( 'beans_test', 'class', 'foo', 'beans-test' ); + + // Run the full systems test by applying the filter. + $this->assertSame( array(), apply_filters( 'beans_test_attributes', array() ) ); + + // Clean up. + remove_filter( 'beans_test_attributes', array( $instance, 'remove' ), 10 ); } } diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index e57581be..69872e21 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -23,100 +23,133 @@ class Tests_BeansReplaceAttribute extends HTML_Test_Case { /** - * Test beans_replace_attribute() should replace an existing attribute value. + * Test beans_replace_attribute() should return register the "replace" callback to the given ID. */ - public function test_should_replace_existing_attribute_value() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); + public function test_should_register_the_add_callback_to_given_id() { + $instance = beans_replace_attribute( 'foo', 'class', 'uk-panel-box', 'beans-test' ); - $attributes = beans_replace_attribute( $beans_id, $attribute, $value, 'beans-test' ); - $hook = $beans_id . '_attributes'; + $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); + $this->assertSame( 10, has_filter( 'foo_attributes', array( $instance, 'replace' ), 10 ) ); - // Run the tests. - $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Clean up. - remove_filter( $hook, array( $attributes, 'replace' ), 10 ); - } + // Clean up. + remove_filter( 'foo_attributes', array( $instance, 'replace' ) ); } /** - * Test beans_replace_attribute() should replace all attribute values with new value when no value given. + * Test beans_replace_attribute() should replace an existing attribute value. */ - public function test_should_replace_all_attributes_when_no_value_given() { + public function test_should_replace_existing_attribute_value() { + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); - foreach ( static::$test_attributes as $beans_id => $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); + $instance = beans_replace_attribute( 'beans_post', 'class', 'uk-panel-box', 'beans-test' ); - $attributes = beans_replace_attribute( $beans_id, $attribute, null, 'beans-test' ); - $hook = $beans_id . '_attributes'; + // Check that the attribute does not contain the new value. + $this->assertNotContains( 'beans-test', $attributes['class'] ); - // Run the tests. - $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = str_replace( $value, 'beans-test', $expected[ $attribute ] ); - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + // Run the full systems test by applying the filter. + $actual = apply_filters( 'beans_post_attributes', $attributes ); - // Clean up. - remove_filter( $hook, array( $attributes, 'replace' ), 10 ); - } + // Check that the attribute is added with the given value. + $this->assertContains( 'beans-test', $actual['class'] ); + $this->assertNotContains( 'uk-panel-box', $actual['class'] ); + + // Clean up. + remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); } /** - * Test beans_replace_attribute() should replace all values with null when no value is passed. + * Test replace() should replace (overwrite) all attribute's values with the new value when the target value is + * empty (null, empty string, etc.). */ - public function test_should_replace_all_values_with_null_when_no_value_passed() { + public function test_should_overwrite_attribute_values_with_new_value() { + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); + + foreach ( $attributes as $name => $value ) { + // Check when both value and new value are null. + $instance = beans_replace_attribute( 'beans_post', $name, null ); + $actual = apply_filters( 'beans_post_attributes', $attributes ); + $this->assertNull( $actual[ $name ] ); - foreach ( static::$test_attributes as $beans_id => $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); + // Clean up. + remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); - $attributes = beans_replace_attribute( $beans_id, $attribute, '' ); - $hook = $beans_id . '_attributes'; + // Check when the value is null. + $instance = beans_replace_attribute( 'beans_post', $name, null, '' ); + $actual = apply_filters( 'beans_post_attributes', $attributes ); + $this->assertSame( '', $actual[ $name ] ); - // Run the tests. - $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = null; - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - $this->assertSame( $expected, $actual ); - $this->assertNotSame( $value, $actual[ $attribute ] ); - $this->assertNull( $actual[ $attribute ] ); + // Clean up. + remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); + + // Check when the value is an empty string. + $instance = beans_replace_attribute( 'beans_post', $name, '', 'foo' ); + $actual = apply_filters( 'beans_post_attributes', $attributes ); + $this->assertSame( 'foo', $actual[ $name ] ); // Clean up. - remove_filter( $hook, array( $attributes, 'replace' ), 10 ); + remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); } } /** - * Test beans_replace_attribute() should replace all values when an empty value is given as the new value. + * Test replace() should add the attribute when it does not exists in the given attributes. */ - public function test_should_replace_all_values_when_empty_given() { + public function test_should_add_attribute_when_does_not_exist() { + $attributes = array( + 'id' => 47, + 'class' => 'uk-article uk-panel-box category-beans', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/blogPost', + 'itemprop' => 'beans_post', + ); + + $instance = beans_replace_attribute( 'beans_post', 'data-test', 'foo', 'beans-test' ); + + // Check that the attribute does not exist. + $this->assertArrayNotHasKey( 'data-test', $attributes ); + + // Run the full systems test by applying the filter. + $actual = apply_filters( 'beans_post_attributes', $attributes ); + + // Check that the new attribute was added. + $this->assertArrayHasKey( 'data-test', $actual ); + $this->assertSame( 'beans-test', $actual['data-test'] ); + + // Check that only the data-test attribute has affected. + $expected = $attributes; + $expected['data-test'] = 'beans-test'; + $this->assertSame( $expected, $actual ); + + // Clean up. + remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); + } - foreach ( static::$test_attributes as $beans_id => $markup ) { - $value = current( $markup['attributes'] ); - $attribute = key( $markup['attributes'] ); + /** + * Test replace() should add the attribute when an empty array is given. + */ + public function test_should_add_attribute_when_an_empty_array_given() { + $instance = beans_replace_attribute( 'beans_post', 'class', 'foo', 'beans-test' ); - $attributes = beans_replace_attribute( $beans_id, $attribute, null, '' ); - $hook = $beans_id . '_attributes'; + // Run the full systems test by applying the filter. + $actual = apply_filters( 'beans_post_attributes', array() ); - // Run the tests. - $this->assertSame( 10, has_filter( $hook, array( $attributes, 'replace' ), 10 ) ); - $expected = $markup['attributes']; - $expected[ $attribute ] = ''; - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - $this->assertSame( $expected, $actual ); - $this->assertNotSame( $value, $actual[ $attribute ] ); - $this->assertSame( '', $actual[ $attribute ] ); + // Run the tests. + $this->assertArrayHasKey( 'class', $actual ); + $this->assertSame( 'beans-test', $actual['class'] ); - // Clean up. - remove_filter( $hook, array( $attributes, 'replace' ), 10 ); - } + // Clean up. + remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); } } diff --git a/tests/phpunit/unit/api/html/beans-attribute/remove.php b/tests/phpunit/unit/api/html/beans-attribute/remove.php index 15ca3224..e0813f0e 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/remove.php +++ b/tests/phpunit/unit/api/html/beans-attribute/remove.php @@ -69,7 +69,7 @@ public function test_should_remove_attribute_when_value_is_null() { } /** - * Test remote() should remove the given value from the attribute. + * Test remove() should remove the given value from the attribute. */ public function test_should_remove_the_given_value_from_attribute() { $attributes = array( From ff12a93cc1158e9f2b7cde0b332cc328ab3b7390 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 1 Mar 2018 09:30:21 -0600 Subject: [PATCH 162/800] Used the attributes fixture to test the expected behaviors. These functions have the following expected behaviors: 1. Return an instance of _Beans_Attribute. 2. Register the callback to the given ID. --- .../api/html/beansAddAttribute.php | 29 +++++++++++-------- .../api/html/beansRemoveAttribute.php | 20 ++++++++----- .../api/html/beansReplaceAttribute.php | 20 ++++++++----- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php index 91d8ebae..71a55444 100644 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -23,34 +23,39 @@ class Tests_BeansAddAttribute extends HTML_Test_Case { /** - * Test beans_add_attribute() should return register the "add" callback to the given ID. + * Test beans_add_attribute() should return the instance and register the "add" callback to the given ID. */ - public function test_should_register_the_add_callback_to_given_id() { - $instance = beans_add_attribute( 'foo', 'data-test', 'test' ); + public function test_should_return_instance_and_register_callback_to_given_id() { - $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); - $this->assertSame( 10, has_filter( 'foo_attributes', array( $instance, 'add' ), 10 ) ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $instance = beans_add_attribute( $beans_id, 'data-test', 'test' ); + + // Check that it returns an instance of _Beans_Attribute. + $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); - // Clean up. - remove_filter( 'foo_attributes', array( $instance, 'add' ) ); + // Check that the object's "add" method is registered to the filter event for the given ID. + $this->assertSame( 10, has_filter( "{$beans_id}_attributes", array( $instance, 'add' ), 10 ) ); + + // Clean up. + remove_filter( "{$beans_id}_attributes", array( $instance, 'add' ) ); + } } /** - * Test beans_add_attribute() should add the attribute when it does not exist in the given attributes. + * Systems test beans_add_attribute() should add the attribute when it does not exist in the given attributes. */ public function test_should_add_the_attribute_when_does_not_exist() { foreach ( static::$test_attributes as $beans_id => $markup ) { - $hook = $beans_id . '_attributes'; $instance = beans_add_attribute( $beans_id, 'data-test', 'foo' ); // Run the full systems test by applying the filter. $expected = $markup['attributes']; $expected['data-test'] = 'foo'; - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $this->assertSame( $expected, apply_filters( "{$beans_id}_attributes", $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. - remove_filter( $hook, array( $instance, 'add' ), 10 ); + remove_filter( "{$beans_id}_attributes", array( $instance, 'add' ), 10 ); } } @@ -65,7 +70,7 @@ public function test_should_add_value_to_existing_attribute_values() { $instance = beans_add_attribute( $beans_id, $name, 'beans-test' ); // Run the full systems test by applying the filter. - $expected = $markup['attributes']; + $expected = $markup['attributes']; $expected[ $name ] .= ' beans-test'; $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php index 59ed37d7..7f145f75 100644 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -23,16 +23,22 @@ class Tests_BeansRemoveAttribute extends HTML_Test_Case { /** - * Test beans_remove_attribute() should return register the "remove" callback to the given ID. + * Test beans_remove_attribute() should return the instance and register the "remove" callback to the given ID. */ - public function test_should_register_the_add_callback_to_given_id() { - $instance = beans_remove_attribute( 'foo', 'data-test', 'test' ); + public function test_should_return_instance_and_register_callback_to_given_id() { - $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); - $this->assertSame( 10, has_filter( 'foo_attributes', array( $instance, 'remove' ), 10 ) ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $instance = beans_remove_attribute( $beans_id, 'data-test', 'test' ); - // Clean up. - remove_filter( 'foo_attributes', array( $instance, 'remove' ) ); + // Check that it returns an instance of _Beans_Attribute. + $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); + + // Check that the object's "remove" method is registered to the filter event for the given ID. + $this->assertSame( 10, has_filter( "{$beans_id}_attributes", array( $instance, 'remove' ), 10 ) ); + + // Clean up. + remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ) ); + } } /** diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index 69872e21..f9f7b758 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -23,16 +23,22 @@ class Tests_BeansReplaceAttribute extends HTML_Test_Case { /** - * Test beans_replace_attribute() should return register the "replace" callback to the given ID. + * Test beans_replace_attribute() should return the instance and register the "replace" callback to the given ID. */ - public function test_should_register_the_add_callback_to_given_id() { - $instance = beans_replace_attribute( 'foo', 'class', 'uk-panel-box', 'beans-test' ); + public function test_should_return_instance_and_register_callback_to_given_id() { - $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); - $this->assertSame( 10, has_filter( 'foo_attributes', array( $instance, 'replace' ), 10 ) ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $instance = beans_replace_attribute( $beans_id, key( $markup['attributes'] ), current( $markup['attributes'] ), 'test' ); - // Clean up. - remove_filter( 'foo_attributes', array( $instance, 'replace' ) ); + // Check that it returns an instance of _Beans_Attribute. + $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); + + // Check that the object's "replace" method is registered to the filter event for the given ID. + $this->assertSame( 10, has_filter( "{$beans_id}_attributes", array( $instance, 'replace' ), 10 ) ); + + // Clean up. + remove_filter( "{$beans_id}_attributes", array( $instance, 'replace' ) ); + } } /** From a5a106a9566980db59d0676b06d4b895f9c88c9e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 1 Mar 2018 10:28:30 -0600 Subject: [PATCH 163/800] Improved the systems integration tests. 1. Identified each of the "systems integration tests", as these test through by firing the filter event and checking the returned attributes against the original inputs. 2. Used the test fixture where applicable. --- .../api/html/beansAddAttribute.php | 15 ++- .../api/html/beansRemoveAttribute.php | 74 +++++------ .../api/html/beansReplaceAttribute.php | 118 +++++++++--------- 3 files changed, 104 insertions(+), 103 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php index 71a55444..7409b2f4 100644 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -42,14 +42,14 @@ public function test_should_return_instance_and_register_callback_to_given_id() } /** - * Systems test beans_add_attribute() should add the attribute when it does not exist in the given attributes. + * Systems test beans_add_attribute() by firing the expected filter event for the given ID. Test should add the + * attribute when it does not exist in the given attributes. */ public function test_should_add_the_attribute_when_does_not_exist() { foreach ( static::$test_attributes as $beans_id => $markup ) { $instance = beans_add_attribute( $beans_id, 'data-test', 'foo' ); - // Run the full systems test by applying the filter. $expected = $markup['attributes']; $expected['data-test'] = 'foo'; $this->assertSame( $expected, apply_filters( "{$beans_id}_attributes", $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. @@ -60,22 +60,21 @@ public function test_should_add_the_attribute_when_does_not_exist() { } /** - * Test beans_add_attribute() should add the value to an existing attribute's values. + * Systems test beans_add_attribute() by firing the expected filter event for the given ID. Test should add the + * value to an existing attribute's values. */ public function test_should_add_value_to_existing_attribute_values() { foreach ( static::$test_attributes as $beans_id => $markup ) { - $hook = $beans_id . '_attributes'; $name = key( $markup['attributes'] ); $instance = beans_add_attribute( $beans_id, $name, 'beans-test' ); - // Run the full systems test by applying the filter. - $expected = $markup['attributes']; + $expected = $markup['attributes']; $expected[ $name ] .= ' beans-test'; - $this->assertSame( $expected, apply_filters( $hook, $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $this->assertSame( $expected, apply_filters( "{$beans_id}_attributes", $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Clean up. - remove_filter( $hook, array( $instance, 'add' ), 10 ); + remove_filter( "{$beans_id}_attributes", array( $instance, 'add' ), 10 ); } } } diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php index 7f145f75..ea53da0b 100644 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -42,44 +42,44 @@ public function test_should_return_instance_and_register_callback_to_given_id() } /** - * Test beans_remove_attribute() should return the original attributes when the target attribute does not exist, - * meaning there's nothing to remove in the given attributes. + * Systems test beans_remove_attribute() by firing the expected filter event for the given ID. Test should return + * the original attributes when the target attribute does not exist, meaning there's nothing to remove in the given + * attributes. */ public function test_should_return_original_attributes_when_target_attribute_does_not_exist() { - $attributes = array( - 'href' => 'http://example.com/image.png', - 'title' => 'Some cool image', - ); - $instance = beans_remove_attribute( 'beans_post', 'itemprop' ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $instance = beans_remove_attribute( $beans_id, 'data-test', 'test' ); - // Check that the new attribute does not exist yet. - $this->assertArrayNotHasKey( 'itemprop', $attributes ); + // Check that the new attribute does not exist yet. + $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); - // Run the full systems test by applying the filter. - $this->assertSame( $attributes, apply_filters( 'beans_post_attributes', $attributes ) ); + // Run the full systems test by applying the filter. + $this->assertSame( $markup['attributes'], apply_filters( "{$beans_id}_attributes", $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - // Clean up. - remove_filter( 'beans_post_attributes', array( $instance, 'remove' ), 10 ); + // Clean up. + remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ) ); + } } /** - * Test beans_remove_attribute() should remove the attribute when the given value is null. + * Systems test beans_remove_attribute() by firing the expected filter event for the given ID. Test should remove + * the attribute when the given value is null. */ public function test_should_remove_attribute_when_value_is_null() { - $attributes = array( - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', - 'itemprop' => 'beans_post', - ); - foreach ( $attributes as $name => $value ) { + foreach ( static::$test_attributes as $beans_id => $markup ) { + $name = key( $markup['attributes'] ); $instance = beans_remove_attribute( 'beans_test_post', $name, null ); + $actual = apply_filters( 'beans_test_post_attributes', $markup['attributes'] ); - // Run the full systems test by applying the filter. - $this->assertArrayNotHasKey( $name, apply_filters( 'beans_test_post_attributes', $attributes ) ); + // Check that the attribute is removed. + $this->assertArrayNotHasKey( $name, $actual ); + + // Check that only that attribute is affected. + $expected = $markup['attributes']; + unset( $expected[ $name ] ); + $this->assertSame( $expected, $actual ); // Clean up. remove_filter( 'beans_test_post_attributes', array( $instance, 'remove' ), 10 ); @@ -87,7 +87,8 @@ public function test_should_remove_attribute_when_value_is_null() { } /** - * Test beans_remove_attribute() should remove the given value from the attribute. + * Systems test beans_remove_attribute() by firing the expected filter event for the given ID. Test should remove + * the given value from the attribute. */ public function test_should_remove_the_given_value_from_attribute() { $attributes = array( @@ -99,11 +100,9 @@ public function test_should_remove_the_given_value_from_attribute() { ); $instance = beans_remove_attribute( 'beans_test', 'class', 'uk-panel-box' ); + $actual = apply_filters( 'beans_test_attributes', $attributes ); - // Run the full systems test by applying the filter. - $actual = apply_filters( 'beans_test_attributes', $attributes ); - - // Check that it removed only that attribute. + // Check that it removed only that attribute value. $this->assertNotContains( 'uk-panel-box', $actual['class'] ); $this->assertSame( 'uk-article category-beans', $actual['class'] ); @@ -117,15 +116,20 @@ public function test_should_remove_the_given_value_from_attribute() { } /** - * Test beans_remove_attribute() should the empty array. + * Systems test beans_remove_attribute() by firing the expected filter event for the given ID. Test should return an + * empty array when an empty array is given. Why? There is nothing to remove, as there are no attributes. */ public function test_should_return_original_empty_array() { - $instance = beans_remove_attribute( 'beans_test', 'class', 'foo', 'beans-test' ); - // Run the full systems test by applying the filter. - $this->assertSame( array(), apply_filters( 'beans_test_attributes', array() ) ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $name = key( $markup['attributes'] ); + $value = current( $markup['attributes'] ); + $instance = beans_remove_attribute( $beans_id, $name, $value ); - // Clean up. - remove_filter( 'beans_test_attributes', array( $instance, 'remove' ), 10 ); + $this->assertSame( array(), apply_filters( "{$beans_id}_attributes", array() ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + + // Clean up. + remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ), 10 ); + } } } diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index f9f7b758..dd099216 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -42,7 +42,8 @@ public function test_should_return_instance_and_register_callback_to_given_id() } /** - * Test beans_replace_attribute() should replace an existing attribute value. + * Systems test beans_replace_attribute() by firing the expected filter event for the given ID. Test should replace + * an existing attribute value. */ public function test_should_replace_existing_attribute_value() { $attributes = array( @@ -70,92 +71,89 @@ public function test_should_replace_existing_attribute_value() { } /** - * Test replace() should replace (overwrite) all attribute's values with the new value when the target value is - * empty (null, empty string, etc.). + * Systems test beans_replace_attribute() by firing the expected filter event for the given ID. Test should replace + * (overwrite) all attribute's values with the new value when the target value is empty (null, empty string, etc.). */ - public function test_should_overwrite_attribute_values_with_new_value() { - $attributes = array( - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', - 'itemprop' => 'beans_post', - ); + public function test_should_overwrite_attribute_values_when_target_value_is_empty() { - foreach ( $attributes as $name => $value ) { - // Check when both value and new value are null. - $instance = beans_replace_attribute( 'beans_post', $name, null ); - $actual = apply_filters( 'beans_post_attributes', $attributes ); - $this->assertNull( $actual[ $name ] ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $name = key( $markup['attributes'] ); + $hook = "{$beans_id}_attributes"; - // Clean up. - remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); + // Check when both target value and new value are null. + $instance = beans_replace_attribute( $beans_id, $name, null ); + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $this->assertNull( $actual[ $name ] ); + remove_filter( $hook, array( $instance, 'replace' ), 10 ); - // Check when the value is null. - $instance = beans_replace_attribute( 'beans_post', $name, null, '' ); - $actual = apply_filters( 'beans_post_attributes', $attributes ); + // Check when the target value is null. + $instance = beans_replace_attribute( $beans_id, $name, null, '' ); + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( '', $actual[ $name ] ); + remove_filter( $hook, array( $instance, 'replace' ), 10 ); - // Clean up. - remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); + // Check when the target value is an empty string. + $instance = beans_replace_attribute( $beans_id, $name, null, '' ); + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $this->assertSame( '', $actual[ $name ] ); + remove_filter( $hook, array( $instance, 'replace' ), 10 ); - // Check when the value is an empty string. - $instance = beans_replace_attribute( 'beans_post', $name, '', 'foo' ); - $actual = apply_filters( 'beans_post_attributes', $attributes ); + // Check when the target value is false. + $instance = beans_replace_attribute( $beans_id, $name, false, 'foo' ); + $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( 'foo', $actual[ $name ] ); - - // Clean up. - remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); + remove_filter( $hook, array( $instance, 'replace' ), 10 ); } } /** - * Test replace() should add the attribute when it does not exists in the given attributes. + * Systems test beans_replace_attribute() by firing the expected filter event for the given ID. Test should add the + * attribute when it does not exists in the given attributes. */ public function test_should_add_attribute_when_does_not_exist() { - $attributes = array( - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', - 'itemprop' => 'beans_post', - ); - $instance = beans_replace_attribute( 'beans_post', 'data-test', 'foo', 'beans-test' ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $instance = beans_replace_attribute( $beans_id, 'data-test', 'foo', 'beans-test' ); - // Check that the attribute does not exist. - $this->assertArrayNotHasKey( 'data-test', $attributes ); + // Check that the attribute does not exist. + $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); - // Run the full systems test by applying the filter. - $actual = apply_filters( 'beans_post_attributes', $attributes ); + // Run the full systems test by applying the filter. + $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - // Check that the new attribute was added. - $this->assertArrayHasKey( 'data-test', $actual ); - $this->assertSame( 'beans-test', $actual['data-test'] ); + // Check that the new attribute is added. + $this->assertArrayHasKey( 'data-test', $actual ); + $this->assertSame( 'beans-test', $actual['data-test'] ); - // Check that only the data-test attribute has affected. - $expected = $attributes; - $expected['data-test'] = 'beans-test'; - $this->assertSame( $expected, $actual ); + // Check that only the data-test attribute is affected. + $expected = $markup['attributes']; + $expected['data-test'] = 'beans-test'; + $this->assertSame( $expected, $actual ); - // Clean up. - remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); + // Clean up. + remove_filter( "{$beans_id}_attributes", array( $instance, 'replace' ), 10 ); + } } /** - * Test replace() should add the attribute when an empty array is given. + * Systems test beans_replace_attribute() by firing the expected filter event for the given ID. Test should add the + * attribute when an empty array is given. */ public function test_should_add_attribute_when_an_empty_array_given() { - $instance = beans_replace_attribute( 'beans_post', 'class', 'foo', 'beans-test' ); - // Run the full systems test by applying the filter. - $actual = apply_filters( 'beans_post_attributes', array() ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $name = key( $markup['attributes'] ); + $value = current( $markup['attributes'] ); - // Run the tests. - $this->assertArrayHasKey( 'class', $actual ); - $this->assertSame( 'beans-test', $actual['class'] ); + $instance = beans_replace_attribute( $beans_id, $name, $value, 'beans-test' ); + $actual = apply_filters( "{$beans_id}_attributes", array() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - // Clean up. - remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); + // Check that it did add the attribute. + $this->assertArrayHasKey( $name, $actual ); + $this->assertSame( array( $name => 'beans-test' ), $actual ); + + // Clean up. + remove_filter( "{$beans_id}_attributes", array( $instance, 'replace' ), 10 ); + } } } From 7af59bf82cf5487f62024031aa0705e3d42c4370 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 1 Mar 2018 10:53:54 -0600 Subject: [PATCH 164/800] Improved the unit tests. 1. Cleaned up the instance and method, standardizing on the actual. 2. Used the test fixture where applicable. --- .../api/html/beansAddAttribute.php | 14 +++- .../api/html/beansReplaceAttribute.php | 17 +++-- .../unit/api/html/beans-attribute/add.php | 29 +++++--- .../unit/api/html/beans-attribute/remove.php | 61 ++++++++------- .../unit/api/html/beans-attribute/replace.php | 74 +++++++++---------- 5 files changed, 104 insertions(+), 91 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php index 7409b2f4..68a4357d 100644 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -50,9 +50,16 @@ public function test_should_add_the_attribute_when_does_not_exist() { foreach ( static::$test_attributes as $beans_id => $markup ) { $instance = beans_add_attribute( $beans_id, 'data-test', 'foo' ); + // Check that the attribute does not exist before we add it. + $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); + + // Fire the event to do the add. + $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + + // Check that the attribute is added with the given value. $expected = $markup['attributes']; $expected['data-test'] = 'foo'; - $this->assertSame( $expected, apply_filters( "{$beans_id}_attributes", $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $this->assertSame( $expected, $actual ); // Clean up. remove_filter( "{$beans_id}_attributes", array( $instance, 'add' ), 10 ); @@ -69,9 +76,12 @@ public function test_should_add_value_to_existing_attribute_values() { $name = key( $markup['attributes'] ); $instance = beans_add_attribute( $beans_id, $name, 'beans-test' ); + // Fire the event to do the add. + $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $expected = $markup['attributes']; $expected[ $name ] .= ' beans-test'; - $this->assertSame( $expected, apply_filters( "{$beans_id}_attributes", $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $this->assertSame( $expected, $actual ); // Clean up. remove_filter( "{$beans_id}_attributes", array( $instance, 'add' ), 10 ); diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index dd099216..9c4cd1a3 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -59,7 +59,7 @@ public function test_should_replace_existing_attribute_value() { // Check that the attribute does not contain the new value. $this->assertNotContains( 'beans-test', $attributes['class'] ); - // Run the full systems test by applying the filter. + // Fire the event to run the replace. $actual = apply_filters( 'beans_post_attributes', $attributes ); // Check that the attribute is added with the given value. @@ -93,9 +93,9 @@ public function test_should_overwrite_attribute_values_when_target_value_is_empt remove_filter( $hook, array( $instance, 'replace' ), 10 ); // Check when the target value is an empty string. - $instance = beans_replace_attribute( $beans_id, $name, null, '' ); + $instance = beans_replace_attribute( $beans_id, $name, '', 'foo' ); $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - $this->assertSame( '', $actual[ $name ] ); + $this->assertSame( 'foo', $actual[ $name ] ); remove_filter( $hook, array( $instance, 'replace' ), 10 ); // Check when the target value is false. @@ -118,7 +118,7 @@ public function test_should_add_attribute_when_does_not_exist() { // Check that the attribute does not exist. $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); - // Run the full systems test by applying the filter. + // Fire the event to run the replace. $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Check that the new attribute is added. @@ -142,11 +142,12 @@ public function test_should_add_attribute_when_does_not_exist() { public function test_should_add_attribute_when_an_empty_array_given() { foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $value = current( $markup['attributes'] ); - + $name = key( $markup['attributes'] ); + $value = current( $markup['attributes'] ); $instance = beans_replace_attribute( $beans_id, $name, $value, 'beans-test' ); - $actual = apply_filters( "{$beans_id}_attributes", array() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + + // Fire the event to run the replace. + $actual = apply_filters( "{$beans_id}_attributes", array() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Check that it did add the attribute. $this->assertArrayHasKey( $name, $actual ); diff --git a/tests/phpunit/unit/api/html/beans-attribute/add.php b/tests/phpunit/unit/api/html/beans-attribute/add.php index 3b82a7b4..a5dbbe96 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/add.php +++ b/tests/phpunit/unit/api/html/beans-attribute/add.php @@ -29,22 +29,28 @@ class Tests_Beans_Attribute_Add extends HTML_Test_Case { public function test_should_add_the_attribute_when_does_not_exist() { foreach ( static::$test_attributes as $beans_id => $markup ) { - $instance = new _Beans_Attribute( $beans_id, 'data-test', 'foo' ); - // Check that the attribute does not exist before we add it. $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); + $actual = ( new _Beans_Attribute( $beans_id, 'data-test', 'foo' ) )->add( $markup['attributes'] ); + // Check that the attribute is added with the given value. $expected = $markup['attributes']; $expected['data-test'] = 'foo'; - $this->assertSame( $expected, $instance->add( $markup['attributes'] ) ); + $this->assertSame( $expected, $actual ); } + } - // Check it with an empty array. - $instance = new _Beans_Attribute( 'foo', 'data-test', 'test' ); - $actual = $instance->add( array() ); - $this->assertArrayHasKey( 'data-test', $actual ); - $this->assertSame( 'test', $actual['data-test'] ); + /** + * Test add() should add the attribute when an empty array is given. + */ + public function test_should_add_the_attribute_when_empty_array_given() { + + foreach ( array_keys( static::$test_attributes ) as $beans_id ) { + $actual = ( new _Beans_Attribute( $beans_id, 'data-test', 'foo' ) )->add( array() ); + + $this->assertSame( array( 'data-test' => 'foo' ), $actual ); + } } /** @@ -53,16 +59,17 @@ public function test_should_add_the_attribute_when_does_not_exist() { public function test_should_add_value_to_existing_attribute_values() { foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $instance = new _Beans_Attribute( $beans_id, $name, 'beans-test' ); + $name = key( $markup['attributes'] ); // This test seems silly as we just grabbed the key above. But it's here to make a point that the attribute exists. $this->assertArrayHasKey( $name, $markup['attributes'] ); + $actual = ( new _Beans_Attribute( $beans_id, $name, 'beans-test' ) )->add( $markup['attributes'] ); + // Check that the given value is appended to the end of the existing attribute. $expected = $markup['attributes']; $expected[ $name ] .= ' beans-test'; - $this->assertSame( $expected, $instance->add( $markup['attributes'] ) ); + $this->assertSame( $expected, $actual ); } } } diff --git a/tests/phpunit/unit/api/html/beans-attribute/remove.php b/tests/phpunit/unit/api/html/beans-attribute/remove.php index e0813f0e..68b31fa1 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/remove.php +++ b/tests/phpunit/unit/api/html/beans-attribute/remove.php @@ -29,42 +29,34 @@ class Tests_Beans_Attribute_Remove extends HTML_Test_Case { * nothing to remove in the given attributes. */ public function test_should_return_original_attributes_when_target_attribute_does_not_exist() { - $attributes = array( - 'href' => 'http://example.com/image.png', - 'title' => 'Some cool image', - ); - $instance = new _Beans_Attribute( 'beans_post', 'itemprop' ); - $this->assertArrayNotHasKey( 'itemprop', $attributes ); - $this->assertSame( $attributes, $instance->remove( $attributes ) ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $instance = new _Beans_Attribute( $beans_id, 'data-test', 'test' ); - $attributes = array( - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', - 'itemprop' => 'beans_post', - ); - $instance = new _Beans_Attribute( 'beans_post', 'data-test', 'uk-panel-box', 'beans-test' ); - $this->assertArrayNotHasKey( 'data-test', $attributes ); - $this->assertSame( $attributes, $instance->remove( $attributes ) ); + // Check that the attribute does not exist before we run the test. + $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); + + // Check that the original attributes are returned. + $this->assertSame( $markup['attributes'], $instance->remove( $markup['attributes'] ) ); + } } /** * Test remove() should remove the attribute when the given value is null. */ public function test_should_remove_attribute_when_value_is_null() { - $attributes = array( - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', - 'itemprop' => 'beans_post', - ); - foreach ( $attributes as $name => $value ) { - $instance = new _Beans_Attribute( 'beans_post', $name, null ); - $this->assertArrayNotHasKey( $name, $instance->remove( $attributes ) ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $name = key( $markup['attributes'] ); + $actual = ( new _Beans_Attribute( 'beans_test_post', $name ) )->remove( $markup['attributes'] ); + + // Check that the attribute is removed. + $this->assertArrayNotHasKey( $name, $actual ); + + // Check that only that attribute is affected. + $expected = $markup['attributes']; + unset( $expected[ $name ] ); + $this->assertSame( $expected, $actual ); } } @@ -82,7 +74,7 @@ public function test_should_remove_the_given_value_from_attribute() { $instance = new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box' ); - // Check that it removed only that attribute. + // Check that it removed only that attribute value. $actual = $instance->remove( $attributes ); $this->assertNotContains( 'uk-panel-box', $actual['class'] ); $this->assertSame( 'uk-article category-beans', $actual['class'] ); @@ -94,12 +86,17 @@ public function test_should_remove_the_given_value_from_attribute() { } /** - * Test remove() should the empty array. + * Test remove() should the empty array when an empty array is given. Why? There is nothing to remove, as there are + * no attributes. */ public function test_should_return_original_empty_array() { - $instance = new _Beans_Attribute( 'beans_post', 'class', 'foo', 'beans-test' ); - $actual = $instance->remove( array() ); - $this->assertSame( array(), $actual ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $name = key( $markup['attributes'] ); + $value = current( $markup['attributes'] ); + $instance = new _Beans_Attribute( $beans_id, $name, $value ); + + $this->assertSame( array(), $instance->remove( array() ) ); + } } } diff --git a/tests/phpunit/unit/api/html/beans-attribute/replace.php b/tests/phpunit/unit/api/html/beans-attribute/replace.php index 75863a5f..edce4cee 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/replace.php +++ b/tests/phpunit/unit/api/html/beans-attribute/replace.php @@ -28,7 +28,6 @@ class Tests_Beans_Attribute_Replace extends HTML_Test_Case { * Test replace() should replace an existing attribute value. */ public function test_should_replace_existing_attribute_value() { - $instance = new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box', 'beans-test' ); $attributes = array( 'id' => 47, 'class' => 'uk-article uk-panel-box category-beans', @@ -37,6 +36,8 @@ public function test_should_replace_existing_attribute_value() { 'itemprop' => 'beans_post', ); + $instance = new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box', 'beans-test' ); + // Check that the attribute does not contain the new value. $this->assertNotContains( 'beans-test', $attributes['class'] ); @@ -53,28 +54,24 @@ public function test_should_replace_existing_attribute_value() { * empty (null, empty string, etc.). */ public function test_should_overwrite_attribute_values_with_new_value() { - $attributes = array( - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', - 'itemprop' => 'beans_post', - ); - foreach ( $attributes as $name => $value ) { + foreach ( static::$test_attributes as $beans_id => $markup ) { + $name = key( $markup['attributes'] ); + // Check when both value and new value are null. - $instance = new _Beans_Attribute( 'beans_post', $name ); - $actual = $instance->replace( $attributes ); + $actual = ( new _Beans_Attribute( 'beans_post', $name ) )->replace( $markup['attributes'] ); $this->assertNull( $actual[ $name ] ); // Check when the value is null. - $instance = new _Beans_Attribute( 'beans_post', $name, null, '' ); - $actual = $instance->replace( $attributes ); + $actual = ( new _Beans_Attribute( 'beans_post', $name, null, '' ) )->replace( $markup['attributes'] ); $this->assertSame( '', $actual[ $name ] ); // Check when the value is an empty string. - $instance = new _Beans_Attribute( 'beans_post', $name, '', 'foo' ); - $actual = $instance->replace( $attributes ); + $actual = ( new _Beans_Attribute( 'beans_post', $name, '', 'foo' ) )->replace( $markup['attributes'] ); + $this->assertSame( 'foo', $actual[ $name ] ); + + // Check when the target value is false. + $actual = ( new _Beans_Attribute( 'beans_post', $name, false, 'foo' ) )->replace( $markup['attributes'] ); $this->assertSame( 'foo', $actual[ $name ] ); } } @@ -83,40 +80,41 @@ public function test_should_overwrite_attribute_values_with_new_value() { * Test replace() should add the attribute when it does not exists in the given attributes. */ public function test_should_add_attribute_when_does_not_exist() { - $attributes = array( - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', - 'itemprop' => 'beans_post', - ); - $instance = new _Beans_Attribute( 'beans_post', 'data-test', 'foo', 'beans-test' ); + foreach ( static::$test_attributes as $beans_id => $markup ) { - // Check that the attribute does not exist. - $this->assertArrayNotHasKey( 'data-test', $attributes ); + $instance = new _Beans_Attribute( $beans_id, 'data-test', 'foo', 'beans-test' ); - // Run the replace. - $actual = $instance->replace( $attributes ); + // Check that the attribute does not exist. + $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); + + // Run the replace. + $actual = $instance->replace( $markup['attributes'] ); - // Check that the new attribute was added. - $this->assertArrayHasKey( 'data-test', $actual ); - $this->assertSame( 'beans-test', $actual['data-test'] ); + // Check that the new attribute is added. + $this->assertArrayHasKey( 'data-test', $actual ); + $this->assertSame( 'beans-test', $actual['data-test'] ); - // Check that only the data-test attribute has affected. - $expected = $attributes; - $expected['data-test'] = 'beans-test'; - $this->assertSame( $expected, $actual ); + // Check that only the data-test attribute is affected. + $expected = $markup['attributes']; + $expected['data-test'] = 'beans-test'; + $this->assertSame( $expected, $actual ); + } } /** * Test replace() should add the attribute when an empty array is given. */ public function test_should_add_attribute_when_an_empty_array_given() { - $instance = new _Beans_Attribute( 'beans_post', 'class', 'foo', 'beans-test' ); - $actual = $instance->replace( array() ); - $this->assertArrayHasKey( 'class', $actual ); - $this->assertSame( 'beans-test', $actual['class'] ); + foreach ( static::$test_attributes as $beans_id => $markup ) { + $name = key( $markup['attributes'] ); + $value = current( $markup['attributes'] ); + $actual = ( new _Beans_Attribute( $beans_id, $name, $value, 'beans-test' ) )->replace( array() ); + + // Check that it did add the attribute. + $this->assertArrayHasKey( $name, $actual ); + $this->assertSame( array( $name => 'beans-test' ), $actual ); + } } } From 71b93c946b45041ebac2e28d43124e3f539d517a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 1 Mar 2018 11:35:16 -0600 Subject: [PATCH 165/800] Improved documentation. 1. Fixed full test documentation. 2. Changed the `@group`. 3. Standardized for the $actual result. --- .../api/html/beans-attribute/init.php | 2 +- .../api/html/beansAddAttribute.php | 6 +-- .../api/html/beansRemoveAttribute.php | 46 ++++++++++++------- .../api/html/beansReplaceAttribute.php | 10 ++-- .../unit/api/html/beans-attribute/add.php | 2 +- .../unit/api/html/beans-attribute/init.php | 2 +- .../unit/api/html/beans-attribute/remove.php | 30 +++++++----- .../unit/api/html/beans-attribute/replace.php | 2 +- .../unit/api/html/beansIsHtmlDevMode.php | 2 +- 9 files changed, 60 insertions(+), 42 deletions(-) diff --git a/tests/phpunit/integration/api/html/beans-attribute/init.php b/tests/phpunit/integration/api/html/beans-attribute/init.php index e2b8dca5..92f696d8 100644 --- a/tests/phpunit/integration/api/html/beans-attribute/init.php +++ b/tests/phpunit/integration/api/html/beans-attribute/init.php @@ -18,8 +18,8 @@ * Class Tests_Beans_Attribute_Init * * @package Beans\Framework\Tests\Integration\API\HTML - * @group integration-tests * @group api + * @group api-html */ class Tests_Beans_Attribute_Init extends HTML_Test_Case { diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php index 68a4357d..6f680da2 100644 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -17,8 +17,8 @@ * Class Tests_BeansAddAttribute * * @package Beans\Framework\Tests\Integration\API\HTML - * @group integration-tests * @group api + * @group api-html */ class Tests_BeansAddAttribute extends HTML_Test_Case { @@ -42,7 +42,7 @@ public function test_should_return_instance_and_register_callback_to_given_id() } /** - * Systems test beans_add_attribute() by firing the expected filter event for the given ID. Test should add the + * Test the end result of beans_add_attribute() by firing the expected filter event for the given ID. Test should add the * attribute when it does not exist in the given attributes. */ public function test_should_add_the_attribute_when_does_not_exist() { @@ -67,7 +67,7 @@ public function test_should_add_the_attribute_when_does_not_exist() { } /** - * Systems test beans_add_attribute() by firing the expected filter event for the given ID. Test should add the + * Test the end result of beans_add_attribute() by firing the expected filter event for the given ID. Test should add the * value to an existing attribute's values. */ public function test_should_add_value_to_existing_attribute_values() { diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php index ea53da0b..6ff7b4ab 100644 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -17,8 +17,8 @@ * Class Tests_BeansRemoveAttribute * * @package Beans\Framework\Tests\Integration\API\HTML - * @group integration-tests * @group api + * @group api-html */ class Tests_BeansRemoveAttribute extends HTML_Test_Case { @@ -42,9 +42,9 @@ public function test_should_return_instance_and_register_callback_to_given_id() } /** - * Systems test beans_remove_attribute() by firing the expected filter event for the given ID. Test should return - * the original attributes when the target attribute does not exist, meaning there's nothing to remove in the given - * attributes. + * Test the end result of beans_remove_attribute() by firing the expected filter event for the given ID. Test + * should return the original attributes when the target attribute does not exist, meaning there's nothing to + * remove in the given attributes. */ public function test_should_return_original_attributes_when_target_attribute_does_not_exist() { @@ -54,8 +54,11 @@ public function test_should_return_original_attributes_when_target_attribute_doe // Check that the new attribute does not exist yet. $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); + // Fire the event to run the remove. + $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + // Run the full systems test by applying the filter. - $this->assertSame( $markup['attributes'], apply_filters( "{$beans_id}_attributes", $markup['attributes'] ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $this->assertSame( $markup['attributes'], $actual ); // Clean up. remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ) ); @@ -63,15 +66,17 @@ public function test_should_return_original_attributes_when_target_attribute_doe } /** - * Systems test beans_remove_attribute() by firing the expected filter event for the given ID. Test should remove - * the attribute when the given value is null. + * Test the end result of beans_remove_attribute() by firing the expected filter event for the given ID. Test + * should remove the attribute when the given value is null. */ public function test_should_remove_attribute_when_value_is_null() { foreach ( static::$test_attributes as $beans_id => $markup ) { $name = key( $markup['attributes'] ); - $instance = beans_remove_attribute( 'beans_test_post', $name, null ); - $actual = apply_filters( 'beans_test_post_attributes', $markup['attributes'] ); + $instance = beans_remove_attribute( $beans_id, $name, null ); + + // Fire the event to run the remove. + $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Check that the attribute is removed. $this->assertArrayNotHasKey( $name, $actual ); @@ -82,13 +87,13 @@ public function test_should_remove_attribute_when_value_is_null() { $this->assertSame( $expected, $actual ); // Clean up. - remove_filter( 'beans_test_post_attributes', array( $instance, 'remove' ), 10 ); + remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ), 10 ); } } /** - * Systems test beans_remove_attribute() by firing the expected filter event for the given ID. Test should remove - * the given value from the attribute. + * Test the end result of beans_remove_attribute() by firing the expected filter event for the given ID. Test + * should remove the given value from the attribute. */ public function test_should_remove_the_given_value_from_attribute() { $attributes = array( @@ -100,7 +105,9 @@ public function test_should_remove_the_given_value_from_attribute() { ); $instance = beans_remove_attribute( 'beans_test', 'class', 'uk-panel-box' ); - $actual = apply_filters( 'beans_test_attributes', $attributes ); + + // Fire the event to run the remove. + $actual = apply_filters( 'beans_test_attributes', $attributes ); // Check that it removed only that attribute value. $this->assertNotContains( 'uk-panel-box', $actual['class'] ); @@ -116,17 +123,22 @@ public function test_should_remove_the_given_value_from_attribute() { } /** - * Systems test beans_remove_attribute() by firing the expected filter event for the given ID. Test should return an - * empty array when an empty array is given. Why? There is nothing to remove, as there are no attributes. + * Test the end result of beans_remove_attribute() by firing the expected filter event for the given ID. Test + * should return an empty array when an empty array is given. Why? There is nothing to remove, as there are no + * attributes. */ - public function test_should_return_original_empty_array() { + public function test_should_return_empty_array_when_empty_array_given() { foreach ( static::$test_attributes as $beans_id => $markup ) { $name = key( $markup['attributes'] ); $value = current( $markup['attributes'] ); $instance = beans_remove_attribute( $beans_id, $name, $value ); - $this->assertSame( array(), apply_filters( "{$beans_id}_attributes", array() ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + // Fire the event to run the remove. + $actual = apply_filters( "{$beans_id}_attributes", array() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + + // Check that an empty array is returned. + $this->assertSame( array(), $actual ); // Clean up. remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ), 10 ); diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index 9c4cd1a3..8027c884 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -17,8 +17,8 @@ * Class Tests_BeansReplaceAttribute * * @package Beans\Framework\Tests\Integration\API\HTML - * @group integration-tests * @group api + * @group api-html */ class Tests_BeansReplaceAttribute extends HTML_Test_Case { @@ -42,7 +42,7 @@ public function test_should_return_instance_and_register_callback_to_given_id() } /** - * Systems test beans_replace_attribute() by firing the expected filter event for the given ID. Test should replace + * Test the end result of beans_replace_attribute() by firing the expected filter event for the given ID. Test should replace * an existing attribute value. */ public function test_should_replace_existing_attribute_value() { @@ -71,7 +71,7 @@ public function test_should_replace_existing_attribute_value() { } /** - * Systems test beans_replace_attribute() by firing the expected filter event for the given ID. Test should replace + * Test the end result of beans_replace_attribute() by firing the expected filter event for the given ID. Test should replace * (overwrite) all attribute's values with the new value when the target value is empty (null, empty string, etc.). */ public function test_should_overwrite_attribute_values_when_target_value_is_empty() { @@ -107,7 +107,7 @@ public function test_should_overwrite_attribute_values_when_target_value_is_empt } /** - * Systems test beans_replace_attribute() by firing the expected filter event for the given ID. Test should add the + * Test the end result of beans_replace_attribute() by firing the expected filter event for the given ID. Test should add the * attribute when it does not exists in the given attributes. */ public function test_should_add_attribute_when_does_not_exist() { @@ -136,7 +136,7 @@ public function test_should_add_attribute_when_does_not_exist() { } /** - * Systems test beans_replace_attribute() by firing the expected filter event for the given ID. Test should add the + * Test the end result of beans_replace_attribute() by firing the expected filter event for the given ID. Test should add the * attribute when an empty array is given. */ public function test_should_add_attribute_when_an_empty_array_given() { diff --git a/tests/phpunit/unit/api/html/beans-attribute/add.php b/tests/phpunit/unit/api/html/beans-attribute/add.php index a5dbbe96..ef08131c 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/add.php +++ b/tests/phpunit/unit/api/html/beans-attribute/add.php @@ -18,8 +18,8 @@ * Class Tests_Beans_Attribute_Add * * @package Beans\Framework\Tests\Unit\API\HTML - * @group unit-tests * @group api + * @group api-html */ class Tests_Beans_Attribute_Add extends HTML_Test_Case { diff --git a/tests/phpunit/unit/api/html/beans-attribute/init.php b/tests/phpunit/unit/api/html/beans-attribute/init.php index 56d2ae87..5d17ea51 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/init.php +++ b/tests/phpunit/unit/api/html/beans-attribute/init.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Attribute_Init * * @package Beans\Framework\Tests\Unit\API\HTML - * @group unit-tests * @group api + * @group api-html */ class Tests_Beans_Attribute_Init extends HTML_Test_Case { diff --git a/tests/phpunit/unit/api/html/beans-attribute/remove.php b/tests/phpunit/unit/api/html/beans-attribute/remove.php index 68b31fa1..ba414b1c 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/remove.php +++ b/tests/phpunit/unit/api/html/beans-attribute/remove.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Attribute_Remove * * @package Beans\Framework\Tests\Unit\API\HTML - * @group unit-tests * @group api + * @group api-html */ class Tests_Beans_Attribute_Remove extends HTML_Test_Case { @@ -31,13 +31,14 @@ class Tests_Beans_Attribute_Remove extends HTML_Test_Case { public function test_should_return_original_attributes_when_target_attribute_does_not_exist() { foreach ( static::$test_attributes as $beans_id => $markup ) { - $instance = new _Beans_Attribute( $beans_id, 'data-test', 'test' ); - // Check that the attribute does not exist before we run the test. $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); + // Run the remove. + $actual = ( new _Beans_Attribute( $beans_id, 'data-test', 'test' ) )->remove( $markup['attributes'] ); + // Check that the original attributes are returned. - $this->assertSame( $markup['attributes'], $instance->remove( $markup['attributes'] ) ); + $this->assertSame( $markup['attributes'], $actual ); } } @@ -47,7 +48,9 @@ public function test_should_return_original_attributes_when_target_attribute_doe public function test_should_remove_attribute_when_value_is_null() { foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); + $name = key( $markup['attributes'] ); + + // Run the remove. $actual = ( new _Beans_Attribute( 'beans_test_post', $name ) )->remove( $markup['attributes'] ); // Check that the attribute is removed. @@ -72,10 +75,10 @@ public function test_should_remove_the_given_value_from_attribute() { 'itemprop' => 'beans_post', ); - $instance = new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box' ); + // Run the remove. + $actual = ( new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box' ) )->remove( $attributes ); // Check that it removed only that attribute value. - $actual = $instance->remove( $attributes ); $this->assertNotContains( 'uk-panel-box', $actual['class'] ); $this->assertSame( 'uk-article category-beans', $actual['class'] ); @@ -89,14 +92,17 @@ public function test_should_remove_the_given_value_from_attribute() { * Test remove() should the empty array when an empty array is given. Why? There is nothing to remove, as there are * no attributes. */ - public function test_should_return_original_empty_array() { + public function test_should_return_empty_array_when_empty_array_given() { foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $value = current( $markup['attributes'] ); - $instance = new _Beans_Attribute( $beans_id, $name, $value ); + $name = key( $markup['attributes'] ); + $value = current( $markup['attributes'] ); + + // Run the remove. + $actual = ( new _Beans_Attribute( $beans_id, $name, $value ) )->remove( array() ); - $this->assertSame( array(), $instance->remove( array() ) ); + // Check that an empty array is returned. + $this->assertSame( array(), $actual ); } } } diff --git a/tests/phpunit/unit/api/html/beans-attribute/replace.php b/tests/phpunit/unit/api/html/beans-attribute/replace.php index edce4cee..0dd41094 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/replace.php +++ b/tests/phpunit/unit/api/html/beans-attribute/replace.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Attribute_Replace * * @package Beans\Framework\Tests\Unit\API\HTML - * @group unit-tests * @group api + * @group api-html */ class Tests_Beans_Attribute_Replace extends HTML_Test_Case { diff --git a/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php b/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php index 6fb1296a..62b38763 100644 --- a/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php +++ b/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php @@ -18,8 +18,8 @@ * Class Tests_BeansIsHtmlDevMode * * @package Beans\Framework\Tests\Unit\API\HTML - * @group unit-tests * @group api + * @group api-html */ class Tests_BeansIsHtmlDevMode extends HTML_Test_Case { From 74c92ca1e6ec9d4d6e31338c7a07a6a0909d7ad8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 1 Mar 2018 11:43:38 -0600 Subject: [PATCH 166/800] Improved _beans_is_html_dev_mode tests. 1. Added integration tests to check expected behavior with option value. 2. Added check for the constant. --- lib/api/html/functions.php | 4 +- .../api/html/beansIsHtmlDevMode.php | 49 +++++++++++++++++++ .../unit/api/html/beansIsHtmlDevMode.php | 20 +++++++- 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beansIsHtmlDevMode.php diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 5aa45775..f3f84a9b 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -620,8 +620,8 @@ function beans_remove_attribute( $id, $attribute, $value = null ) { function _beans_is_html_dev_mode() { if ( defined( 'BEANS_HTML_DEV_MODE' ) ) { - return BEANS_HTML_DEV_MODE; + return (bool) BEANS_HTML_DEV_MODE; } - return get_option( 'beans_dev_mode', false ); + return (bool) get_option( 'beans_dev_mode', false ); } diff --git a/tests/phpunit/integration/api/html/beansIsHtmlDevMode.php b/tests/phpunit/integration/api/html/beansIsHtmlDevMode.php new file mode 100644 index 00000000..19f3342a --- /dev/null +++ b/tests/phpunit/integration/api/html/beansIsHtmlDevMode.php @@ -0,0 +1,49 @@ +assertFalse( defined( 'BEANS_HTML_DEV_MODE' ) ); + $this->assertFalse( _beans_is_html_dev_mode() ); + } + + /** + * Test _beans_is_html_dev_mode() should return the option's value. + */ + public function test_should_return_option_value() { + add_option( 'beans_dev_mode', 1 ); + $this->assertTrue( _beans_is_html_dev_mode() ); + + update_option( 'beans_dev_mode', 0 ); + $this->assertFalse( _beans_is_html_dev_mode() ); + + // Clean up. + delete_option( 'beans_dev_mode' ); + } +} diff --git a/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php b/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php index 62b38763..4e4a40b3 100644 --- a/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php +++ b/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php @@ -33,6 +33,7 @@ public function test_should_false_when_option_does_not_exist() { ->with( 'beans_dev_mode', false ) ->once() ->andReturn( false ); + $this->assertFalse( _beans_is_html_dev_mode() ); } @@ -40,13 +41,28 @@ public function test_should_false_when_option_does_not_exist() { * Test _beans_is_html_dev_mode() should return the option's value. */ public function test_should_return_option_value() { - $this->assertFalse( defined( 'BEANS_HTML_DEV_MODE' ) ); + Monkey\Functions\expect( 'get_option' ) + ->with( 'beans_dev_mode', false ) + ->once() + ->andReturn( 0 ); + + $this->assertFalse( _beans_is_html_dev_mode() ); Monkey\Functions\expect( 'get_option' ) ->with( 'beans_dev_mode', false ) ->once() - ->andReturn( true ); + ->andReturn( 1 ); $this->assertTrue( _beans_is_html_dev_mode() ); } + + /** + * Test _beans_is_html_dev_mode() should return the constant's value. + */ + public function test_should_return_constant_value() { + Monkey\Functions\expect( 'get_option' )->never(); + + define( 'BEANS_HTML_DEV_MODE', 0 ); + $this->assertFalse( _beans_is_html_dev_mode() ); + } } From 2ca6095416581048002719a11cc7224d9f2ae841 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Thu, 1 Mar 2018 16:41:30 -0500 Subject: [PATCH 167/800] Add tests for beans_get_term_meta() (#150) * Add unit tests for beans_get_term_meta() * Fixes #146 --- lib/api/term-meta/functions.php | 2 +- .../api/term-meta/beansGetTermMeta.php | 82 ++++++++++++++ .../unit/api/term-meta/beansGetTermMeta.php | 107 ++++++++++++++++++ 3 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/integration/api/term-meta/beansGetTermMeta.php create mode 100644 tests/phpunit/unit/api/term-meta/beansGetTermMeta.php diff --git a/lib/api/term-meta/functions.php b/lib/api/term-meta/functions.php index eb9bc213..291f07ce 100644 --- a/lib/api/term-meta/functions.php +++ b/lib/api/term-meta/functions.php @@ -26,5 +26,5 @@ function beans_get_term_meta( $field_id, $default = false, $term_id = false ) { $term_id = $_term_id ? $_term_id : beans_get( 'tag_ID' ); } - return get_option( "beans_term_{$term_id}_{$field_id}", $default ); + return $term_id ? get_option( "beans_term_{$term_id}_{$field_id}", $default ) : $default; } diff --git a/tests/phpunit/integration/api/term-meta/beansGetTermMeta.php b/tests/phpunit/integration/api/term-meta/beansGetTermMeta.php new file mode 100644 index 00000000..18daa4c2 --- /dev/null +++ b/tests/phpunit/integration/api/term-meta/beansGetTermMeta.php @@ -0,0 +1,82 @@ +assertFalse( beans_get_term_meta( 'beans_layout' ) ); + + $_GET['tag_ID'] = 1; // a tag_ID is set. + $this->assertFalse( beans_get_term_meta( 'beans_layout' ) ); + + $term_id = $this->factory()->category->create(); + $this->go_to( ( '?cat=' . $term_id ) ); // a term_id is set. + + $this->assertFalse( beans_get_term_meta( 'beans_layout' ) ); + } + + /** + * Test beans_get_term_meta() should return default when given and term meta does not exist. + */ + public function test_should_return_default_when_default_given_and_term_meta_not_set() { + $default_term_id = $this->factory()->category->create(); + $provided_term_id = $this->factory()->category->create(); + $this->go_to( ( '?cat=' . $default_term_id ) ); + + $this->assertSame( 'default_fallback', beans_get_term_meta( 'beans_layout', 'default_fallback' ) ); + $this->assertSame( 'default_fallback', beans_get_term_meta( 'beans_layout', 'default_fallback', $provided_term_id ) ); + } + + /** + * Test beans_get_term_meta() should return term's meta value when it exists. + */ + public function test_should_return_term_meta_when_meta_is_set() { + $default_term_id = $this->factory()->category->create(); + update_option( "beans_term_{$default_term_id}_beans_layout", 'sp-c' ); + $provided_term_id = $this->factory()->category->create(); + update_option( "beans_term_{$provided_term_id}_beans_layout", 'c-sp' ); + $this->go_to( ( '?cat=' . $default_term_id ) ); + + $this->assertSame( 'sp-c', beans_get_term_meta( 'beans_layout', 'default_fallback' ) ); + $this->assertSame( 'c-sp', beans_get_term_meta( 'beans_layout', 'default_fallback', $provided_term_id ) ); + } + + /** + * Test beans_get_term_meta() should return default when given and tag_ID set but term meta does not exist. + */ + public function test_should_return_default_when_given_and_tag_id_exists_but_term_meta_not_set() { + $_GET['tag_ID'] = 2; + + $this->assertSame( 'default_fallback', beans_get_term_meta( 'beans_layout', 'default_fallback' ) ); + } + + /** + * Test beans_get_term_meta() should return meta term's value when given and tag_ID set and meta exists. + */ + public function test_should_return_term_meta_when_given_and_tag_id_exists_but_term_meta_not_set() { + $_GET['tag_ID'] = 3; + update_option( 'beans_term_3_beans_layout', 'sp-c' ); + + $this->assertSame( 'sp-c', beans_get_term_meta( 'beans_layout', 'default_fallback' ) ); + } +} diff --git a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php new file mode 100644 index 00000000..4c98866e --- /dev/null +++ b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php @@ -0,0 +1,107 @@ +once() + ->andReturn( (object) array( 'post_id' => 1 ) ); // return an object with no term_id. + Monkey\Functions\expect( 'get_option' )->never(); + + $this->assertFalse( beans_get_term_meta( 'beans_layout' ) ); + } + + /** + * Test beans_get_term_meta() should return default when given and queried object has a term_id but term meta does not exist. + */ + public function test_should_return_default_when_default_given_and_queried_obj_has_term_id_but_term_meta_not_set() { + Monkey\Functions\expect( 'get_queried_object' ) + ->once() + ->andReturn( (object) array( 'term_id' => 1 ) ); + Monkey\Functions\expect( 'get_option' ) + ->with( 'beans_term_1_beans_layout', 'default_fallback' ) + ->twice() + ->andReturn( 'default_fallback' ); + + $this->assertSame( 'default_fallback', beans_get_term_meta( 'beans_layout', 'default_fallback' ) ); + $this->assertSame( 'default_fallback', beans_get_term_meta( 'beans_layout', 'default_fallback', 1 ) ); + } + + /** + * Test beans_get_term_meta() should return meta term's value when queried object has a term_id and meta for that id exists. + */ + public function test_should_return_term_meta_when_queried_object_has_term_id_and_meta_is_set() { + Monkey\Functions\expect( 'get_queried_object' ) + ->once() + ->andReturn( (object) array( 'term_id' => 1 ) ); + Monkey\Functions\expect( 'get_option' ) + ->with( 'beans_term_1_beans_layout', 'default_fallback' ) + ->twice() + ->andReturn( 'c-sp' ); + + $this->assertSame( 'c-sp', beans_get_term_meta( 'beans_layout', 'default_fallback' ) ); + $this->assertSame( 'c-sp', beans_get_term_meta( 'beans_layout', 'default_fallback', 1 ) ); + } + + /** + * Test beans_get_term_meta() should return default when given and term_id is tag_ID but term meta does not exist. + */ + public function test_should_return_default_when_default_given_and_term_id_is_tag_id_but_term_meta_not_set() { + $_GET['tag_ID'] = 1; + Monkey\Functions\expect( 'get_queried_object' ) + ->once() + ->andReturn( (object) array( 'post_id' => 1 ) ); + Monkey\Functions\expect( 'get_option' ) + ->with( 'beans_term_1_beans_layout', 'default_fallback' ) + ->once() + ->andReturn( 'default_fallback' ); + + $this->assertSame( 'default_fallback', beans_get_term_meta( 'beans_layout', 'default_fallback' ) ); + } + + /** + * Test beans_get_term_meta() should return meta term's value when term_id is tag_ID and term meta for that id exists. + */ + public function test_should_return_term_meta_when_default_given_and_term_id_is_tag_id_and_term_meta_exists() { + $_GET['tag_ID'] = 1; + Monkey\Functions\expect( 'get_queried_object' ) + ->once() + ->andReturn( (object) array( 'post_id' => 1 ) ); + Monkey\Functions\expect( 'get_option' ) + ->with( 'beans_term_1_beans_layout', 'default_fallback' ) + ->once() + ->andReturn( 'c-sp' ); + + $this->assertSame( 'c-sp', beans_get_term_meta( 'beans_layout', 'default_fallback' ) ); + } +} From 20dba6ba7de602fc855d7ae99468dd6b8f478c6f Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 2 Mar 2018 12:42:48 -0500 Subject: [PATCH 168/800] Made lib\templates\structure WPCS compliant (#140) --- lib/templates/structure/comment.php | 36 ++++++++----- lib/templates/structure/comments.php | 31 ++++++----- lib/templates/structure/content.php | 8 ++- lib/templates/structure/footer-partial.php | 20 ++++--- lib/templates/structure/footer.php | 4 +- lib/templates/structure/header-partial.php | 20 ++++--- lib/templates/structure/header.php | 31 +++++++---- lib/templates/structure/loop.php | 33 ++++++------ lib/templates/structure/sidebar-primary.php | 20 ++++--- lib/templates/structure/sidebar-secondary.php | 20 ++++--- lib/templates/structure/widget-area.php | 54 +++++++++++-------- 11 files changed, 175 insertions(+), 102 deletions(-) diff --git a/lib/templates/structure/comment.php b/lib/templates/structure/comment.php index e34d0451..74910ec6 100644 --- a/lib/templates/structure/comment.php +++ b/lib/templates/structure/comment.php @@ -2,16 +2,22 @@ /** * Echo the structural markup for each comment. It also calls the comment action hooks. * - * @package Structure\Comment + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ -beans_open_markup_e( 'beans_comment', 'article', array( - 'id' => 'div-comment-' . get_comment_ID(), // Automatically escaped. - 'class' => 'uk-comment', - 'itemprop' => 'comment', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/Comment', -) ); +beans_open_markup_e( + 'beans_comment', + 'article', + array( + 'id' => 'div-comment-' . get_comment_ID(), // Automatically escaped. + 'class' => 'uk-comment', + 'itemprop' => 'comment', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/Comment', + ) +); beans_open_markup_e( 'beans_comment_header', 'header', array( 'class' => 'uk-comment-header' ) ); @@ -24,10 +30,14 @@ beans_close_markup_e( 'beans_comment_header', 'header' ); - beans_open_markup_e( 'beans_comment_body', 'div', array( - 'class' => 'uk-comment-body', - 'itemprop' => 'text', - ) ); + beans_open_markup_e( + 'beans_comment_body', + 'div', + array( + 'class' => 'uk-comment-body', + 'itemprop' => 'text', + ) + ); /** * Fires in the comment body. @@ -38,4 +48,4 @@ beans_close_markup_e( 'beans_comment_body', 'div' ); -beans_close_markup_e( 'beans_comment', 'article' ); +beans_close_markup_e( 'beans_comment', 'article' ); // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect -- Code structure mirrors HTML markup. diff --git a/lib/templates/structure/comments.php b/lib/templates/structure/comments.php index 4dd335f1..56f2ef29 100644 --- a/lib/templates/structure/comments.php +++ b/lib/templates/structure/comments.php @@ -4,7 +4,9 @@ * * This template will return empty if the post which is called is password protected. * - * @package Structure\Comments + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ // Stop here if the post is password protected. @@ -12,21 +14,28 @@ return; } -beans_open_markup_e( 'beans_comments', 'div', array( 'id' => 'comments', 'class' => 'tm-comments' . ( current_theme_supports( 'beans-default-styling' ) ? ' uk-panel-box' : null ) ) ); - +beans_open_markup_e( + 'beans_comments', + 'div', + array( + 'id' => 'comments', + 'class' => 'tm-comments' . ( current_theme_supports( 'beans-default-styling' ) ? ' uk-panel-box' : null ), + ) +); + // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Code structure mirrors HTML markup. if ( comments_open() || get_comments_number() ) : if ( have_comments() ) : - beans_open_markup_e( 'beans_comments_list', 'ol', array( 'class' => 'uk-comment-list' ) ); - wp_list_comments( array( - 'avatar_size' => 50, - 'callback' => 'beans_comment_callback', - ) ); + wp_list_comments( + array( + 'avatar_size' => 50, + 'callback' => 'beans_comment_callback', + ) + ); beans_close_markup_e( 'beans_comments_list', 'ol' ); - else : /** @@ -37,7 +46,6 @@ * @since 1.0.0 */ do_action( 'beans_no_comment' ); - endif; /** @@ -48,7 +56,6 @@ * @since 1.0.0 */ do_action( 'beans_after_open_comments' ); - endif; if ( ! comments_open() ) : @@ -59,7 +66,7 @@ * @since 1.0.0 */ do_action( 'beans_comments_closed' ); - endif; beans_close_markup_e( 'beans_comments', 'div' ); +//phpcs:enable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Code structure mirrors HTML markup. diff --git a/lib/templates/structure/content.php b/lib/templates/structure/content.php index 556994a7..be4c85a0 100644 --- a/lib/templates/structure/content.php +++ b/lib/templates/structure/content.php @@ -2,9 +2,12 @@ /** * Echo the structural markup for the main content. It also calls the content action hooks. * - * @package Structure\Content + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variable called in a function scope. $content_attributes = array( 'class' => 'tm-content', 'role' => 'main', @@ -23,9 +26,10 @@ if ( is_search() ) { $content_attributes['itemscope'] = 'itemscope'; // Automatically escaped. - $content_attributes['itemtype'] = 'http://schema.org/SearchResultsPage'; // Automatically escaped. + $content_attributes['itemtype'] = 'http://schema.org/SearchResultsPage'; // Automatically escaped. } +// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound beans_open_markup_e( 'beans_content', 'div', $content_attributes ); diff --git a/lib/templates/structure/footer-partial.php b/lib/templates/structure/footer-partial.php index 4a3a9138..dba6d54b 100644 --- a/lib/templates/structure/footer-partial.php +++ b/lib/templates/structure/footer-partial.php @@ -2,15 +2,21 @@ /** * Since WordPress force us to use the footer.php name to close the document, we add a footer-partial.php template for the actual footer. * - * @package Structure\Footer + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ -beans_open_markup_e( 'beans_footer', 'footer', array( - 'class' => 'tm-footer uk-block', - 'role' => 'contentinfo', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPFooter', -) ); +beans_open_markup_e( + 'beans_footer', + 'footer', + array( + 'class' => 'tm-footer uk-block', + 'role' => 'contentinfo', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/WPFooter', + ) +); beans_open_markup_e( 'beans_fixed_wrap[_footer]', 'div', 'class=uk-container uk-container-center' ); diff --git a/lib/templates/structure/footer.php b/lib/templates/structure/footer.php index fa4395ba..e4d745c4 100644 --- a/lib/templates/structure/footer.php +++ b/lib/templates/structure/footer.php @@ -4,7 +4,9 @@ * * This template must be called using get_footer(). * - * @package Structure\Footer + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ beans_close_markup_e( 'beans_primary', 'div' ); diff --git a/lib/templates/structure/header-partial.php b/lib/templates/structure/header-partial.php index f5d3d2c9..9deda11d 100644 --- a/lib/templates/structure/header-partial.php +++ b/lib/templates/structure/header-partial.php @@ -2,15 +2,21 @@ /** * Since WordPress force us to use the header.php name to open the document, we add a header-partial.php template for the actual header. * - * @package Structure\Header + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ -beans_open_markup_e( 'beans_header', 'header', array( - 'class' => 'tm-header uk-block', - 'role' => 'banner', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPHeader', -) ); +beans_open_markup_e( + 'beans_header', + 'header', + array( + 'class' => 'tm-header uk-block', + 'role' => 'banner', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/WPHeader', + ) +); beans_open_markup_e( 'beans_fixed_wrap[_header]', 'div', 'class=uk-container uk-container-center' ); diff --git a/lib/templates/structure/header.php b/lib/templates/structure/header.php index ed46e0cf..34fd2587 100644 --- a/lib/templates/structure/header.php +++ b/lib/templates/structure/header.php @@ -4,7 +4,9 @@ * * This template must be called using get_header(). * - * @package Structure\Header + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ beans_output_e( 'beans_doctype', '' ); @@ -26,12 +28,16 @@ beans_close_markup_e( 'beans_head', 'head' ); - beans_open_markup_e( 'beans_body', 'body', array( - 'class' => implode( ' ', get_body_class( 'uk-form no-js' ) ), - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WebPage', + beans_open_markup_e( + 'beans_body', + 'body', + array( + 'class' => implode( ' ', get_body_class( 'uk-form no-js' ) ), + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/WebPage', - ) ); + ) + ); beans_open_markup_e( 'beans_site', 'div', array( 'class' => 'tm-site' ) ); @@ -39,8 +45,13 @@ beans_open_markup_e( 'beans_fixed_wrap[_main]', 'div', 'class=uk-container uk-container-center' ); - beans_open_markup_e( 'beans_main_grid', 'div', array( 'class' => 'uk-grid', 'data-uk-grid-margin' => '' ) ); + beans_open_markup_e( + 'beans_main_grid', + 'div', + array( + 'class' => 'uk-grid', + 'data-uk-grid-margin' => '', + ) + ); - beans_open_markup_e( 'beans_primary', 'div', array( - 'class' => 'tm-primary ' . beans_get_layout_class( 'content' ), - ) ); + beans_open_markup_e( 'beans_primary', 'div', array( 'class' => 'tm-primary ' . beans_get_layout_class( 'content' ) ) ); diff --git a/lib/templates/structure/loop.php b/lib/templates/structure/loop.php index 37d85632..a21515f1 100644 --- a/lib/templates/structure/loop.php +++ b/lib/templates/structure/loop.php @@ -2,7 +2,9 @@ /** * Echo the posts loop structural markup. It also calls the loop action hooks. * - * @package Structure\Loop + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ /** @@ -13,7 +15,7 @@ * @since 1.0.0 */ do_action( 'beans_before_loop' ); - + // phpcs:disable Generic.WhiteSpace.ScopeIndent -- Code structure mirrors HTML markup. if ( have_posts() && ! is_404() ) : /** @@ -25,8 +27,10 @@ */ do_action( 'beans_before_posts_loop' ); - while ( have_posts() ) : the_post(); + while ( have_posts() ) : + the_post(); + // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variable called in a function scope. $article_attributes = array( 'id' => get_the_ID(), // Automatically escaped. 'class' => implode( ' ', get_post_class( array( 'uk-article', ( current_theme_supports( 'beans-default-styling' ) ? 'uk-panel-box' : null ) ) ) ), // Automatically escaped. @@ -39,11 +43,12 @@ $article_attributes['itemtype'] = 'http://schema.org/BlogPosting'; - // Only add to blogPost attribute to the main query, + // Only add to blogPost attribute to the main query. if ( is_main_query() && ! is_search() ) { - $article_attributes['itemprop'] = 'blogPost'; + $article_attributes['itemprop'] = 'blogPost'; } } + // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound beans_open_markup_e( 'beans_post', 'article', $article_attributes ); @@ -70,7 +75,6 @@ beans_close_markup_e( 'beans_post_body', 'div' ); beans_close_markup_e( 'beans_post', 'article' ); - endwhile; /** @@ -81,16 +85,14 @@ * @since 1.0.0 */ do_action( 'beans_after_posts_loop' ); - else : - /** - * Fires if no posts exist. - * - * @since 1.0.0 - */ - do_action( 'beans_no_post' ); - + /** + * Fires if no posts exist. + * + * @since 1.0.0 + */ + do_action( 'beans_no_post' ); endif; /** @@ -100,4 +102,5 @@ * * @since 1.0.0 */ -do_action( 'beans_after_loop' ); + do_action( 'beans_after_loop' ); +// phpcs:enable Generic.WhiteSpace.ScopeIndent -- Code structure mirrors HTML markup. diff --git a/lib/templates/structure/sidebar-primary.php b/lib/templates/structure/sidebar-primary.php index 69180913..8d379787 100644 --- a/lib/templates/structure/sidebar-primary.php +++ b/lib/templates/structure/sidebar-primary.php @@ -2,15 +2,21 @@ /** * Echo the primary sidebar structural markup. It also calls the primary sidebar action hooks. * - * @package Structure\Primary_Sidebar + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ -beans_open_markup_e( 'beans_sidebar_primary', 'aside', array( - 'class' => 'tm-secondary ' . beans_get_layout_class( 'sidebar_primary' ), // Automatically escaped. - 'role' => 'complementary', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPSideBar', -) ); +beans_open_markup_e( + 'beans_sidebar_primary', + 'aside', + array( + 'class' => 'tm-secondary ' . beans_get_layout_class( 'sidebar_primary' ), // Automatically escaped. + 'role' => 'complementary', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/WPSideBar', + ) +); /** * Fires in the primary sidebar. diff --git a/lib/templates/structure/sidebar-secondary.php b/lib/templates/structure/sidebar-secondary.php index 34485059..d3570a2b 100644 --- a/lib/templates/structure/sidebar-secondary.php +++ b/lib/templates/structure/sidebar-secondary.php @@ -2,15 +2,21 @@ /** * Echo the secondary sidebar structural markup. It also calls the secondary sidebar action hooks. * - * @package Structure\Secondary_Sidebar + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ -beans_open_markup_e( 'beans_sidebar_secondary', 'aside', array( - 'class' => 'tm-tertiary ' . beans_get_layout_class( 'sidebar_secondary' ), // Automatically escaped. - 'role' => 'complementary', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPSideBar', -) ); +beans_open_markup_e( + 'beans_sidebar_secondary', + 'aside', + array( + 'class' => 'tm-tertiary ' . beans_get_layout_class( 'sidebar_secondary' ), // Automatically escaped. + 'role' => 'complementary', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/WPSideBar', + ) +); /** * Fires in the secondary sidebar. diff --git a/lib/templates/structure/widget-area.php b/lib/templates/structure/widget-area.php index f71e3363..51b8a55a 100644 --- a/lib/templates/structure/widget-area.php +++ b/lib/templates/structure/widget-area.php @@ -3,25 +3,38 @@ * Echo the widget area and widget loop structural markup. It also calls the widget area and widget loop * action hooks. * - * @package Structure\Widget_Area + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ // This includes everything added to wp hooks before the widgets. -echo beans_get_widget_area( 'before_widgets' ); - - if ( 'grid' == beans_get_widget_area( 'beans_type' ) ) { - beans_open_markup_e( 'beans_widget_area_grid' . _beans_widget_area_subfilters(), 'div', array( 'class' => 'uk-grid', 'data-uk-grid-margin' => '' ) ); +echo beans_get_widget_area( 'before_widgets' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Widget area has to be echoed. + + // phpcs:disable Generic.WhiteSpace.ScopeIndent -- Code structure mirrors HTML markup. + if ( 'grid' === beans_get_widget_area( 'beans_type' ) ) { + beans_open_markup_e( + 'beans_widget_area_grid' . _beans_widget_area_subfilters(), + 'div', + array( + 'class' => 'uk-grid', + 'data-uk-grid-margin' => '', + ) + ); } - if ( 'offcanvas' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'offcanvas' === beans_get_widget_area( 'beans_type' ) ) { - beans_open_markup_e( 'beans_widget_area_offcanvas_wrap' . _beans_widget_area_subfilters(), 'div', array( - 'id' => beans_get_widget_area( 'id' ), // Automatically escaped. - 'class' => 'uk-offcanvas', - ) ); + beans_open_markup_e( + 'beans_widget_area_offcanvas_wrap' . _beans_widget_area_subfilters(), + 'div', + array( + 'id' => beans_get_widget_area( 'id' ), // Automatically escaped. + 'class' => 'uk-offcanvas', + ) + ); beans_open_markup_e( 'beans_widget_area_offcanvas_bar' . _beans_widget_area_subfilters(), 'div', array( 'class' => 'uk-offcanvas-bar' ) ); - } // Widgets. @@ -36,9 +49,10 @@ */ do_action( 'beans_before_widgets_loop' ); - while ( beans_have_widgets() ) : beans_setup_widget(); + while ( beans_have_widgets() ) : + beans_setup_widget(); - if ( 'grid' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'grid' === beans_get_widget_area( 'beans_type' ) ) { beans_open_markup_e( 'beans_widget_grid' . _beans_widget_subfilters(), 'div', beans_widget_shortcodes( 'class=uk-width-medium-1-{count}' ) ); } @@ -53,10 +67,9 @@ beans_close_markup_e( 'beans_widget_panel' . _beans_widget_subfilters(), 'div' ); - if ( 'grid' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'grid' === beans_get_widget_area( 'beans_type' ) ) { beans_close_markup_e( 'beans_widget_grid' . _beans_widget_subfilters(), 'div' ); } - endwhile; /** @@ -67,7 +80,6 @@ * @since 1.0.0 */ do_action( 'beans_after_widgets_loop' ); - else : /** @@ -76,20 +88,20 @@ * @since 1.0.0 */ do_action( 'beans_no_widget' ); - endif; - if ( 'offcanvas' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'offcanvas' === beans_get_widget_area( 'beans_type' ) ) { beans_close_markup_e( 'beans_widget_area_offcanvas_bar' . _beans_widget_area_subfilters(), 'div' ); beans_close_markup_e( 'beans_widget_area_offcanvas_wrap' . _beans_widget_area_subfilters(), 'div' ); - } - if ( 'grid' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'grid' === beans_get_widget_area( 'beans_type' ) ) { beans_close_markup_e( 'beans_widget_area_grid' . _beans_widget_area_subfilters(), 'div' ); } // This includes everything added to wp hooks after the widgets. -echo beans_get_widget_area( 'after_widgets' ); +echo beans_get_widget_area( 'after_widgets' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Widget area has to be echoed. + +// phpcs:enable Generic.WhiteSpace.ScopeIndent -- Code structure mirrors HTML markup. From 8bb42f9c163f491cfe8d986169970df88dbe7c08 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 2 Mar 2018 13:52:22 -0600 Subject: [PATCH 169/800] Added ability to load original function into memory before the monkey patch. The tests were failing due to the original functions not being loaded into memory _before_ using Brain Monkey and Patchwork. The sequence to redefine an original function is: 1. Load the original function into memory. 2. Monkey patch it with Brain Monkey expect() or when(), which redefines that function for our unit tests. 3. Then restore the function back to its original declaration, which is handled at tear down by Brain Monkey. --- .../unit/api/layout/beansGetDefaultLayout.php | 6 ++++- .../unit/api/layout/beansGetLayout.php | 7 +++++- .../unit/api/layout/beansGetLayoutClass.php | 8 +++++-- tests/phpunit/unit/class-test-case.php | 23 +++++++++++++++++-- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php index 09724618..be21012d 100644 --- a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php @@ -16,8 +16,8 @@ * Class Tests_BeansGetDefaultLayout * * @package Beans\Framework\Tests\Unit\API\Layout - * @group unit-tests * @group api + * @group api-layout */ class Tests_BeansGetDefaultLayout extends Test_Case { @@ -28,6 +28,10 @@ protected function setUp() { parent::setUp(); require_once BEANS_TESTS_LIB_DIR . 'api/layout/functions.php'; + + $this->load_original_functions( array( + 'api/widget/functions.php', + ) ); } /** diff --git a/tests/phpunit/unit/api/layout/beansGetLayout.php b/tests/phpunit/unit/api/layout/beansGetLayout.php index b301b0b5..54acd067 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetLayout.php @@ -16,8 +16,8 @@ * Class Tests_BeansGetLayout * * @package Beans\Framework\Tests\Unit\API\Layout - * @group unit-tests * @group api + * @group api-layout */ class Tests_BeansGetLayout extends Test_Case { @@ -28,6 +28,11 @@ protected function setUp() { parent::setUp(); require_once BEANS_TESTS_LIB_DIR . 'api/layout/functions.php'; + + $this->load_original_functions( array( + 'api/post-meta/functions.php', + 'api/term-meta/functions.php', + ) ); } /** diff --git a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php index 5ce3e5d9..b25cfc20 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php @@ -16,8 +16,8 @@ * Class Tests_BeansGetLayoutClass * * @package Beans\Framework\Tests\Unit\API\Layout - * @group unit-tests * @group api + * @group api-layout */ class Tests_BeansGetLayoutClass extends Test_Case { @@ -28,7 +28,11 @@ protected function setUp() { parent::setUp(); require_once BEANS_TESTS_LIB_DIR . 'api/layout/functions.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; + + $this->load_original_functions( array( + 'api/utilities/functions.php', + 'api/post-meta/functions.php', + ) ); } /** diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 5a6abf18..46fd3568 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -27,7 +27,7 @@ protected function setUp() { parent::setUp(); Monkey\setUp(); - Functions\when( 'wp_normalize_path' )->alias( function ( $path ) { + Functions\when( 'wp_normalize_path' )->alias( function( $path ) { $path = str_replace( '\\', '/', $path ); $path = preg_replace( '|(?<=.)/+|', '/', $path ); @@ -38,7 +38,7 @@ protected function setUp() { return $path; } ); - Functions\when( 'wp_json_encode' )->alias( function ( $array ) { + Functions\when( 'wp_json_encode' )->alias( function( $array ) { return json_encode( $array ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode -- Required as part of our mock. } ); } @@ -50,4 +50,23 @@ protected function tearDown() { Monkey\tearDown(); parent::tearDown(); } + + /** + * Load the original Beans' functions into memory before we start. + * + * Then in our tests, we monkey patch via Brain Monkey, which redefines the original function. + * At tear down, the original function is restored in Brain Monkey, by calling Patchwork\restoreAll(). + * + * @since 1.0.0 + * + * @param array $files Array of files to load into memory. + * + * @return void + */ + protected function load_original_functions( array $files ) { + + foreach ( $files as $file ) { + require_once BEANS_TESTS_LIB_DIR . $file; + } + } } From 7232cf647d76e15b6b53eb03199ebb78d515b2ba Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 2 Mar 2018 15:10:54 -0500 Subject: [PATCH 170/800] Made lib\api\html\functions WPCS compliant --- lib/api/html/functions.php | 150 ++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 85 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 4a3f14fe..767a4eb7 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -8,6 +8,8 @@ * @since 1.5.0 */ +// phpcs:disable Squiz.Commenting.FunctionComment.ExtraParamComment -- The extra parameter is intentional for documentation. + /** * Register output by ID. * @@ -27,8 +29,7 @@ * @return string The output. */ function beans_output( $id, $output ) { - - $args = func_get_args(); + $args = func_get_args(); $args[0] = $id . '_output'; $output = call_user_func_array( 'beans_apply_filters', $args ); @@ -42,7 +43,6 @@ function beans_output( $id, $output ) { } return $output; - } /** @@ -63,11 +63,8 @@ function beans_output( $id, $output ) { * @param mixed $var Additional variables passed to the functions hooked to $id. */ function beans_output_e( $id, $output ) { - $args = func_get_args(); - - echo call_user_func_array( 'beans_output', $args ); - + echo call_user_func_array( 'beans_output', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. } /** @@ -83,9 +80,7 @@ function beans_output_e( $id, $output ) { * @return bool Will always return true. */ function beans_remove_output( $id ) { - return beans_add_filter( $id . '_output', false ); - } /** @@ -101,8 +96,8 @@ function beans_remove_output( $id ) { * * @since 1.0.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but + * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). + * @param string|bool $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but * the actions hook will be called. If set the Null, both markup HTML tag and actions * hooks will be removed. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the @@ -111,15 +106,14 @@ function beans_remove_output( $id ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. * * @return string The output. */ function beans_open_markup( $id, $tag, $attributes = array() ) { - global $_temp_beans_selfclose_markup; - $args = func_get_args(); + $args = func_get_args(); $attributes_args = $args; // Set markup tag filter id. @@ -133,7 +127,9 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { unset( $attributes_args[1] ); // Stop here if the tag is set to false, the before and after actions won't run in this case. - if ( null === ( $tag = call_user_func_array( 'beans_apply_filters', $args ) ) ) { + $tag = call_user_func_array( 'beans_apply_filters', $args ); + + if ( null === $tag ) { return; } @@ -146,9 +142,9 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { $output = call_user_func_array( '_beans_render_action', $args ); // Don't output the tag if empty, the before and after actions still run. - if ( $tag ) { - $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_temp_beans_selfclose_markup ? '/' : '' ) . '>'; - } + if ( $tag ) { + $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_temp_beans_selfclose_markup ? '/' : '' ) . '>'; + } // Set after action id. $args[0] = $id . ( $_temp_beans_selfclose_markup ? '_after_markup' : '_prepend_markup' ); @@ -159,7 +155,6 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { unset( $GLOBALS['_temp_beans_selfclose_markup'] ); return $output; - } /** @@ -175,8 +170,8 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { * * @since 1.4.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but + * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). + * @param string|bool $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but * the actions hook will be called. If set the Null, both markup HTML tag and actions * hooks will be removed. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the @@ -185,26 +180,25 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * + * @return void */ function beans_open_markup_e( $id, $tag, $attributes = array() ) { - $args = func_get_args(); - - echo call_user_func_array( 'beans_open_markup', $args ); - + echo call_user_func_array( 'beans_open_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. } /** * Register self-close markup and attributes by ID. * - * This function is shortuct of {@see beans_open_markup()}. It should be used for self-closed HTML markup such as + * This function is shortuct of {@see beans_open_markup()}. It should be used for self-closing HTML markup such as * images or inputs. * * @since 1.0.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string|bool $tag The HTML self-close tag.If set to False or empty, the markup HTML tag will + * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). + * @param string|bool $tag The HTML self-close tag.If set to False or empty, the markup HTML tag will * be removed but the actions hook will be called. If set the Null, both * markup HTML tag and actions hooks will be removed. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the @@ -213,31 +207,29 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. * * @return string The output. */ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { - global $_temp_beans_selfclose_markup; - $_temp_beans_selfclose_markup = true; - $args = func_get_args(); + $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + $args = func_get_args(); return call_user_func_array( 'beans_open_markup', $args ); - } /** * Echo self-close markup and attributes registered by ID. * - * This function is shortuct of {@see beans_open_markup()}. It should be used for self-closed HTML markup such as + * This function is shortuct of {@see beans_open_markup()}. It should be used for self-closing HTML markup such as * images or inputs. * * @since 1.4.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string|bool $tag The HTML self-close tag.If set to False or empty, the markup HTML tag will + * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). + * @param string|bool $tag The HTML self-close tag.If set to False or empty, the markup HTML tag will * be removed but the actions hook will be called. If set the Null, both * markup HTML tag and actions hooks will be removed. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the @@ -246,14 +238,13 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * + * @return void */ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { - $args = func_get_args(); - - echo call_user_func_array( 'beans_selfclose_markup', $args ); - + echo call_user_func_array( 'beans_selfclose_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. } /** @@ -271,9 +262,10 @@ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { * @return string The output. */ function beans_close_markup( $id, $tag ) { - // Stop here if the tag is set to false, the before and after actions won't run in this case. - if ( null === ( $tag = beans_apply_filters( $id . '_markup', $tag ) ) ) { + $tag = beans_apply_filters( $id . '_markup', $tag ); + + if ( null === $tag ) { return; } @@ -287,10 +279,10 @@ function beans_close_markup( $id, $tag ) { $output = call_user_func_array( '_beans_render_action', $args ); - // Don't output the tag if empty, the before and after actions still run. - if ( $tag ) { - $output .= ''; - } + // Don't output the tag if empty, the before and after actions still run. + if ( $tag ) { + $output .= ''; + } // Set after action id. $args[0] = $id . '_after_markup'; @@ -298,7 +290,6 @@ function beans_close_markup( $id, $tag ) { $output .= call_user_func_array( '_beans_render_action', $args ); return $output; - } /** @@ -314,17 +305,14 @@ function beans_close_markup( $id, $tag ) { * @param mixed $var Additional variables passed to the functions hooked to $id. */ function beans_close_markup_e( $id, $tag ) { - $args = func_get_args(); - - echo call_user_func_array( 'beans_close_markup', $args ); - + echo call_user_func_array( 'beans_close_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. } /** - * Modify opening and closing HTML tag. Also works for self-closed markup. + * Modify opening and closing HTML tag. Also works for self-closing markup. * - * This function will automatically modify the opening and the closing HTML tag. If the markup is self-closed, + * This function will automatically modify the opening and the closing HTML tag. If the markup is self-closing, * the HTML tag will be modified accordingly. * * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very @@ -340,20 +328,18 @@ function beans_close_markup_e( $id, $tag ) { * Lower numbers correspond with earlier execution, * and functions with the same priority are executed * in the order in which they were added to the action. - * @param int $args Optional. The number of arguments the function accepts. Default 1. + * @param int $args Optional. The number of arguments the function accepts. Default 1. * * @return bool Will always return true. */ function beans_modify_markup( $id, $markup, $priority = 10, $args = 1 ) { - return beans_add_filter( $id . '_markup', $markup, $priority, $args ); - } /** * Remove markup. * - * This function will automatically remove the opening and the closing HTML tag. If the markup is self-closed, + * This function will automatically remove the opening and the closing HTML tag. If the markup is self-closing, * the HTML tag will be removed accordingly. * * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very @@ -363,7 +349,7 @@ function beans_modify_markup( $id, $markup, $priority = 10, $args = 1 ) { * * @param string $id The markup ID. * @param bool $remove_actions Optional. Whether elements attached to a markup should be removed or not. This must be used - * with absolute caution. + * with absolute caution. * * @return bool Will always return true. */ @@ -374,7 +360,6 @@ function beans_remove_markup( $id, $remove_actions = false ) { } return beans_add_filter( $id . '_markup', false ); - } /** @@ -390,13 +375,11 @@ function beans_remove_markup( $id, $remove_actions = false ) { * * @param string $id The markup ID. * - * @return bool Will always return true. + * @return void */ function beans_reset_markup( $id ) { - remove_all_filters( $id . '_markup' ); remove_all_filters( preg_replace( '#(\[|\])#', '', $id ) . '_markup' ); - } /** @@ -407,21 +390,20 @@ function beans_reset_markup( $id ) { * * @since 1.0.0 * - * @param string $id The markup ID. - * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $tag The HTML wrap tag. + * @param string $id The markup ID. + * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). + * @param string $tag The HTML wrap tag. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value define the attribute value. Setting * the array value to '' will display the attribute value as empty * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Additional variables passed to the functions hooked to $id. + * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return bool Will always return true. */ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { - $args = func_get_args(); unset( $args[0] ); @@ -432,7 +414,6 @@ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { _beans_add_anonymous_action( $id . '_after_markup', array( 'beans_close_markup', $args ), 1 ); return true; - } /** @@ -443,21 +424,20 @@ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { * * @since 1.0.0 * - * @param string $id The markup ID. - * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $tag The HTML wrap tag. + * @param string $id The markup ID. + * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). + * @param string $tag The HTML wrap tag. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value define the attribute value. Setting * the array value to '' will display the attribute value as empty * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Additional variables passed to the functions hooked to $id. + * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return bool Will always return true. */ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { - $args = func_get_args(); unset( $args[0] ); @@ -468,7 +448,6 @@ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { _beans_add_anonymous_action( $id . '_append_markup', array( 'beans_close_markup', $args ), 9999 ); return true; - } /** @@ -481,20 +460,19 @@ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { * * @since 1.0.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). + * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value define the attribute value. Setting * the array value to '' will display the attribute value as empty * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Additional variables passed to the functions hooked to $id. + * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return string The HTML attributes. */ function beans_add_attributes( $id, $attributes = array() ) { - - $args = func_get_args(); + $args = func_get_args(); $args[0] = $id . '_attributes'; if ( ! isset( $args[1] ) ) { @@ -506,9 +484,10 @@ function beans_add_attributes( $id, $attributes = array() ) { $attributes = call_user_func_array( 'beans_apply_filters', $args ); return beans_esc_attributes( $attributes ); - } +// phpcs:enable Squiz.Commenting.FunctionComment.ExtraParamComment -- The extra parameter is intentional for documentation. + /** * Reset markup attributes. * @@ -522,13 +501,11 @@ function beans_add_attributes( $id, $attributes = array() ) { * * @param string $id The markup ID. * - * @return bool Will always return true. + * @return void */ function beans_reset_attributes( $id ) { - remove_all_filters( $id . '_attributes' ); remove_all_filters( preg_replace( '#(\[|\])#', '', $id ) . '_attributes' ); - } /** @@ -611,7 +588,11 @@ function beans_remove_attribute( $id, $attribute, $value = null ) { /** * Check if development mode is enabled taking in consideration legacy constant. * + * @since 1.0.0 * @ignore + * @access private + * + * @return bool */ function _beans_is_html_dev_mode() { @@ -620,5 +601,4 @@ function _beans_is_html_dev_mode() { } return get_option( 'beans_dev_mode', false ); - } From c4000c5645354256181230703507318a98fcf26c Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 2 Mar 2018 15:36:44 -0500 Subject: [PATCH 171/800] Made lib\render WPCS compliant (#137) --- lib/render/fragments.php | 15 ++--- lib/render/menu.php | 61 +++++++++--------- lib/render/template-parts.php | 91 ++++++++++++++------------ lib/render/walker.php | 118 +++++++++++++++++++++------------- lib/render/widget-area.php | 14 ++-- 5 files changed, 170 insertions(+), 129 deletions(-) diff --git a/lib/render/fragments.php b/lib/render/fragments.php index 70f98c7d..b4024fff 100644 --- a/lib/render/fragments.php +++ b/lib/render/fragments.php @@ -2,7 +2,9 @@ /** * Loads Beans fragments. * - * @package Render\Fragments + * @package Beans\Framework\Render + * + * @since 1.0.0 */ // Filter. @@ -12,12 +14,9 @@ * * @since 1.0.0 * - * @param string $template The template filename. - * - * @return string The template filename. + * @return void */ function beans_load_global_fragments() { - beans_load_fragment_file( 'breadcrumb' ); beans_load_fragment_file( 'footer' ); beans_load_fragment_file( 'header' ); @@ -27,7 +26,6 @@ function beans_load_global_fragments() { beans_load_fragment_file( 'widget-area' ); beans_load_fragment_file( 'embed' ); beans_load_fragment_file( 'deprecated' ); - } // Filter. @@ -52,7 +50,6 @@ function beans_load_comments_fragment( $template ) { beans_load_fragment_file( 'comments' ); return $template; - } beans_add_smart_action( 'dynamic_sidebar_before', 'beans_load_widget_fragment', -1 ); @@ -66,9 +63,7 @@ function beans_load_comments_fragment( $template ) { * @return bool True on success, false on failure. */ function beans_load_widget_fragment() { - return beans_load_fragment_file( 'widget' ); - } beans_add_smart_action( 'pre_get_search_form', 'beans_load_search_form_fragment' ); @@ -82,7 +77,5 @@ function beans_load_widget_fragment() { * @return bool True on success, false on failure. */ function beans_load_search_form_fragment() { - return beans_load_fragment_file( 'searchform' ); - } diff --git a/lib/render/menu.php b/lib/render/menu.php index f1b82f87..d013212c 100644 --- a/lib/render/menu.php +++ b/lib/render/menu.php @@ -1,8 +1,10 @@ __( 'Primary Menu', 'tm-beans' ), ) ); - } // Filter. @@ -55,7 +58,7 @@ function beans_do_register_nav_menus() { /** * Modify wp_nav_menu arguments. * - * This function converts the wp_nav_menu to UIKit format. It uses Beans custom walker and also makes + * This function converts the wp_nav_menu to UIkit format. It uses the Beans custom walker and also makes * use of the Beans HTML API. * * @since 1.0.0 @@ -65,16 +68,17 @@ function beans_do_register_nav_menus() { * @return array The modified wp_nav_menu arguments. */ function beans_modify_menu_args( $args ) { - // Get type. $type = beans_get( 'beans_type', $args ); // Check if the menu is in a widget area and set the type accordingly if it is defined. - if ( $widget_area_type = beans_get_widget_area( 'beans_type' ) ) { - $type = ( 'stack' == $widget_area_type ) ? 'sidenav' : $widget_area_type; + $widget_area_type = beans_get_widget_area( 'beans_type' ); + + if ( $widget_area_type ) { + $type = 'stack' === $widget_area_type ? 'sidenav' : $widget_area_type; } - // Stop if it isn't a beans menu. + // Stop if it isn't a Beans menu. if ( ! $type ) { return $args; } @@ -85,38 +89,36 @@ function beans_modify_menu_args( $args ) { 'class' => array( beans_get( 'menu_class', $args ) ), ); - // Add UIKit navbar item wrap attributes. - if ( 'navbar' == $type ) { + // Add UIkit navbar item wrap attributes. + if ( 'navbar' === $type ) { $attr['class'][] = 'uk-navbar-nav'; } - // Add UIKit sidenav item wrap attributes. - if ( 'sidenav' == $type ) { - - $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-side'; + // Add UIkit sidenav item wrap attributes. + if ( 'sidenav' === $type ) { + $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-side'; $attr['data-uk-nav'] = '{multiple:true}'; - } - // Add UIKit offcanvas item wrap attributes. - if ( 'offcanvas' == $type ) { - - $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-offcanvas'; + // Add UIkit offcanvas item wrap attributes. + if ( 'offcanvas' === $type ) { + $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-offcanvas'; $attr['data-uk-nav'] = '{multiple:true}'; - } // Implode to avoid empty spaces. $attr['class'] = implode( ' ', array_filter( $attr['class'] ) ); - // Set to null if empty to avoid outputing empty class html attribute. + // Set to null if empty to avoid outputing an empty HTML class attribute. if ( ! $attr['class'] ) { $attr['class'] = null; } - $location_subfilter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; + $location = beans_get( 'theme_location', $args ); - // Force beans menu arguments. + $location_subfilter = $location ? "[_{$location}]" : null; + + // Force Beans menu arguments. $force = array( 'beans_type' => $type, 'items_wrap' => beans_open_markup( "beans_menu[_{$type}]{$location_subfilter}", 'ul', $attr, $args ) . '%3$s' . beans_close_markup( "beans_menu[_{$type}]{$location_subfilter}", 'ul', $args ), @@ -124,12 +126,13 @@ function beans_modify_menu_args( $args ) { // Allow walker overwrite. if ( ! beans_get( 'walker', $args ) ) { - $args['walker'] = new _Beans_Walker_Nav_Menu; + $args['walker'] = new _Beans_Walker_Nav_Menu(); } // Adapt level to walker depth. - $force['beans_start_level'] = ( $level = beans_get( 'beans_start_level', $args ) ) ? ( $level - 1 ) : 0; + $level = beans_get( 'beans_start_level', $args ); - return array_merge( $args, $force ); + $force['beans_start_level'] = $level ? $level - 1 : 0; + return array_merge( $args, $force ); } diff --git a/lib/render/template-parts.php b/lib/render/template-parts.php index f225cf46..67ed3f5a 100644 --- a/lib/render/template-parts.php +++ b/lib/render/template-parts.php @@ -1,10 +1,12 @@ beans_start_level ) { return; } - $type = beans_get( 'beans_type', $args ); - $location_subfilter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; + $type = beans_get( 'beans_type', $args ); + $location = beans_get( 'theme_location', $args ); + $location_subfilter = $location ? "[_{$location}]" : null; // Default attributes. $attr = array( 'class' => array( 'sub-menu' ), ); - // Add UIKit sidenav and offcanvas class. - if ( $depth > 0 || in_array( $type, array( 'sidenav', 'offcanvas' ) ) ) { + // Add UIkit sidenav and offcanvas class. + if ( $depth > 0 || in_array( $type, array( 'sidenav', 'offcanvas' ), true ) ) { $attr['class'][] = 'uk-nav-sub'; } - // Add UIKit navbar stuff. + // Add UIkit navbar stuff. if ( 'navbar' === $type && $args->beans_start_level === $depth ) { - // Add UIKit navbar attributes. - $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-dropdown'; + // Add UIkit navbar attributes. + $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-dropdown'; $attr['data-uk-nav'] = '{multiple:true}'; // Open sub_menu wrap. $output .= beans_open_markup( "beans_sub_menu_wrap[_{$type}]{$location_subfilter}", 'div', 'class=uk-dropdown uk-dropdown-navbar', $depth, $args ); - } // Implode to avoid empty spaces. @@ -61,23 +75,31 @@ function start_lvl( &$output, $depth = 0, $args = array() ) { // Open sub_menu. $output .= beans_open_markup( "beans_sub_menu[_{$type}]{$location_subfilter}", 'ul', $attr, $depth, $args ); - } /** * Extend WordPress end first menu level. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + * + * @return void */ - function end_lvl( &$output, $depth = 0, $args = array() ) { + public function end_lvl( &$output, $depth = 0, $args = array() ) { // Stop here if the depth is smaller than starting depth. if ( $depth < $args->beans_start_level ) { return; } - $type = beans_get( 'beans_type', $args ); - $location_subfilter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; + $type = beans_get( 'beans_type', $args ); + $location = beans_get( 'theme_location', $args ); + $location_subfilter = $location ? "[_{$location}]" : null; // Close sub_menu. $output .= beans_close_markup( "beans_sub_menu[_{$type}]{$location_subfilter}", 'ul' ); @@ -86,15 +108,24 @@ function end_lvl( &$output, $depth = 0, $args = array() ) { if ( 'navbar' === $type && $args->beans_start_level === $depth ) { $output .= beans_close_markup( "beans_sub_menu_wrap[_{$type}]{$location_subfilter}", 'div', $depth, $args ); } - } /** * Extend WordPress start menu elements. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $output Used to append additional content (passed by reference). + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $id Current item ID. + * + * @return void */ - function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { + public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { // Stop here if the depth is smaller than starting depth. if ( $depth < $args->beans_start_level ) { @@ -103,12 +134,12 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $item_id = $item->ID; - // Wp item attributes. - $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args ); - $classes = empty( $item->classes ) ? array() : (array) $item->classes; + // WP item attributes. + $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args ); //phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. + $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; - $_classes = join( ' ', (array) apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); + $_classes = join( ' ', (array) apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. // WP link attributes. $_link_attr = array( @@ -126,29 +157,26 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { } } - $link_attr = apply_filters( 'nav_menu_link_attributes', $_link_attr, $item, $args ); + $link_attr = apply_filters( 'nav_menu_link_attributes', $_link_attr, $item, $args ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. - // Set wp item attributes as defaults. + // Set WP item attributes as defaults. $item_attr = array( 'class' => array( $_classes ), 'itemprop' => 'name', ); - // Add UIKit active class. - if ( in_array( 'current-menu-item', $classes ) ) { + // Add UIkit active class. + if ( in_array( 'current-menu-item', $classes, true ) ) { $item_attr['class'][] = 'uk-active'; } - // Add UIKit parent attributes. - if ( $args->beans_start_level == $depth && in_array( 'menu-item-has-children', $classes ) ) { - + // Add UIkit parent attributes. + if ( $args->beans_start_level === $depth && in_array( 'menu-item-has-children', $classes, true ) ) { $item_attr['class'][] = 'uk-parent'; - if ( beans_get( 'beans_type', $args ) == 'navbar' ) { - + if ( beans_get( 'beans_type', $args ) === 'navbar' ) { $item_attr['data-uk-dropdown'] = ''; - $child_indicator = true; - + $child_indicator = true; } } @@ -166,29 +194,35 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $item_output .= beans_open_markup( "beans_menu_item_link[_{$item_id}]", 'a', $link_attr, $item, $depth, $args ); - $item_output .= beans_output( "beans_menu_item_text[_{$item_id}]", $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after ); - - if ( isset( $child_indicator ) ) { + $item_output .= beans_output( "beans_menu_item_text[_{$item_id}]", $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. - $item_output .= beans_open_markup( "beans_menu_item_child_indicator[_{$item_id}]", 'i', array( 'class' => 'uk-icon-caret-down uk-margin-small-left' ), $item, $depth, $args ); - $item_output .= beans_close_markup( "beans_menu_item_child_indicator[_{$item_id}]", 'i', $item, $depth, $args ); - - } + if ( isset( $child_indicator ) ) { + $item_output .= beans_open_markup( "beans_menu_item_child_indicator[_{$item_id}]", 'i', array( 'class' => 'uk-icon-caret-down uk-margin-small-left' ), $item, $depth, $args ); + $item_output .= beans_close_markup( "beans_menu_item_child_indicator[_{$item_id}]", 'i', $item, $depth, $args ); + } $item_output .= beans_close_markup( "beans_menu_item_link[_{$item_id}]", 'a', $link_attr, $item, $depth, $args ); $item_output .= $args->after; - $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); - + $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. } /** * Extend WordPress end menu elements. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $output Used to append additional content (passed by reference). + * @param WP_Post $item Page data object. Not used. + * @param int $depth Depth of page. Not Used. + * @param stdClass $args An object of wp_nav_menu() arguments. + * + * @return void */ - function end_el( &$output, $item, $depth = 0, $args = array() ) { + public function end_el( &$output, $item, $depth = 0, $args = array() ) { // Stop here if the depth is smaller than starting depth. if ( $depth < $args->beans_start_level ) { @@ -196,8 +230,6 @@ function end_el( &$output, $item, $depth = 0, $args = array() ) { } $item_id = $item->ID; - $output .= beans_close_markup( "beans_menu_item[_{$item_id}]", 'li', $item, $depth, $args ); - } } diff --git a/lib/render/widget-area.php b/lib/render/widget-area.php index 23540b28..27f44536 100644 --- a/lib/render/widget-area.php +++ b/lib/render/widget-area.php @@ -1,8 +1,10 @@ __( 'Sidebar Primary', 'tm-beans' ), @@ -31,17 +34,16 @@ function beans_do_register_widget_areas() { 'beans_type' => 'offcanvas', ) ); } - } /** * Call register sidebar. * - * Because WordPress.org checker don't understand that we are using register_sidebar properly, + * Because the WordPress.org checker doesn't understand that we are using register_sidebar properly, * we have to add this useless call which only has to be declared once. * * @since 1.0.0 - * * @ignore + * @access private */ add_action( 'widgets_init', 'beans_register_widget_area' ); From 6ea49fe637172a4bfff2b0d0b7de469bf990fe87 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Fri, 2 Mar 2018 15:23:22 -0600 Subject: [PATCH 172/800] Load original functions after initializing Patchwork. (#154) Moved dependency files out of the pre setup and into the setup method, i.e. to ensure they are loaded after Patchwork initializes (through Brain Monkey). --- .../actions/includes/class-actions-test-case.php | 12 +++++++++++- .../api/fields/includes/class-fields-test-case.php | 7 +++++-- .../filters/includes/class-filters-test-case.php | 11 ++++++++++- .../unit/api/html/includes/class-html-test-case.php | 11 +++++++++++ .../phpunit/unit/api/post-meta/beansGetPostMeta.php | 6 +++++- .../template/includes/class-template-test-case.php | 4 ++++ .../phpunit/unit/api/term-meta/beansGetTermMeta.php | 13 ++++++++++--- 7 files changed, 56 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index ba5e513c..fc5487a6 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -43,7 +43,6 @@ public static function setUpBeforeClass() { static::$test_ids = array_keys( static::$test_actions ); require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; } /** @@ -69,6 +68,17 @@ public static function tearDownAfterClass() { static::$test_ids = null; } + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + $this->load_original_functions( array( + 'api/utilities/functions.php', + ) ); + } + /** * Reset the test fixture. */ diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 89107dc6..ff2eac46 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -34,9 +34,8 @@ public static function setUpBeforeClass() { static::$test_data = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-fields.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; require_once BEANS_TESTS_LIB_DIR . 'api/fields/functions.php'; - require_once BEANS_THEME_DIR . 'lib/api/fields/class-beans-fields.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/fields/class-beans-fields.php'; } /** @@ -45,6 +44,10 @@ public static function setUpBeforeClass() { public function setUp() { parent::setUp(); + $this->load_original_functions( array( + 'api/utilities/functions.php', + ) ); + foreach ( array( 'esc_attr', 'esc_html', 'esc_textarea', 'esc_url', 'wp_kses_post', '__' ) as $wp_function ) { Monkey\Functions\when( $wp_function )->returnArg(); } diff --git a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php index ff3291aa..e3ee1ca5 100644 --- a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php @@ -35,8 +35,17 @@ public static function setUpBeforeClass() { require_once dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'stubs/functions.php'; static::$test_filters = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-filters.php'; + } + + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . 'api/filters/functions.php'; + $this->load_original_functions( array( + 'api/utilities/functions.php', + ) ); } /** diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index 7fbb4c6c..d946d930 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -46,4 +46,15 @@ public static function setUpBeforeClass() { require_once BEANS_TESTS_LIB_DIR . 'api/html/class-beans-attribute.php'; require_once BEANS_TESTS_LIB_DIR . 'api/html/functions.php'; } + + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + $this->load_original_functions( array( + 'api/filters/functions.php', + ) ); + } } diff --git a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php index 0fa4e09e..a19c7bcb 100644 --- a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php +++ b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php @@ -16,8 +16,8 @@ * Class Tests_BeansGetPostMeta * * @package Beans\Framework\Tests\Unit\API\Post_Meta - * @group unit-tests * @group api + * @group api-post-meta */ class Tests_BeansGetPostMeta extends Test_Case { @@ -28,6 +28,10 @@ protected function setUp() { parent::setUp(); require_once BEANS_TESTS_LIB_DIR . 'api/post-meta/functions.php'; + + $this->load_original_functions( array( + 'api/utilities/functions.php', + ) ); } /** diff --git a/tests/phpunit/unit/api/template/includes/class-template-test-case.php b/tests/phpunit/unit/api/template/includes/class-template-test-case.php index 02dd609b..0a5d91a8 100644 --- a/tests/phpunit/unit/api/template/includes/class-template-test-case.php +++ b/tests/phpunit/unit/api/template/includes/class-template-test-case.php @@ -48,6 +48,10 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); + $this->load_original_functions( array( + 'api/utilities/functions.php', + ) ); + $this->set_up_virtual_filesystem(); if ( ! defined( 'BEANS_STRUCTURE_PATH' ) ) { diff --git a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php index 4c98866e..ffe4f45e 100644 --- a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php +++ b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php @@ -27,6 +27,10 @@ protected function setUp() { parent::setUp(); require_once BEANS_TESTS_LIB_DIR . 'api/term-meta/functions.php'; + + $this->load_original_functions( array( + 'api/utilities/functions.php', + ) ); } /** @@ -42,7 +46,8 @@ public function test_should_return_false_when_no_optional_arguments_given_and_te } /** - * Test beans_get_term_meta() should return default when given and queried object has a term_id but term meta does not exist. + * Test beans_get_term_meta() should return default when given and queried object has a term_id but term meta does + * not exist. */ public function test_should_return_default_when_default_given_and_queried_obj_has_term_id_but_term_meta_not_set() { Monkey\Functions\expect( 'get_queried_object' ) @@ -58,7 +63,8 @@ public function test_should_return_default_when_default_given_and_queried_obj_ha } /** - * Test beans_get_term_meta() should return meta term's value when queried object has a term_id and meta for that id exists. + * Test beans_get_term_meta() should return meta term's value when queried object has a term_id and meta for that + * id exists. */ public function test_should_return_term_meta_when_queried_object_has_term_id_and_meta_is_set() { Monkey\Functions\expect( 'get_queried_object' ) @@ -90,7 +96,8 @@ public function test_should_return_default_when_default_given_and_term_id_is_tag } /** - * Test beans_get_term_meta() should return meta term's value when term_id is tag_ID and term meta for that id exists. + * Test beans_get_term_meta() should return meta term's value when term_id is tag_ID and term meta for that id + * exists. */ public function test_should_return_term_meta_when_default_given_and_term_id_is_tag_id_and_term_meta_exists() { $_GET['tag_ID'] = 1; From 9ac68dd5cc73a21ac571f28592883935048de77f Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Fri, 2 Mar 2018 20:25:06 -0500 Subject: [PATCH 173/800] Allow beans_get_post_meta() to return early when necessary, with test revisions (#155) --- lib/api/post-meta/functions.php | 4 ++++ .../api/post-meta/beansGetPostMeta.php | 8 ++++++++ .../unit/api/post-meta/beansGetPostMeta.php | 20 +++++++++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index 5e086dac..5c1cd665 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -27,6 +27,10 @@ function beans_get_post_meta( $meta_key, $default = false, $post_id = false ) { $post_id = ! $id ? beans_get( 'post' ) : $id; } + if ( ! $post_id ) { + return $default; + } + $post_meta = get_post_meta( $post_id ); if ( isset( $post_meta[ $meta_key ] ) ) { diff --git a/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php b/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php index 00ca1785..fd1a8dc0 100644 --- a/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php +++ b/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php @@ -20,6 +20,14 @@ */ class Tests_BeansGetPostMeta extends WP_UnitTestCase { + /** + * Test beans_get_post_meta() should return the default when the post_id cannot be resolved. + */ + public function test_should_return_default_when_post_id_cannot_be_resolved() { + $this->assertFalse( beans_get_post_meta( 'beans_layout' ) ); + $this->assertSame( 'default_fallback', beans_get_post_meta( 'beans_layout', 'default_fallback' ) ); + } + /** * Test beans_get_post_meta() should return the default when the post meta does not exist. */ diff --git a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php index a19c7bcb..ce5983df 100644 --- a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php +++ b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php @@ -34,6 +34,18 @@ protected function setUp() { ) ); } + /** + * Test beans_get_post_meta() should return the default when the post_id cannot be resolved. + */ + public function test_should_return_default_when_post_id_cannot_be_resolved() { + Monkey\Functions\expect( 'get_the_id' )->twice()->andReturn( false ); + Monkey\Functions\expect( 'beans_get' )->twice()->andReturn( null ); + Monkey\Functions\expect( 'get_post_meta' )->never(); + + $this->assertFalse( beans_get_post_meta( 'beans_layout' ) ); + $this->assertSame( 'default_fallback', beans_get_post_meta( 'beans_layout', 'default_fallback' ) ); + } + /** * Test beans_get_post_meta() should return the default when the post meta does not exist. */ @@ -53,12 +65,10 @@ public function test_should_get_post_id_when_none_is_provided() { Monkey\Functions\expect( 'get_post_meta' )->with( 47 )->once()->andReturn( array() ); $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); - $_GET['post'] = '18'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 0 ); + Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 18 ); Monkey\Functions\expect( 'get_post_meta' )->with( '18' )->once()->andReturn( array() ); $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); - unset( $_GET['post'] ); } /** @@ -90,9 +100,8 @@ public function test_should_return_post_meta_value() { ->andReturn( 'sp_c' ); $this->assertSame( 'sp_c', beans_get_post_meta( 'beans_layout' ) ); - $_GET['post'] = '18'; - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 0 ); + Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 18 ); Monkey\Functions\expect( 'get_post_meta' ) ->with( '18' ) ->once() @@ -104,6 +113,5 @@ public function test_should_return_post_meta_value() { ->ordered() ->andReturn( 'default_fallback' ); $this->assertSame( 'default_fallback', beans_get_post_meta( 'beans_layout', 'c' ) ); - unset( $_GET['post'] ); } } From 576314f31213269222f9252e26c4bf26b6a8e6a2 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 2 Mar 2018 22:42:53 -0500 Subject: [PATCH 174/800] Made lib\template\fragments WPCS compliant (#138) --- lib/templates/fragments/breadcrumb.php | 84 +-- lib/templates/fragments/comments.php | 431 +++++++----- lib/templates/fragments/deprecated.php | 37 +- lib/templates/fragments/embed.php | 6 +- lib/templates/fragments/footer.php | 61 +- lib/templates/fragments/header.php | 119 ++-- lib/templates/fragments/menu.php | 100 +-- lib/templates/fragments/post-shortcodes.php | 81 ++- lib/templates/fragments/post.php | 742 +++++++++++--------- lib/templates/fragments/searchform.php | 42 +- lib/templates/fragments/widget-area.php | 21 +- lib/templates/fragments/widget.php | 55 +- 12 files changed, 993 insertions(+), 786 deletions(-) diff --git a/lib/templates/fragments/breadcrumb.php b/lib/templates/fragments/breadcrumb.php index 15a0e5a6..f2387b3c 100644 --- a/lib/templates/fragments/breadcrumb.php +++ b/lib/templates/fragments/breadcrumb.php @@ -2,7 +2,9 @@ /** * Echo breadcrumb fragment. * - * @package Fragments\Breadcrumb + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_main_grid_before_markup', 'beans_breadcrumb' ); @@ -10,6 +12,8 @@ * Echo the breadcrumb. * * @since 1.0.0 + * + * @return void */ function beans_breadcrumb() { @@ -17,33 +21,33 @@ function beans_breadcrumb() { return; } - wp_reset_query(); + wp_reset_query(); // phpcs:ignore WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query -- Ensure the main query has been reset to the original main query. global $post; - $post_type = get_post_type(); - $breadcrumbs = array(); + $post_type = get_post_type(); + $breadcrumbs = array(); $breadcrumbs[ home_url() ] = __( 'Home', 'tm-beans' ); // Custom post type. - if ( ! in_array( $post_type, array( 'page', 'attachment', 'post' ) ) && ! is_404() ) { + if ( ! in_array( $post_type, array( 'page', 'attachment', 'post' ), true ) && ! is_404() ) { - if ( $post_type_object = get_post_type_object( $post_type ) ) { + $post_type_object = get_post_type_object( $post_type ); + + if ( $post_type_object ) { $breadcrumbs[ get_post_type_archive_link( $post_type ) ] = $post_type_object->labels->name; } } // Single posts. - if ( is_single() && 'post' == $post_type ) { + if ( is_single() && 'post' === $post_type ) { foreach ( get_the_category( $post->ID ) as $category ) { $breadcrumbs[ get_category_link( $category->term_id ) ] = $category->name; } $breadcrumbs[] = get_the_title(); - } elseif ( is_singular() && ! is_home() && ! is_front_page() ) { // Pages/custom post type. - $current_page = array( $post ); // Get the parent pages of the current page if they exist. @@ -58,11 +62,8 @@ function beans_breadcrumb() { $breadcrumbs[ get_page_link( $page->ID ) ] = $page->post_title; } } elseif ( is_category() ) { // Categories. - $breadcrumbs[] = single_cat_title( '', false ); - } elseif ( is_tax() ) { // Taxonomies. - $current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $ancestors = array_reverse( get_ancestors( $current_term->term_id, get_query_var( 'taxonomy' ) ) ); @@ -72,76 +73,55 @@ function beans_breadcrumb() { $ancestor = get_term( $ancestor, get_query_var( 'taxonomy' ) ); $breadcrumbs[ get_term_link( $ancestor->slug, get_query_var( 'taxonomy' ) ) ] = $ancestor->name; - } $breadcrumbs[] = $current_term->name; - } elseif ( is_search() ) { // Searches. - $breadcrumbs[] = __( 'Results:', 'tm-beans' ) . ' ' . get_search_query(); - } elseif ( is_author() ) { // Author archives. - - $author = get_queried_object(); + $author = get_queried_object(); $breadcrumbs[] = __( 'Author Archives:', 'tm-beans' ) . ' ' . $author->display_name; - } elseif ( is_tag() ) {// Tag archives. - $breadcrumbs[] = __( 'Tag Archives:', 'tm-beans' ) . ' ' . single_tag_title( '', false ); - } elseif ( is_date() ) { // Date archives. - $breadcrumbs[] = __( 'Archives:', 'tm-beans' ) . ' ' . get_the_time( 'F Y' ); - } elseif ( is_404() ) { // 404. - $breadcrumbs[] = __( '404', 'tm-beans' ); - } // Open breadcrumb. beans_open_markup_e( 'beans_breadcrumb', 'ul', array( 'class' => 'uk-breadcrumb uk-width-1-1' ) ); - $i = 0; - foreach ( $breadcrumbs as $breadcrumb_url => $breadcrumb ) { - - // Breadcrumb items. - if ( count( $breadcrumbs ) - 1 != $i ) { - - beans_open_markup_e( 'beans_breadcrumb_item', 'li' ); - - beans_open_markup_e( 'beans_breadcrumb_item_link', 'a', array( - 'href' => $breadcrumb_url, // Automatically escaped. - ) ); + foreach ( $breadcrumbs as $breadcrumb_url => $breadcrumb ) { - // Used for mobile devices. - beans_open_markup_e( 'beans_breadcrumb_item_link_inner', 'span' ); + // Breadcrumb items. + if ( count( $breadcrumbs ) - 1 !== $i ) { + beans_open_markup_e( 'beans_breadcrumb_item', 'li' ); - beans_output_e( 'beans_breadcrumb_item_text', $breadcrumb );; + beans_open_markup_e( 'beans_breadcrumb_item_link', 'a', array( 'href' => $breadcrumb_url ) ); // Automatically escaped. - beans_close_markup_e( 'beans_breadcrumb_item_link_inner', 'span' ); + // Used for mobile devices. + beans_open_markup_e( 'beans_breadcrumb_item_link_inner', 'span' ); - beans_close_markup_e( 'beans_breadcrumb_item_link', 'a' ); + beans_output_e( 'beans_breadcrumb_item_text', $breadcrumb ); - beans_close_markup_e( 'beans_breadcrumb_item', 'li' ); + beans_close_markup_e( 'beans_breadcrumb_item_link_inner', 'span' ); - } else { // Active. + beans_close_markup_e( 'beans_breadcrumb_item_link', 'a' ); - beans_open_markup_e( 'beans_breadcrumb_item[_active]', 'li', array( 'class' => 'uk-active uk-text-muted' ) ); + beans_close_markup_e( 'beans_breadcrumb_item', 'li' ); + } else { // Active. + beans_open_markup_e( 'beans_breadcrumb_item[_active]', 'li', array( 'class' => 'uk-active uk-text-muted' ) ); - beans_output_e( 'beans_breadcrumb_item[_active]_text', $breadcrumb ); - - beans_close_markup_e( 'beans_breadcrumb_item[_active]', 'li' ); - - } - - $i++; + beans_output_e( 'beans_breadcrumb_item[_active]_text', $breadcrumb ); + beans_close_markup_e( 'beans_breadcrumb_item[_active]', 'li' ); } + $i++; + } + // Close breadcrumb. beans_close_markup_e( 'beans_breadcrumb', 'ul' ); - } diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index 1a6e02d4..170e80c8 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -2,7 +2,9 @@ /** * Echo comments fragments. * - * @package Fragments\Comments + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_comments_list_before_markup', 'beans_comments_title' ); @@ -10,18 +12,22 @@ * Echo the comments title. * * @since 1.0.0 + * + * @return void */ function beans_comments_title() { beans_open_markup_e( 'beans_comments_title', 'h2' ); - beans_output_e( 'beans_comments_title_text', sprintf( - _n( '%s Comment', '%s Comments', get_comments_number(), 'tm-beans' ), - number_format_i18n( get_comments_number() ) - ) ); + beans_output_e( + 'beans_comments_title_text', sprintf( + // translators: Number of comments, one or many. + _n( '%s Comment', '%s Comments', get_comments_number(), 'tm-beans' ), + number_format_i18n( get_comments_number() ) + ) + ); beans_close_markup_e( 'beans_comments_title', 'h2' ); - } beans_add_smart_action( 'beans_comment_header', 'beans_comment_avatar', 5 ); @@ -29,22 +35,24 @@ function beans_comments_title() { * Echo the comment avatar. * * @since 1.0.0 + * + * @return void */ function beans_comment_avatar() { - global $comment; // Stop here if no avatar. - if ( ! $avatar = get_avatar( $comment, $comment->args['avatar_size'] ) ) { + $avatar = get_avatar( $comment, $comment->args['avatar_size'] ); + + if ( ! $avatar ) { return; } beans_open_markup_e( 'beans_comment_avatar', 'div', array( 'class' => 'uk-comment-avatar' ) ); - echo $avatar; + echo $avatar; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes get_avatar(). beans_close_markup_e( 'beans_comment_avatar', 'div' ); - } beans_add_smart_action( 'beans_comment_header', 'beans_comment_author' ); @@ -52,20 +60,24 @@ function beans_comment_avatar() { * Echo the comment author title. * * @since 1.0.0 + * + * @return void */ function beans_comment_author() { - - beans_open_markup_e( 'beans_comment_title', 'div', array( - 'class' => 'uk-comment-title', - 'itemprop' => 'author', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/Person', - ) ); + beans_open_markup_e( + 'beans_comment_title', + 'div', + array( + 'class' => 'uk-comment-title', + 'itemprop' => 'author', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/Person', + ) + ); echo get_comment_author_link(); beans_close_markup_e( 'beans_comment_title', 'div' ); - } beans_add_smart_action( 'beans_comment_title_append_markup', 'beans_comment_badges' ); @@ -73,55 +85,47 @@ function beans_comment_author() { * Echo the comment badges. * * @since 1.0.0 + * + * @return void */ function beans_comment_badges() { - global $comment; // Trackback badge. - if ( 'trackback' == $comment->comment_type ) { - + if ( 'trackback' === $comment->comment_type ) { beans_open_markup_e( 'beans_trackback_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left' ) ); beans_output_e( 'beans_trackback_text', __( 'Trackback', 'tm-beans' ) ); beans_close_markup_e( 'beans_trackback_badge', 'span' ); - } // Pindback badge. - if ( 'pingback' == $comment->comment_type ) { - + if ( 'pingback' === $comment->comment_type ) { beans_open_markup_e( 'beans_pingback_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left' ) ); beans_output_e( 'beans_pingback_text', __( 'Pingback', 'tm-beans' ) ); beans_close_markup_e( 'beans_pingback_badge', 'span' ); - } // Moderation badge. - if ( '0' == $comment->comment_approved ) { - + if ( '0' === $comment->comment_approved ) { beans_open_markup_e( 'beans_moderation_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left uk-badge-warning' ) ); beans_output_e( 'beans_moderation_text', __( 'Awaiting Moderation', 'tm-beans' ) ); beans_close_markup_e( 'beans_moderation_badge', 'span' ); - } // Moderator badge. if ( user_can( $comment->user_id, 'moderate_comments' ) ) { - beans_open_markup_e( 'beans_moderator_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left' ) ); beans_output_e( 'beans_moderator_text', __( 'Moderator', 'tm-beans' ) ); beans_close_markup_e( 'beans_moderator_badge', 'span' ); - } - } beans_add_smart_action( 'beans_comment_header', 'beans_comment_metadata', 15 ); @@ -129,26 +133,33 @@ function beans_comment_badges() { * Echo the comment metadata. * * @since 1.0.0 + * + * @return void */ function beans_comment_metadata() { - beans_open_markup_e( 'beans_comment_meta', 'div', array( 'class' => 'uk-comment-meta' ) ); - beans_open_markup_e( 'beans_comment_time', 'time', array( - 'datetime' => get_comment_time( 'c' ), - 'itemprop' => 'datePublished', - ) ); - - beans_output_e( 'beans_comment_time_text', sprintf( - _x( '%1$s at %2$s', '1: date, 2: time', 'tm-beans' ), - get_comment_date(), - get_comment_time() - ) ); + beans_open_markup_e( + 'beans_comment_time', + 'time', + array( + 'datetime' => get_comment_time( 'c' ), + 'itemprop' => 'datePublished', + ) + ); + + beans_output_e( + 'beans_comment_time_text', sprintf( + // translators: Date of the comment, time of the comment. + _x( '%1$s at %2$s', '1: date, 2: time', 'tm-beans' ), + get_comment_date(), + get_comment_time() + ) + ); beans_close_markup_e( 'beans_comment_time', 'time' ); beans_close_markup_e( 'beans_comment_meta', 'div' ); - } beans_add_smart_action( 'beans_comment_content', 'beans_comment_content' ); @@ -156,11 +167,11 @@ function beans_comment_metadata() { * Echo the comment content. * * @since 1.0.0 + * + * @return void */ function beans_comment_content() { - beans_output_e( 'beans_comment_content', beans_render_function( 'comment_text' ) ); - } beans_add_smart_action( 'beans_comment_content', 'beans_comment_links', 15 ); @@ -168,45 +179,56 @@ function beans_comment_content() { * Echo the comment links. * * @since 1.0.0 + * + * @return void */ function beans_comment_links() { - global $comment; beans_open_markup_e( 'beans_comment_links', 'ul', array( 'class' => 'tm-comment-links uk-subnav uk-subnav-line' ) ); // Reply. - echo get_comment_reply_link( array_merge( $comment->args, array( - 'add_below' => 'comment-content', - 'depth' => $comment->depth, - 'max_depth' => $comment->args['max_depth'], - 'before' => beans_open_markup( 'beans_comment_item[_reply]', 'li' ), - 'after' => beans_close_markup( 'beans_comment_item[_reply]', 'li' ), - ) ) ); + echo get_comment_reply_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + array_merge( + $comment->args, array( + 'add_below' => 'comment-content', + 'depth' => $comment->depth, + 'max_depth' => $comment->args['max_depth'], + 'before' => beans_open_markup( 'beans_comment_item[_reply]', 'li' ), + 'after' => beans_close_markup( 'beans_comment_item[_reply]', 'li' ), + ) + ) + ); // Edit. - if ( current_user_can( 'moderate_comments' ) ) : - - beans_open_markup_e( 'beans_comment_item[_edit]', 'li' ); + if ( current_user_can( 'moderate_comments' ) ) : + beans_open_markup_e( 'beans_comment_item[_edit]', 'li' ); - beans_open_markup_e( 'beans_comment_item_link[_edit]', 'a', array( + beans_open_markup_e( + 'beans_comment_item_link[_edit]', + 'a', + array( 'href' => get_edit_comment_link( $comment->comment_ID ), // Automatically escaped. - ) ); - - beans_output_e( 'beans_comment_edit_text', __( 'Edit', 'tm-beans' ) ); + ) + ); - beans_close_markup_e( 'beans_comment_item_link[_edit]', 'a' ); + beans_output_e( 'beans_comment_edit_text', __( 'Edit', 'tm-beans' ) ); - beans_close_markup_e( 'beans_comment_item[_edit]', 'li' ); + beans_close_markup_e( 'beans_comment_item_link[_edit]', 'a' ); - endif; + beans_close_markup_e( 'beans_comment_item[_edit]', 'li' ); +endif; // Link. beans_open_markup_e( 'beans_comment_item[_link]', 'li' ); - beans_open_markup_e( 'beans_comment_item_link[_link]', 'a', array( - 'href' => get_comment_link( $comment->comment_ID ), // Automatically escaped. - ) ); + beans_open_markup_e( + 'beans_comment_item_link[_link]', + 'a', + array( + 'href' => get_comment_link( $comment->comment_ID ), // Automatically escaped. + ) + ); beans_output_e( 'beans_comment_link_text', __( 'Link', 'tm-beans' ) ); @@ -215,7 +237,6 @@ function beans_comment_links() { beans_close_markup_e( 'beans_comment_item[_link]', 'li' ); beans_close_markup_e( 'beans_comment_links', 'ul' ); - } beans_add_smart_action( 'beans_no_comment', 'beans_no_comment' ); @@ -223,15 +244,15 @@ function beans_comment_links() { * Echo no comment content. * * @since 1.0.0 + * + * @return void */ function beans_no_comment() { - beans_open_markup_e( 'beans_no_comment', 'p', 'class=uk-text-muted' ); beans_output_e( 'beans_no_comment_text', __( 'No comment yet, add your voice below!', 'tm-beans' ) ); beans_close_markup_e( 'beans_no_comment', 'p' ); - } beans_add_smart_action( 'beans_comments_closed', 'beans_comments_closed' ); @@ -239,15 +260,15 @@ function beans_no_comment() { * Echo closed comments content. * * @since 1.0.0 + * + * @return void */ function beans_comments_closed() { - beans_open_markup_e( 'beans_comments_closed', 'p', array( 'class' => 'uk-alert uk-alert-warning uk-margin-bottom-remove' ) ); beans_output_e( 'beans_comments_closed_text', __( 'Comments are closed for this article!', 'tm-beans' ) ); beans_close_markup_e( 'beans_comments_closed', 'p' ); - } beans_add_smart_action( 'beans_comments_list_after_markup', 'beans_comments_navigation' ); @@ -255,6 +276,8 @@ function beans_comments_closed() { * Echo comments navigation. * * @since 1.0.0 + * + * @return void */ function beans_comments_navigation() { @@ -262,49 +285,56 @@ function beans_comments_navigation() { return; } - beans_open_markup_e( 'beans_comments_navigation', 'ul', array( - 'class' => 'uk-pagination', - 'role' => 'navigation', - ) ); + beans_open_markup_e( + 'beans_comments_navigation', + 'ul', + array( + 'class' => 'uk-pagination', + 'role' => 'navigation', + ) + ); // Previous. - if ( get_previous_comments_link() ) { + if ( get_previous_comments_link() ) { + beans_open_markup_e( 'beans_comments_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); - beans_open_markup_e( 'beans_comments_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); - - $previous_icon = beans_open_markup( 'beans_previous_icon[_comments_navigation]', 'i', array( + $previous_icon = beans_open_markup( + 'beans_previous_icon[_comments_navigation]', + 'i', + array( 'class' => 'uk-icon-angle-double-left uk-margin-small-right', - ) ); - $previous_icon .= beans_close_markup( 'beans_previous_icon[_comments_navigation]', 'i' ); - - echo get_previous_comments_link( - $previous_icon . beans_output( 'beans_previous_text[_comments_navigation]', __( 'Previous', 'tm-beans' ) ) - ); + ) + ); + $previous_icon .= beans_close_markup( 'beans_previous_icon[_comments_navigation]', 'i' ); - beans_close_markup_e( 'beans_comments_navigation_item[_previous]', 'li' ); + echo get_previous_comments_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + $previous_icon . beans_output( 'beans_previous_text[_comments_navigation]', __( 'Previous', 'tm-beans' ) ) + ); - } + beans_close_markup_e( 'beans_comments_navigation_item[_previous]', 'li' ); + } // Next. - if ( get_next_comments_link() ) { + if ( get_next_comments_link() ) { + beans_open_markup_e( 'beans_comments_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); - beans_open_markup_e( 'beans_comments_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); - - $next_icon = beans_open_markup( 'beans_next_icon[_comments_navigation]', 'i', array( + $next_icon = beans_open_markup( + 'beans_next_icon[_comments_navigation]', + 'i', + array( 'class' => 'uk-icon-angle-double-right uk-margin-small-right', - ) ); - $next_icon .= beans_close_markup( 'beans_next_icon[_comments_navigation]', 'i' ); - - echo get_next_comments_link( - beans_output( 'beans_next_text[_comments_navigation]', __( 'Next', 'tm-beans' ) ) . $next_icon - ); + ) + ); + $next_icon .= beans_close_markup( 'beans_next_icon[_comments_navigation]', 'i' ); - beans_close_markup_e( 'beans_comments_navigation_item_[_next]', 'li' ); + echo get_next_comments_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + beans_output( 'beans_next_text[_comments_navigation]', __( 'Next', 'tm-beans' ) ) . $next_icon + ); - } + beans_close_markup_e( 'beans_comments_navigation_item_[_next]', 'li' ); + } beans_close_markup_e( 'beans_comments_navigation', 'ul' ); - } beans_add_smart_action( 'beans_after_open_comments', 'beans_comment_form_divider' ); @@ -312,11 +342,11 @@ function beans_comments_navigation() { * Echo comment divider. * * @since 1.0.0 + * + * @return void */ function beans_comment_form_divider() { - beans_selfclose_markup_e( 'beans_comment_form_divider', 'hr', array( 'class' => 'uk-article-divider' ) ); - } beans_add_smart_action( 'beans_after_open_comments', 'beans_comment_form' ); @@ -324,56 +354,68 @@ function beans_comment_form_divider() { * Echo comment navigation. * * @since 1.0.0 + * + * @return void */ function beans_comment_form() { - $output = beans_open_markup( 'beans_comment_form_wrap', 'div', array( 'class' => 'uk-form tm-comment-form-wrap' ) ); - $output .= beans_render_function( 'comment_form', array( - 'title_reply' => beans_output( 'beans_comment_form_title_text', __( 'Add a Comment', 'tm-beans' ) ), - ) ); + $output .= beans_render_function( 'comment_form', array( 'title_reply' => beans_output( 'beans_comment_form_title_text', __( 'Add a Comment', 'tm-beans' ) ) ) ); $output .= beans_close_markup( 'beans_comment_form_wrap', 'div' ); - $submit = beans_open_markup( 'beans_comment_form_submit', 'button', array( - 'class' => 'uk-button uk-button-primary', - 'type' => 'submit', - ) ); + $submit = beans_open_markup( + 'beans_comment_form_submit', + 'button', + array( + 'class' => 'uk-button uk-button-primary', + 'type' => 'submit', + ) + ); $submit .= beans_output( 'beans_comment_form_submit_text', __( 'Post Comment', 'tm-beans' ) ); $submit .= beans_close_markup( 'beans_comment_form_submit', 'button' ); // WordPress, please make it easier for us. - echo preg_replace( '#]+type="submit"[^>]+>#', $submit, $output ); - + echo preg_replace( '#]+type="submit"[^>]+>#', $submit, $output ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. } // Filter. -beans_add_smart_action( 'cancel_comment_reply_link', 'beans_comment_cancel_reply_link', 10 , 3 ); +beans_add_smart_action( 'cancel_comment_reply_link', 'beans_comment_cancel_reply_link', 10, 3 ); /** * Echo comment cancel reply link. * * This function replaces the default WordPress comment cancel reply link. * * @since 1.0.0 + * + * @param string $html HTML. + * @param string $link Cancel reply link. + * @param string $text Text to output. + * + * @return string */ function beans_comment_cancel_reply_link( $html, $link, $text ) { - $output = beans_open_markup( 'beans_comment_cancel_reply_link', 'a', array( - 'rel' => 'nofollow', - 'id' => 'cancel-comment-reply-link', - 'class' => 'uk-button uk-button-small uk-button-danger uk-margin-small-right', - 'style' => isset( $_GET['replytocom'] ) ? '' : 'display:none;', - 'href' => $link, // Automatically escaped. - ) ); + $output = beans_open_markup( + 'beans_comment_cancel_reply_link', + 'a', + array( + 'rel' => 'nofollow', + 'id' => 'cancel-comment-reply-link', + 'class' => 'uk-button uk-button-small uk-button-danger uk-margin-small-right', + // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- Used to determine inline style. + 'style' => isset( $_GET['replytocom'] ) ? '' : 'display:none;', + 'href' => $link, // Automatically escaped. + ) + ); $output .= beans_output( 'beans_comment_cancel_reply_link_text', $text ); $output .= beans_close_markup( 'beans_comment_cancel_reply_link', 'a' ); return $output; - } // Filter. @@ -384,9 +426,10 @@ function beans_comment_cancel_reply_link( $html, $link, $text ) { * This function replaces the default WordPress comment textarea field. * * @since 1.0.0 + * + * @return string */ function beans_comment_form_comment() { - $output = beans_open_markup( 'beans_comment_form[_comment]', 'p', array( 'class' => 'uk-margin-top' ) ); /** @@ -394,30 +437,30 @@ function beans_comment_form_comment() { * * @since 1.0.0 */ - if ( beans_apply_filters( 'beans_comment_form_legend[_comment]', true ) ) { - - $output .= beans_open_markup( 'beans_comment_form_legend[_comment]', 'legend' ); + if ( beans_apply_filters( 'beans_comment_form_legend[_comment]', true ) ) { - $output .= beans_output( 'beans_comment_form_legend_text[_comment]', __( 'Comment *', 'tm-beans' ) ); + $output .= beans_open_markup( 'beans_comment_form_legend[_comment]', 'legend' ); - $output .= beans_close_markup( 'beans_comment_form_legend[_comment]', 'legend' ); + $output .= beans_output( 'beans_comment_form_legend_text[_comment]', __( 'Comment *', 'tm-beans' ) ); - } + $output .= beans_close_markup( 'beans_comment_form_legend[_comment]', 'legend' ); + } - $output .= beans_open_markup( 'beans_comment_form_field[_comment]', 'textarea', array( - 'id' => 'comment', - 'class' => 'uk-width-1-1', - 'name' => 'comment', - 'required' => '', - 'rows' => 8, - ) ); + $output .= beans_open_markup( + 'beans_comment_form_field[_comment]', 'textarea', array( + 'id' => 'comment', + 'class' => 'uk-width-1-1', + 'name' => 'comment', + 'required' => '', + 'rows' => 8, + ) + ); $output .= beans_close_markup( 'beans_comment_form_field[_comment]', 'textarea' ); $output .= beans_close_markup( 'beans_comment_form[_comment]', 'p' ); return $output; - } beans_add_smart_action( 'comment_form_before_fields', 'beans_comment_before_fields', 9999 ); @@ -428,16 +471,18 @@ function beans_comment_form_comment() { * the user is not logged in. * * @since 1.0.0 + * + * @return void */ function beans_comment_before_fields() { - beans_open_markup_e( 'beans_comment_fields_wrap', 'div', array( 'class' => 'uk-width-medium-1-1' ) ); - beans_open_markup_e( 'beans_comment_fields_inner_wrap', 'div', array( - 'class' => 'uk-grid uk-grid-small', - 'data-uk-grid-margin' => '', - ) ); - + beans_open_markup_e( + 'beans_comment_fields_inner_wrap', 'div', array( + 'class' => 'uk-grid uk-grid-small', + 'data-uk-grid-margin' => '', + ) + ); } // Filter. @@ -456,7 +501,7 @@ function beans_comment_before_fields() { function beans_comment_form_fields( $fields ) { $commenter = wp_get_current_commenter(); - $grid = count( (array) $fields ); + $grid = count( (array) $fields ); // Author. if ( isset( $fields['author'] ) ) { @@ -468,34 +513,32 @@ function beans_comment_form_fields( $fields ) { * * @since 1.0.0 */ - if ( beans_apply_filters( 'beans_comment_form_legend[_name]', true ) ) { - - $author .= beans_open_markup( 'beans_comment_form_legend[_name]', 'legend' ); + if ( beans_apply_filters( 'beans_comment_form_legend[_name]', true ) ) { + $author .= beans_open_markup( 'beans_comment_form_legend[_name]', 'legend' ); - $author .= beans_output( 'beans_comment_form_legend_text[_name]', __( 'Name *', 'tm-beans' ) ); + $author .= beans_output( 'beans_comment_form_legend_text[_name]', __( 'Name *', 'tm-beans' ) ); - $author .= beans_close_markup( 'beans_comment_form_legend[_name]', 'legend' ); - - } + $author .= beans_close_markup( 'beans_comment_form_legend[_name]', 'legend' ); + } - $author .= beans_selfclose_markup( 'beans_comment_form_field[_name]', 'input', array( - 'id' => 'author', - 'class' => 'uk-width-1-1', - 'type' => 'text', - 'value' => $commenter['comment_author'], // Automatically escaped. - 'name' => 'author', - 'required' => 'required', - ) ); + $author .= beans_selfclose_markup( + 'beans_comment_form_field[_name]', 'input', array( + 'id' => 'author', + 'class' => 'uk-width-1-1', + 'type' => 'text', + 'value' => $commenter['comment_author'], // Automatically escaped. + 'name' => 'author', + 'required' => 'required', + ) + ); $author .= beans_close_markup( 'beans_comment_form[_name]', 'div' ); $fields['author'] = $author; - } // Email. if ( isset( $fields['email'] ) ) { - $email = beans_open_markup( 'beans_comment_form[_email]', 'div', array( 'class' => "uk-width-medium-1-$grid" ) ); /** @@ -503,34 +546,35 @@ function beans_comment_form_fields( $fields ) { * * @since 1.0.0 */ - if ( beans_apply_filters( 'beans_comment_form_legend[_email]', true ) ) { - - $email .= beans_open_markup( 'beans_comment_form_legend[_email]', 'legend' ); + if ( beans_apply_filters( 'beans_comment_form_legend[_email]', true ) ) { + $email .= beans_open_markup( 'beans_comment_form_legend[_email]', 'legend' ); - $email .= beans_output( 'beans_comment_form_legend_text[_email]', sprintf( __( 'Email %s', 'tm-beans' ), ( get_option( 'require_name_email' ) ? ' *' : '' ) ) ); - - $email .= beans_close_markup( 'beans_comment_form_legend[_email]', 'legend' ); + $email .= beans_output( 'beans_comment_form_legend_text[_email]', + // translators: Whether or not submitting an email address is required. + sprintf( __( 'Email %s', 'tm-beans' ), ( get_option( 'require_name_email' ) ? ' *' : '' ) ) + ); - } + $email .= beans_close_markup( 'beans_comment_form_legend[_email]', 'legend' ); + } - $email .= beans_selfclose_markup( 'beans_comment_form_field[_email]', 'input', array( - 'id' => 'email', - 'class' => 'uk-width-1-1', - 'type' => 'text', - 'value' => $commenter['comment_author_email'], // Automatically escaped. - 'name' => 'email', - 'required' => get_option( 'require_name_email' ) ? 'required' : null, - ) ); + $email .= beans_selfclose_markup( + 'beans_comment_form_field[_email]', 'input', array( + 'id' => 'email', + 'class' => 'uk-width-1-1', + 'type' => 'text', + 'value' => $commenter['comment_author_email'], // Automatically escaped. + 'name' => 'email', + 'required' => get_option( 'require_name_email' ) ? 'required' : null, + ) + ); $email .= beans_close_markup( 'beans_comment_form[_email]', 'div' ); $fields['email'] = $email; - } // Url. if ( isset( $fields['url'] ) ) { - $url = beans_open_markup( 'beans_comment_form[_website]', 'div', array( 'class' => "uk-width-medium-1-$grid" ) ); /** @@ -538,28 +582,27 @@ function beans_comment_form_fields( $fields ) { * * @since 1.0.0 */ - if ( beans_apply_filters( 'beans_comment_form_legend[_url]', true ) ) { - - $url .= beans_open_markup( 'beans_comment_form_legend', 'legend' ); - - $url .= beans_output( 'beans_comment_form_legend_text[_url]', __( 'Website', 'tm-beans' ) ); + if ( beans_apply_filters( 'beans_comment_form_legend[_url]', true ) ) { + $url .= beans_open_markup( 'beans_comment_form_legend', 'legend' ); - $url .= beans_close_markup( 'beans_comment_form_legend[_url]', 'legend' ); + $url .= beans_output( 'beans_comment_form_legend_text[_url]', __( 'Website', 'tm-beans' ) ); - } + $url .= beans_close_markup( 'beans_comment_form_legend[_url]', 'legend' ); + } - $url .= beans_selfclose_markup( 'beans_comment_form_field[_url]', 'input', array( - 'id' => 'url', - 'class' => 'uk-width-1-1', - 'type' => 'text', - 'value' => $commenter['comment_author_url'], // Automatically escaped. - 'name' => 'url', - ) ); + $url .= beans_selfclose_markup( + 'beans_comment_form_field[_url]', 'input', array( + 'id' => 'url', + 'class' => 'uk-width-1-1', + 'type' => 'text', + 'value' => $commenter['comment_author_url'], // Automatically escaped. + 'name' => 'url', + ) + ); $url .= beans_close_markup( 'beans_comment_form[_website]', 'div' ); $fields['url'] = $url; - } return $fields; @@ -573,11 +616,11 @@ function beans_comment_form_fields( $fields ) { * the user is not logged in. * * @since 1.0.0 + * + * @return void */ function beans_comment_form_after_fields() { - beans_close_markup_e( 'beans_comment_fields_inner_wrap', 'div' ); beans_close_markup_e( 'beans_comment_fields_wrap', 'div' ); - } diff --git a/lib/templates/fragments/deprecated.php b/lib/templates/fragments/deprecated.php index ed077bc8..bb7ea560 100644 --- a/lib/templates/fragments/deprecated.php +++ b/lib/templates/fragments/deprecated.php @@ -2,7 +2,9 @@ /** * Deprecated fragments. * - * @package Fragments\Deprecated + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ /** @@ -12,13 +14,12 @@ * * @since 1.0.0 * @deprecated 1.2.0 + * + * @return void */ function beans_head_title() { - _deprecated_function( __FUNCTION__, '1.2.0', 'wp_title()' ); - wp_title( '|', true, 'right' ); - } /** @@ -35,9 +36,7 @@ function beans_head_title() { * @return string The modified title. */ function beans_wp_title( $title, $sep ) { - _deprecated_function( __FUNCTION__, '1.2.0', 'wp_title()' ); - global $page, $paged; if ( is_feed() ) { @@ -48,34 +47,40 @@ function beans_wp_title( $title, $sep ) { $title .= get_bloginfo( 'name' ); // Add the blog description for the home/front page. - if ( ( $site_description = get_bloginfo( 'description', 'display' ) ) && ( is_home() || is_front_page() ) ) { + $site_description = get_bloginfo( 'description', 'display' ); + + if ( $site_desciption && ( is_home() || is_front_page() ) ) { $title .= " $sep $site_description"; } // Add a page number if necessary. if ( $paged >= 2 || $page >= 2 ) { + // translators: Page number. $title .= " $sep " . sprintf( __( 'Page %s', 'tm-beans' ), max( $paged, $page ) ); } return $title; - } /** * Deprecated shortcodes. * - * We declare the shortcodes for backward compatibility purposes but it shouldn't be used for further development. + * We declare the shortcodes for backward compatibility purposes but they shouldn't be used for further development. * * @deprecated 1.2.0 * * @ignore + * + * @return void */ global $shortcode_tags; -$shortcode_tags = array_merge( $shortcode_tags, array( - 'beans_post_meta_date' => 'beans_post_meta_date_shortcode', - 'beans_post_meta_author' => 'beans_post_meta_author_shortcode', - 'beans_post_meta_comments' => 'beans_post_meta_comments_shortcode', - 'beans_post_meta_tags' => 'beans_post_meta_tags_shortcode', - 'beans_post_meta_categories' => 'beans_post_meta_categories_shortcode', -) ); +$shortcode_tags = array_merge( // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Deprecated function. + $shortcode_tags, array( + 'beans_post_meta_date' => 'beans_post_meta_date_shortcode', + 'beans_post_meta_author' => 'beans_post_meta_author_shortcode', + 'beans_post_meta_comments' => 'beans_post_meta_comments_shortcode', + 'beans_post_meta_tags' => 'beans_post_meta_tags_shortcode', + 'beans_post_meta_categories' => 'beans_post_meta_categories_shortcode', + ) +); diff --git a/lib/templates/fragments/embed.php b/lib/templates/fragments/embed.php index 11954761..10a92c1f 100644 --- a/lib/templates/fragments/embed.php +++ b/lib/templates/fragments/embed.php @@ -2,7 +2,9 @@ /** * Extends WordPress Embed. * - * @package Fragments\Embed + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ // Filter. @@ -17,7 +19,6 @@ * @return string The modified embed HTML. */ function beans_embed_oembed( $html ) { - $output = beans_open_markup( 'beans_embed_oembed', 'div', 'class=tm-oembed' ); $output .= $html; @@ -25,5 +26,4 @@ function beans_embed_oembed( $html ) { $output .= beans_close_markup( 'beans_embed_oembed', 'div' ); return $output; - } diff --git a/lib/templates/fragments/footer.php b/lib/templates/fragments/footer.php index 33164413..de133600 100644 --- a/lib/templates/fragments/footer.php +++ b/lib/templates/fragments/footer.php @@ -2,7 +2,9 @@ /** * Echo footer fragments. * - * @package Fragments\Footer + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_footer', 'beans_footer_content' ); @@ -10,45 +12,53 @@ * Echo the footer content. * * @since 1.0.0 + * + * @return void */ function beans_footer_content() { - beans_open_markup_e( 'beans_footer_credit', 'div', array( 'class' => 'uk-clearfix uk-text-small uk-text-muted' ) ); - beans_open_markup_e( 'beans_footer_credit_left', 'span', array( - 'class' => 'uk-align-medium-left uk-margin-small-bottom', - ) ); + beans_open_markup_e( 'beans_footer_credit_left', 'span', array( 'class' => 'uk-align-medium-left uk-margin-small-bottom' ) ); - beans_output_e( 'beans_footer_credit_text', sprintf( - __( '© %1$s - %2$s. All rights reserved.', 'tm-beans' ), - date( 'Y' ), - get_bloginfo( 'name' ) - ) ); + beans_output_e( + 'beans_footer_credit_text', + sprintf( + // translators: Footer credits. Date followed by the name of the website. + __( '© %1$s - %2$s. All rights reserved.', 'tm-beans' ), + date( 'Y' ), + get_bloginfo( 'name' ) + ) + ); beans_close_markup_e( 'beans_footer_credit_left', 'span' ); - $framework_link = beans_open_markup( 'beans_footer_credit_framework_link', 'a', array( - 'href' => 'http://www.getbeans.io', // Automatically escaped. - 'rel' => 'designer', - ) ); + $framework_link = beans_open_markup( + 'beans_footer_credit_framework_link', + 'a', + array( + 'href' => 'http://www.getbeans.io', // Automatically escaped. + 'rel' => 'designer', + ) + ); $framework_link .= beans_output( 'beans_footer_credit_framework_link_text', 'Beans' ); $framework_link .= beans_close_markup( 'beans_footer_credit_framework_link', 'a' ); - beans_open_markup_e( 'beans_footer_credit_right', 'span', array( - 'class' => 'uk-align-medium-right uk-margin-bottom-remove', - ) ); + beans_open_markup_e( 'beans_footer_credit_right', 'span', array( 'class' => 'uk-align-medium-right uk-margin-bottom-remove' ) ); - beans_output_e( 'beans_footer_credit_right_text', sprintf( - __( '%1$s theme for WordPress.', 'tm-beans' ), - $framework_link - ) ); + beans_output_e( + 'beans_footer_credit_right_text', + sprintf( + // translators: Link to the Beans website. + __( '%1$s theme for WordPress.', 'tm-beans' ), + $framework_link + ) + ); beans_close_markup_e( 'beans_footer_credit_right', 'span' ); beans_close_markup_e( 'beans_footer_credit', 'div' ); - } beans_add_smart_action( 'wp_footer', 'beans_replace_nojs_class' ); @@ -56,13 +66,14 @@ function beans_footer_content() { * Print inline JavaScript in the footer to replace the 'no-js' class with 'js'. * * @since 1.0.0 + * + * @return void */ function beans_replace_nojs_class() { - ?> + - + + + 'Shortcut Icon', - 'href' => $url, // Automatically escaped. - 'type' => 'image/x-icon', - ) ); - + beans_selfclose_markup_e( + 'beans_favicon', + 'link', + array( + 'rel' => 'Shortcut Icon', + 'href' => $url, // Automatically escaped. + 'type' => 'image/x-icon', + ) + ); } beans_add_smart_action( 'wp_head', 'beans_header_image' ); @@ -60,22 +69,26 @@ function beans_favicon() { * Print the header image css inline in the header. * * @since 1.0.0 + * + * @return void */ function beans_header_image() { + $header_image = get_header_image(); - if ( ! current_theme_supports( 'custom-header' ) || ! ( $header_image = get_header_image() ) || empty( $header_image ) ) { + if ( ! current_theme_supports( 'custom-header' ) || ! $header_image || empty( $header_image ) ) { return; } - ?> + 'tm-site-branding uk-float-left' . ( ! get_bloginfo( 'description' ) ? ' uk-margin-small-top' : null ), - ) ); - - beans_open_markup_e( 'beans_site_title_link', 'a', array( - 'href' => home_url(), // Automatically escaped. - 'rel' => 'home', - 'itemprop' => 'headline', - ) ); - - if ( $logo = get_theme_mod( 'beans_logo_image', false ) ) { - beans_selfclose_markup_e( 'beans_logo_image', 'img', array( - 'class' => 'tm-logo', - 'src' => $logo, // Automatically escaped. - 'alt' => get_bloginfo( 'name' ), // Automatically escaped. - ) ); + beans_open_markup_e( + 'beans_site_branding', + 'div', + array( + 'class' => 'tm-site-branding uk-float-left' . ( ! get_bloginfo( 'description' ) ? ' uk-margin-small-top' : null ), + ) + ); + + beans_open_markup_e( + 'beans_site_title_link', + 'a', + array( + 'href' => home_url(), // Automatically escaped. + 'rel' => 'home', + 'itemprop' => 'headline', + ) + ); + + $logo = get_theme_mod( 'beans_logo_image', false ); + + // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Code structure mimics HTML markup. + if ( $logo ) { + beans_selfclose_markup_e( + 'beans_logo_image', + 'img', + array( + 'class' => 'tm-logo', + 'src' => $logo, // Automatically escaped. + 'alt' => get_bloginfo( 'name' ), // Automatically escaped. + ) + ); } else { beans_output_e( 'beans_site_title_text', get_bloginfo( 'name' ) ); } + // phpcs:enable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Code structure mimics HTML markup. beans_close_markup_e( 'beans_site_title_link', 'a' ); beans_close_markup_e( 'beans_site_branding', 'div' ); - } beans_add_smart_action( 'beans_site_branding_append_markup', 'beans_site_title_tag' ); @@ -117,21 +146,27 @@ function beans_site_branding() { * Echo header site title tag. * * @since 1.0.0 + * + * @return void */ function beans_site_title_tag() { - // Stop here if there isn't a description. - if ( ! $description = get_bloginfo( 'description' ) ) { + $description = get_bloginfo( 'description' ); + + if ( ! $description ) { return; } - beans_open_markup_e( 'beans_site_title_tag', 'span', array( - 'class' => 'tm-site-title-tag uk-text-small uk-text-muted uk-display-block', - 'itemprop' => 'description', - ) ); + beans_open_markup_e( + 'beans_site_title_tag', + 'span', + array( + 'class' => 'tm-site-title-tag uk-text-small uk-text-muted uk-display-block', + 'itemprop' => 'description', + ) + ); beans_output_e( 'beans_site_title_tag_text', $description ); beans_close_markup_e( 'beans_site_title_tag', 'span' ); - } diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index 27c2aa28..36fbb729 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -2,7 +2,9 @@ /** * Echo menu fragments. * - * @package Fragments\Menu + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_header', 'beans_primary_menu', 15 ); @@ -10,17 +12,22 @@ * Echo primary menu. * * @since 1.0.0 + * + * @return void */ function beans_primary_menu() { - $nav_visibility = current_theme_supports( 'offcanvas-menu' ) ? 'uk-visible-large' : ''; - beans_open_markup_e( 'beans_primary_menu', 'nav', array( - 'class' => 'tm-primary-menu uk-float-right uk-navbar', - 'role' => 'navigation', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/SiteNavigationElement', - ) ); + beans_open_markup_e( + 'beans_primary_menu', + 'nav', + array( + 'class' => 'tm-primary-menu uk-float-right uk-navbar', + 'role' => 'navigation', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/SiteNavigationElement', + ) + ); /** * Filter the primary menu arguments. @@ -29,20 +36,22 @@ function beans_primary_menu() { * * @param array $args Nav menu arguments. */ - $args = apply_filters( 'beans_primary_menu_args', array( - 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', - 'fallback_cb' => 'beans_no_menu_notice', - 'container' => '', - 'menu_class' => $nav_visibility, // Automatically escaped. - 'echo' => false, - 'beans_type' => 'navbar', - ) ); + $args = apply_filters( + 'beans_primary_menu_args', + array( + 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', + 'fallback_cb' => 'beans_no_menu_notice', + 'container' => '', + 'menu_class' => $nav_visibility, // Automatically escaped. + 'echo' => false, + 'beans_type' => 'navbar', + ) + ); // Navigation. beans_output_e( 'beans_primary_menu', wp_nav_menu( $args ) ); beans_close_markup_e( 'beans_primary_menu', 'nav' ); - } beans_add_smart_action( 'beans_primary_menu_append_markup', 'beans_primary_menu_offcanvas_button', 5 ); @@ -50,6 +59,8 @@ function beans_primary_menu() { * Echo primary menu offcanvas button. * * @since 1.0.0 + * + * @return void */ function beans_primary_menu_offcanvas_button() { @@ -57,22 +68,23 @@ function beans_primary_menu_offcanvas_button() { return; } - beans_open_markup_e( 'beans_primary_menu_offcanvas_button', 'a', array( - 'href' => '#offcanvas_menu', - 'class' => 'uk-button uk-hidden-large', - 'data-uk-offcanvas' => '', - ) ); + beans_open_markup_e( + 'beans_primary_menu_offcanvas_button', + 'a', + array( + 'href' => '#offcanvas_menu', + 'class' => 'uk-button uk-hidden-large', + 'data-uk-offcanvas' => '', + ) + ); - beans_open_markup_e( 'beans_primary_menu_offcanvas_button_icon', 'i', array( - 'class' => 'uk-icon-navicon uk-margin-small-right', - ) ); + beans_open_markup_e( 'beans_primary_menu_offcanvas_button_icon', 'i', array( 'class' => 'uk-icon-navicon uk-margin-small-right' ) ); beans_close_markup_e( 'beans_primary_menu_offcanvas_button_icon', 'i' ); beans_output_e( 'beans_offcanvas_menu_button', __( 'Menu', 'tm-beans' ) ); beans_close_markup_e( 'beans_primary_menu_offcanvas_button', 'a' ); - } beans_add_smart_action( 'beans_widget_area_offcanvas_bar_offcanvas_menu_prepend_markup', 'beans_primary_offcanvas_menu' ); @@ -80,6 +92,8 @@ function beans_primary_menu_offcanvas_button() { * Echo off-canvas primary menu. * * @since 1.0.0 + * + * @return void */ function beans_primary_offcanvas_menu() { @@ -87,10 +101,14 @@ function beans_primary_offcanvas_menu() { return; } - beans_open_markup_e( 'beans_primary_offcanvas_menu', 'nav', array( - 'class' => 'tm-primary-offcanvas-menu uk-margin uk-margin-top', - 'role' => 'navigation', - ) ); + beans_open_markup_e( + 'beans_primary_offcanvas_menu', + 'nav', + array( + 'class' => 'tm-primary-offcanvas-menu uk-margin uk-margin-top', + 'role' => 'navigation', + ) + ); /** * Filter the off-canvas primary menu arguments. @@ -99,31 +117,33 @@ function beans_primary_offcanvas_menu() { * * @param array $args Off-canvas nav menu arguments. */ - $args = apply_filters( 'beans_primary_offcanvas_menu_args', array( - 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', - 'fallback_cb' => 'beans_no_menu_notice', - 'container' => '', - 'echo' => false, - 'beans_type' => 'offcanvas', - ) ); + $args = apply_filters( + 'beans_primary_offcanvas_menu_args', + array( + 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', + 'fallback_cb' => 'beans_no_menu_notice', + 'container' => '', + 'echo' => false, + 'beans_type' => 'offcanvas', + ) + ); beans_output_e( 'beans_primary_offcanvas_menu', wp_nav_menu( $args ) ); beans_close_markup_e( 'beans_primary_offcanvas_menu', 'nav' ); - } /** * Echo no menu notice. * * @since 1.0.0 + * + * @return void */ function beans_no_menu_notice() { - beans_open_markup_e( 'beans_no_menu_notice', 'p', array( 'class' => 'uk-alert uk-alert-warning' ) ); beans_output_e( 'beans_no_menu_notice_text', __( 'Whoops, your site does not have a menu!', 'tm-beans' ) ); beans_close_markup_e( 'beans_no_menu_notice', 'p' ); - } diff --git a/lib/templates/fragments/post-shortcodes.php b/lib/templates/fragments/post-shortcodes.php index 758773b0..d6426b2d 100644 --- a/lib/templates/fragments/post-shortcodes.php +++ b/lib/templates/fragments/post-shortcodes.php @@ -2,7 +2,9 @@ /** * Add post shortcodes. * - * @package Fragments\Post_Shortcodes + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_post_meta_date', 'beans_post_meta_date_shortcode' ); @@ -10,20 +12,24 @@ * Echo post meta date shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_date_shortcode() { - beans_output_e( 'beans_post_meta_date_prefix', __( 'Posted on ', 'tm-beans' ) ); - beans_open_markup_e( 'beans_post_meta_date', 'time', array( - 'datetime' => get_the_time( 'c' ), - 'itemprop' => 'datePublished', - ) ); + beans_open_markup_e( + 'beans_post_meta_date', + 'time', + array( + 'datetime' => get_the_time( 'c' ), + 'itemprop' => 'datePublished', + ) + ); beans_output_e( 'beans_post_meta_date_text', get_the_time( get_option( 'date_format' ) ) ); beans_close_markup_e( 'beans_post_meta_date', 'time' ); - } beans_add_smart_action( 'beans_post_meta_author', 'beans_post_meta_author_shortcode' ); @@ -31,28 +37,36 @@ function beans_post_meta_date_shortcode() { * Echo post meta author shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_author_shortcode() { - beans_output_e( 'beans_post_meta_author_prefix', __( 'By ', 'tm-beans' ) ); - beans_open_markup_e( 'beans_post_meta_author', 'a', array( - 'href' => get_author_posts_url( get_the_author_meta( 'ID' ) ), // Automatically escaped. - 'rel' => 'author', - 'itemprop' => 'author', - 'itemscope' => '', - 'itemtype' => 'http://schema.org/Person', - ) ); + beans_open_markup_e( + 'beans_post_meta_author', + 'a', + array( + 'href' => get_author_posts_url( get_the_author_meta( 'ID' ) ), // Automatically escaped. + 'rel' => 'author', + 'itemprop' => 'author', + 'itemscope' => '', + 'itemtype' => 'http://schema.org/Person', + ) + ); beans_output_e( 'beans_post_meta_author_text', get_the_author() ); - beans_selfclose_markup_e( 'beans_post_meta_author_name_meta', 'meta', array( - 'itemprop' => 'name', - 'content' => get_the_author(), // Automatically escaped. - ) ); + beans_selfclose_markup_e( + 'beans_post_meta_author_name_meta', + 'meta', + array( + 'itemprop' => 'name', + 'content' => get_the_author(), // Automatically escaped. + ) + ); beans_close_markup_e( 'beans_post_meta_author', 'a' ); - } beans_add_smart_action( 'beans_post_meta_comments', 'beans_post_meta_comments_shortcode' ); @@ -60,9 +74,10 @@ function beans_post_meta_author_shortcode() { * Echo post meta comments shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_comments_shortcode() { - global $post; if ( post_password_required() || ! comments_open() ) { @@ -76,17 +91,18 @@ function beans_post_meta_comments_shortcode() { } elseif ( 1 === $comments_number ) { $comment_text = beans_output( 'beans_post_meta_comments_text_singular', __( '1 comment', 'tm-beans' ) ); } else { - $comment_text = beans_output( 'beans_post_meta_comments_text_plurial', __( '%s comments', 'tm-beans' ) ); + $comment_text = beans_output( + 'beans_post_meta_comments_text_plural', + // translators: Number of comments. Plural. + __( '%s comments', 'tm-beans' ) + ); } - beans_open_markup_e( 'beans_post_meta_comments', 'a', array( - 'href' => get_comments_link(), // Automatically escaped. - ) ); + beans_open_markup_e( 'beans_post_meta_comments', 'a', array( 'href' => get_comments_link() ) ); // Automatically escaped. - printf( $comment_text, (int) get_comments_number( $post->ID ) ); + printf( $comment_text, (int) get_comments_number( $post->ID ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. beans_close_markup_e( 'beans_post_meta_comments', 'a' ); - } beans_add_smart_action( 'beans_post_meta_tags', 'beans_post_meta_tags_shortcode' ); @@ -94,6 +110,8 @@ function beans_post_meta_comments_shortcode() { * Echo post meta tags shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_tags_shortcode() { @@ -103,8 +121,7 @@ function beans_post_meta_tags_shortcode() { return; } - printf( '%1$s%2$s', beans_output( 'beans_post_meta_tags_prefix', __( 'Tagged with: ', 'tm-beans' ) ), $tags ); - + printf( '%1$s%2$s', beans_output( 'beans_post_meta_tags_prefix', __( 'Tagged with: ', 'tm-beans' ) ), $tags ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. } beans_add_smart_action( 'beans_post_meta_categories', 'beans_post_meta_categories_shortcode' ); @@ -112,15 +129,15 @@ function beans_post_meta_tags_shortcode() { * Echo post meta categories shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_categories_shortcode() { - $categories = get_the_category_list( ', ' ); if ( ! $categories || is_wp_error( $categories ) ) { return; } - printf( '%1$s%2$s', beans_output( 'beans_post_meta_categories_prefix', __( 'Filed under: ', 'tm-beans' ) ), $categories ); - + printf( '%1$s%2$s', beans_output( 'beans_post_meta_categories_prefix', __( 'Filed under: ', 'tm-beans' ) ), $categories ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. } diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 7557c0c8..5218c3b2 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -2,7 +2,9 @@ /** * Echo post fragments. * - * @package Fragments\Post + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_post_header', 'beans_post_title' ); @@ -10,10 +12,11 @@ * Echo post title. * * @since 1.0.0 + * + * @return void */ function beans_post_title() { - - $title = beans_output( 'beans_post_title_text', get_the_title() ); + $title = beans_output( 'beans_post_title_text', get_the_title() ); $title_tag = 'h1'; if ( empty( $title ) ) { @@ -21,31 +24,35 @@ function beans_post_title() { } if ( ! is_singular() ) { + $title_link = beans_open_markup( + 'beans_post_title_link', + 'a', + array( + 'href' => get_permalink(), // Automatically escaped. + 'title' => the_title_attribute( 'echo=0' ), + 'rel' => 'bookmark', + ) + ); - $title_link = beans_open_markup( 'beans_post_title_link', 'a', array( - 'href' => get_permalink(), // Automatically escaped. - 'title' => the_title_attribute( 'echo=0' ), - 'rel' => 'bookmark', - ) ); - - $title_link .= $title; - + $title_link .= $title; $title_link .= beans_close_markup( 'beans_post_title_link', 'a' ); - $title = $title_link; + $title = $title_link; $title_tag = 'h2'; - } - beans_open_markup_e( 'beans_post_title', $title_tag, array( - 'class' => 'uk-article-title', - 'itemprop' => 'headline', - ) ); + beans_open_markup_e( + 'beans_post_title', + $title_tag, + array( + 'class' => 'uk-article-title', + 'itemprop' => 'headline', + ) + ); - echo $title; + echo $title; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. beans_close_markup_e( 'beans_post_title', $title_tag ); - } beans_add_smart_action( 'beans_before_loop', 'beans_post_search_title' ); @@ -53,6 +60,8 @@ function beans_post_title() { * Echo search post title. * * @since 1.0.0 + * + * @return void */ function beans_post_search_title() { @@ -62,10 +71,9 @@ function beans_post_search_title() { beans_open_markup_e( 'beans_search_title', 'h1', array( 'class' => 'uk-article-title' ) ); - printf( '%1$s%2$s', beans_output( 'beans_search_title_text', __( 'Search results for: ', 'tm-beans' ) ), get_search_query() ); + printf( '%1$s%2$s', beans_output( 'beans_search_title_text', __( 'Search results for: ', 'tm-beans' ) ), get_search_query() ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. beans_close_markup_e( 'beans_search_title', 'h1' ); - } @@ -74,6 +82,8 @@ function beans_post_search_title() { * Echo archive post title. * * @since 1.4.0 + * + * @return void */ function beans_post_archive_title() { @@ -86,7 +96,6 @@ function beans_post_archive_title() { beans_output_e( 'beans_archive_title_text', get_the_archive_title() ); beans_close_markup_e( 'beans_archive_title', 'h1' ); - } beans_add_smart_action( 'beans_post_header', 'beans_post_meta', 15 ); @@ -94,6 +103,8 @@ function beans_post_archive_title() { * Echo post meta. * * @since 1.0.0 + * + * @return void */ function beans_post_meta() { @@ -104,7 +115,7 @@ function beans_post_meta() { * * @param bool $pre True to short-circuit, False to let the function run. */ - if ( apply_filters( 'beans_pre_post_meta', 'post' != get_post_type() ) ) { + if ( apply_filters( 'beans_pre_post_meta', 'post' !== get_post_type() ) ) { return; } @@ -120,30 +131,33 @@ function beans_post_meta() { * * @param array $fragments An array of fragment files. */ - $meta_items = apply_filters( 'beans_post_meta_items', array( - 'date' => 10, - 'author' => 20, - 'comments' => 30, - ) ); + $meta_items = apply_filters( + 'beans_post_meta_items', + array( + 'date' => 10, + 'author' => 20, + 'comments' => 30, + ) + ); asort( $meta_items ); - foreach ( $meta_items as $meta => $priority ) { + foreach ( $meta_items as $meta => $priority ) { - if ( ! $content = beans_render_function( 'do_action', "beans_post_meta_$meta" ) ) { - continue; - } + $content = beans_render_function( 'do_action', "beans_post_meta_$meta" ); - beans_open_markup_e( "beans_post_meta_item[_{$meta}]", 'li' ); + if ( ! $content ) { + continue; + } - beans_output_e( "beans_post_meta_item_{$meta}_text", $content ); + beans_open_markup_e( "beans_post_meta_item[_{$meta}]", 'li' ); - beans_close_markup_e( "beans_post_meta_item[_{$meta}]", 'li' ); + beans_output_e( "beans_post_meta_item_{$meta}_text", $content ); - } + beans_close_markup_e( "beans_post_meta_item[_{$meta}]", 'li' ); + } beans_close_markup_e( 'beans_post_meta', 'ul' ); - } beans_add_smart_action( 'beans_post_body', 'beans_post_image', 5 ); @@ -151,6 +165,8 @@ function beans_post_meta() { * Echo post image. * * @since 1.0.0 + * + * @return bool */ function beans_post_image() { @@ -179,9 +195,12 @@ function beans_post_image() { * @param bool|array $edit_args Arguments used by {@see beans_edit_image()}. Set to false to use WordPress * large size. */ - $edit_args = apply_filters( 'beans_edit_post_image_args', array( - 'resize' => array( 800, false ), - ) ); + $edit_args = apply_filters( + 'beans_edit_post_image_args', + array( + 'resize' => array( 800, false ), + ) + ); if ( empty( $edit_args ) ) { $image = beans_get_post_attachment( $post->ID, 'large' ); @@ -199,9 +218,12 @@ function beans_post_image() { * @param bool|array $edit_args Arguments used by {@see beans_edit_image()}. Set to false to use WordPress * small size. */ - $edit_small_args = apply_filters( 'beans_edit_post_image_small_args', array( - 'resize' => array( 480, false ), - ) ); + $edit_small_args = apply_filters( + 'beans_edit_post_image_small_args', + array( + 'resize' => array( 480, false ), + ) + ); if ( empty( $edit_small_args ) ) { $image_small = beans_get_post_attachment( $post->ID, 'thumbnail' ); @@ -212,45 +234,54 @@ function beans_post_image() { beans_open_markup_e( 'beans_post_image', 'div', array( 'class' => 'tm-article-image' ) ); - if ( ! is_singular() ) { - beans_open_markup_e( 'beans_post_image_link', 'a', array( + if ( ! is_singular() ) { + beans_open_markup_e( + 'beans_post_image_link', + 'a', + array( 'href' => get_permalink(), // Automatically escaped. 'title' => the_title_attribute( 'echo=0' ), - ) ); - } + ) + ); + } beans_open_markup_e( 'beans_post_image_item_wrap', 'picture' ); - if ( $edit ) { - - beans_selfclose_markup_e( 'beans_post_image_small_item', 'source', array( - 'media' => '(max-width: ' . $image_small->width . 'px)', - 'srcset' => esc_url( $image_small->src ), - ), $image_small ); - - beans_selfclose_markup_e( 'beans_post_image_item', 'img', array( - 'width' => $image->width, - 'height' => $image->height, - 'src' => $image->src, // Automatically escaped. - 'alt' => $image->alt, // Automatically escaped. - 'itemprop' => 'image', - ), $image ); - - } else { - - // Beans API isn't available, use wp_get_attachment_image_attributes filter instead. - the_post_thumbnail(); - - } + if ( $edit ) { + beans_selfclose_markup_e( + 'beans_post_image_small_item', + 'source', + array( + 'media' => '(max-width: ' . $image_small->width . 'px)', + 'srcset' => esc_url( $image_small->src ), + ), + $image_small + ); + + beans_selfclose_markup_e( + 'beans_post_image_item', + 'img', + array( + 'width' => $image->width, + 'height' => $image->height, + 'src' => $image->src, // Automatically escaped. + 'alt' => $image->alt, // Automatically escaped. + 'itemprop' => 'image', + ), + $image + ); + } else { + // Beans API isn't available, use wp_get_attachment_image_attributes filter instead. + the_post_thumbnail(); + } beans_close_markup_e( 'beans_post_image_item_wrap', 'picture' ); - if ( ! is_singular() ) { - beans_close_markup_e( 'beans_post_image_link', 'a' ); - } + if ( ! is_singular() ) { + beans_close_markup_e( 'beans_post_image_link', 'a' ); + } beans_close_markup_e( 'beans_post_image', 'div' ); - } beans_add_smart_action( 'beans_post_body', 'beans_post_content' ); @@ -258,28 +289,30 @@ function beans_post_image() { * Echo post content. * * @since 1.0.0 + * + * @return void */ function beans_post_content() { - global $post; - beans_open_markup_e( 'beans_post_content', 'div', array( - 'class' => 'tm-article-content', - 'itemprop' => 'text', - ) ); + beans_open_markup_e( + 'beans_post_content', + 'div', + array( + 'class' => 'tm-article-content', + 'itemprop' => 'text', + ) + ); the_content(); - if ( is_singular() && 'open' === get_option( 'default_ping_status' ) && post_type_supports( $post->post_type, 'trackbacks' ) ) { - - echo '' . "\n"; - - } + if ( is_singular() && 'open' === get_option( 'default_ping_status' ) && post_type_supports( $post->post_type, 'trackbacks' ) ) { + echo '' . "\n"; + } beans_close_markup_e( 'beans_post_content', 'div' ); - } // Filter. @@ -292,25 +325,31 @@ function beans_post_content() { * @return string The modified "more link". */ function beans_post_more_link() { - global $post; - $output = beans_open_markup( 'beans_post_more_link', 'a', array( - 'href' => get_permalink(), // Automatically escaped. - 'class' => 'more-link', - ) ); + $output = beans_open_markup( + 'beans_post_more_link', + 'a', + array( + 'href' => get_permalink(), // Automatically escaped. + 'class' => 'more-link', + ) + ); $output .= beans_output( 'beans_post_more_link_text', __( 'Continue reading', 'tm-beans' ) ); - $output .= beans_open_markup( 'beans_next_icon[_more_link]', 'i', array( - 'class' => 'uk-icon-angle-double-right uk-margin-small-left', - ) ); + $output .= beans_open_markup( + 'beans_next_icon[_more_link]', + 'i', + array( + 'class' => 'uk-icon-angle-double-right uk-margin-small-left', + ) + ); $output .= beans_close_markup( 'beans_next_icon[_more_link]', 'i' ); $output .= beans_close_markup( 'beans_post_more_link', 'a' ); return $output; - } beans_add_smart_action( 'beans_post_body', 'beans_post_content_navigation', 20 ); @@ -318,15 +357,17 @@ function beans_post_more_link() { * Echo post content navigation. * * @since 1.0.0 + * + * @return void */ function beans_post_content_navigation() { - - echo wp_link_pages( array( - 'before' => beans_open_markup( 'beans_post_content_navigation', 'p', array( 'class' => 'uk-text-bold' ) ) . beans_output( 'beans_post_content_navigation_text', __( 'Pages:', 'tm-beans' ) ), - 'after' => beans_close_markup( 'beans_post_content_navigation', 'p' ), - 'echo' => false, - ) ); - + echo wp_link_pages( + array( + 'before' => beans_open_markup( 'beans_post_content_navigation', 'p', array( 'class' => 'uk-text-bold' ) ) . beans_output( 'beans_post_content_navigation_text', __( 'Pages:', 'tm-beans' ) ), + 'after' => beans_close_markup( 'beans_post_content_navigation', 'p' ), + 'echo' => false, + ) + ); } beans_add_smart_action( 'beans_post_body', 'beans_post_meta_categories', 25 ); @@ -334,19 +375,21 @@ function beans_post_content_navigation() { * Echo post meta categories. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_categories() { + $categories = beans_render_function( 'do_shortcode', '[beans_post_meta_categories]' ); - if ( ! $categories = beans_render_function( 'do_shortcode', '[beans_post_meta_categories]' ) ) { + if ( ! $categories ) { return; } beans_open_markup_e( 'beans_post_meta_categories', 'span', array( 'class' => 'uk-text-small uk-text-muted uk-clearfix' ) ); - echo $categories; + echo $categories; // // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. beans_close_markup_e( 'beans_post_meta_categories', 'span' ); - } beans_add_smart_action( 'beans_post_body', 'beans_post_meta_tags', 30 ); @@ -356,17 +399,17 @@ function beans_post_meta_categories() { * @since 1.0.0 */ function beans_post_meta_tags() { + $tags = beans_render_function( 'do_shortcode', '[beans_post_meta_tags]' ); - if ( ! $tags = beans_render_function( 'do_shortcode', '[beans_post_meta_tags]' ) ) { + if ( ! $tags ) { return; } beans_open_markup_e( 'beans_post_meta_tags', 'span', array( 'class' => 'uk-text-small uk-text-muted uk-clearfix' ) ); - echo $tags; + echo $tags; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. beans_close_markup_e( 'beans_post_meta_tags', 'span' ); - } // Filter. @@ -376,22 +419,34 @@ function beans_post_meta_tags() { * * @since 1.0.0 * + * @param string $output "Next link" output. + * @param string $format Link output format. + * @param string $link Link permalink format. + * @param int $post Post ID. + * @return string The modified "previous link". */ function beans_previous_post_link( $output, $format, $link, $post ) { - // Using $link won't apply wp filters, so rather strip tags the $output. $text = strip_tags( $output ); - $output = beans_open_markup( 'beans_previous_link[_post_navigation]', 'a', array( - 'href' => get_permalink( $post ), // Automatically escaped. - 'rel' => 'previous', - 'title' => $post->post_title, // Automatically escaped. - ) ); + $output = beans_open_markup( + 'beans_previous_link[_post_navigation]', + 'a', + array( + 'href' => get_permalink( $post ), // Automatically escaped. + 'rel' => 'previous', + 'title' => $post->post_title, // Automatically escaped. + ) + ); - $output .= beans_open_markup( 'beans_previous_icon[_post_navigation]', 'i', array( - 'class' => 'uk-icon-angle-double-left uk-margin-small-right', - ) ); + $output .= beans_open_markup( + 'beans_previous_icon[_post_navigation]', + 'i', + array( + 'class' => 'uk-icon-angle-double-left uk-margin-small-right', + ) + ); $output .= beans_close_markup( 'beans_previous_icon[_post_navigation]', 'i' ); @@ -400,7 +455,6 @@ function beans_previous_post_link( $output, $format, $link, $post ) { $output .= beans_close_markup( 'beans_previous_link[_post_navigation]', 'a' ); return $output; - } // Filter. @@ -410,31 +464,42 @@ function beans_previous_post_link( $output, $format, $link, $post ) { * * @since 1.0.0 * + * @param string $output "Next link" output. + * @param string $format Link output format. + * @param string $link Link permalink format. + * @param int $post Post ID. + * * @return string The modified "next link". */ function beans_next_post_link( $output, $format, $link, $post ) { - - // Using $link won't apply wp filters, so rather strip tags the $output. + // Using $link won't apply WP filters, so rather strip tags the $output. $text = strip_tags( $output ); - $output = beans_open_markup( 'beans_next_link[_post_navigation]', 'a', array( - 'href' => get_permalink( $post ), // Automatically escaped. - 'rel' => 'next', - 'title' => $post->post_title, // Automatically escaped. - ) ); + $output = beans_open_markup( + 'beans_next_link[_post_navigation]', + 'a', + array( + 'href' => get_permalink( $post ), // Automatically escaped. + 'rel' => 'next', + 'title' => $post->post_title, // Automatically escaped. + ) + ); $output .= beans_output( 'beans_next_text[_post_navigation]', $text ); - $output .= beans_open_markup( 'beans_next_icon[_post_navigation]', 'i', array( - 'class' => 'uk-icon-angle-double-right uk-margin-small-left', - ) ); + $output .= beans_open_markup( + 'beans_next_icon[_post_navigation]', + 'i', + array( + 'class' => 'uk-icon-angle-double-right uk-margin-small-left', + ) + ); $output .= beans_close_markup( 'beans_next_icon[_post_navigation]', 'i' ); $output .= beans_close_markup( 'beans_next_link[_post_navigation]', 'a' ); return $output; - } beans_add_smart_action( 'beans_post_after_markup', 'beans_post_navigation' ); @@ -442,6 +507,8 @@ function beans_next_post_link( $output, $format, $link, $post ) { * Echo post navigation. * * @since 1.0.0 + * + * @return void */ function beans_post_navigation() { @@ -456,42 +523,41 @@ function beans_post_navigation() { return; } - $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); - $next = get_adjacent_post( false, '', false ); + $previous = is_attachment() ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); + $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) { return; } - beans_open_markup_e( 'beans_post_navigation', 'ul', array( - 'class' => 'uk-pagination', - 'role' => 'navigation', - ) ); - - if ( $previous ) { - - // Previous. - beans_open_markup_e( 'beans_post_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); - - echo get_previous_post_link( '%link', __( 'Previous', 'tm-beans' ) ); - - beans_close_markup_e( 'beans_post_navigation_item[_previous]', 'li' ); + beans_open_markup_e( + 'beans_post_navigation', + 'ul', + array( + 'class' => 'uk-pagination', + 'role' => 'navigation', + ) + ); - } + if ( $previous ) { + // Previous. + beans_open_markup_e( 'beans_post_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); - if ( $next ) { + echo get_previous_post_link( '%link', __( 'Previous', 'tm-beans' ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTMl output. - // Next. - beans_open_markup_e( 'beans_post_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); + beans_close_markup_e( 'beans_post_navigation_item[_previous]', 'li' ); + } - echo get_next_post_link( '%link', __( 'Next', 'tm-beans' ) ); + if ( $next ) { + // Next. + beans_open_markup_e( 'beans_post_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); - beans_close_markup_e( 'beans_post_navigation_item[_next]', 'li' ); + echo get_next_post_link( '%link', __( 'Next', 'tm-beans' ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTMl output. - } + beans_close_markup_e( 'beans_post_navigation_item[_next]', 'li' ); + } beans_close_markup_e( 'beans_post_navigation', 'ul' ); - } beans_add_smart_action( 'beans_after_posts_loop', 'beans_posts_pagination' ); @@ -499,6 +565,8 @@ function beans_post_navigation() { * Echo posts pagination. * * @since 1.0.0 + * + * @return void */ function beans_posts_pagination() { @@ -520,131 +588,141 @@ function beans_posts_pagination() { } $current = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; - $count = intval( $wp_query->max_num_pages ); - - beans_open_markup_e( 'beans_posts_pagination', 'ul', array( - 'class' => 'uk-pagination uk-grid-margin', - 'role' => 'navigation', - ) ); + $count = intval( $wp_query->max_num_pages ); + + beans_open_markup_e( + 'beans_posts_pagination', + 'ul', + array( + 'class' => 'uk-pagination uk-grid-margin', + 'role' => 'navigation', + ) + ); // Previous. - if ( get_previous_posts_link() ) { + if ( get_previous_posts_link() ) { + beans_open_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); - beans_open_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); - - beans_open_markup_e( 'beans_previous_link[_posts_pagination]', 'a', array( + beans_open_markup_e( + 'beans_previous_link[_posts_pagination]', + 'a', + array( 'href' => previous_posts( false ), // Automatically escaped. - ), $current ); + ), + $current + ); - beans_open_markup_e( 'beans_previous_icon[_posts_pagination]', 'i', array( + beans_open_markup_e( + 'beans_previous_icon[_posts_pagination]', + 'i', + array( 'class' => 'uk-icon-angle-double-left uk-margin-small-right', - ) ); + ) + ); - beans_close_markup_e( 'beans_previous_icon[_posts_pagination]', 'i' ); + beans_close_markup_e( 'beans_previous_icon[_posts_pagination]', 'i' ); - beans_output_e( 'beans_previous_text[_posts_pagination]', __( 'Previous', 'tm-beans' ) ); + beans_output_e( 'beans_previous_text[_posts_pagination]', __( 'Previous', 'tm-beans' ) ); - beans_close_markup_e( 'beans_previous_link[_posts_pagination]', 'a' ); + beans_close_markup_e( 'beans_previous_link[_posts_pagination]', 'a' ); - beans_close_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); - - } + beans_close_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); + } // Links. - foreach ( range( 1, $wp_query->max_num_pages ) as $link ) { + foreach ( range( 1, $wp_query->max_num_pages ) as $link ) { - // Skip if next is set. - if ( isset( $next ) && $link != $next ) { - continue; - } else { - $next = $link + 1; - } - - $is_separator = array( - 1 != $link, // Not first. - 1 == $current && 3 == $link ? false : true, // Force first 3 items. - $count > 3, // More. - $count != $link, // Not last. - ( $current - 1 ) != $link, // Not previous. - $current != $link, // Not current. - ( $current + 1 ) != $link, // Not next. - ); - - // Separator. - if ( ! in_array( false, $is_separator ) ) { - - beans_open_markup_e( 'beans_posts_pagination_item[_separator]', 'li' ); - - beans_output_e( 'beans_posts_pagination_item_separator_text', '...' ); - - beans_close_markup_e( 'beans_posts_pagination_item[_separator]', 'li' ); - - // Jump. - if ( $link < $current ) { - $next = $current - 1; - } elseif ( $link > $current ) { - $next = $count; - } - - continue; + // Skip if next is set. + if ( isset( $next ) && $link !== $next ) { + continue; + } else { + $next = $link + 1; + } + $is_separator = array( + 1 !== $link, // Not first. + 1 === $current && 3 === $link ? false : true, // Force first 3 items. + $count > 3, // More. + $count !== $link, // Not last. + ( $current - 1 ) !== $link, // Not previous. + $current !== $link, // Not current. + ( $current + 1 ) !== $link, // Not next. + ); + + // Separator. + if ( ! in_array( false, $is_separator, true ) ) { + beans_open_markup_e( 'beans_posts_pagination_item[_separator]', 'li' ); + + beans_output_e( 'beans_posts_pagination_item_separator_text', '...' ); + + beans_close_markup_e( 'beans_posts_pagination_item[_separator]', 'li' ); + + // Jump. + if ( $link < $current ) { + $next = $current - 1; + } elseif ( $link > $current ) { + $next = $count; } - // Integer. - if ( $link == $current ) { - - beans_open_markup_e( 'beans_posts_pagination_item[_active]', 'li', array( 'class' => 'uk-active' ) ); - - beans_open_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); + continue; + } - beans_output_e( 'beans_posts_pagination_item[_active]_text', $link ); + // Integer. + if ( $link === $current ) { + beans_open_markup_e( 'beans_posts_pagination_item[_active]', 'li', array( 'class' => 'uk-active' ) ); - beans_close_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); + beans_open_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); - beans_close_markup_e( 'beans_posts_pagination_item[_active]', 'li' ); + beans_output_e( 'beans_posts_pagination_item[_active]_text', $link ); - } else { + beans_close_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); - beans_open_markup_e( 'beans_posts_pagination_item', 'li' ); + beans_close_markup_e( 'beans_posts_pagination_item[_active]', 'li' ); + } else { + beans_open_markup_e( 'beans_posts_pagination_item', 'li' ); - beans_open_markup_e( 'beans_posts_pagination_item_link', 'a', array( + beans_open_markup_e( + 'beans_posts_pagination_item_link', + 'a', + array( 'href' => get_pagenum_link( $link ), // Automatically escaped. - ), $link ); - - beans_output_e( 'beans_posts_pagination_item_link_text', $link ); + ), + $link + ); - beans_close_markup_e( 'beans_posts_pagination_item_link', 'a' ); + beans_output_e( 'beans_posts_pagination_item_link_text', $link ); - beans_close_markup_e( 'beans_posts_pagination_item', 'li' ); + beans_close_markup_e( 'beans_posts_pagination_item_link', 'a' ); - } + beans_close_markup_e( 'beans_posts_pagination_item', 'li' ); } + } // Next. - if ( get_next_posts_link() ) { + if ( get_next_posts_link() ) { + beans_open_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); - beans_open_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); - - beans_open_markup_e( 'beans_next_link[_posts_pagination]', 'a', array( + beans_open_markup_e( + 'beans_next_link[_posts_pagination]', + 'a', + array( 'href' => next_posts( $count, false ), // Automatically escaped. - ), $current ); - - beans_output_e( 'beans_next_text[_posts_pagination]', __( 'Next', 'tm-beans' ) ); + ), + $current + ); - beans_open_markup_e( 'beans_next_icon[_posts_pagination]', 'i', array( - 'class' => 'uk-icon-angle-double-right uk-margin-small-left', - ) ); + beans_output_e( 'beans_next_text[_posts_pagination]', __( 'Next', 'tm-beans' ) ); - beans_close_markup_e( 'beans_next_icon[_posts_pagination]', 'i' ); + beans_open_markup_e( 'beans_next_icon[_posts_pagination]', 'i', array( 'class' => 'uk-icon-angle-double-right uk-margin-small-left' ) ); - beans_close_markup_e( 'beans_next_link[_posts_pagination]', 'a' ); + beans_close_markup_e( 'beans_next_icon[_posts_pagination]', 'i' ); - beans_close_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); + beans_close_markup_e( 'beans_next_link[_posts_pagination]', 'a' ); - } + beans_close_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); + } beans_close_markup_e( 'beans_posts_pagination', 'ul' ); - } beans_add_smart_action( 'beans_no_post', 'beans_no_post' ); @@ -652,9 +730,10 @@ function beans_posts_pagination() { * Echo no post content. * * @since 1.0.0 + * + * @return void */ function beans_no_post() { - beans_open_markup_e( 'beans_post', 'article', array( 'class' => 'tm-no-article uk-article' . ( current_theme_supports( 'beans-default-styling' ) ? ' uk-panel-box' : null ) ) ); beans_open_markup_e( 'beans_post_header', 'header' ); @@ -684,7 +763,6 @@ function beans_no_post() { beans_close_markup_e( 'beans_post_body', 'div' ); beans_close_markup_e( 'beans_post', 'article' ); - } // Filter. @@ -697,7 +775,6 @@ function beans_no_post() { * @return string The form. */ function beans_post_password_form() { - global $post; $label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID ); @@ -710,30 +787,41 @@ function beans_post_password_form() { $output .= beans_close_markup( 'beans_password_form_notice', 'p' ); // Form. - $output .= beans_open_markup( 'beans_password_form', 'form', array( - 'class' => 'uk-form uk-margin-bottom', - 'method' => 'post', - 'action' => site_url( 'wp-login.php?action=postpass', 'login_post' ), // Automatically escaped. - ) ); - - $output .= beans_selfclose_markup( 'beans_password_form_input', 'input', array( - 'class' => 'uk-margin-small-top uk-margin-small-right', - 'type' => 'password', - 'placeholder' => apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ), // Automatically escaped. - 'name' => 'post_password', - ) ); - - $output .= beans_selfclose_markup( 'beans_password_form_submit', 'input', array( - 'class' => 'uk-button uk-margin-small-top', - 'type' => 'submit', - 'name' => 'submit', - 'value' => esc_attr( apply_filters( 'beans_password_form_submit_text', __( 'Submit', 'tm-beans' ) ) ), - ) ); + $output .= beans_open_markup( + 'beans_password_form', + 'form', + array( + 'class' => 'uk-form uk-margin-bottom', + 'method' => 'post', + 'action' => site_url( 'wp-login.php?action=postpass', 'login_post' ), // Automatically escaped. + ) + ); + + $output .= beans_selfclose_markup( + 'beans_password_form_input', + 'input', + array( + 'class' => 'uk-margin-small-top uk-margin-small-right', + 'type' => 'password', + 'placeholder' => apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ), // Automatically escaped. + 'name' => 'post_password', + ) + ); + + $output .= beans_selfclose_markup( + 'beans_password_form_submit', + 'input', + array( + 'class' => 'uk-button uk-margin-small-top', + 'type' => 'submit', + 'name' => 'submit', + 'value' => esc_attr( apply_filters( 'beans_password_form_submit_text', __( 'Submit', 'tm-beans' ) ) ), + ) + ); $output .= beans_close_markup( 'beans_password_form', 'form' ); return $output; - } // Filter. @@ -752,9 +840,8 @@ function beans_post_password_form() { * @return string HTML content to display gallery. */ function beans_post_gallery( $output, $attr, $instance ) { - - $post = get_post(); - $html5 = current_theme_supports( 'html5', 'gallery' ); + $post = get_post(); + $html5 = current_theme_supports( 'html5', 'gallery' ); $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order ID', @@ -768,20 +855,21 @@ function beans_post_gallery( $output, $attr, $instance ) { 'exclude' => '', 'link' => '', ); - $atts = shortcode_atts( $defaults, $attr, 'gallery' ); - $id = intval( $atts['id'] ); + $atts = shortcode_atts( $defaults, $attr, 'gallery' ); + $id = intval( $atts['id'] ); // Set attachements. if ( ! empty( $atts['include'] ) ) { - - $_attachments = get_posts( array( - 'include' => $atts['include'], - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $atts['order'], - 'orderby' => $atts['orderby'], - ) ); + $_attachments = get_posts( + array( + 'include' => $atts['include'], + 'post_status' => 'inherit', + 'post_type' => 'attachment', + 'post_mime_type' => 'image', + 'order' => $atts['order'], + 'orderby' => $atts['orderby'], + ) + ); $attachments = array(); @@ -789,28 +877,28 @@ function beans_post_gallery( $output, $attr, $instance ) { $attachments[ $val->ID ] = $_attachments[ $key ]; } } elseif ( ! empty( $atts['exclude'] ) ) { - - $attachments = get_children( array( - 'post_parent' => $id, - 'exclude' => $atts['exclude'], - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $atts['order'], - 'orderby' => $atts['orderby'], - ) ); - + $attachments = get_children( + array( + 'post_parent' => $id, + 'exclude' => $atts['exclude'], + 'post_status' => 'inherit', + 'post_type' => 'attachment', + 'post_mime_type' => 'image', + 'order' => $atts['order'], + 'orderby' => $atts['orderby'], + ) + ); } else { - - $attachments = get_children( array( - 'post_parent' => $id, - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $atts['order'], - 'orderby' => $atts['orderby'], - ) ); - + $attachments = get_children( + array( + 'post_parent' => $id, + 'post_status' => 'inherit', + 'post_type' => 'attachment', + 'post_mime_type' => 'image', + 'order' => $atts['order'], + 'orderby' => $atts['orderby'], + ) + ); } // Stop here if no attachment. @@ -819,7 +907,6 @@ function beans_post_gallery( $output, $attr, $instance ) { } if ( is_feed() ) { - $output = "\n"; foreach ( $attachments as $att_id => $attachment ) { @@ -827,12 +914,11 @@ function beans_post_gallery( $output, $attr, $instance ) { } return $output; - } // Valid tags. $valid_tags = wp_kses_allowed_html( 'post' ); - $validate = array( + $validate = array( 'itemtag', 'captiontag', 'icontag', @@ -846,14 +932,20 @@ function beans_post_gallery( $output, $attr, $instance ) { } // Set variables used in the output. - $columns = intval( $atts['columns'] ); + $columns = intval( $atts['columns'] ); $size_class = sanitize_html_class( $atts['size'] ); - // WP adds the opening div in the gallery_style filter (weird), so we follow it as don't want to break people's site. - $gallery_div = beans_open_markup( "beans_post_gallery[_{$id}]", 'div', array( - 'class' => "uk-grid uk-grid-width-small-1-{$columns} gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}", // Automatically escaped. - 'data-uk-grid-margin' => false, - ), $id, $columns ); + // WP adds the opening div in the gallery_style filter (weird), so we follow it as we don't want to break people's site. + $gallery_div = beans_open_markup( + "beans_post_gallery[_{$id}]", + 'div', + array( + 'class' => "uk-grid uk-grid-width-small-1-{$columns} gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}", // Automatically escaped. + 'data-uk-grid-margin' => false, + ), + $id, + $columns + ); /** * Apply WP core filter. Filter the default gallery shortcode CSS styles. @@ -862,24 +954,24 @@ function beans_post_gallery( $output, $attr, $instance ) { * * @ignore */ - $output = apply_filters( 'gallery_style', $gallery_div ); + $output = apply_filters( 'gallery_style', $gallery_div ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used in function scope. $i = 0; foreach ( $attachments as $attachment_id => $attachment ) { - $attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "gallery-{$instance}-{$id}" ) : ''; - $image_meta = wp_get_attachment_metadata( $attachment_id ); + $attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "gallery-{$instance}-{$id}" ) : ''; + $image_meta = wp_get_attachment_metadata( $attachment_id ); $orientation = ''; - if ( isset( $image_meta['height'], $image_meta['width'] ) ) { - $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; - } + if ( isset( $image_meta['height'], $image_meta['width'] ) ) { + $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; + } // Set the image output. - if ( 'none' === $atts['link'] ) { - $image_output = wp_get_attachment_image( $attachment_id, $atts['size'], false, $attr ); - } else { - $image_output = wp_get_attachment_link( $attachment_id, $atts['size'], ( 'file' !== $atts['link'] ), false, false, $attr ); - } + if ( 'none' === $atts['link'] ) { + $image_output = wp_get_attachment_image( $attachment_id, $atts['size'], false, $attr ); + } else { + $image_output = wp_get_attachment_link( $attachment_id, $atts['size'], ( 'file' !== $atts['link'] ), false, false, $attr ); + } $output .= beans_open_markup( "beans_post_gallery_item[_{$attachment_id}]", $atts['itemtag'], array( 'class' => 'gallery-item' ) ); @@ -889,22 +981,18 @@ function beans_post_gallery( $output, $attr, $instance ) { $output .= beans_close_markup( "beans_post_gallery_icon[_{$attachment_id}]", $atts['icontag'] ); - if ( $atts['captiontag'] && trim( $attachment->post_excerpt ) ) { - - $output .= beans_open_markup( "beans_post_gallery_caption[_{$attachment_id}]", $atts['captiontag'], array( 'class' => 'wp-caption-text gallery-caption' ) ); + if ( $atts['captiontag'] && trim( $attachment->post_excerpt ) ) { + $output .= beans_open_markup( "beans_post_gallery_caption[_{$attachment_id}]", $atts['captiontag'], array( 'class' => 'wp-caption-text gallery-caption' ) ); - $output .= beans_output( "beans_post_gallery_caption_text[_{$attachment_id}]", wptexturize( $attachment->post_excerpt ) ); + $output .= beans_output( "beans_post_gallery_caption_text[_{$attachment_id}]", wptexturize( $attachment->post_excerpt ) ); - $output .= beans_close_markup( "beans_post_gallery_caption[_{$attachment_id}]", $atts['captiontag'] ); - - } + $output .= beans_close_markup( "beans_post_gallery_caption[_{$attachment_id}]", $atts['captiontag'] ); + } $output .= beans_close_markup( "beans_post_gallery_item[_{$attachment_id}]", $atts['itemtag'] ); - } - $output .= beans_close_markup( "beans_post_gallery[_{$id}]", 'div' ); - - return $output; + $output .= beans_close_markup( "beans_post_gallery[_{$id}]", 'div' ); + return $output; } diff --git a/lib/templates/fragments/searchform.php b/lib/templates/fragments/searchform.php index aded642d..ea7d8fac 100644 --- a/lib/templates/fragments/searchform.php +++ b/lib/templates/fragments/searchform.php @@ -2,7 +2,9 @@ /** * Modify the search from. * - * @package Fragments\Search_Form + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ // Filter. @@ -15,21 +17,28 @@ * @return string The form. */ function beans_search_form() { - - $output = beans_open_markup( 'beans_search_form', 'form', array( - 'class' => 'uk-form uk-form-icon uk-form-icon-flip uk-width-1-1', - 'method' => 'get', - 'action' => esc_url( home_url( '/' ) ), - 'role' => 'search', - ) ); - - $output .= beans_selfclose_markup( 'beans_search_form_input', 'input', array( - 'class' => 'uk-width-1-1', - 'type' => 'search', - 'placeholder' => __( 'Search', 'tm-beans' ), // Automatically escaped. - 'value' => esc_attr( get_search_query() ), - 'name' => 's', - ) ); + $output = beans_open_markup( + 'beans_search_form', + 'form', + array( + 'class' => 'uk-form uk-form-icon uk-form-icon-flip uk-width-1-1', + 'method' => 'get', + 'action' => esc_url( home_url( '/' ) ), + 'role' => 'search', + ) + ); + + $output .= beans_selfclose_markup( + 'beans_search_form_input', + 'input', + array( + 'class' => 'uk-width-1-1', + 'type' => 'search', + 'placeholder' => __( 'Search', 'tm-beans' ), // Automatically escaped. + 'value' => esc_attr( get_search_query() ), + 'name' => 's', + ) + ); $output .= beans_open_markup( 'beans_search_form_input_icon', 'i', 'class=uk-icon-search' ); @@ -38,5 +47,4 @@ function beans_search_form() { $output .= beans_close_markup( 'beans_search_form', 'form' ); return $output; - } diff --git a/lib/templates/fragments/widget-area.php b/lib/templates/fragments/widget-area.php index 7332d9f2..5b65ef5a 100644 --- a/lib/templates/fragments/widget-area.php +++ b/lib/templates/fragments/widget-area.php @@ -2,7 +2,9 @@ /** * Echo widget areas. * - * @package Fragments\Widget_Area + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_sidebar_primary', 'beans_widget_area_sidebar_primary' ); @@ -10,11 +12,11 @@ * Echo primary sidebar widget area. * * @since 1.0.0 + * + * @return void */ function beans_widget_area_sidebar_primary() { - - echo beans_widget_area( 'sidebar_primary' ); - + echo beans_widget_area( 'sidebar_primary' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. } beans_add_smart_action( 'beans_sidebar_secondary', 'beans_widget_area_sidebar_secondary' ); @@ -22,11 +24,11 @@ function beans_widget_area_sidebar_primary() { * Echo secondary sidebar widget area. * * @since 1.0.0 + * + * @return void */ function beans_widget_area_sidebar_secondary() { - - echo beans_widget_area( 'sidebar_secondary' ); - + echo beans_widget_area( 'sidebar_secondary' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. } beans_add_smart_action( 'beans_site_after_markup', 'beans_widget_area_offcanvas_menu' ); @@ -34,6 +36,8 @@ function beans_widget_area_sidebar_secondary() { * Echo off-canvas widget area. * * @since 1.0.0 + * + * @return void */ function beans_widget_area_offcanvas_menu() { @@ -41,6 +45,5 @@ function beans_widget_area_offcanvas_menu() { return; } - echo beans_widget_area( 'offcanvas_menu' ); - + echo beans_widget_area( 'offcanvas_menu' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. } diff --git a/lib/templates/fragments/widget.php b/lib/templates/fragments/widget.php index e4b78390..49806bce 100644 --- a/lib/templates/fragments/widget.php +++ b/lib/templates/fragments/widget.php @@ -2,7 +2,9 @@ /** * Echo widget fragments. * - * @package Fragments\Widget + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_widget', 'beans_widget_badge', 5 ); @@ -10,6 +12,8 @@ * Echo widget badge. * * @since 1.0.0 + * + * @return void */ function beans_widget_badge() { @@ -19,10 +23,9 @@ function beans_widget_badge() { beans_open_markup_e( 'beans_widget_badge' . _beans_widget_subfilters(), 'div', 'class=uk-panel-badge uk-badge' ); - echo beans_widget_shortcodes( beans_get_widget( 'badge_content' ) ); + echo beans_widget_shortcodes( beans_get_widget( 'badge_content' ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. beans_close_markup_e( 'beans_widget_badge' . _beans_widget_subfilters(), 'div' ); - } beans_add_smart_action( 'beans_widget', 'beans_widget_title' ); @@ -30,10 +33,13 @@ function beans_widget_badge() { * Echo widget title. * * @since 1.0.0 + * + * @return void */ function beans_widget_title() { + $title = beans_get_widget( 'title' ); - if ( ! ( $title = beans_get_widget( 'title' ) ) || ! beans_get_widget( 'show_title' ) ) { + if ( ! $title || ! beans_get_widget( 'show_title' ) ) { return; } @@ -42,7 +48,6 @@ function beans_widget_title() { beans_output_e( 'beans_widget_title_text', $title ); beans_close_markup_e( 'beans_widget_title' . _beans_widget_subfilters(), 'h3' ); - } beans_add_smart_action( 'beans_widget', 'beans_widget_content', 15 ); @@ -50,15 +55,15 @@ function beans_widget_title() { * Echo widget content. * * @since 1.0.0 + * + * @return void */ function beans_widget_content() { - beans_open_markup_e( 'beans_widget_content' . _beans_widget_subfilters(), 'div' ); beans_output_e( 'beans_widget_content' . _beans_widget_subfilters(), beans_get_widget( 'content' ) ); beans_close_markup_e( 'beans_widget_content' . _beans_widget_subfilters(), 'div' ); - } beans_add_smart_action( 'beans_no_widget', 'beans_no_widget' ); @@ -66,20 +71,25 @@ function beans_widget_content() { * Echo no widget content. * * @since 1.0.0 + * + * @return void */ function beans_no_widget() { // Only apply this notice to sidebar_primary and sidebar_secondary. - if ( ! in_array( beans_get_widget_area( 'id' ), array( 'sidebar_primary', 'sidebar_secondary' ) ) ) { + if ( ! in_array( beans_get_widget_area( 'id' ), array( 'sidebar_primary', 'sidebar_secondary' ), true ) ) { return; } beans_open_markup_e( 'beans_no_widget_notice', 'p', array( 'class' => 'uk-alert uk-alert-warning' ) ); - beans_output_e( 'beans_no_widget_notice_text', sprintf( __( '%s does not have any widget assigned!', 'tm-beans' ), beans_get_widget_area( 'name' ) ) ); + beans_output_e( + 'beans_no_widget_notice_text', + // translators: Name of the widget area. + sprintf( __( '%s does not have any widget assigned!', 'tm-beans' ), beans_get_widget_area( 'name' ) ) + ); beans_close_markup_e( 'beans_no_widget_notice', 'p' ); - } beans_add_filter( 'beans_widget_content_rss_output', 'beans_widget_rss_content' ); @@ -88,14 +98,13 @@ function beans_no_widget() { * * @since 1.0.0 * - * @return The RSS widget content. + * @return string The RSS widget content. */ function beans_widget_rss_content() { $options = beans_get_widget( 'options' ); return '

    ' . __( 'Read feed', 'tm-beans' ) . '

    '; - } beans_add_filter( 'beans_widget_content_attributes', 'beans_modify_widget_content_attributes' ); @@ -109,7 +118,6 @@ function beans_widget_rss_content() { * @return array The modified widget attributes. */ function beans_modify_widget_content_attributes( $attributes ) { - $type = beans_get_widget( 'type' ); $target = array( @@ -124,16 +132,15 @@ function beans_modify_widget_content_attributes( $attributes ) { $current_class = isset( $attributes['class'] ) ? $attributes['class'] . ' ' : ''; - if ( in_array( beans_get_widget( 'type' ), $target ) ) { + if ( in_array( beans_get_widget( 'type' ), $target, true ) ) { $attributes['class'] = $current_class . 'uk-list'; // Automatically escaped. } - if ( 'calendar' == $type ) { + if ( 'calendar' === $type ) { $attributes['class'] = $current_class . 'uk-table uk-table-condensed'; // Automatically escaped. } return $attributes; - } beans_add_filter( 'beans_widget_content_categories_output', 'beans_modify_widget_count' ); @@ -148,26 +155,18 @@ function beans_modify_widget_content_attributes( $attributes ) { * @return string The modified widget content. */ function beans_modify_widget_count( $content ) { - $count = beans_output( 'beans_widget_count', '$1' ); - if ( true == beans_get( 'dropdown', beans_get_widget( 'options' ) ) ) { - + if ( true === beans_get( 'dropdown', beans_get_widget( 'options' ) ) ) { $output = $count; - } else { - - $output = beans_open_markup( 'beans_widget_count', 'span', 'class=tm-count' ); - - $output .= $count; - + $output = beans_open_markup( 'beans_widget_count', 'span', 'class=tm-count' ); + $output .= $count; $output .= beans_close_markup( 'beans_widget_count', 'span' ); - } // Keep closing tag to avoid overwriting the inline JavaScript. return preg_replace( '#>((\s| )\((.*)\))#', '>' . $output, $content ); - } beans_add_filter( 'beans_widget_content_categories_output', 'beans_remove_widget_dropdown_label' ); @@ -182,7 +181,5 @@ function beans_modify_widget_count( $content ) { * @return string The modified widget content. */ function beans_remove_widget_dropdown_label( $content ) { - return preg_replace( '#]*)class="screen-reader-text"(.*?)>(.*?)#', '', $content ); - } From 1527bdffe9aed4b30ed0aa715304e56cd19e4417 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Sat, 3 Mar 2018 08:32:24 -0500 Subject: [PATCH 175/800] Revise unit test beans_get_term_meta() As of PR #154, we should now mock `beans_get()` for this test. --- tests/phpunit/unit/api/term-meta/beansGetTermMeta.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php index ffe4f45e..cf48f3b7 100644 --- a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php +++ b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php @@ -83,10 +83,10 @@ public function test_should_return_term_meta_when_queried_object_has_term_id_and * Test beans_get_term_meta() should return default when given and term_id is tag_ID but term meta does not exist. */ public function test_should_return_default_when_default_given_and_term_id_is_tag_id_but_term_meta_not_set() { - $_GET['tag_ID'] = 1; Monkey\Functions\expect( 'get_queried_object' ) ->once() ->andReturn( (object) array( 'post_id' => 1 ) ); + Monkey\Functions\expect( 'beans_get' )->once()->with( 'tag_ID' )->andReturn( 1 ); Monkey\Functions\expect( 'get_option' ) ->with( 'beans_term_1_beans_layout', 'default_fallback' ) ->once() @@ -100,10 +100,10 @@ public function test_should_return_default_when_default_given_and_term_id_is_tag * exists. */ public function test_should_return_term_meta_when_default_given_and_term_id_is_tag_id_and_term_meta_exists() { - $_GET['tag_ID'] = 1; Monkey\Functions\expect( 'get_queried_object' ) ->once() ->andReturn( (object) array( 'post_id' => 1 ) ); + Monkey\Functions\expect( 'beans_get' )->once()->with( 'tag_ID' )->andReturn( 1 ); Monkey\Functions\expect( 'get_option' ) ->with( 'beans_term_1_beans_layout', 'default_fallback' ) ->once() From e179334c993309cabd4c537d9463fc99be178b1d Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Sat, 3 Mar 2018 08:57:07 -0600 Subject: [PATCH 176/800] Fixed formatting. --- lib/api/image/functions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/api/image/functions.php b/lib/api/image/functions.php index 0466529b..53460fbc 100644 --- a/lib/api/image/functions.php +++ b/lib/api/image/functions.php @@ -62,7 +62,6 @@ function beans_get_post_attachment( $post_id, $size = 'full' ) { $obj->description = $post->post_content; return $obj; - } /** From ebac3fcb36cd3f28f1b223abe1ae7628219ada09 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 20:20:26 -0600 Subject: [PATCH 177/800] stuff --- lib/api/compiler/class-compiler.php | 308 ++++++++++++++++++---------- lib/api/components.php | 2 +- 2 files changed, 197 insertions(+), 113 deletions(-) diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-compiler.php index 8aaa19c9..a77e8a5f 100644 --- a/lib/api/compiler/class-compiler.php +++ b/lib/api/compiler/class-compiler.php @@ -1,49 +1,61 @@ false, ); - $this->compiler = array_merge( $defaults, $args ); - $this->dir = beans_get_compiler_dir( is_admin() ) . $this->compiler['id']; - $this->url = beans_get_compiler_url( is_admin() ) . $this->compiler['id']; + $this->compiler = array_merge( $defaults, $config ); + $this->dir = beans_get_compiler_dir( is_admin() ) . $this->compiler['id']; + $this->url = beans_get_compiler_url( is_admin() ) . $this->compiler['id']; $this->set_fragments(); $this->set_filname(); if ( ! $this->cache_file_exist() ) { - $this->filesystem(); $this->maybe_make_dir(); $this->cache_file(); - } $this->enqueue_file(); - // Keep it safe and reset WP Filsystem method. + // Keep it safe and reset WP Filesystem method. remove_filter( 'filesystem_method', array( $this, 'filesystem_method' ) ); - } /** - * Set WP Filsystem method. + * Callback to set WP Filesystem method. + * + * @since 1.0.0 + * + * @return void */ public function filesystem_method() { - return 'direct'; - } /** * Initialise WP Filsystem. + * + * @since 1.0.0 + * + * @return void */ public function filesystem() { - // Initialize the WordPress Filsystem. + // Initialize the WordPress Filesystem. if ( ! isset( $GLOBALS['wp_filesystem'] ) || empty( $GLOBALS['wp_filesystem'] ) ) { - require_once( ABSPATH . '/wp-admin/includes/file.php' ); if ( ! WP_Filesystem() ) { @@ -104,34 +118,37 @@ public function filesystem() { } return true; - } /** * Make directory. + * + * @since 1.0.0 + * + * @return void */ public function maybe_make_dir() { - if ( ! @is_dir( $this->dir ) ) { + if ( ! @is_dir( $this->dir ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. wp_mkdir_p( $this->dir ); } - if ( ! is_writable( $this->dir ) ) { - return false; - } - - return true; - + return is_writable( $this->dir ); } /** * Set class fragments. + * + * @since 1.0.0 + * + * @return void */ public function set_fragments() { - global $_beans_compiler_added_fragments; - if ( $added_fragments = beans_get( $this->compiler['id'], $_beans_compiler_added_fragments[ $this->compiler['format'] ] ) ) { + $added_fragments = beans_get( $this->compiler['id'], $_beans_compiler_added_fragments[ $this->compiler['format'] ] ); + + if ( $added_fragments ) { $this->compiler['fragments'] = array_merge( $this->compiler['fragments'], $added_fragments ); } @@ -145,19 +162,18 @@ public function set_fragments() { * @param array $fragments An array of fragment files. */ $this->compiler['fragments'] = apply_filters( 'beans_compiler_fragments_' . $this->compiler['id'], $this->compiler['fragments'] ); - } /** * Set class filname. */ public function set_filname() { - $hash = substr( md5( @serialize( $this->compiler ) ), 0, 7 ); // Stop here and return filename if not in dev mode or if not using filesystem. - if ( ! _beans_is_compiler_dev_mode() || ! @is_dir( $this->dir ) ) { - return $this->compiler['filename'] = $hash . '.' . $this->get_extension(); + if ( ! _beans_is_compiler_dev_mode() || ! @is_dir( $this->dir ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $this->compiler['filename'] = $hash . '.' . $this->get_extension(); + return; } $fragments_filemtime = array(); @@ -171,17 +187,17 @@ public function set_filname() { } // Only check file time for internal files. - if ( false !== strpos( $fragment, $_SERVER['HTTP_HOST'] ) || true == preg_match( '#^\/[^\/]#', $fragment ) ) { - $fragments_filemtime[ $id ] = @filemtime( beans_url_to_path( $fragment ) ); + if ( false !== strpos( $fragment, $_SERVER['HTTP_HOST'] ) || 1 === preg_match( '#^\/[^\/]#', $fragment ) ) { + $fragments_filemtime[ $id ] = @filemtime( beans_url_to_path( $fragment ) ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. } } if ( ! empty( $fragments_filemtime ) ) { // Set filemtime hash. - $_hash = substr( md5( @serialize( $fragments_filemtime ) ), 0, 7 ); + $_hash = substr( md5( @serialize( $fragments_filemtime ) ), 0, 7 ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. - $items = @scandir( $this->dir ); + $items = @scandir( $this->dir ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. unset( $items[0], $items[1] ); // Clean up other modified files. @@ -189,70 +205,98 @@ public function set_filname() { // Remove if it contains initial hash, is the same format and doesn't contain the filemtime hash. if ( false !== stripos( $item, $hash ) && false !== stripos( $item, $this->get_extension() ) && false === stripos( $item, $_hash ) ) { - @unlink( $this->dir . '/' . $item ); + @unlink( $this->dir . '/' . $item ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. } } // Set the new hash which will trigger to new compiling. $hash = $hash . '-' . $_hash; - } $this->compiler['filename'] = $hash . '.' . $this->get_extension(); - } /** - * Check if cached file exists. + * Checks if the file exists on the filesystem, meaning it's been cached. + * + * @since 1.0.0 + * + * @return bool */ public function cache_file_exist() { + $filename = $this->get_filename(); - if ( ( $filname = beans_get( 'filename', $this->compiler ) ) && file_exists( $this->dir . '/' . $filname ) ) { - return true; + if ( empty( $filename ) ) { + return false; } - return false; + return file_exists( $filename ); + } + /** + * Get the absolute path of the cached and compiled file. + * + * @since 1.5.0 + * + * @return string + */ + public function get_filename() { + if ( isset( $this->config['filename'] ) ) { + return $this->dir . '/' . $this->config['filename']; + } + + return ''; } /** * Create cached file. + * + * @since 1.0.0 + * + * @return bool */ public function cache_file() { + $content = $this->combine_fragments(); + $filename = $this->get_filename(); - $content = $this->combine_fragments(); - $filename = $this->dir . '/' . $this->compiler['filename']; - - // Safe to access filesystem since we made sure it was set. - if ( ! $GLOBALS['wp_filesystem']->put_contents( $filename, $content, FS_CHMOD_FILE ) ) { + if ( empty( $filename ) ) { return false; } - return true; - + // Safe to access filesystem since we made sure it was set. + return $GLOBALS['wp_filesystem']->put_contents( $filename, $content, FS_CHMOD_FILE ); } /** * Enqueue cached file. + * + * @since 1.0.0 + * + * @return void|bool */ public function enqueue_file() { // Enqueue css. if ( 'style' == $this->compiler['type'] ) { return wp_enqueue_style( $this->compiler['id'], $this->get_url(), $this->compiler['depedencies'], $this->compiler['version'] ); - } elseif ( 'script' == $this->compiler['type'] ) { // Enqueue js file. + } + + // Enqueue js file. + if ( 'script' == $this->compiler['type'] ) { return wp_enqueue_script( $this->compiler['id'], $this->get_url(), $this->compiler['depedencies'], $this->compiler['version'], $this->compiler['in_footer'] ); } return false; - } /** * Get cached file url. + * + * @since 1.0.0 + * + * @return string */ public function get_url() { - $url = trailingslashit( $this->url ) . beans_get( 'filename', $this->compiler ); if ( is_ssl() ) { @@ -260,27 +304,34 @@ public function get_url() { } return $url; - } /** - * Get file extension. + * Get the file extension from the configured "type". + * + * @since 1.0.0 + * + * @return string|null */ public function get_extension() { if ( 'style' == $this->compiler['type'] ) { return 'css'; - } elseif ( 'script' == $this->compiler['type'] ) { - return 'js'; } + if ( 'script' == $this->compiler['type'] ) { + return 'js'; + } } /** * Combine fragments content. + * + * @since 1.0.0 + * + * @return string */ public function combine_fragments() { - $content = ''; // Loop through fragments. @@ -296,11 +347,9 @@ public function combine_fragments() { // Treat function. if ( $this->is_function( $fragment ) ) { - $get_content = $this->get_function_content(); } else { // Treat file. - $get_content = $this->get_internal_content(); // Try remote content if the internal content returned false. @@ -316,25 +365,24 @@ public function combine_fragments() { // Add the content. if ( 'style' == $this->compiler['type'] ) { - $get_content = $this->replace_css_url( $get_content ); $get_content = $this->add_content_media_query( $get_content ); - } $content .= ( $content ? "\n\n" : '' ) . $get_content; - } return $this->format_content( $content ); - } /** * Get internal file content. + * + * @since 1.0.0 + * + * @return string|bool */ public function get_internal_content() { - $fragment = $this->current_fragment; if ( ! file_exists( $fragment ) ) { @@ -343,58 +391,80 @@ public function get_internal_content() { $fragment = beans_url_to_path( $fragment ); // Stop here if it isn't a valid file. - if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { + if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. return false; } } // Safe to access filesystem since we made sure it was set. return $GLOBALS['wp_filesystem']->get_contents( $fragment ); - } /** * Get external file content. + * + * @since 1.0.0 + * + * @return string|bool */ public function get_remote_content() { - $fragment = $this->current_fragment; - // Replace double slaches by http. Mostly used for font referencing urls. - if ( true == preg_match( '#^\/\/#', $fragment ) ) { + // Replace double slashes by http. Mostly used for font referencing urls. + if ( 1 === preg_match( '#^\/\/#', $fragment ) ) { $fragment = preg_replace( '#^\/\/#', 'http://', $fragment ); - } elseif ( true == preg_match( '#^\/#', $fragment ) ) { // Add domain if it is local but could not be fetched as a file. + } elseif ( 1 === preg_match( '#^\/#', $fragment ) ) { // Add domain if it is local but could not be fetched as a file. $fragment = site_url( $fragment ); } $request = wp_remote_get( $fragment ); + if ( is_wp_error( $request ) ) { + return ''; + } + // If failed to get content, try with ssl url, otherwise go to next fragment. - if ( ! is_wp_error( $request ) && ( ! isset( $request['body'] ) || 200 != $request['response']['code'] ) ) { + if ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) { $fragment = preg_replace( '#^http#', 'https', $fragment ); - $request = wp_remote_get( $fragment ); + $request = wp_remote_get( $fragment ); + + if ( is_wp_error( $request ) ) { + return ''; + } - if ( ! is_wp_error( $request ) && ( ! isset( $request['body'] ) || 200 != $request['response']['code'] ) ) { + if ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) { return false; } } return wp_remote_retrieve_body( $request ); - } /** * Get function content. + * + * @since 1.0.0 + * + * @return string|bool */ public function get_function_content() { - return call_user_func( $this->current_fragment ); + if ( ! is_callable( $this->current_fragment ) ) { + return false; + } + return call_user_func( $this->current_fragment ); } /** * Wrap content in query. + * + * @since 1.0.0 + * + * @param string $content Given content to process. + * + * @return string */ public function add_content_media_query( $content ) { @@ -404,25 +474,27 @@ public function add_content_media_query( $content ) { } $parse_url = parse_url( $this->current_fragment ); + $query = beans_get( 'query', $parse_url ); - // Return content if it no media query is set. - if ( ! ( $query = beans_get( 'query', $parse_url ) ) || false === stripos( $query, 'beans_compiler_media_query' ) ) { + // Bail out if there are no query args or no media query. + if ( empty( $query ) || false === stripos( $query, 'beans_compiler_media_query' ) ) { return $content; } // Wrap the content in the query. - $new_content = '@media ' . beans_get( 'beans_compiler_media_query', wp_parse_args( $query ) ) . ' {' . "\n"; - - $new_content .= $content . "\n"; - - $new_content .= '}' . "\n"; - - return $new_content; - + return sprintf( + "@media %s {\n%s\n}\n", + beans_get( 'beans_compiler_media_query', wp_parse_args( $query ) ), + $content + ); } /** * Formal CSS, LESS and JS content. + * + * @param string $content Given content to process. + * + * @return string */ public function format_content( $content ) { @@ -434,15 +506,15 @@ public function format_content( $content ) { require_once( BEANS_API_PATH . 'compiler/vendors/lessc.php' ); } - $less = new Beans_Lessc(); - + $less = new Beans_Lessc(); $content = $less->compile( $content ); - } if ( ! _beans_is_compiler_dev_mode() ) { - $content = $this->strip_whitespace( $content ); + return $this->strip_whitespace( $content ); } + + return $content; } if ( 'script' == $this->compiler['type'] && ! _beans_is_compiler_dev_mode() && $this->compiler['minify_js'] ) { @@ -452,37 +524,49 @@ public function format_content( $content ) { } $js_min = new JSMin( $content ); - - $content = $js_min->min(); + return $js_min->min(); } return $content; - } /** * Replace CSS url shortcuts with a valid url. + * + * @since 1.0.0 + * + * @param string $content Given content to process. + * + * @return string */ public function replace_css_url( $content ) { - - // Replace css path to urls. - return preg_replace_callback( '#url\s*\(\s*[\'"]*?([^\'"\)]+)[\'"]*\s*\)#i', array( $this, 'css_path_to_url' ) , $content ); - + return preg_replace_callback( + '#url\s*\(\s*[\'"]*?([^\'"\)]+)[\'"]*\s*\)#i', + array( $this, 'replace_css_url_callback' ), + $content + ); } /** - * replace_css_url() callback. + * Convert any CSS url relative paths to absolute URLs. + * + * @since 1.0.0 + * + * @param array $matches Matches to process, where 0 is the CSS' url() and 1 is the URI. + * + * @return string */ - public function css_path_to_url( $matches, $base_is_path = false ) { - - $base = $this->current_fragment; + public function replace_css_url_callback( $matches ) { // Stop here if it isn't a internal file or not a valid format. if ( true == preg_match( '#^(http|https|\/\/|data)#', $matches[1] ) ) { return $matches[0]; } + $base = $this->current_fragment; + + // Separate the placeholders and path. $explode_path = explode( '../', $matches[1] ); // Replace the base part according to the path "../". @@ -491,7 +575,7 @@ public function css_path_to_url( $matches, $base_is_path = false ) { } // Rebuild path. - $replace = preg_replace( '#^\/#', '', $explode_path ); + $replace = preg_replace( '#^\/#', '', $explode_path ); $rebuilt_path = end( $replace ); // Make sure it is a valid base. @@ -517,7 +601,7 @@ public function strip_whitespace( $content ) { '#\s\s+#' => ' ', // Strip excess whitespace. ); - $search = array_keys( $replace ); + $search = array_keys( $replace ); $content = preg_replace( $search, $replace, $content ); $replace = array( diff --git a/lib/api/components.php b/lib/api/components.php index c1062adb..5dff03a2 100644 --- a/lib/api/components.php +++ b/lib/api/components.php @@ -42,7 +42,7 @@ function beans_load_api_components( $components ) { 'image' => $root . 'image/functions.php', 'compiler' => array( $root . 'compiler/functions.php', - $root . 'compiler/class-compiler.php', + $root . 'compiler/class-beans-compiler.php', $root . 'compiler/class-page-compiler.php', ), 'uikit' => array( From 646525a481b9c0d5fa8433553b770f8c754839e6 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 20:32:14 -0600 Subject: [PATCH 178/800] Made wpcs compliant & improved. 1. Made WPCS compliant. 2. Added documentation. 3. Changed properties visibility keyword. 4. Fixed spelling errors. 5. Refactored and added get_filename() method. 6. Refactored and added hash() method. --- lib/api/compiler/class-compiler.php | 110 +++++++++++++++++----------- 1 file changed, 68 insertions(+), 42 deletions(-) diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-compiler.php index a77e8a5f..cdea9438 100644 --- a/lib/api/compiler/class-compiler.php +++ b/lib/api/compiler/class-compiler.php @@ -93,24 +93,24 @@ public function __construct( array $config ) { * * @since 1.0.0 * - * @return void + * @return string */ public function filesystem_method() { return 'direct'; } /** - * Initialise WP Filsystem. + * Initialise WP Filesystem. * * @since 1.0.0 * - * @return void + * @return bool|void */ public function filesystem() { // Initialize the WordPress Filesystem. if ( ! isset( $GLOBALS['wp_filesystem'] ) || empty( $GLOBALS['wp_filesystem'] ) ) { - require_once( ABSPATH . '/wp-admin/includes/file.php' ); + require_once ABSPATH . '/wp-admin/includes/file.php'; if ( ! WP_Filesystem() ) { return $this->kill(); @@ -125,7 +125,7 @@ public function filesystem() { * * @since 1.0.0 * - * @return void + * @return bool */ public function maybe_make_dir() { @@ -168,7 +168,7 @@ public function set_fragments() { * Set class filname. */ public function set_filname() { - $hash = substr( md5( @serialize( $this->compiler ) ), 0, 7 ); + $hash = $this->hash( $this->compiler ); // Stop here and return filename if not in dev mode or if not using filesystem. if ( ! _beans_is_compiler_dev_mode() || ! @is_dir( $this->dir ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. @@ -195,7 +195,7 @@ public function set_filname() { if ( ! empty( $fragments_filemtime ) ) { // Set filemtime hash. - $_hash = substr( md5( @serialize( $fragments_filemtime ) ), 0, 7 ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $_hash = $this->hash( $fragments_filemtime ); $items = @scandir( $this->dir ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. unset( $items[0], $items[1] ); @@ -216,6 +216,19 @@ public function set_filname() { $this->compiler['filename'] = $hash . '.' . $this->get_extension(); } + /** + * Hash the given array. + * + * @since 1.5.0 + * + * @param array $given_array Given array to be hashed. + * + * @return string + */ + public function hash( array $given_array ) { + return substr( md5( @serialize( $given_array ) ), 0, 7 ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + } + /** * Checks if the file exists on the filesystem, meaning it's been cached. * @@ -277,12 +290,12 @@ public function cache_file() { public function enqueue_file() { // Enqueue css. - if ( 'style' == $this->compiler['type'] ) { + if ( 'style' === $this->compiler['type'] ) { return wp_enqueue_style( $this->compiler['id'], $this->get_url(), $this->compiler['depedencies'], $this->compiler['version'] ); } // Enqueue js file. - if ( 'script' == $this->compiler['type'] ) { + if ( 'script' === $this->compiler['type'] ) { return wp_enqueue_script( $this->compiler['id'], $this->get_url(), $this->compiler['depedencies'], $this->compiler['version'], $this->compiler['in_footer'] ); } @@ -315,11 +328,11 @@ public function get_url() { */ public function get_extension() { - if ( 'style' == $this->compiler['type'] ) { + if ( 'style' === $this->compiler['type'] ) { return 'css'; } - if ( 'script' == $this->compiler['type'] ) { + if ( 'script' === $this->compiler['type'] ) { return 'js'; } } @@ -348,7 +361,6 @@ public function combine_fragments() { // Treat function. if ( $this->is_function( $fragment ) ) { $get_content = $this->get_function_content(); - } else { // Treat file. $get_content = $this->get_internal_content(); @@ -364,7 +376,7 @@ public function combine_fragments() { } // Add the content. - if ( 'style' == $this->compiler['type'] ) { + if ( 'style' === $this->compiler['type'] ) { $get_content = $this->replace_css_url( $get_content ); $get_content = $this->add_content_media_query( $get_content ); } @@ -498,12 +510,12 @@ public function add_content_media_query( $content ) { */ public function format_content( $content ) { - if ( 'style' == $this->compiler['type'] ) { + if ( 'style' === $this->compiler['type'] ) { - if ( 'less' == $this->compiler['format'] ) { + if ( 'less' === $this->compiler['format'] ) { if ( ! class_exists( 'Beans_Lessc' ) ) { - require_once( BEANS_API_PATH . 'compiler/vendors/lessc.php' ); + require_once BEANS_API_PATH . 'compiler/vendors/lessc.php'; } $less = new Beans_Lessc(); @@ -517,15 +529,14 @@ public function format_content( $content ) { return $content; } - if ( 'script' == $this->compiler['type'] && ! _beans_is_compiler_dev_mode() && $this->compiler['minify_js'] ) { + if ( 'script' === $this->compiler['type'] && ! _beans_is_compiler_dev_mode() && $this->compiler['minify_js'] ) { if ( ! class_exists( 'JSMin' ) ) { - require_once( BEANS_API_PATH . 'compiler/vendors/js-minifier.php' ); + require_once BEANS_API_PATH . 'compiler/vendors/js-minifier.php'; } $js_min = new JSMin( $content ); return $js_min->min(); - } return $content; @@ -560,7 +571,7 @@ public function replace_css_url( $content ) { public function replace_css_url_callback( $matches ) { // Stop here if it isn't a internal file or not a valid format. - if ( true == preg_match( '#^(http|https|\/\/|data)#', $matches[1] ) ) { + if ( 1 === preg_match( '#^(http|https|\/\/|data)#', $matches[1] ) ) { return $matches[0]; } @@ -569,7 +580,11 @@ public function replace_css_url_callback( $matches ) { // Separate the placeholders and path. $explode_path = explode( '../', $matches[1] ); - // Replace the base part according to the path "../". + /** + * Walk backwards through each of the the fragment's directories, one-by-one. The `foreach` loop + * provides us with a performant way to walk the fragment back to its base path based upon the + * number of placeholders. + */ foreach ( $explode_path as $value ) { $base = dirname( $base ); } @@ -588,14 +603,16 @@ public function replace_css_url_callback( $matches ) { // Return the rebuilt path converted to url. return 'url("' . $url . '")'; - } /** - * Minify CSS. + * Minify the CSS. + * + * @param string $content Given content to process. + * + * @return string */ public function strip_whitespace( $content ) { - $replace = array( '#/\*.*?\*/#s' => '', // Strip comments. '#\s\s+#' => ' ', // Strip excess whitespace. @@ -615,30 +632,33 @@ public function strip_whitespace( $content ) { ',\n' => ',', // Don't wrap multiple selectors. '\n}' => '}', // Don't wrap closing braces. '} ' => "}\n", // Put each rule on it's own line. - '\n' => '', // Take out all line breaks + '\n' => '', // Take out all line breaks. ); $search = array_keys( $replace ); return trim( str_replace( $search, $replace, $content ) ); - } /** - * Is the fragement a function. + * Checks if the given fragment is a callable. + * + * @since 1.0.0 + * + * @param mixed $fragment Given fragment to check. + * + * @return bool */ public function is_function( $fragment ) { - - if ( is_array( $fragment ) || is_callable( $fragment ) ) { - return true; - } - - return false; - + return ( is_array( $fragment ) || is_callable( $fragment ) ); } /** * Kill it :( + * + * @since 1.0.0 + * + * @return void */ public function kill() { @@ -668,17 +688,19 @@ public function kill() { __( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' ) ) ); - wp_die( $html ); - + wp_die( wp_kses_post( $html ) ); } /** * Send report. + * + * @since 1.0.0 + * + * @return void */ public function report() { - // Send report. - $send = wp_mail( + wp_mail( 'hello@getbeans.io', 'Compiler error', 'Compiler error reported by ' . home_url(), @@ -692,10 +714,14 @@ public function report() { ); // Die and display message. - wp_die( beans_output( 'beans_compiler_report_error_text', sprintf( - '

    %s

    ', - __( 'Thanks for your contribution by reporting this issue. We hope to hear from you again.', 'tm-beans' ) - ) ) ); + $message = beans_output( + 'beans_compiler_report_error_text', + sprintf( + '

    %s

    ', + __( 'Thanks for your contribution by reporting this issue. We hope to hear from you again.', 'tm-beans' ) + ) + ); + wp_die( wp_kses_post( $message ) ); } } From ef4b932f44862e6b16aa476c47a01f839b2090cf Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 20:37:19 -0600 Subject: [PATCH 179/800] Changed property to "config" to better represent the data it holds. --- lib/api/compiler/class-compiler.php | 48 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-compiler.php index cdea9438..88a52ef6 100644 --- a/lib/api/compiler/class-compiler.php +++ b/lib/api/compiler/class-compiler.php @@ -23,7 +23,7 @@ final class _Beans_Compiler { * * @var array */ - protected $compiler; + protected $config; /** * Cache dir. @@ -69,9 +69,9 @@ public function __construct( array $config ) { 'version' => false, ); - $this->compiler = array_merge( $defaults, $config ); - $this->dir = beans_get_compiler_dir( is_admin() ) . $this->compiler['id']; - $this->url = beans_get_compiler_url( is_admin() ) . $this->compiler['id']; + $this->config = array_merge( $defaults, $config ); + $this->dir = beans_get_compiler_dir( is_admin() ) . $this->config['id']; + $this->url = beans_get_compiler_url( is_admin() ) . $this->config['id']; $this->set_fragments(); $this->set_filname(); @@ -146,40 +146,40 @@ public function maybe_make_dir() { public function set_fragments() { global $_beans_compiler_added_fragments; - $added_fragments = beans_get( $this->compiler['id'], $_beans_compiler_added_fragments[ $this->compiler['format'] ] ); + $added_fragments = beans_get( $this->config['id'], $_beans_compiler_added_fragments[ $this->config['format'] ] ); if ( $added_fragments ) { - $this->compiler['fragments'] = array_merge( $this->compiler['fragments'], $added_fragments ); + $this->config['fragments'] = array_merge( $this->config['fragments'], $added_fragments ); } /** * Filter the compiler fragment files. * - * The dynamic portion of the hook name, $this->compiler['id'], refers to the compiler id used as a reference. + * The dynamic portion of the hook name, $this->config['id'], refers to the compiler id used as a reference. * * @since 1.0.0 * * @param array $fragments An array of fragment files. */ - $this->compiler['fragments'] = apply_filters( 'beans_compiler_fragments_' . $this->compiler['id'], $this->compiler['fragments'] ); + $this->config['fragments'] = apply_filters( 'beans_compiler_fragments_' . $this->config['id'], $this->config['fragments'] ); } /** * Set class filname. */ public function set_filname() { - $hash = $this->hash( $this->compiler ); + $hash = $this->hash( $this->config ); // Stop here and return filename if not in dev mode or if not using filesystem. if ( ! _beans_is_compiler_dev_mode() || ! @is_dir( $this->dir ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. - $this->compiler['filename'] = $hash . '.' . $this->get_extension(); + $this->config['filename'] = $hash . '.' . $this->get_extension(); return; } $fragments_filemtime = array(); // Check for internal file changes. - foreach ( $this->compiler['fragments'] as $id => $fragment ) { + foreach ( $this->config['fragments'] as $id => $fragment ) { // Ignore if the fragment is a function. if ( $this->is_function( $fragment ) ) { @@ -213,7 +213,7 @@ public function set_filname() { $hash = $hash . '-' . $_hash; } - $this->compiler['filename'] = $hash . '.' . $this->get_extension(); + $this->config['filename'] = $hash . '.' . $this->get_extension(); } /** @@ -290,13 +290,13 @@ public function cache_file() { public function enqueue_file() { // Enqueue css. - if ( 'style' === $this->compiler['type'] ) { - return wp_enqueue_style( $this->compiler['id'], $this->get_url(), $this->compiler['depedencies'], $this->compiler['version'] ); + if ( 'style' === $this->config['type'] ) { + return wp_enqueue_style( $this->config['id'], $this->get_url(), $this->config['depedencies'], $this->config['version'] ); } // Enqueue js file. - if ( 'script' === $this->compiler['type'] ) { - return wp_enqueue_script( $this->compiler['id'], $this->get_url(), $this->compiler['depedencies'], $this->compiler['version'], $this->compiler['in_footer'] ); + if ( 'script' === $this->config['type'] ) { + return wp_enqueue_script( $this->config['id'], $this->get_url(), $this->config['depedencies'], $this->config['version'], $this->config['in_footer'] ); } return false; @@ -310,7 +310,7 @@ public function enqueue_file() { * @return string */ public function get_url() { - $url = trailingslashit( $this->url ) . beans_get( 'filename', $this->compiler ); + $url = trailingslashit( $this->url ) . beans_get( 'filename', $this->config ); if ( is_ssl() ) { $url = str_replace( 'http://', 'https://', $url ); @@ -328,11 +328,11 @@ public function get_url() { */ public function get_extension() { - if ( 'style' === $this->compiler['type'] ) { + if ( 'style' === $this->config['type'] ) { return 'css'; } - if ( 'script' === $this->compiler['type'] ) { + if ( 'script' === $this->config['type'] ) { return 'js'; } } @@ -348,7 +348,7 @@ public function combine_fragments() { $content = ''; // Loop through fragments. - foreach ( $this->compiler['fragments'] as $fragment ) { + foreach ( $this->config['fragments'] as $fragment ) { // Stop here if the fragment is empty. if ( empty( $fragment ) ) { @@ -376,7 +376,7 @@ public function combine_fragments() { } // Add the content. - if ( 'style' === $this->compiler['type'] ) { + if ( 'style' === $this->config['type'] ) { $get_content = $this->replace_css_url( $get_content ); $get_content = $this->add_content_media_query( $get_content ); } @@ -510,9 +510,9 @@ public function add_content_media_query( $content ) { */ public function format_content( $content ) { - if ( 'style' === $this->compiler['type'] ) { + if ( 'style' === $this->config['type'] ) { - if ( 'less' === $this->compiler['format'] ) { + if ( 'less' === $this->config['format'] ) { if ( ! class_exists( 'Beans_Lessc' ) ) { require_once BEANS_API_PATH . 'compiler/vendors/lessc.php'; @@ -529,7 +529,7 @@ public function format_content( $content ) { return $content; } - if ( 'script' === $this->compiler['type'] && ! _beans_is_compiler_dev_mode() && $this->compiler['minify_js'] ) { + if ( 'script' === $this->config['type'] && ! _beans_is_compiler_dev_mode() && $this->config['minify_js'] ) { if ( ! class_exists( 'JSMin' ) ) { require_once BEANS_API_PATH . 'compiler/vendors/js-minifier.php'; From 1b1a55ab495cce5e45c2a5c854f472afad7b2cd5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 20:51:47 -0600 Subject: [PATCH 180/800] Separated run tasks from constructor. A constructor sets up the object to run. It should not automatically run upon creation. 1. Created a `run_compiler()` method. 2. Added an `init_config` method to handle the task of defaults & merging. Additional stuff in this one include: 1. Made functions.php WPCS compliant. 2. Added documentation to functions.php. --- lib/api/compiler/class-compiler.php | 52 +++++++--- lib/api/compiler/functions.php | 145 +++++++++++++++------------- 2 files changed, 115 insertions(+), 82 deletions(-) diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-compiler.php index 88a52ef6..f3afa802 100644 --- a/lib/api/compiler/class-compiler.php +++ b/lib/api/compiler/class-compiler.php @@ -55,24 +55,22 @@ final class _Beans_Compiler { * @param array $config Runtime configuration parameters for the Compiler. */ public function __construct( array $config ) { + $this->config = $this->init_config( $config ); + $this->dir = beans_get_compiler_dir( is_admin() ) . $this->config['id']; + $this->url = beans_get_compiler_url( is_admin() ) . $this->config['id']; + } + + /** + * Run the compiler. + * + * @since 1.5.0 + * + * @return void + */ + public function run_compiler() { // Modify the WP Filesystem method. add_filter( 'filesystem_method', array( $this, 'filesystem_method' ) ); - $defaults = array( - 'id' => false, - 'type' => false, - 'format' => false, - 'fragments' => array(), - 'depedencies' => false, - 'in_footer' => false, - 'minify_js' => false, - 'version' => false, - ); - - $this->config = array_merge( $defaults, $config ); - $this->dir = beans_get_compiler_dir( is_admin() ) . $this->config['id']; - $this->url = beans_get_compiler_url( is_admin() ) . $this->config['id']; - $this->set_fragments(); $this->set_filname(); @@ -724,4 +722,28 @@ public function report() { wp_die( wp_kses_post( $message ) ); } + + /** + * Initialize the configuration. + * + * @since 1.5.0 + * + * @param array $config Runtime configuration parameters for the Compiler. + * + * @return array + */ + private function init_config( array $config ) { + $defaults = array( + 'id' => false, + 'type' => false, + 'format' => false, + 'fragments' => array(), + 'depedencies' => false, + 'in_footer' => false, + 'minify_js' => false, + 'version' => false, + ); + + return array_merge( $defaults, $config ); + } } diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 0ad4ca4e..f2fa8dd6 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -21,14 +21,17 @@ * * @since 1.0.0 * - * @param string $id A unique string used as a reference. Similar to the WordPress scripts - * $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase compiling time. - * @param array $args { - * Optional. Array of arguments used by the compiler. - * - * @type array $depedencies An array of registered handles this script depends on. Default false. + * @param string $id A unique string used as a reference. Similar to the WordPress scripts + * $handle argument. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * compiling time. + * @param array $args { + * Optional. Array of arguments used by the compiler. + * + * @type array $depedencies An array of registered handles this script depends on. Default false. * } + * + * @return void|bool */ function beans_compile_css_fragments( $id, $fragments, $args = array() ) { @@ -43,8 +46,8 @@ function beans_compile_css_fragments( $id, $fragments, $args = array() ) { 'fragments' => (array) $fragments, ); - new _Beans_Compiler( $params + $args ); - + $compiler = new _Beans_Compiler( $params + $args ); + $compiler->run_compiler(); } /** @@ -57,13 +60,16 @@ function beans_compile_css_fragments( $id, $fragments, $args = array() ) { * * @since 1.0.0 * - * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase compiling time. - * @param array $args { - * Optional. Array of arguments used by the compiler. + * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * compiling time. + * @param array $args { + * Optional. Array of arguments used by the compiler. * - * @type array $depedencies An array of registered handles this script depends on. Default false. + * @type array $depedencies An array of registered handles this script depends on. Default false. * } + * + * @return void|bool */ function beans_compile_less_fragments( $id, $fragments, $args = array() ) { @@ -78,8 +84,8 @@ function beans_compile_less_fragments( $id, $fragments, $args = array() ) { 'fragments' => (array) $fragments, ); - new _Beans_Compiler( $params + $args ); - + $compiler = new _Beans_Compiler( $params + $args ); + $compiler->run_compiler(); } /** @@ -92,17 +98,21 @@ function beans_compile_less_fragments( $id, $fragments, $args = array() ) { * * @since 1.0.0 * - * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase compiling time. - * @param array $args { - * Optional. Array of arguments used by the compiler. - * - * @type array $depedencies An array of registered handles this script depends on. Default false. - * @type bool $in_footer Whether to enqueue the script before or before . Default false. - * @type bool $minify_js Whether the JavaScript should be minified or not. Be aware that minifying - * the JavaScript can considerably slow down the process of compiling files. - * Default false. + * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * compiling time. + * @param array $args { + * Optional. Array of arguments used by the compiler. + * + * @type array $depedencies An array of registered handles this script depends on. Default false. + * @type array $depedencies An array of registered handles this script depends on. Default false. + * @type bool $in_footer Whether to enqueue the script before or before . Default false. + * @type bool $minify_js Whether the JavaScript should be minified or not. Be aware that minifying + * the JavaScript can considerably slow down the process of compiling files. + * Default false. * } + * + * @return void|bool */ function beans_compile_js_fragments( $id, $fragments, $args = array() ) { @@ -117,8 +127,8 @@ function beans_compile_js_fragments( $id, $fragments, $args = array() ) { 'fragments' => (array) $fragments, ); - new _Beans_Compiler( $params + $args ); - + $compiler = new _Beans_Compiler( $params + $args ); + $compiler->run_compiler(); } /** @@ -130,9 +140,12 @@ function beans_compile_js_fragments( $id, $fragments, $args = array() ) { * @since 1.0.0 * * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase compiling time. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * compiling time. * @param string $format Compiler format the fragments should be added to. Accepts 'css', * 'less' or 'js'. + * + * @return void|bool */ function beans_compiler_add_fragment( $id, $fragments, $format ) { @@ -145,21 +158,17 @@ function beans_compiler_add_fragment( $id, $fragments, $format ) { foreach ( (array) $fragments as $key => $fragment ) { // Stop here if the format isn't valid. - if ( ! isset( $_beans_compiler_added_fragments[ $format ] ) ) : + if ( ! isset( $_beans_compiler_added_fragments[ $format ] ) ) { continue; + } // Register new compiler id if it doesn't exist and add fragment. - elseif ( ! isset( $_beans_compiler_added_fragments[ $format ][ $id ] ) ) : + if ( ! isset( $_beans_compiler_added_fragments[ $format ][ $id ] ) ) { $_beans_compiler_added_fragments[ $format ][ $id ] = array( $fragment ); - - // Add fragment to existing compiler. - else : + } else { // Add fragment to existing compiler. $_beans_compiler_added_fragments[ $format ][ $id ][] = $fragment; - - endif; - + } } - } /** @@ -174,23 +183,22 @@ function beans_compiler_add_fragment( $id, $fragments, $format ) { * @param string|bool $file_format Optional. Define which files format should be removed. Both CSS and JS * files will be removed if set to false. Accepts 'false', 'css' or 'js'. * @param bool $admin Optional. Whether it is an admin compiler or not. + * + * @return void|bool */ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { - static $beans_flushed = false; $cache_dir = beans_get_compiler_dir( $admin ); - // Always flush beans global chache. + // Always flush beans global cache. if ( ! $beans_flushed ) { - $beans_flushed = true; beans_flush_compiler( 'beans', $file_format, $admin ); - } - $dir = trailingslashit( $cache_dir ) . $id; + $dir = trailingslashit( $cache_dir ) . $id; // Stop here if directory doesn't exist. if ( ! is_dir( $dir ) ) { @@ -199,22 +207,20 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { // Remove only specified format files. if ( $file_format ) { - $items = scandir( $dir ); unset( $items[0], $items[1] ); foreach ( $items as $item ) { - if ( false !== stripos( $item, '.' . $file_format ) ) { - @unlink( trailingslashit( $dir ) . $item ); + @unlink( trailingslashit( $dir ) . $item ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. } } - } else { // Remove all format files. - - beans_remove_dir( $dir ); + return; } + // Remove all format files. + beans_remove_dir( $dir ); } /** @@ -227,59 +233,63 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. * @param string|bool $file_format Optional. Define which files format should be removed. Both CSS and JS * files will be removed if set to false. Accepts 'false', 'css' or 'js'. + * + * @return void */ function beans_flush_admin_compiler( $id, $file_format = false ) { - beans_flush_compiler( $id, $file_format, true ); - } /** - * Get beans compiler directory. + * Get absolute path to the Beans' compiler directory. * * @since 1.0.0 * - * @return string Compiler directory. + * @param bool $is_admin Optional. When true, gets the admin compiler directory. Default is false. + * + * @return string */ -function beans_get_compiler_dir( $admin = false ) { - +function beans_get_compiler_dir( $is_admin = false ) { $wp_upload_dir = wp_upload_dir(); - $suffix = $admin ? 'beans/admin-compiler/' : 'beans/compiler/'; + $suffix = $is_admin ? 'beans/admin-compiler/' : 'beans/compiler/'; /** * Deprecated. Filter the beans compiler directory. * * This filter is deprecated for security and compatibility purposes. * - * @since 1.0.0 + * @since 1.0.0 * @deprecated 1.3.0 */ - $deprecated = apply_filters( 'beans_compiler_dir', false, $admin ); + apply_filters( 'beans_compiler_dir', false, $is_admin ); return wp_normalize_path( trailingslashit( $wp_upload_dir['basedir'] ) . $suffix ); - } /** - * Get beans compiler url. + * Get absolute URL to the Beans' compiler directory. * * @since 1.3.0 * - * @return string Compiler directory. + * @param bool $is_admin Optional. When true, gets the admin compiler directory. Default is false. + * + * @return string */ -function beans_get_compiler_url( $admin = false ) { - +function beans_get_compiler_url( $is_admin = false ) { $wp_upload_dir = wp_upload_dir(); - $suffix = $admin ? 'beans/admin-compiler/' : 'beans/compiler/'; + $suffix = $is_admin ? 'beans/admin-compiler/' : 'beans/compiler/'; return trailingslashit( $wp_upload_dir['baseurl'] ) . $suffix; - } /** - * Check if development mode is enabled taking in consideration legacy constant. + * Check if development mode is enabled, taking in consideration legacy constant. * + * @since 1.0.0 * @ignore + * @access private + * + * @return bool */ function _beans_is_compiler_dev_mode() { @@ -288,13 +298,14 @@ function _beans_is_compiler_dev_mode() { } return get_option( 'beans_dev_mode', false ); - } /** * Initialize added fragments global. * + * @since 1.0.0 * @ignore + * @access private */ global $_beans_compiler_added_fragments; From de7cf57172e7b762c9727bb0ad8c79e8188f413e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:11:12 -0600 Subject: [PATCH 181/800] Added tests for beans_get_compiler_dir() and beans_get_compiler_url(). 1. Added tests. 2. Changed the compiler file name. --- ...-compiler.php => class-beans-compiler.php} | 0 .../api/compiler/beansGetCompilerDir.php | 58 ++++ .../api/compiler/beansGetCompilerUrl.php | 44 +++ .../api/compiler/fixtures/jquery.test.js | 29 ++ .../api/compiler/fixtures/my-game-clock.js | 21 ++ .../api/compiler/fixtures/style.css | 16 + .../api/compiler/fixtures/test.less | 7 + .../api/compiler/fixtures/variables.less | 8 + .../includes/class-compiler-test-case.php | 312 +++++++++++++++++ .../unit/api/compiler/beansGetCompilerDir.php | 45 +++ .../unit/api/compiler/beansGetCompilerUrl.php | 44 +++ .../unit/api/compiler/fixtures/jquery.test.js | 29 ++ .../api/compiler/fixtures/my-game-clock.js | 21 ++ .../unit/api/compiler/fixtures/style.css | 16 + .../unit/api/compiler/fixtures/test.less | 7 + .../unit/api/compiler/fixtures/variables.less | 8 + .../includes/class-compiler-test-case.php | 313 ++++++++++++++++++ tests/phpunit/unit/class-test-case.php | 14 +- 18 files changed, 991 insertions(+), 1 deletion(-) rename lib/api/compiler/{class-compiler.php => class-beans-compiler.php} (100%) create mode 100644 tests/phpunit/integration/api/compiler/beansGetCompilerDir.php create mode 100644 tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php create mode 100644 tests/phpunit/integration/api/compiler/fixtures/jquery.test.js create mode 100644 tests/phpunit/integration/api/compiler/fixtures/my-game-clock.js create mode 100644 tests/phpunit/integration/api/compiler/fixtures/style.css create mode 100644 tests/phpunit/integration/api/compiler/fixtures/test.less create mode 100644 tests/phpunit/integration/api/compiler/fixtures/variables.less create mode 100644 tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php create mode 100644 tests/phpunit/unit/api/compiler/beansGetCompilerDir.php create mode 100644 tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php create mode 100644 tests/phpunit/unit/api/compiler/fixtures/jquery.test.js create mode 100644 tests/phpunit/unit/api/compiler/fixtures/my-game-clock.js create mode 100644 tests/phpunit/unit/api/compiler/fixtures/style.css create mode 100644 tests/phpunit/unit/api/compiler/fixtures/test.less create mode 100644 tests/phpunit/unit/api/compiler/fixtures/variables.less create mode 100644 tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-beans-compiler.php similarity index 100% rename from lib/api/compiler/class-compiler.php rename to lib/api/compiler/class-beans-compiler.php diff --git a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php new file mode 100644 index 00000000..4947b053 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php @@ -0,0 +1,58 @@ +assertSame( + $this->get_virtual_dir( 'compiled/beans/compiler/' ), + beans_get_compiler_dir() + ); + } + + /** + * Test beans_get_compiler_dir() should return the absolute path to the Beans' uploads admin compiler folder. + */ + public function test_should_return_absolute_path_to_compiler_admin_folder() { + $this->assertSame( + $this->get_virtual_dir( 'compiled/beans/admin-compiler/' ), + beans_get_compiler_dir( true ) + ); + } + + /** + * Get the virtual directory. Modify the root, as wp_normalize_path changes it. + * + * @since 1.5.0 + * + * @param string $path The path to get. + * + * @return string + */ + protected function get_virtual_dir( $path ) { + return str_replace( 'vfs://', 'vfs:/', vfsStream::url( $path ) ); + } +} diff --git a/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php b/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php new file mode 100644 index 00000000..492b7337 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php @@ -0,0 +1,44 @@ +assertSame( + site_url( 'compiled/beans/compiler/' ), + beans_get_compiler_url() + ); + } + + /** + * Test should return the URL to the Beans' admin compiler folder. + */ + public function test_should_return_url_to_compiler_admin_folder() { + $this->assertSame( + site_url( 'compiled/beans/admin-compiler/' ), + beans_get_compiler_url( true ) + ); + } +} diff --git a/tests/phpunit/integration/api/compiler/fixtures/jquery.test.js b/tests/phpunit/integration/api/compiler/fixtures/jquery.test.js new file mode 100644 index 00000000..73d60dc5 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/fixtures/jquery.test.js @@ -0,0 +1,29 @@ +(function( $ ){ + 'use strict'; + + /** + * Initialize the script. + */ + var init = function() { + $( 'some-button' ).on( 'click', clickHandler ); + } + + /** + * Handle the button's click event. + * + * @param event + */ + var clickHandler = function( event ) { + event.preventDefault(); + + // do something cool here. + } + + /** + * Wait until the document is ready. + */ + $( document ).ready( function(){ + init(); + }); + +})( jQuery ); diff --git a/tests/phpunit/integration/api/compiler/fixtures/my-game-clock.js b/tests/phpunit/integration/api/compiler/fixtures/my-game-clock.js new file mode 100644 index 00000000..ac082973 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/fixtures/my-game-clock.js @@ -0,0 +1,21 @@ +class MyGameClock { + + /** + * Creates an instance of MyGameClock. + * + * @param maxTime Clock's timeout increment. + */ + constructor( maxTime ) { + this.maxTime = maxTime; + this.currentClock = 0; + } + + /** + * Get the remaining time on the clock. + * + * @returns {number} + */ + getRemainingTime() { + return this.maxTime - this.currentClock; + } +} \ No newline at end of file diff --git a/tests/phpunit/integration/api/compiler/fixtures/style.css b/tests/phpunit/integration/api/compiler/fixtures/style.css new file mode 100644 index 00000000..a5aa904b --- /dev/null +++ b/tests/phpunit/integration/api/compiler/fixtures/style.css @@ -0,0 +1,16 @@ +/*! + Stylesheet. + */ +body { + background-color: #fff; + color: #000; + font-size: 18px; +} + +a { + color: #cc0000; +} + +p { + margin-bottom: 30px; +} diff --git a/tests/phpunit/integration/api/compiler/fixtures/test.less b/tests/phpunit/integration/api/compiler/fixtures/test.less new file mode 100644 index 00000000..fcda49a7 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/fixtures/test.less @@ -0,0 +1,7 @@ +@test-font-size: 18px; + +body { + background-color: #fff; + color: @body-color; + font-size: @test-font-size; +} diff --git a/tests/phpunit/integration/api/compiler/fixtures/variables.less b/tests/phpunit/integration/api/compiler/fixtures/variables.less new file mode 100644 index 00000000..18615d17 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/fixtures/variables.less @@ -0,0 +1,8 @@ +/** +These are the global variables. + */ +@body-color: #000; +@link-color: #039460; +@hover-color: #016F47; +@base-font: normal 18px / 22px "Helvetica Neue",Helvetica,Arial,sans-serif; +@base-font-size: 18px; /* this is an inline comment */ \ No newline at end of file diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php new file mode 100644 index 00000000..e30e6364 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -0,0 +1,312 @@ +set_up_virtual_filesystem(); + $this->compiled_dir = vfsStream::url( 'compiled' ); + + // Set the Uploads directory to our virtual filesystem. + add_filter( 'upload_dir', function( array $uploads_dir ) { + $uploads_dir['path'] = $this->compiled_dir . $uploads_dir['subdir']; + $uploads_dir['url'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['url'] ); + $uploads_dir['basedir'] = $this->compiled_dir; + $uploads_dir['baseurl'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['baseurl'] ); + + return $uploads_dir; + } ); + } + + /** + * Tear down the test fixture. + */ + public function tearDown() { + Mockery::close(); + parent::tearDown(); + + unset( $GLOBALS['wp_filesystem'] ); + } + + /** + * Set up the virtual filesystem. + */ + private function set_up_virtual_filesystem() { + $structure = array( + 'beans' => array( + 'compiler' => array( + 'index.php' => '', + ), + 'admin-compiler' => array( + 'index.php' => '', + ), + ), + 'fixtures' => array(), + ); + + $filenames = array( 'jquery.test.js', 'my-game-clock.js', 'style.css', 'test.less', 'variables.less' ); + $fixtures_dir = basename( __DIR__ ) === 'compiler' + ? __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR + : dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR; + + + // Load the fixture files and content into the virtual filesystem. + foreach ( $filenames as $filename ) { + $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); + } + + // Set up the "compiled" directory's virtual filesystem. + $this->mock_filesystem = vfsStream::setup( 'compiled', 0755, $structure ); + + // Set the fixture file dates back a week. + $fixtures_dir = $this->mock_filesystem->getChild( 'fixtures' ); + $file_modification_time = time() - ( 7 * 24 * 60 * 60 ); + foreach ( $filenames as $filename ) { + $fixtures_dir->getChild( $filename )->lastModified( $file_modification_time ); + } + } + + /** + * Add the virtual directory to the filesystem. + * + * @since 1.5.0 + * + * @param string $dir_name Directory name. + * @param string $root_dir Optional. Root directory(ies) for the new directory. + * + * @return void + */ + protected function add_virtual_directory( $dir_name, $root_dir = 'compiled/beans/compiler' ) { + vfsStream::newDirectory( $dir_name )->at( $this->mock_filesystem->getChild( $root_dir ) ); + } + + /** + * Set the protected property "current_fragment". + * + * @since 1.5.0 + * + * @param \_Beans_Compiler $compiler The Compiler instance. + * @param mixed $fragment The given value to set. + * + * @return void + */ + protected function set_current_fragment( $compiler, $fragment ) { + $current_fragment = ( new \ReflectionClass( $compiler ) )->getProperty( 'current_fragment' ); + $current_fragment->setAccessible( true ); + $current_fragment->setValue( $compiler, $fragment ); + $current_fragment->setAccessible( false ); + } + + /** + * Fix the compiler's "dir" property, as the wp_normalize_path() converts "vfs://" to "vfs:/". + * + * @since 1.5.0 + * + * @param array $config Compiler's configuration. + * + * @return \_Beans_Compiler + */ + protected function create_compiler( $config ) { + $compiler = new \_Beans_Compiler( $config ); + + $dir = ( new \ReflectionClass( $compiler ) )->getProperty( 'dir' ); + $dir->setAccessible( true ); + + if ( substr( $compiler->dir, 0, 6 ) !== 'vfs://' ) { + $dir->setValue( $compiler, str_replace( 'vfs:/', 'vfs://', $compiler->dir ) ); + } + + $dir->setAccessible( false ); + return $compiler; + } + + /** + * Get the filename. + * + * @since 1.5.0 + * + * @param \_Beans_Compiler $compiler Instance of the compiler. + * @param array $config The compiler's configuration. + * @param int $filemtime Optional. The fragment's filemtime. Default is null. + * + * @return string + */ + protected function get_filename( $compiler, $config, $filemtime = null ) { + + if ( is_null( $filemtime ) ) { + foreach ( $config['fragments'] as $index => $fragment ) { + $filemtimes[ $index ] = filemtime( $fragment ); + } + } else { + $filemtimes = array( $filemtime ); + } + + return sprintf( + '%s-%s.%s', + $compiler->hash( $config ), + $compiler->hash( $filemtimes ), + 'style' === $config['type'] ? 'css' : 'js' + ); + } + + /** + * Set up the filesystem mocks for the fragments. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the Compiler. + * @param int $times_called Optional. Number of times the mock will be called. Default is 1. + * @param string $class Mock's class name. + * + * @return void + */ + protected function mock_filesystem_for_fragments( + $compiler, + $times_called = 1, + $class = 'WP_Filesystem_Direct_Mock' + ) { + + if ( ! defined( 'FS_CHMOD_FILE' ) ) { + define( 'FS_CHMOD_FILE', 0644 ); + } + + unset( $GLOBALS['wp_filesystem'] ); + + // Now set up the mock. + $mock = Mockery::mock( $class ); + + foreach ( $compiler->config['fragments'] as $fragment ) { + $mock->shouldReceive( 'get_contents' ) + ->times( $times_called ) + ->with( $fragment ) + ->andReturn( file_get_contents( $fragment ) ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents && WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents - valid in this edge case. + } + + $GLOBALS['wp_filesystem'] = $mock; // @codingStandardsIgnoreLine - WordPress.Variables.GlobalVariables.OverrideProhibited This is a valid use case as we are mocking the filesystem. + } + + /** + * Set Development Mode. + * + * @since 1.5.0 + * + * @param bool $is_enabled Optional. When true, turns on development mode. Default is false. + * + * @return void + */ + protected function set_dev_mode( $is_enabled = false ) { + update_option( 'beans_dev_mode', $is_enabled ); + } + + /** + * Get the compiled jQuery. + * + * @since 1.5.0 + * + * @return string + */ + protected function get_compiled_jquery() { + $compiled_content = <<assertSame( + vfsStream::url( 'compiled/beans/compiler/' ), + beans_get_compiler_dir() + ); + } + + /** + * Test beans_get_compiler_dir() should return the absolute path to the Beans' uploads admin compiler folder. + */ + public function test_should_return_absolute_path_to_compiler_admin_folder() { + $this->assertSame( + vfsStream::url( 'compiled/beans/admin-compiler/' ), + beans_get_compiler_dir( true ) + ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php b/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php new file mode 100644 index 00000000..91418289 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php @@ -0,0 +1,44 @@ +assertSame( + $this->compiled_url . 'beans/compiler/', + beans_get_compiler_url() + ); + } + + /** + * Test should return the URL to the Beans' admin compiler folder. + */ + public function test_should_return_url_to_compiler_admin_folder() { + $this->assertSame( + $this->compiled_url . 'beans/admin-compiler/', + beans_get_compiler_url( true ) + ); + } +} diff --git a/tests/phpunit/unit/api/compiler/fixtures/jquery.test.js b/tests/phpunit/unit/api/compiler/fixtures/jquery.test.js new file mode 100644 index 00000000..73d60dc5 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/fixtures/jquery.test.js @@ -0,0 +1,29 @@ +(function( $ ){ + 'use strict'; + + /** + * Initialize the script. + */ + var init = function() { + $( 'some-button' ).on( 'click', clickHandler ); + } + + /** + * Handle the button's click event. + * + * @param event + */ + var clickHandler = function( event ) { + event.preventDefault(); + + // do something cool here. + } + + /** + * Wait until the document is ready. + */ + $( document ).ready( function(){ + init(); + }); + +})( jQuery ); diff --git a/tests/phpunit/unit/api/compiler/fixtures/my-game-clock.js b/tests/phpunit/unit/api/compiler/fixtures/my-game-clock.js new file mode 100644 index 00000000..ac082973 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/fixtures/my-game-clock.js @@ -0,0 +1,21 @@ +class MyGameClock { + + /** + * Creates an instance of MyGameClock. + * + * @param maxTime Clock's timeout increment. + */ + constructor( maxTime ) { + this.maxTime = maxTime; + this.currentClock = 0; + } + + /** + * Get the remaining time on the clock. + * + * @returns {number} + */ + getRemainingTime() { + return this.maxTime - this.currentClock; + } +} \ No newline at end of file diff --git a/tests/phpunit/unit/api/compiler/fixtures/style.css b/tests/phpunit/unit/api/compiler/fixtures/style.css new file mode 100644 index 00000000..a5aa904b --- /dev/null +++ b/tests/phpunit/unit/api/compiler/fixtures/style.css @@ -0,0 +1,16 @@ +/*! + Stylesheet. + */ +body { + background-color: #fff; + color: #000; + font-size: 18px; +} + +a { + color: #cc0000; +} + +p { + margin-bottom: 30px; +} diff --git a/tests/phpunit/unit/api/compiler/fixtures/test.less b/tests/phpunit/unit/api/compiler/fixtures/test.less new file mode 100644 index 00000000..fcda49a7 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/fixtures/test.less @@ -0,0 +1,7 @@ +@test-font-size: 18px; + +body { + background-color: #fff; + color: @body-color; + font-size: @test-font-size; +} diff --git a/tests/phpunit/unit/api/compiler/fixtures/variables.less b/tests/phpunit/unit/api/compiler/fixtures/variables.less new file mode 100644 index 00000000..18615d17 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/fixtures/variables.less @@ -0,0 +1,8 @@ +/** +These are the global variables. + */ +@body-color: #000; +@link-color: #039460; +@hover-color: #016F47; +@base-font: normal 18px / 22px "Helvetica Neue",Helvetica,Arial,sans-serif; +@base-font-size: 18px; /* this is an inline comment */ \ No newline at end of file diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php new file mode 100644 index 00000000..ccdeebd4 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -0,0 +1,313 @@ +set_up_virtual_filesystem(); + $this->compiled_dir = vfsStream::url( 'compiled' ); + $this->compiled_url = 'http:://beans.local/compiled/'; + + Functions\expect( 'wp_upload_dir' )->andReturn( array( + 'path' => '', + 'url' => '', + 'subdir' => '', + 'basedir' => $this->compiled_dir, + 'baseurl' => $this->compiled_url, + 'error' => false, + ) ); + + Functions\expect( 'is_admin' )->andReturn( $this->is_admin ); + Functions\expect( 'site_url' )->andReturn( 'http:://beans.local' ); + } + + /** + * Tear down the test fixture. + */ + protected function tearDown() { + Mockery::close(); + parent::tearDown(); + + // Reset the global fragments container. + global $_beans_compiler_added_fragments; + $_beans_compiler_added_fragments = array( + 'css' => array(), + 'less' => array(), + 'js' => array(), + ); + + unset( $GLOBALS['wp_filesystem'] ); + } + + /** + * Set up the virtual filesystem. + */ + private function set_up_virtual_filesystem() { + $structure = array( + 'beans' => array( + 'compiler' => array( + 'index.php' => '', + ), + 'admin-compiler' => array( + 'index.php' => '', + ), + ), + 'fixtures' => array(), + ); + + $filenames = array( 'jquery.test.js', 'my-game-clock.js', 'style.css', 'test.less', 'variables.less' ); + $fixtures_dir = basename( __DIR__ ) === 'compiler' + ? __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR + : dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR; + + + // Load the fixture files and content into the virtual filesystem. + foreach ( $filenames as $filename ) { + $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); + } + + // Set up the "compiled" directory's virtual filesystem. + $this->mock_filesystem = vfsStream::setup( 'compiled', 0755, $structure ); + + // Set the fixture file dates back a week. + $fixtures_dir = $this->mock_filesystem->getChild( 'fixtures' ); + $file_modification_time = time() - ( 7 * 24 * 60 * 60 ); + foreach ( $filenames as $filename ) { + $fixtures_dir->getChild( $filename )->lastModified( $file_modification_time ); + } + } + + /** + * Add the virtual directory to the filesystem. + * + * @since 1.5.0 + * + * @param string $dir_name Directory name. + * @param string $root_dir Optional. Root directory(ies) for the new directory. + * + * @return void + */ + protected function add_virtual_directory( $dir_name, $root_dir = 'compiled/beans/compiler' ) { + vfsStream::newDirectory( $dir_name )->at( $this->mock_filesystem->getChild( $root_dir ) ); + } + + /** + * Set the protected property "current_fragment". + * + * @since 1.5.0 + * + * @param \_Beans_Compiler $compiler The Compiler instance. + * @param mixed $fragment The given value to set. + * + * @return void + */ + protected function set_current_fragment( $compiler, $fragment ) { + $current_fragment = ( new \ReflectionClass( $compiler ) )->getProperty( 'current_fragment' ); + $current_fragment->setAccessible( true ); + $current_fragment->setValue( $compiler, $fragment ); + $current_fragment->setAccessible( false ); + } + + /** + * Get the filename. + * + * @since 1.5.0 + * + * @param \_Beans_Compiler $compiler Instance of the compiler. + * @param array $config The compiler's configuration. + * @param int $filemtime Optional. The fragment's filemtime. Default is null. + * + * @return string + */ + protected function get_filename( $compiler, $config, $filemtime = null ) { + + if ( is_null( $filemtime ) ) { + foreach ( $config['fragments'] as $index => $fragment ) { + $filemtimes[ $index ] = filemtime( $fragment ); + } + } else { + $filemtimes = array( $filemtime ); + } + + return sprintf( + '%s-%s.%s', + $compiler->hash( $config ), + $compiler->hash( $filemtimes ), + 'style' === $config['type'] ? 'css' : 'js' + ); + } + + /** + * Set up the filesystem mocks for the fragments. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the Compiler. + * @param int $times_called Optional. Number of times the mock will be called. Default is 1. + * + * @return void + */ + protected function mock_filesystem_for_fragments( $compiler, $times_called = 1 ) { + $mock = Mockery::mock( 'WP_Filesystem_Direct' ); + + foreach ( $compiler->config['fragments'] as $fragment ) { + $mock->shouldReceive( 'get_contents' ) + ->times( $times_called ) + ->with( $fragment ) + ->andReturn( file_get_contents( $fragment ) ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents && WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents - valid in this edge case. + } + + $GLOBALS['wp_filesystem'] = $mock; // @codingStandardsIgnoreLine - WordPress.Variables.GlobalVariables.OverrideProhibited This is a valid use case as we are mocking the filesystem. + } + + /** + * Mock the site's development mode. + * + * @since 1.5.0 + * + * @param bool $is_enabled Optional. When true, developement mode is enabled. Default is false. + * + * @return void + */ + protected function mock_dev_mode( $is_enabled = false ) { + Monkey\Functions\expect( 'get_option' ) + ->with( 'beans_dev_mode', false ) + ->andReturn( $is_enabled ); + } + + /** + * Get the compiled jQuery. + * + * @since 1.5.0 + * + * @return string + */ + protected function get_compiled_jquery() { + $compiled_content = <<alias( function( $path ) { + + if ( true === $this->just_return_path ) { + return $path; + } + $path = str_replace( '\\', '/', $path ); $path = preg_replace( '|(?<=.)/+|', '/', $path ); @@ -57,7 +69,7 @@ protected function tearDown() { * Then in our tests, we monkey patch via Brain Monkey, which redefines the original function. * At tear down, the original function is restored in Brain Monkey, by calling Patchwork\restoreAll(). * - * @since 1.0.0 + * @since 1.5.0 * * @param array $files Array of files to load into memory. * From 3cbbc337c0784314255d61a54a3306873dd63889 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:12:32 -0600 Subject: [PATCH 182/800] Added __get() method to make it easier to test. We need read-only access to the properties. --- lib/api/compiler/class-beans-compiler.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index f3afa802..f88e548e 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -746,4 +746,21 @@ private function init_config( array $config ) { return array_merge( $defaults, $config ); } + + /** + * Get the property's value. + * + * @since 1.5.0 + * + * @param string $property Name of the property to get. + * + * @return mixed + */ + public function __get( $property ) { + + // If the property exists, return it. + if ( property_exists( $this, $property ) ) { + return $this->{$property}; + } + } } From 065a467b5a2255d8ec41b2da9204fe2060ad1d21 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:13:53 -0600 Subject: [PATCH 183/800] Added tests for __get(). --- .../unit/api/compiler/beans-compiler/get.php | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/get.php diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/get.php b/tests/phpunit/unit/api/compiler/beans-compiler/get.php new file mode 100644 index 00000000..7ac9b01c --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/get.php @@ -0,0 +1,116 @@ + 'test', + 'type' => 'script', + 'depedencies' => array( 'jquery' ), + ); + + $compiler = new \_Beans_Compiler( $config ); + + $this->assertArrayNotHasKey( 'depedencies', $compiler->config ); + $this->assertArrayHasKey( 'dependencies', $compiler->config ); + $this->assertSame( array( 'jquery' ), $compiler->config['dependencies'] ); + } + + /** + * Test should return the configuration. + */ + public function test_should_return_configuration() { + $compiler = new \_Beans_Compiler( array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ) ); + $this->assertSame( + array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array(), + 'dependencies' => false, + 'in_footer' => false, + 'minify_js' => false, + 'version' => false, + ), + $compiler->config + ); + + $compiler = new \_Beans_Compiler( array( + 'id' => 'test_scripts', + 'type' => 'script', + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'version' => null, + ) ); + $this->assertSame( + array( + 'id' => 'test_scripts', + 'type' => 'script', + 'format' => false, + 'fragments' => array(), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => false, + 'version' => null, + ), + $compiler->config + ); + } + + /** + * Test should return the absolute path to the compiled files directory. + */ + public function test_should_return_dir() { + $config = array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ); + + $compiler = new \_Beans_Compiler( $config ); + + $this->assertSame( vfsStream::url( 'compiled/beans/compiler/test' ), $compiler->dir ); + } + + /** + * Test should return compiled files directory's URL. + */ + public function test_should_return_url() { + $config = array( + 'id' => 'test_scripts', + 'type' => 'script', + ); + + $compiler = new \_Beans_Compiler( $config ); + + $this->assertSame( $this->compiled_url . 'beans/compiler/test_scripts', $compiler->url ); + } +} From 8b5c9e75c72e864aa25fe492eadacebf2a38dd86 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:15:21 -0600 Subject: [PATCH 184/800] Fixed "depedencies" in config with a fallback. --- lib/api/compiler/class-beans-compiler.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index f88e548e..72754335 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -733,15 +733,21 @@ public function report() { * @return array */ private function init_config( array $config ) { + // Fix dependencies, if "depedencies" is specified. + if ( isset( $config['depedencies'] ) ) { + $config['dependencies'] = $config['depedencies']; + unset( $config['depedencies'] ); + } + $defaults = array( - 'id' => false, - 'type' => false, - 'format' => false, - 'fragments' => array(), - 'depedencies' => false, - 'in_footer' => false, - 'minify_js' => false, - 'version' => false, + 'id' => false, + 'type' => false, + 'format' => false, + 'fragments' => array(), + 'dependencies' => false, + 'in_footer' => false, + 'minify_js' => false, + 'version' => false, ); return array_merge( $defaults, $config ); From 17acacbe0d1a45f0e8a67ca842f836f4f6f6e9e9 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:16:10 -0600 Subject: [PATCH 185/800] Added test for get_extension() --- .../compiler/beans-compiler/getExtension.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php new file mode 100644 index 00000000..7e137b30 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php @@ -0,0 +1,59 @@ + 'style' ) ); + + $this->assertSame( 'css', $compiler->get_extension() ); + } + + /** + * Test should return "js" when the type is "script". + */ + public function test_should_return_js_when_script() { + $compiler = new \_Beans_Compiler( array( 'type' => 'script' ) ); + + $this->assertSame( 'js', $compiler->get_extension() ); + } + + /** + * Test should return "js" when the type is "script". + */ + public function test_should_return_null_when_invalid_type() { + $compiler = new \_Beans_Compiler( array( 'type' => 'invalid' ) ); + $this->assertNull( $compiler->get_extension() ); + + $compiler = new \_Beans_Compiler( array( 'type' => null ) ); + $this->assertNull( $compiler->get_extension() ); + + $compiler = new \_Beans_Compiler( array( 'type' => false ) ); + $this->assertNull( $compiler->get_extension() ); + + $compiler = new \_Beans_Compiler( array() ); + $this->assertNull( $compiler->get_extension() ); + } +} From d86c4cb6f0d9967a09082d3e2d3765ce8311b0e4 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:19:39 -0600 Subject: [PATCH 186/800] Refactored & added tests for filesystem(). Included check to initialize when the global is not set to the direct class. --- lib/api/compiler/class-beans-compiler.php | 17 ++- .../api/compiler/beans-compiler/fileystem.php | 103 ++++++++++++++++++ .../api/compiler/beans-compiler/fileystem.php | 43 ++++++++ 3 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 72754335..b6c8797b 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -69,7 +69,7 @@ public function __construct( array $config ) { */ public function run_compiler() { // Modify the WP Filesystem method. - add_filter( 'filesystem_method', array( $this, 'filesystem_method' ) ); + add_filter( 'filesystem_method', array( $this, 'modify_filesystem_method' ) ); $this->set_fragments(); $this->set_filname(); @@ -83,7 +83,7 @@ public function run_compiler() { $this->enqueue_file(); // Keep it safe and reset WP Filesystem method. - remove_filter( 'filesystem_method', array( $this, 'filesystem_method' ) ); + remove_filter( 'filesystem_method', array( $this, 'modify_filesystem_method' ) ); } /** @@ -93,7 +93,7 @@ public function run_compiler() { * * @return string */ - public function filesystem_method() { + public function modify_filesystem_method() { return 'direct'; } @@ -106,11 +106,16 @@ public function filesystem_method() { */ public function filesystem() { - // Initialize the WordPress Filesystem. - if ( ! isset( $GLOBALS['wp_filesystem'] ) || empty( $GLOBALS['wp_filesystem'] ) ) { + // WP_Filesystem is not already loaded, load it. + if ( ! function_exists( 'WP_Filesystem' ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; + } + + // If WP_Filesystem is not initialized or it's not set to WP_Filesystem_Direct, initialize it. + if ( ! isset( $GLOBALS['wp_filesystem'] ) || ! is_a( $GLOBALS['wp_filesystem'], 'WP_Filesystem_Direct' ) ) { - if ( ! WP_Filesystem() ) { + // Fail-safe. If something happens, generate a report and then exit. + if ( true !== WP_Filesystem() ) { return $this->kill(); } } diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php new file mode 100644 index 00000000..c19785aa --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php @@ -0,0 +1,103 @@ +assertTrue( function_exists( 'WP_Filesystem' ) ); + $this->assertArrayNotHasKey( 'wp_filesystem', $GLOBALS ); + + global $wp_filesystem; + $this->assertFalse( isset( $wp_filesystem ) ); + } + + /** + * Test filesystem() should render a report and die when no filesystem is selected. + */ + public function test_should_render_report_and_die_when_no_filesystem_selected() { + $compiler = new _Beans_Compiler( array() ); + + Functions\expect( __NAMESPACE__ . '\set_wp_die_handler' ) + ->once() + ->andReturn( __NAMESPACE__ . '\mock_wp_die_handler' ); + + Functions\when( __NAMESPACE__ . '\mock_wp_die_handler' ) + ->alias( function( $message ) { + $this->assertContains( 'Beans cannot work its magic', $message ); + } ); + + add_filter( 'wp_die_handler', __NAMESPACE__ . '\set_wp_die_handler' ); + + // Initialize the WP Filesystem. + $this->assertNull( $compiler->filesystem() ); + + remove_filter( 'wp_die_handler', __NAMESPACE__ . '\set_wp_die_handler' ); + } + + /** + * Test filesystem() should initialize the WP Filesystem. + */ + public function test_should_init_wp_filesystem() { + $compiler = new _Beans_Compiler( array() ); + + add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + + // Initialize the WP Filesystem. + $this->assertTrue( $compiler->filesystem() ); + + // Check that it was initialized. + $this->assertTrue( function_exists( 'WP_Filesystem' ) ); + $this->assertTrue( class_exists( 'WP_Filesystem_Direct' ) ); + $this->assertArrayHasKey( 'wp_filesystem', $GLOBALS ); + $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); + + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + } + + /** + * Test filesystem() should set WP_Filesystem_Direct when not set as WP_Filesystem method. + */ + public function test_should_set_wp_filesystem_direct() { + // First, set something else as the WP_Filesystem method. + Functions\expect( __NAMESPACE__ . '\set_filesystem_method_to_base' ) + ->once() + ->andReturn( 'base' ); + + add_filter( 'filesystem_method', __NAMESPACE__ . '\set_filesystem_method_to_base' ); + WP_Filesystem(); + $this->assertInstanceOf( 'WP_Filesystem_Base', $GLOBALS['wp_filesystem'] ); + remove_filter( 'filesystem_method', __NAMESPACE__ . '\set_filesystem_method_to_base' ); + + // Next, let's run our Compiler's filesystem and check that it did initialize WP_Filesystem_Direct. + $compiler = new _Beans_Compiler( array() ); + + add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + $this->assertTrue( $compiler->filesystem() ); + $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php new file mode 100644 index 00000000..caa38804 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php @@ -0,0 +1,43 @@ +justReturn( true ); + + // Test that WP Filesystem is not loaded yet. + $compiler = new \_Beans_Compiler( array() ); + $this->assertTrue( $compiler->filesystem() ); + + unset( $GLOBALS['wp_filesystem'] ); + } +} From d0512165b2ffd85583d76a0e56df5c96aeb5208e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:23:03 -0600 Subject: [PATCH 187/800] Added tests for get_internal_content(). --- .../beans-compiler/getInternalContent.php | 73 +++++++++++++++++++ .../beans-compiler/getInternalContent.php | 69 ++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php new file mode 100644 index 00000000..fe568bbd --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php @@ -0,0 +1,73 @@ +assertfalse( $compiler->get_internal_content( '' ) ); + } + + /** + * Test get_internal_content() should return false when the file does not exist. + */ + public function test_should_return_false_when_file_does_not_exist() { + // Set up the compiler. + $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; + $compiler = new _Beans_Compiler( array( + 'fragments' => array( $fragment ), + ) ); + $this->set_current_fragment( $compiler, $fragment ); + + // Run the test. + $this->assertfalse( $compiler->get_internal_content( $fragment ) ); + } + + /** + * Test get_internal_content() should fragment's contents. + */ + public function test_should_return_fragment_contents() { + // Set up the compiler. + $fragment = vfsStream::url( 'compiled/fixtures/test.less' ); + $compiler = new _Beans_Compiler( array( + 'fragments' => array( $fragment ), + ) ); + $this->set_current_fragment( $compiler, $fragment ); + + // Set the WP Filesystem. + add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + $compiler->filesystem(); + $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); + + // Run the tests. + $contents = $compiler->get_internal_content( $fragment ); + $this->assertContains( 'body {', $contents ); + $this->assertContains( 'color: @body-color;', $contents ); + + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php new file mode 100644 index 00000000..b49a85f3 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php @@ -0,0 +1,69 @@ +assertfalse( $compiler->get_internal_content() ); + } + + /** + * Test get_internal_content() should return false when the file does not exist. + */ + public function test_should_return_false_when_file_does_not_exist() { + // Set up the compiler. + $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; + $compiler = new _Beans_Compiler( array( + 'fragments' => array( $fragment ), + ) ); + $this->set_current_fragment( $compiler, $fragment ); + + // Run the test. + $this->assertfalse( $compiler->get_internal_content() ); + } + + /** + * Test get_internal_content() should fragment's contents. + */ + public function test_should_return_fragment_contents() { + // Set up the compiler. + $fragment = vfsStream::url( 'compiled/fixtures/test.less' ); + $compiler = new _Beans_Compiler( array( + 'fragments' => array( $fragment ), + ) ); + $this->set_current_fragment( $compiler, $fragment ); + + // Set up the mocks. + $this->mock_filesystem_for_fragments( $compiler ); + + // Run the tests. + $contents = $compiler->get_internal_content(); + $this->assertContains( 'body {', $contents ); + $this->assertContains( 'color: @body-color;', $contents ); + } +} From 195b6783cd25b3fb40b3d55e4f0584736dd05e8f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:27:31 -0600 Subject: [PATCH 188/800] Refactored & added tests for get_remote_content(). 1.Replaced regex with substr to improve performance. 2.Added check to only retry if the URL is not https. 3.Added tests. --- lib/api/compiler/class-beans-compiler.php | 32 +-- .../beans-compiler/getRemoteContent.php | 99 ++++++++ .../beans-compiler/getRemoteContent.php | 221 ++++++++++++++++++ 3 files changed, 337 insertions(+), 15 deletions(-) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index b6c8797b..fdd05f52 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -425,10 +425,14 @@ public function get_internal_content() { public function get_remote_content() { $fragment = $this->current_fragment; - // Replace double slashes by http. Mostly used for font referencing urls. - if ( 1 === preg_match( '#^\/\/#', $fragment ) ) { - $fragment = preg_replace( '#^\/\/#', 'http://', $fragment ); - } elseif ( 1 === preg_match( '#^\/#', $fragment ) ) { // Add domain if it is local but could not be fetched as a file. + if ( empty( $fragment ) ) { + return false; + } + + // For a relative URL, add the http: to it. + if ( substr( $fragment, 0, 2 ) === '//' ) { + $fragment = 'http:' . $fragment; + } elseif ( substr( $fragment, 0, 1 ) === '/' ) { // Add domain if it is local but could not be fetched as a file. $fragment = site_url( $fragment ); } @@ -438,19 +442,17 @@ public function get_remote_content() { return ''; } - // If failed to get content, try with ssl url, otherwise go to next fragment. - if ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) { - - $fragment = preg_replace( '#^http#', 'https', $fragment ); + // If no content received and the URL is not https, then convert the URL to SSL and retry. + if ( + ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) && + ( substr( $fragment, 0, 8 ) !== 'https://' ) + ) { + $fragment = str_replace( 'http://', 'https://', $fragment ); $request = wp_remote_get( $fragment ); + } - if ( is_wp_error( $request ) ) { - return ''; - } - - if ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) { - return false; - } + if ( ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) ) { + return false; } return wp_remote_retrieve_body( $request ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php new file mode 100644 index 00000000..75878ab9 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php @@ -0,0 +1,99 @@ +assertfalse( $compiler->get_remote_content( '' ) ); + } + + /** + * Test get_remote_content() should return empty string when the remote site or file does not exist. + */ + public function test_should_return_empty_string_when_remote_does_not_exist() { + $fragment = 'http://beans.local/invalid-file.js'; + $compiler = new _Beans_Compiler( array( + 'fragments' => array( $fragment ), + ) ); + $this->set_current_fragment( $compiler, $fragment ); + + $this->assertSame( '', $compiler->get_remote_content( $fragment ) ); + } + + /** + * Test get_remote_content() should return the content when fragment is a relative url. + */ + public function test_should_return_content_when_relative_url() { + $fragment = '//fonts.googleapis.com/css?family=Lato'; + $compiler = new _Beans_Compiler( array( + 'fragments' => array( $fragment ), + ) ); + $this->set_current_fragment( $compiler, $fragment ); + + $content = $compiler->get_remote_content( $fragment ); + + $this->assertContains( "font-family: 'Lato';", $content ); + $this->assertContains( 'font-style: normal;', $content ); + $this->assertContains( 'font-weight: 400;', $content ); + $this->assertContains( "src: local('Lato Regular')", $content ); + } + + /** + * Test get_remote_content() should return the content when fragment is http URL. + */ + public function test_should_return_content_when_http() { + $fragment = 'http://fonts.googleapis.com/css?family=Roboto'; + $compiler = new _Beans_Compiler( array( + 'fragments' => array( $fragment ), + ) ); + $this->set_current_fragment( $compiler, $fragment ); + + $content = $compiler->get_remote_content( $fragment ); + + $this->assertContains( "font-family: 'Roboto';", $content ); + $this->assertContains( 'font-style: normal;', $content ); + $this->assertContains( 'font-weight: 400;', $content ); + $this->assertContains( "src: local('Roboto')", $content ); + } + + /** + * Test get_remote_content() should return the content when fragment is https URL. + */ + public function test_should_return_content_when_https() { + $fragment = 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'; + $compiler = new _Beans_Compiler( array( + 'fragments' => array( $fragment ), + ) ); + $this->set_current_fragment( $compiler, $fragment ); + + $content = $compiler->get_remote_content( $fragment ); + + $this->assertContains( 'Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome', $content ); + $this->assertContains( "@font-face{font-family:'FontAwesome';", $content ); + $this->assertContains( "src:url('../fonts/fontawesome-webfont.eot?v=4.7.0');", $content ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php new file mode 100644 index 00000000..91edce96 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -0,0 +1,221 @@ +assertfalse( $compiler->get_remote_content() ); + $this->set_current_fragment( $compiler, false ); + $this->assertfalse( $compiler->get_remote_content() ); + $this->set_current_fragment( $compiler, '' ); + $this->assertfalse( $compiler->get_remote_content() ); + } + + /** + * Test get_remote_content() should return empty string when the remote site or file does not exist. + */ + public function test_should_return_empty_string_when_remote_does_not_exist() { + // Set up the compiler. + $fragment = 'http://beans.local/invalid-file.js'; + $compiler = new _Beans_Compiler( array() ); + $this->set_current_fragment( $compiler, $fragment ); + + // Set up the mocks. + Functions\expect( 'wp_remote_get' )->once(); + Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + + // Run the test. + $this->assertSame( '', $compiler->get_remote_content() ); + } + + /** + * Test get_remote_content() should retry and then return false when the remote file does not exist. + */ + public function test_should_return_retry_and_return_false() { + // Set up the compiler. + $fragment = 'http://beans.local/invalid-file.js'; + $compiler = new _Beans_Compiler( array() ); + $this->set_current_fragment( $compiler, $fragment ); + + // Set up the mocks. + Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Functions\expect( 'wp_remote_get' ) + ->with( $fragment ) + ->once() + ->ordered() + // No "body" element is returned. + ->andReturn( array() ) + ->andAlsoExpectIt() + // During the retry, it should change to URL to https. + ->with( 'https://beans.local/invalid-file.js' ) + ->once() + ->ordered() + ->andReturn( array( + 'body' => '', + 'response' => array( + 'code' => 404, // HTTP code is 404 and not 200. + ), + ) ); + + // Run the test. + $this->assertFalse( $compiler->get_remote_content() ); + } + + /** + * Test get_remote_content() should return the content when fragment is a relative url. + */ + public function test_should_return_content_when_relative_url() { + // Set up the compiler. + $fragment = '//fonts.googleapis.com/css?family=Lato'; + $compiler = new _Beans_Compiler( array() ); + $this->set_current_fragment( $compiler, $fragment ); + $request = array( + 'body' => $this->get_expected_content(), + 'response' => array( + 'code' => 200, + ), + ); + + // Set up the mocks. + Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Functions\expect( 'wp_remote_get' ) + // Check that it did add http: to the relative URL. + ->with( 'http:' . $fragment ) + ->once() + ->andReturn( $request ); + Functions\expect( 'wp_remote_retrieve_body' ) + ->with( $request ) + ->once() + ->andReturn( $this->get_expected_content() ); + + // Run the tests. + $content = $compiler->get_remote_content(); + + $this->assertContains( "font-family: 'Lato';", $content ); + $this->assertContains( 'font-style: normal;', $content ); + $this->assertContains( 'font-weight: 400;', $content ); + $this->assertContains( "src: local('Lato Regular')", $content ); + } + + /** + * Test get_remote_content() should return the content when fragment is http URL. + */ + public function test_should_return_content_when_http() { + // Set up the compiler. + $fragment = 'http://fonts.googleapis.com/css?family=Lato'; + $compiler = new _Beans_Compiler( array() ); + $this->set_current_fragment( $compiler, $fragment ); + $request = array( + 'body' => $this->get_expected_content(), + 'response' => array( + 'code' => 200, + ), + ); + + // Set up the mocks. + Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Functions\expect( 'wp_remote_get' ) + // Check that it did add http: to the relative URL. + ->with( $fragment ) + ->once() + ->andReturn( $request ); + Functions\expect( 'wp_remote_retrieve_body' ) + ->with( $request ) + ->once() + ->andReturn( $this->get_expected_content() ); + + // Run the tests. + $content = $compiler->get_remote_content(); + + $this->assertContains( "font-family: 'Lato';", $content ); + $this->assertContains( 'font-style: normal;', $content ); + $this->assertContains( 'font-weight: 400;', $content ); + $this->assertContains( "src: local('Lato Regular')", $content ); + } + + /** + * Test get_remote_content() should return the content when fragment is https URL. + */ + public function test_should_return_content_when_https() { + // Set up the compiler. + $fragment = 'https://fonts.googleapis.com/css?family=Lato'; + $compiler = new _Beans_Compiler( array() ); + $this->set_current_fragment( $compiler, $fragment ); + $request = array( + 'body' => $this->get_expected_content(), + 'response' => array( + 'code' => 200, + ), + ); + + // Set up the mocks. + Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Functions\expect( 'wp_remote_get' ) + // Check that it did add http: to the relative URL. + ->with( $fragment ) + ->once() + ->andReturn( $request ); + Functions\expect( 'wp_remote_retrieve_body' ) + ->with( $request ) + ->once() + ->andReturn( $this->get_expected_content() ); + + // Run the tests. + $content = $compiler->get_remote_content(); + + $this->assertContains( "font-family: 'Lato';", $content ); + $this->assertContains( 'font-style: normal;', $content ); + $this->assertContains( 'font-weight: 400;', $content ); + $this->assertContains( "src: local('Lato Regular')", $content ); + } + + /** + * Get the expected content. + */ + private function get_expected_content() { + return << Date: Mon, 29 Jan 2018 21:28:43 -0600 Subject: [PATCH 189/800] Added tests for get_function_content(). --- .../beans-compiler/getFunctionContent.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php new file mode 100644 index 00000000..96398138 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php @@ -0,0 +1,71 @@ +assertfalse( $compiler->get_function_content() ); + $this->set_current_fragment( $compiler, 'function_does_not_exists' ); + $this->assertfalse( $compiler->get_function_content() ); + $this->set_current_fragment( $compiler, array( $this, 'method_does_not_exist' ) ); + $this->assertfalse( $compiler->get_function_content() ); + } + + /** + * Test get_function_content() should return content from function. + */ + public function test_should_return_return_content_from_function() { + $fragment = 'beans_test_get_function_content_callback'; + $compiler = new \_Beans_Compiler( array() ); + + // Set up the function mocks. + Functions\expect( $fragment )->once()->andReturn( 'Beans rocks' ); + $this->set_current_fragment( $compiler, $fragment ); + + // Run the test. + $this->assertSame( 'Beans rocks', $compiler->get_function_content() ); + } + + /** + * Test get_function_content() should return content from an object's method. + */ + public function test_should_return_return_content_from_method() { + $compiler = new \_Beans_Compiler( array() ); + + // Set up the mock. + $mock = Mockery::mock( 'Get_Function_Content_Mock' ); + $mock->shouldReceive( 'get_content' ) + ->once() + ->andReturn( 'Beans is innovative!' ); + $this->set_current_fragment( $compiler, array( $mock, 'get_content' ) ); + + // Run the test. + $this->assertSame( 'Beans is innovative!', $compiler->get_function_content() ); + } +} From ae9ff4f931c489fd994bd830edcc0007a0a908a7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:32:56 -0600 Subject: [PATCH 190/800] Refactored & added tests for filname(). 1. Replaced the conditional expression that checks for internal files. Now using file_exists(). 2. Added tests. --- lib/api/compiler/class-beans-compiler.php | 2 +- .../beans-compiler/cacheFileExist.php | 95 +++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index fdd05f52..a946cf32 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -190,7 +190,7 @@ public function set_filname() { } // Only check file time for internal files. - if ( false !== strpos( $fragment, $_SERVER['HTTP_HOST'] ) || 1 === preg_match( '#^\/[^\/]#', $fragment ) ) { + if ( file_exists( $fragment ) ) { $fragments_filemtime[ $id ] = @filemtime( beans_url_to_path( $fragment ) ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. } } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php new file mode 100644 index 00000000..571f7283 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php @@ -0,0 +1,95 @@ + 'test', + 'type' => 'script', + 'fragments' => array( $fragment ), + ) ); + + // Check that the filename does not exist. + $this->assertArrayNotHasKey( 'filename', $compiler->config ); + + // Run cache_file_exist(). + $this->assertFalse( $compiler->cache_file_exist() ); + } + + /** + * Test cache_file_exist() should return false when the cached file does not exist. + */ + public function test_should_return_false_when_file_does_not_exist() { + $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); + $compiler = new \_Beans_Compiler( array( + 'id' => 'test-script', + 'type' => 'script', + 'fragments' => array( $fragment ), + ) ); + + // Set up the mocks. + $this->mock_dev_mode( true ); + $this->add_virtual_directory( 'test-script' ); + + // Generate the filename. + $compiler->set_filname(); + + // Check that the cached file does not exist in the virtual filesystem. + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $compiler->config['filename'] ) ); + + // Run cache_file_exist(). + $this->assertFalse( $compiler->cache_file_exist() ); + } + + /** + * Test cache_file_exist() should return true when the cached file does exist. + */ + public function test_should_return_true_when_file_exists() { + $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); + $compiler = new \_Beans_Compiler( array( + 'id' => 'test-script', + 'type' => 'script', + 'fragments' => array( $fragment ), + ) ); + + // Set up the mocks. + $this->mock_dev_mode( true ); + $this->add_virtual_directory( 'test-script' ); + + // Add the cached file to the virtual filesystem. + $compiler->set_filname(); + vfsStream::newFile( $compiler->config['filename'] ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/test-script' ) ); + + // Check that the filename exists. + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $compiler->config['filename'] ) ); + + // Run cache_file_exist(). + $this->assertTrue( $compiler->cache_file_exist() ); + } +} From c6a3796e57d3fbec3a719639d206439b11779064 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:35:50 -0600 Subject: [PATCH 191/800] Changed set_filname to set_filename. 1. Deprecated set_filname() method. 2. Added set_filename() to replace it. --- lib/api/compiler/class-beans-compiler.php | 25 ++++++++++++++++--- .../beans-compiler/cacheFileExist.php | 4 +-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index a946cf32..b02bfd68 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -72,7 +72,7 @@ public function run_compiler() { add_filter( 'filesystem_method', array( $this, 'modify_filesystem_method' ) ); $this->set_fragments(); - $this->set_filname(); + $this->set_filename(); if ( ! $this->cache_file_exist() ) { $this->filesystem(); @@ -168,9 +168,14 @@ public function set_fragments() { } /** - * Set class filname. + * Set the filename for the compiled asset. + * + * @since 1.0.0 + * @since 1.5.0 Renamed method. + * + * @return void */ - public function set_filname() { + public function set_filename() { $hash = $this->hash( $this->config ); // Stop here and return filename if not in dev mode or if not using filesystem. @@ -760,6 +765,20 @@ private function init_config( array $config ) { return array_merge( $defaults, $config ); } + /** + * Set the filename for the compiled asset. + * + * This method has been replaced with {@see set_filename()}. + * + * @since 1.0.0 + * @deprecated 1.5.0. + */ + public function set_filname() { + _deprecated_function( __METHOD__, '1.5.0', 'set_filename' ); + + $this->set_filename(); + } + /** * Get the property's value. * diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php index 571f7283..4e700563 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php @@ -57,7 +57,7 @@ public function test_should_return_false_when_file_does_not_exist() { $this->add_virtual_directory( 'test-script' ); // Generate the filename. - $compiler->set_filname(); + $compiler->set_filename(); // Check that the cached file does not exist in the virtual filesystem. $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $compiler->config['filename'] ) ); @@ -82,7 +82,7 @@ public function test_should_return_true_when_file_exists() { $this->add_virtual_directory( 'test-script' ); // Add the cached file to the virtual filesystem. - $compiler->set_filname(); + $compiler->set_filename(); vfsStream::newFile( $compiler->config['filename'] ) ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/test-script' ) ); From a74a0d304483ba8450febcc4dcaa4f9dd351575f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:38:59 -0600 Subject: [PATCH 192/800] Refactored set_filename(), breaking up the tasks. It was doing too much. Broke it up into individual private methods. --- lib/api/compiler/class-beans-compiler.php | 144 ++++++++++++++++------ 1 file changed, 108 insertions(+), 36 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index b02bfd68..9bf52407 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -184,42 +184,8 @@ public function set_filename() { return; } - $fragments_filemtime = array(); - - // Check for internal file changes. - foreach ( $this->config['fragments'] as $id => $fragment ) { - - // Ignore if the fragment is a function. - if ( $this->is_function( $fragment ) ) { - continue; - } - - // Only check file time for internal files. - if ( file_exists( $fragment ) ) { - $fragments_filemtime[ $id ] = @filemtime( beans_url_to_path( $fragment ) ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. - } - } - - if ( ! empty( $fragments_filemtime ) ) { - - // Set filemtime hash. - $_hash = $this->hash( $fragments_filemtime ); - - $items = @scandir( $this->dir ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. - unset( $items[0], $items[1] ); - - // Clean up other modified files. - foreach ( $items as $item ) { - - // Remove if it contains initial hash, is the same format and doesn't contain the filemtime hash. - if ( false !== stripos( $item, $hash ) && false !== stripos( $item, $this->get_extension() ) && false === stripos( $item, $_hash ) ) { - @unlink( $this->dir . '/' . $item ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. - } - } - - // Set the new hash which will trigger to new compiling. - $hash = $hash . '-' . $_hash; - } + $fragments_filemtime = $this->get_fragments_filemtime(); + $hash = $this->get_new_hash( $hash, $fragments_filemtime ); $this->config['filename'] = $hash . '.' . $this->get_extension(); } @@ -765,6 +731,112 @@ private function init_config( array $config ) { return array_merge( $defaults, $config ); } + /** + * Get the fragments' modification times. + * + * @since 1.5.0 + * + * @return array + */ + private function get_fragments_filemtime() { + $fragments_filemtime = array(); + + foreach ( $this->config['fragments'] as $index => $fragment ) { + + // Skip this one if the fragment is a function. + if ( $this->is_function( $fragment ) ) { + continue; + } + + if ( file_exists( $fragment ) ) { + $fragments_filemtime[ $index ] = @filemtime( $fragment ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + } + } + + return $fragments_filemtime; + } + + /** + * Get the new hash for the given fragments' modification times. + * + * @since 1.5.0 + * + * @param string $hash The original hash to modify. + * @param array $fragments_filemtime Array of fragments' modification times. + * + * @return string + */ + private function get_new_hash( $hash, array $fragments_filemtime ) { + + if ( empty( $fragments_filemtime ) ) { + return $hash; + } + + // Set filemtime hash. + $_hash = $this->hash( $fragments_filemtime ); + + $this->remove_modified_files( $hash, $_hash ); + + // Set the new hash which will trigger to new compiling. + return $hash . '-' . $_hash; + } + + /** + * Remove any modified files. A file is considered modified when: + * + * 1. It has both a base hash and filemtime hash, separated by '-'. + * 2. Its base hash matches the given hash. + * 3. Its filemtime hash has does not match the given filemtime hash. + * + * @since 1.5.0 + * + * @param string $hash Base hash. + * @param string $filemtime_hash The filemtime hash (from hashing the fragments). + * + * @return void + */ + private function remove_modified_files( $hash, $filemtime_hash ) { + $items = @scandir( $this->dir ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + unset( $items[0], $items[1] ); + + if ( empty( $items ) ) { + return; + } + + foreach ( $items as $item ) { + + // Skip this one if it's a directory. + if ( @is_dir( $item ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + continue; + } + + // Skip this one if it's not the same type. + if ( pathinfo( $item, PATHINFO_EXTENSION ) !== $this->get_extension() ) { + continue; + } + + // Skip this one if it does not a '-' in the filename. + if ( strpos( $item, '-' ) === false ) { + continue; + } + + $hash_parts = explode( '-', pathinfo( $item, PATHINFO_FILENAME ) ); + + // Skip this one if it does not match the given base hash. + if ( $hash_parts[0] !== $hash ) { + continue; + } + + // Skip this one if it does match the given filemtime's hash. + if ( $hash_parts[1] === $filemtime_hash ) { + continue; + } + + // Clean up other modified files. + @unlink( $this->dir . '/' . $item ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + } + } + /** * Set the filename for the compiled asset. * From b01bf9cda3ade4dd45e52ebaf95e17ebe8635c2d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:40:57 -0600 Subject: [PATCH 193/800] Fixed #107. See issue #107. Now, the filename will always be a config hash - fragments filemtime hash. --- lib/api/compiler/class-beans-compiler.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 9bf52407..1f56a654 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -176,14 +176,7 @@ public function set_fragments() { * @return void */ public function set_filename() { - $hash = $this->hash( $this->config ); - - // Stop here and return filename if not in dev mode or if not using filesystem. - if ( ! _beans_is_compiler_dev_mode() || ! @is_dir( $this->dir ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. - $this->config['filename'] = $hash . '.' . $this->get_extension(); - return; - } - + $hash = $this->hash( $this->config ); $fragments_filemtime = $this->get_fragments_filemtime(); $hash = $this->get_new_hash( $hash, $fragments_filemtime ); From f15a5b4ab7d079a06d3b048c8049240b340a5e5f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:42:09 -0600 Subject: [PATCH 194/800] Added tests for set_fragments(). --- .../compiler/beans-compiler/setFragments.php | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php new file mode 100644 index 00000000..118632bf --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php @@ -0,0 +1,109 @@ + 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + ); + + $compiler = new \_Beans_Compiler( $config ); + + // Check before we start. + $this->assertSame( $config['fragments'], $compiler->config['fragments'] ); + + // Set the fragments. Test. + $compiler->set_fragments(); + $this->assertSame( $config['fragments'], $compiler->config['fragments'] ); + } + + /** + * Test should return fragments merged with the fragments stored in the global variable. + */ + public function test_should_return_fragments_merged_with_global() { + $config = array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + ); + + $compiler = new \_Beans_Compiler( $config ); + global $_beans_compiler_added_fragments; + $_beans_compiler_added_fragments['less'] = array( + 'test' => array( + 'some-file.less', + 'another-file.less', + ), + ); + + // Check before we start. + $this->assertSame( $config['fragments'], $compiler->config['fragments'] ); + + // Set the fragments. Test. + $expected = array_merge( $config['fragments'], $_beans_compiler_added_fragments['less']['test'] ); + $compiler->set_fragments(); + $this->assertSame( $expected, $compiler->config['fragments'] ); + } + + /** + * Test should fire the "beans_compiler_fragments_{id}" event. + */ + public function test_should_fire_event() { + $config = array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + ); + + $compiler = new \_Beans_Compiler( $config ); + + // Set up the expectation first before firing the event. + Monkey\Filters\expectApplied( 'beans_compiler_fragments_test' ) + ->once() + ->with( $config['fragments'] ) + ->andReturn( $compiler->config['fragments'] ); + + // Set the fragments. Test. + $compiler->set_fragments(); + $this->assertSame( $config['fragments'], $compiler->config['fragments'] ); + } +} From 82c063012e92a7d43f09714626ef0a97a3b131a8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:43:44 -0600 Subject: [PATCH 195/800] Added tests for replace_css_url(). --- .../compiler/beans-compiler/replaceCssUrl.php | 201 ++++++++++++++++++ .../compiler/beans-compiler/replaceCssUrl.php | 191 +++++++++++++++++ 2 files changed, 392 insertions(+) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php new file mode 100644 index 00000000..21244fc3 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php @@ -0,0 +1,201 @@ +assertSame( $css, $compiler->replace_css_url( $css ) ); + } + + /** + * Test replace_css_url() should return original content when it has a valid URI. + */ + public function test_should_return_original_content_when_valid_uri() { + $compiler = new _Beans_Compiler( array() ); + $css = <<assertSame( $css, $compiler->replace_css_url( $css ) ); + } + + /** + * Test replace_css_url() should convert the relative URL when it does not have ../. + */ + public function test_should_convert_relative_url_when_no_up_levels() { + $compiler = new _Beans_Compiler( array() ); + + // Set up the mocks. + $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); + + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + } + + /** + * Test replace_css_url() should convert the relative URL. + */ + public function test_should_convert_relative_url() { + $compiler = new _Beans_Compiler( array() ); + + // Set up the mocks. + $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); + + // Test with no spaces, single quotes, or double quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + + // Test with spaces and single quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + + // Test with spaces and double quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + } + + /** + * Test replace_css_url() should convert a deeper relative URL. + */ + public function test_should_convert_deeper_relative_url() { + $compiler = new _Beans_Compiler( array() ); + + // Set up the mocks. + $this->set_current_fragment( $compiler, 'http://example.com/assets/less/partials/hero.less' ); + + // Test with no spaces, single quotes, or double quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + + // Test with spaces and single quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + + // Test with spaces and double quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + } + + /** + * Set the protected property "current_fragment". + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler The Compiler instance. + * @param mixed $fragment The given value to set. + * + * @return void + */ + protected function set_current_fragment( $compiler, $fragment ) { + $current_fragment = ( new \ReflectionClass( $compiler ) )->getProperty( 'current_fragment' ); + $current_fragment->setAccessible( true ); + $current_fragment->setValue( $compiler, $fragment ); + $current_fragment->setAccessible( false ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php new file mode 100644 index 00000000..3696a819 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php @@ -0,0 +1,191 @@ +assertSame( $css, $compiler->replace_css_url( $css ) ); + } + + /** + * Test replace_css_url() should return original content when it has a valid URI. + */ + public function test_should_return_original_content_when_valid_uri() { + $compiler = new _Beans_Compiler( array() ); + $css = <<assertSame( $css, $compiler->replace_css_url( $css ) ); + } + + /** + * Test replace_css_url() should convert the relative URL when it does not have ../. + */ + public function test_should_convert_relative_url_when_no_up_levels() { + $compiler = new _Beans_Compiler( array() ); + + // Set up the mocks. + $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); + Functions\expect( 'is_main_site' )->andReturn( true ); + Functions\expect( 'site_url' )->andReturn( 'http://foo.com/' ); + + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + } + + /** + * Test replace_css_url() should convert the relative URL. + */ + public function test_should_convert_relative_url() { + $compiler = new _Beans_Compiler( array() ); + + // Set up the mocks. + $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); + Functions\expect( 'is_main_site' )->andReturn( true ); + Functions\expect( 'site_url' )->andReturn( 'http://foo.com/' ); + + // Test with no spaces, single quotes, or double quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + + // Test with spaces and single quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + + // Test with spaces and double quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + } + + /** + * Test replace_css_url() should convert a deeper relative URL. + */ + public function test_should_convert_deeper_relative_url() { + $compiler = new _Beans_Compiler( array() ); + + // Set up the mocks. + $this->set_current_fragment( $compiler, 'http://example.com/assets/less/partials/hero.less' ); + Functions\expect( 'is_main_site' )->andReturn( true ); + Functions\expect( 'site_url' )->andReturn( 'http://example.com/' ); + + // Test with no spaces, single quotes, or double quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + + // Test with spaces and single quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + + // Test with spaces and double quotes. + $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); + } +} From 3114c88f3dd510b04031ef9c5897c09333ce4b37 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:48:07 -0600 Subject: [PATCH 196/800] Abstracted is URI check to create _beans_is_uri(). The regex check to determine if the URI starts with http, https, //, or data was repeated. Abstracted the check into a private function. Added tests. --- lib/api/compiler/class-beans-compiler.php | 4 +- lib/api/utilities/functions.php | 21 +++++- .../phpunit/unit/api/utilities/beansIsUrl.php | 74 +++++++++++++++++++ 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 tests/phpunit/unit/api/utilities/beansIsUrl.php diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 1f56a654..c2ce60be 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -539,8 +539,8 @@ public function replace_css_url( $content ) { */ public function replace_css_url_callback( $matches ) { - // Stop here if it isn't a internal file or not a valid format. - if ( 1 === preg_match( '#^(http|https|\/\/|data)#', $matches[1] ) ) { + // If the URI is absolute, bail out and return the CSS. + if ( _beans_is_uri( $matches[1] ) ) { return $matches[0]; } diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index a0857010..a9075d62 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -109,7 +109,7 @@ function beans_path_to_url( $path, $force_rebuild = false ) { static $root_path, $root_url; // Stop here if it is already a url or data format. - if ( preg_match( '#^(http|https|\/\/|data)#', $path ) ) { + if ( _beans_is_uri( $path ) ) { return $path; } @@ -513,3 +513,22 @@ function beans_esc_attributes( $attributes ) { return trim( $string ); } + +/** + * Checks if the given input is a URL or data URI. It checks that the given input begins with: + * - http + * - https + * - // + * - data + * + * @since 1.5.0 + * @ignore + * @access private + * + * @param string $maybe_uri The given input to check. + * + * @return bool + */ +function _beans_is_uri( $maybe_uri ) { + return ( 1 === preg_match( '#^(http|https|\/\/|data)#', $maybe_uri ) ); +} diff --git a/tests/phpunit/unit/api/utilities/beansIsUrl.php b/tests/phpunit/unit/api/utilities/beansIsUrl.php new file mode 100644 index 00000000..84b35eff --- /dev/null +++ b/tests/phpunit/unit/api/utilities/beansIsUrl.php @@ -0,0 +1,74 @@ +assertFalse( _beans_is_uri( __FILE__ ) ); + $this->assertFalse( _beans_is_uri( __DIR__ ) ); + $this->assertFalse( _beans_is_uri( '/blog' ) ); + $this->assertFalse( _beans_is_uri( ':,Hello%2C%20World!' ) ); + $this->assertFalse( _beans_is_uri( ':text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) ); + } + + /** + * Test _beans_is_uri() should return true when starts with http + */ + public function test_should_return_true_when_http() { + $this->assertTrue( _beans_is_uri( 'http://getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( 'http://www.getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( 'http://getbeans.io/blog/' ) ); + $this->assertTrue( _beans_is_uri( 'http://8.8.8.8' ) ); + $this->assertTrue( _beans_is_uri( 'http://8000:8.8.8.8' ) ); + } + + /** + * Test _beans_is_uri() should return true when starts with http + */ + public function test_should_return_true_when_https() { + $this->assertTrue( _beans_is_uri( 'https://getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( 'https://www.getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( 'https://getbeans.io/blog/' ) ); + $this->assertTrue( _beans_is_uri( 'http://8.8.8.8' ) ); + $this->assertTrue( _beans_is_uri( 'http://8000:8.8.8.8' ) ); + } + + /** + * Test _beans_is_uri() should true when relative URL. + */ + public function test_should_bail_out_when_relative_url() { + $this->assertTrue( _beans_is_uri( '//getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( '//www.getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( '//getbeans.io/blog/' ) ); + $this->assertTrue( _beans_is_uri( '//8.8.8.8' ) ); + $this->assertTrue( _beans_is_uri( '//8000:8.8.8.8' ) ); + } + + /** + * Test _beans_is_uri() should return true when Data URI. + */ + public function test_should_return_true_when_data_url() { + $this->assertTrue( _beans_is_uri( 'data:,Hello%2C%20World!' ) ); + $this->assertTrue( _beans_is_uri( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) ); + } +} From 92408e71d3e4857ec0652134090913c378735675 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:51:31 -0600 Subject: [PATCH 197/800] Removed regex & replaced with ltrim. Made the method more performant by removing the expensie regex. In this case, ltrim does the job. --- lib/api/compiler/class-beans-compiler.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index c2ce60be..40ee142c 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -547,28 +547,24 @@ public function replace_css_url_callback( $matches ) { $base = $this->current_fragment; // Separate the placeholders and path. - $explode_path = explode( '../', $matches[1] ); + $paths = explode( '../', $matches[1] ); /** * Walk backwards through each of the the fragment's directories, one-by-one. The `foreach` loop * provides us with a performant way to walk the fragment back to its base path based upon the * number of placeholders. */ - foreach ( $explode_path as $value ) { + foreach ( $paths as $path ) { $base = dirname( $base ); } - // Rebuild path. - $replace = preg_replace( '#^\/#', '', $explode_path ); - $rebuilt_path = end( $replace ); - // Make sure it is a valid base. if ( '.' === $base ) { $base = ''; } // Rebuild url and make sure it is a valid one using the beans_path_to_url function. - $url = beans_path_to_url( trailingslashit( $base ) . $rebuilt_path ); + $url = beans_path_to_url( trailingslashit( $base ) . ltrim( end( $paths ), '/' ) ); // Return the rebuilt path converted to url. return 'url("' . $url . '")'; From 4bd1a0eae21695e144a30e0b974c9cb21dd7f8a2 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:53:36 -0600 Subject: [PATCH 198/800] Added tests for add_content_media_query(). --- .../beans-compiler/addContentMediaQuery.php | 108 ++++++++++++++++ .../beans-compiler/addContentMediaQuery.php | 116 ++++++++++++++++++ 2 files changed, 224 insertions(+) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php new file mode 100644 index 00000000..cedef7f4 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php @@ -0,0 +1,108 @@ +set_current_fragment( $compiler, array( $this, __METHOD__ ) ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + } + + /** + * Test add_content_media_query() should return original content when there are no query args. + */ + public function test_should_return_content_when_no_query_args() { + $compiler = new _Beans_Compiler( array() ); + $css = <<set_current_fragment( $compiler, 'http://foo.com/foo.css' ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + + $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/foo.less' ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + } + + /** + * Test add_content_media_query() should return original content when the 'beans_compiler_media_query' + * query arg is not present in the current fragment. + */ + public function test_should_return_content_when_no_media_query() { + $compiler = new _Beans_Compiler( array() ); + $css = <<set_current_fragment( $compiler, 'http://foo.com/base.css?beans=rocks' ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + + $this->set_current_fragment( $compiler, 'http://foo.com/style.css?beans=rocks&beans_compiler=media_query' ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + } + + /** + * Test add_content_media_query() should wrap the content in the specified media query. + */ + public function test_should_wrap_content_in_media_query() { + $compiler = new _Beans_Compiler( array() ); + $css = <<set_current_fragment( $compiler, 'http://foo.com/base.css?beans_compiler_media_query=' . $media_query ); + $this->assertSame( + "@media {$media_query} {\n{$css}\n}\n", + $compiler->add_content_media_query( $css ) + ); + } + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php new file mode 100644 index 00000000..edf0f5c1 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php @@ -0,0 +1,116 @@ +set_current_fragment( $compiler, array( $this, __METHOD__ ) ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + } + + /** + * Test add_content_media_query() should return original content when there are no query args. + */ + public function test_should_return_content_when_no_query_args() { + $compiler = new _Beans_Compiler( array() ); + $css = <<set_current_fragment( $compiler, 'http://foo.com/foo.css' ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + + $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/foo.less' ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + } + + /** + * Test add_content_media_query() should return original content when the 'beans_compiler_media_query' + * query arg is not present in the current fragment. + */ + public function test_should_return_content_when_no_media_query() { + $compiler = new _Beans_Compiler( array() ); + $css = <<set_current_fragment( $compiler, 'http://foo.com/base.css?beans=rocks' ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + + $this->set_current_fragment( $compiler, 'http://foo.com/style.css?beans=rocks&beans_compiler=media_query' ); + $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); + } + + /** + * Test add_content_media_query() should wrap the content in the specified media query. + */ + public function test_should_wrap_content_in_media_query() { + $compiler = new _Beans_Compiler( array() ); + $css = << function( $query_args ) { + parse_str( $query_args, $args ); + return $args; + }, + ] ); + + foreach ( $media_queries as $media_query ) { + $this->set_current_fragment( $compiler, 'http://foo.com/base.css?beans_compiler_media_query=' . $media_query ); + $this->assertSame( + "@media {$media_query} {\n{$css}\n}\n", + $compiler->add_content_media_query( $css ) + ); + } + } +} From 07dfd0869ba3b31ee33c1fc2d136c9ecee8bf4a1 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 29 Jan 2018 21:54:56 -0600 Subject: [PATCH 199/800] Refactored to combine query into one line. --- lib/api/compiler/class-beans-compiler.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 40ee142c..4817481e 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -454,8 +454,7 @@ public function add_content_media_query( $content ) { return $content; } - $parse_url = parse_url( $this->current_fragment ); - $query = beans_get( 'query', $parse_url ); + $query = parse_url( $this->current_fragment, PHP_URL_QUERY ); // Bail out if there are no query args or no media query. if ( empty( $query ) || false === stripos( $query, 'beans_compiler_media_query' ) ) { From e62f130c232564eb9876f790b73130471422bf04 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 08:53:03 -0600 Subject: [PATCH 200/800] Added format_content() tests. --- .../compiler/beans-compiler/formatContent.php | 216 +++++++++++++++++ .../compiler/beans-compiler/formatContent.php | 218 ++++++++++++++++++ 2 files changed, 434 insertions(+) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php new file mode 100644 index 00000000..36c15932 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -0,0 +1,216 @@ +mock_filesystem->getChild( 'fixtures' ); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) + ->getContent(); + $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); + $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); + } + + /** + * Test format_content() should return original content when the "type" is not + * a style or script (per the configuration). + */ + public function test_should_return_original_content_when_type_not_style_or_script() { + $compiler = new \_Beans_Compiler( array( + 'type' => 'foo', + ) ); + + $this->assertSame( $this->less, $compiler->format_content( $this->less ) ); + $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); + $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); + } + + /** + * Test format_content() should return compiled CSS (not minified) from the Less combined fragments. + */ + public function test_should_return_compiled_css() { + $compiler = new \_Beans_Compiler( array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ) ); + + update_option( 'beans_dev_mode', true ); + + $expected_css = <<assertSame( $expected_css, $compiler->format_content( $this->less ) ); + } + + /** + * Test format_content() should return minified, compiled CSS from the Less combined fragments. + */ + public function test_should_return_minified_compiled_css() { + $compiler = new \_Beans_Compiler( array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ) ); + + update_option( 'beans_dev_mode', false ); + + $this->assertContains( + 'body{background-color:#fff;color:#000;font-size:18px;', + $compiler->format_content( $this->less ) + ); + } + + /** + * Test format_content() should return the original jQuery when site is not in development mode, + * but "minify_js" is disabled. + */ + public function test_should_return_original_jquery_when_minify_js_disabled() { + $compiler = new \_Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + ) ); + + update_option( 'beans_dev_mode', false ); + + $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); + } + + /** + * Test format_content() should return the original jQuery when "minify_js" is enabled, + * but the site is in development mode. + */ + public function test_should_return_original_jquery_when_not_in_not_dev_mode() { + $compiler = new \_Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ) ); + + update_option( 'beans_dev_mode', true ); + + $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); + } + + /** + * Test format_content() should return minified jQuery. + */ + public function test_should_return_minified_jquery() { + $compiler = new \_Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ) ); + + update_option( 'beans_dev_mode', false ); + + $expected = <<assertSame( str_replace( '/$', '$', $expected ), $compiler->format_content( $this->jquery ) ); + } + + /** + * Test format_content() should return the original JavaScript when site is not in development mode, + * but "minify_js" is disabled. + */ + public function test_should_return_original_js_when_minify_js_disabled() { + $compiler = new \_Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + ) ); + + update_option( 'beans_dev_mode', false ); + + $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); + } + + /** + * Test format_content() should return the original JavaScript when "minify_js" is enabled, + * but the site is in development mode. + */ + public function test_should_return_original_js_when_not_in_not_dev_mode() { + $compiler = new \_Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ) ); + + update_option( 'beans_dev_mode', true ); + + $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); + } + + /** + * Test format_content() should return minified JavaScript. + */ + public function test_should_return_minified_javascript() { + $compiler = new \_Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ) ); + + update_option( 'beans_dev_mode', false ); + + $expected = <<assertSame( $expected, $compiler->format_content( $this->js ) ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php new file mode 100644 index 00000000..192b3808 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -0,0 +1,218 @@ +mock_filesystem->getChild( 'fixtures' ); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) + ->getContent(); + $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); + $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); + } + + /** + * Test format_content() should return original content when the "type" is not + * a style or script (per the configuration). + */ + public function test_should_return_original_content_when_type_not_style_or_script() { + $compiler = new _Beans_Compiler( array( + 'type' => 'foo', + ) ); + + $this->assertSame( $this->less, $compiler->format_content( $this->less ) ); + $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); + $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); + } + + /** + * Test format_content() should return compiled CSS (not minified) from the Less combined fragments. + */ + public function test_should_return_compiled_css() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ) ); + + $this->mock_dev_mode( true ); + + $expected_css = <<assertSame( $expected_css, $compiler->format_content( $this->less ) ); + } + + /** + * Test format_content() should return minified, compiled CSS from the Less combined fragments. + */ + public function test_should_return_minified_compiled_css() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ) ); + + $this->mock_dev_mode( false ); + + $this->assertContains( + 'body{background-color:#fff;color:#000;font-size:18px;', + $compiler->format_content( $this->less ) + ); + } + + /** + * Test format_content() should return the original jQuery when site is not in development mode, + * but "minify_js" is disabled. + */ + public function test_should_return_original_jquery_when_minify_js_disabled() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + ) ); + + $this->mock_dev_mode( false ); + + $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); + } + + /** + * Test format_content() should return the original jQuery when "minify_js" is enabled, + * but the site is in development mode. + */ + public function test_should_return_original_jquery_when_not_in_not_dev_mode() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ) ); + + $this->mock_dev_mode( true ); + + $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); + } + + /** + * Test format_content() should return minified jQuery. + */ + public function test_should_return_minified_jquery() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ) ); + + $this->mock_dev_mode( false ); + + $expected = <<assertSame( str_replace( '/$', '$', $expected ), $compiler->format_content( $this->jquery ) ); + } + + /** + * Test format_content() should return the original JavaScript when site is not in development mode, + * but "minify_js" is disabled. + */ + public function test_should_return_original_js_when_minify_js_disabled() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + ) ); + + $this->mock_dev_mode( false ); + + $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); + } + + /** + * Test format_content() should return the original JavaScript when "minify_js" is enabled, + * but the site is in development mode. + */ + public function test_should_return_original_js_when_not_in_not_dev_mode() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ) ); + + $this->mock_dev_mode( true ); + + $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); + } + + /** + * Test format_content() should return minified JavaScript. + */ + public function test_should_return_minified_javascript() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ) ); + + $this->mock_dev_mode( false ); + + $expected = <<assertSame( $expected, $compiler->format_content( $this->js ) ); + } +} From 39f5227ad830100ea688dc4a06db056e6940dd9e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 08:55:18 -0600 Subject: [PATCH 201/800] Added set_filename() tests. --- .../compiler/beans-compiler/setFilename.php | 150 ++++++++++++ .../compiler/beans-compiler/setFilename.php | 219 ++++++++++++++++++ 2 files changed, 369 insertions(+) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php new file mode 100644 index 00000000..0f33c63a --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php @@ -0,0 +1,150 @@ + 'test-script', + 'type' => 'script', + 'format' => false, + 'fragments' => array( $fragment ), + 'dependencies' => false, + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = $this->create_compiler( $config ); + + // Set up the mocks. + $this->set_dev_mode( true ); + $this->add_virtual_directory( $config['id'] ); + + // Set the filename. Test. + $compiler->set_filename(); + $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); + $this->assertSame( $expected, $compiler->config['filename'] ); + } + + /** + * Test set_filename() should return the hash created with the modification time from each of the fragments. + */ + public function test_should_exclude_external_fragments() { + $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); + $config = array( + 'id' => 'test-script', + 'type' => 'script', + 'format' => false, + 'fragments' => array( + $fragment, + 'http://foo.com/my-script.js', // Should skip this one. + ), + 'dependencies' => false, + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = $this->create_compiler( $config ); + + // Set up the mocks. + $this->set_dev_mode( true ); + $this->add_virtual_directory( $config['id'] ); + + // Test that we are in dev mode & the directory does exist. + $this->assertTrue( _beans_is_compiler_dev_mode() ); + $this->directoryExists( vfsStream::url( 'compiled/beans/compiler/test-script' ) ); + $this->assertTrue( is_dir( $compiler->dir ) ); + + // Set the filename. Test. + $compiler->set_filename(); + $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); + $this->assertSame( $expected, $compiler->config['filename'] ); + } + + /** + * Test set_filename() should remove the old compiled file. + */ + public function test_should_remove_old_file() { + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $config = array( + 'id' => 'test', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( $fragment ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = $this->create_compiler( $config ); + + // Set up the mocks. + $this->set_dev_mode( true ); + $this->add_virtual_directory( $config['id'] ); + + /** + * Set up the original "compiled" file. This is the file that should get removed during this + * test. We add the file into the virtual filesystem. + */ + $original_filemtime = filemtime( $fragment ); + $original_filename = $this->get_filename( $compiler, $config, $original_filemtime ); + vfsStream::newFile( $original_filename ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) + ->setContent( $this->get_compiled_jquery() ); + $original_hashes = explode( '-', pathinfo( $original_filename, PATHINFO_FILENAME ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); + + /** + * Next step is to modify the fragment, which will change it's modification time. Let's add an opening + * comment to the fragment's content and then set up the modified file for our tests. + */ + $file = $this->mock_filesystem->getChild( 'fixtures' )->getChild( 'jquery.test.js' ); + $file->write( "// changed \n" . $file->getContent() ); + $modified_filemtime = filemtime( $fragment ); + $modified_filename = $this->get_filename( $compiler, $config, $modified_filemtime ); + $modified_hashes = explode( '-', pathinfo( $modified_filename, PATHINFO_FILENAME ) ); + + /** + * We've now completed the set up process. Let's test that the original fragment has changed by + * testing that it is not equal to the modification time, filename, and hashes. + */ + $this->assertNotEquals( $modified_filemtime, $original_filemtime ); + $this->assertNotEquals( $modified_filename, $original_filename ); + $this->assertSame( $modified_hashes[0], $original_hashes[0] ); + $this->assertNotEquals( $modified_hashes[1], $original_hashes[1] ); + + /** + * Now let's run the compiler's set_filename() and test that: + * + * 1. The returned filename matches our modified filename. + * 2. The original "compiled" file was removed. + */ + $compiler->set_filename(); + $this->assertSame( $modified_filename, $compiler->config['filename'] ); + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php new file mode 100644 index 00000000..3606bbb0 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php @@ -0,0 +1,219 @@ + 'test-script', +// 'type' => 'script', +// 'format' => false, +// 'fragments' => array( $fragment ), +// 'dependencies' => false, +// 'in_footer' => true, +// 'minify_js' => true, +// 'version' => null, +// ); +// $compiler = new \_Beans_Compiler( $config ); +// +// // Test that we are not in development mode. +// $this->mock_dev_mode( false ); +// $this->assertFalse( _beans_is_compiler_dev_mode() ); +// +// // Set the filename. +// $compiler->set_filename(); +// $filename = $compiler->config['filename']; +// $pathinfo = pathinfo( $filename ); +// $expected = $compiler->hash( $config ); +// +// // Run the tests. +// $this->assertSame( 'js', $pathinfo['extension'] ); +// $this->assertEquals( 7, strlen( $pathinfo['filename'] ) ); +// $this->assertSame( $expected, $pathinfo['filename'] ); +// $this->assertSame( $expected . '.js', $filename ); +// } + +// /** +// * Test set_filename() should return the base hash when not in development mode. +// */ +// public function test_should_return_base_hash_when_dir_does_not_exist() { +// $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); +// $config = array( +// 'id' => 'test-script', +// 'type' => 'script', +// 'format' => false, +// 'fragments' => array( $fragment ), +// 'dependencies' => false, +// 'in_footer' => true, +// 'minify_js' => true, +// 'version' => null, +// ); +// $compiler = new \_Beans_Compiler( $config ); +// +// // Test that we are in dev mode & the cache directory does not exist. +// $this->mock_dev_mode( true ); +// $this->assertTrue( _beans_is_compiler_dev_mode() ); +// $this->assertFalse( is_dir( vfsStream::url( 'compiled/beans/compiler/test-script' ) ) ); +// $this->assertFalse( is_dir( $compiler->dir ) ); +// +// // Set the filename. +// $compiler->set_filename(); +// $filename = $compiler->config['filename']; +// $pathinfo = pathinfo( $filename ); +// $expected = $compiler->hash( $config ); +// +// // Run the tests. +// $this->assertSame( 'js', $pathinfo['extension'] ); +// $this->assertSame( $expected, $pathinfo['filename'] ); +// $this->assertSame( $expected . '.js', $filename ); +// } + + /** + * Test set_filename() should return the hash created with the modification time from each of the fragments. + */ + public function test_should_return_hash_created_with_fragments_filemtime() { + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $config = array( + 'id' => 'test-script', + 'type' => 'script', + 'format' => false, + 'fragments' => array( $fragment ), + 'dependencies' => false, + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = new \_Beans_Compiler( $config ); + + // Set up the mocks. + $this->mock_dev_mode( true ); + $this->add_virtual_directory( 'test-script' ); + + // Set the filename. Test. + $compiler->set_filename(); + $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); + $this->assertSame( $expected, $compiler->config['filename'] ); + } + + /** + * Test set_filename() should return the hash created with the modification time from each of the fragments. + */ + public function test_should_exclude_external_fragments() { + $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); + $config = array( + 'id' => 'test-script', + 'type' => 'script', + 'format' => false, + 'fragments' => array( + $fragment, + 'http://foo.com/my-script.js', // Should skip this one. + ), + 'dependencies' => false, + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = new \_Beans_Compiler( $config ); + + // Set up the mocks. + $this->mock_dev_mode( true ); + $this->add_virtual_directory( 'test-script' ); + + // Test that we are in dev mode & the directory does exist. + $this->assertTrue( _beans_is_compiler_dev_mode() ); + $this->directoryExists( vfsStream::url( 'compiled/beans/compiler/test-script' ) ); + $this->assertTrue( is_dir( $compiler->dir ) ); + + // Set the filename. Test. + $compiler->set_filename(); + $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); + $this->assertSame( $expected, $compiler->config['filename'] ); + } + + /** + * Test set_filename() should remove the old compiled file. + */ + public function test_should_remove_old_file() { + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $config = array( + 'id' => 'test', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( $fragment ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = new \_Beans_Compiler( $config ); + + // Set up the mocks. + $this->mock_dev_mode( true ); + $this->add_virtual_directory( $config['id'] ); + + /** + * Set up the original "compiled" file. This is the file that should get removed during this + * test. We add the file into the virtual filesystem. + */ + $original_filemtime = filemtime( $fragment ); + $original_filename = $this->get_filename( $compiler, $config, $original_filemtime ); + vfsStream::newFile( $original_filename ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) + ->setContent( $this->get_compiled_jquery() ); + $original_hashes = explode( '-', pathinfo( $original_filename, PATHINFO_FILENAME ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); + + /** + * Next step is to modify the fragment, which will change it's modification time. Let's add an opening + * comment to the fragment's content and then set up the modified file for our tests. + */ + $file = $this->mock_filesystem->getChild( 'fixtures' )->getChild( 'jquery.test.js' ); + $file->write( "// changed \n" . $file->getContent() ); + $modified_filemtime = filemtime( $fragment ); + $modified_filename = $this->get_filename( $compiler, $config, $modified_filemtime ); + $modified_hashes = explode( '-', pathinfo( $modified_filename, PATHINFO_FILENAME ) ); + + /** + * We've now completed the set up process. Let's test that the original fragment has changed by + * testing that it is not equal to the modification time, filename, and hashes. + */ + $this->assertNotEquals( $modified_filemtime, $original_filemtime ); + $this->assertNotEquals( $modified_filename, $original_filename ); + $this->assertSame( $modified_hashes[0], $original_hashes[0] ); + $this->assertNotEquals( $modified_hashes[1], $original_hashes[1] ); + + /** + * Now let's run the compiler's set_filename() and test that: + * + * 1. The returned filename matches our modified filename. + * 2. The original "compiled" file was removed. + */ + $compiler->set_filename(); + $this->assertSame( $modified_filename, $compiler->config['filename'] ); + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); + } +} From eaddcca7d49799257b7eb1fdcf45d9d13eca3356 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 09:07:30 -0600 Subject: [PATCH 202/800] Refactored & added tests for combine_fragments(). 1. Added tests. 2. Abstracted get content tasks into separate private method. 3. Instead of returning the formatted content, it now assigns it to a new property. Why? To reduce assignments within the object and to assist with testing. --- lib/api/compiler/class-beans-compiler.php | 69 ++-- .../beans-compiler/combineFragments.php | 310 ++++++++++++++++++ .../beans-compiler/combineFragments.php | 285 ++++++++++++++++ 3 files changed, 643 insertions(+), 21 deletions(-) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 4817481e..8a0a2f44 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -46,6 +46,13 @@ final class _Beans_Compiler { */ protected $current_fragment; + /** + * The compiled content. + * + * @var string + */ + protected $compiled_content; + /** * Create a new Compiler. * @@ -309,7 +316,7 @@ public function get_extension() { * * @since 1.0.0 * - * @return string + * @return void */ public function combine_fragments() { $content = ''; @@ -322,36 +329,56 @@ public function combine_fragments() { continue; } - // Set the current fragment used by other functions. - $this->current_fragment = $fragment; - - // Treat function. - if ( $this->is_function( $fragment ) ) { - $get_content = $this->get_function_content(); - } else { // Treat file. - $get_content = $this->get_internal_content(); - - // Try remote content if the internal content returned false. - if ( ! $get_content ) { - $get_content = $this->get_remote_content(); - } - } + $fragment_content = $this->get_content( $fragment ); // Stop here if no content or content is an html page. - if ( ! $get_content || preg_match( '#^\s*\<#', $get_content ) ) { + if ( ! $fragment_content || preg_match( '#^\s*\<#', $fragment_content ) ) { continue; } - // Add the content. + // Continue processing style. if ( 'style' === $this->config['type'] ) { - $get_content = $this->replace_css_url( $get_content ); - $get_content = $this->add_content_media_query( $get_content ); + $fragment_content = $this->replace_css_url( $fragment_content ); + $fragment_content = $this->add_content_media_query( $fragment_content ); } - $content .= ( $content ? "\n\n" : '' ) . $get_content; + // If there's content, start a new line. + if ( $content ) { + $content .= "\n\n"; + } + + $content .= $fragment_content; } - return $this->format_content( $content ); + $this->compiled_content = $this->format_content( $content ); + } + + /** + * Get the fragment's content. + * + * @since 1.5.0 + * + * @param string|callable $fragment The given fragment from which to get the content. + * + * @return bool|string + */ + private function get_content( $fragment ) { + // Set the current fragment used by other functions. + $this->current_fragment = $fragment; + + // If the fragment is callable, call it to get the content. + if ( $this->is_function( $fragment ) ) { + return $this->get_function_content(); + } + + $content = $this->get_internal_content(); + + // Try remote content if the internal content returned false. + if ( empty( $content ) ) { + $content = $this->get_remote_content(); + } + + return $content; } /** diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php new file mode 100644 index 00000000..98db693d --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php @@ -0,0 +1,310 @@ +mock_filesystem->getChild( 'fixtures' ); + $this->css = $fixtures->getChild( 'style.css' )->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) + ->getContent(); + $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); + $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); + } + + /** + * Test combine_fragments() should return empty string when there are no fragments to combine. + */ + public function test_should_return_empty_string_when_no_fragments() { + $compiler = new _Beans_Compiler( array() ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( '', $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return empty string when the fragment does not exist. + */ + public function test_should_return_empty_string_when_fragment_does_not_exist() { + $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; + $compiler = new _Beans_Compiler( array() ); + $this->set_current_fragment( $compiler, $fragment ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( '', $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should compile the Less fragments and return the compiled CSS. + */ + public function test_should_compiled_less_and_return_css() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + ) ); + + // Set up the test. + $this->set_up_wp_filesystem( $compiler ); + $this->set_dev_mode( true ); + + // Run the test. + $compiler->combine_fragments(); + $expected_css = <<assertSame( $expected_css, $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return minified, compiled Less from the Less combined fragments. + */ + public function test_should_return_minified_compiled_less() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + ) ); + + // Set up the test. + $this->set_up_wp_filesystem( $compiler ); + $this->set_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertContains( $this->get_compiled_less(), $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return the original jQuery when site is not in development mode, + * but "minify_js" is disabled. + */ + public function test_should_return_original_jquery_when_minify_js_disabled() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ), + 'dependencies' => array( 'jquery' ), + ) ); + + // Set up the test. + $this->set_up_wp_filesystem( $compiler ); + $this->set_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->jquery, $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return the original jQuery when "minify_js" is enabled, + * but the site is in development mode. + */ + public function test_should_return_original_jquery_when_not_in_not_dev_mode() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ), + 'dependencies' => array( 'jquery' ), + ) ); + + // Set up the test. + $this->set_up_wp_filesystem( $compiler ); + $this->set_dev_mode( true ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->jquery, $compiler->compiled_content ); + } + + /** + * Test format_content() should return minified jQuery. + */ + public function test_should_return_minified_jquery() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ), + 'dependencies' => array( 'jquery' ), + ) ); + + // Set up the test. + $this->set_up_wp_filesystem( $compiler ); + $this->set_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->get_compiled_jquery(), $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return the original JavaScript when site is not in development mode, + * but "minify_js" is disabled. + */ + public function test_should_return_original_js_when_minify_js_disabled() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ), + ) ); + + // Set up the test. + $this->set_up_wp_filesystem( $compiler ); + $this->set_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->js, $compiler->compiled_content ); + + // Clean up. + unset( $GLOBALS['wp_filesystem'] ); + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + } + + /** + * Test combine_fragments() should return the original JavaScript when "minify_js" is enabled, + * but the site is in development mode. + */ + public function test_should_return_original_js_when_not_in_not_dev_mode() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ), + ) ); + + // Set up the test. + $this->set_up_wp_filesystem( $compiler ); + $this->set_dev_mode( true ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->js, $compiler->compiled_content ); + + // Clean up. + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + } + + /** + * Test format_content() should return minified JavaScript. + */ + public function test_should_return_minified_javascript() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ), + ) ); + + // Set up the test. + $this->set_up_wp_filesystem( $compiler ); + $this->set_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->get_compiled_js(), $compiler->compiled_content ); + + // Clean up. + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + } + + /** + * Set the WP Filesystem. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * + * @return void + */ + private function set_up_wp_filesystem( $compiler ) { + add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + $compiler->filesystem(); + $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php new file mode 100644 index 00000000..673cd88f --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -0,0 +1,285 @@ +mock_filesystem->getChild( 'fixtures' ); + $this->css = $fixtures->getChild( 'style.css' )->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) + ->getContent(); + $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); + $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); + } + + /** + * Test combine_fragments() should return empty string when there are no fragments to combine. + */ + public function test_should_return_empty_string_when_no_fragments() { + $compiler = new _Beans_Compiler( array() ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( '', $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return empty string when the fragment does not exist. + */ + public function test_should_return_empty_string_when_fragment_does_not_exist() { + $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; + $compiler = new _Beans_Compiler( array() ); + $this->set_current_fragment( $compiler, $fragment ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( '', $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should compile the LESS fragments and return the compiled CSS. + */ + public function test_should_compiled_less_and_return_css() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + ) ); + + // Set up the mocks. + $this->mock_filesystem_for_fragments( $compiler ); + $this->mock_dev_mode( true ); + + // Run the test. + $compiler->combine_fragments(); + $expected_css = <<assertSame( $expected_css, $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return minified, compiled CSS from the Less combined fragments. + */ + public function test_should_return_minified_compiled_css() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + ) ); + + // Set up the mocks. + $this->mock_filesystem_for_fragments( $compiler ); + $this->mock_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertContains( 'body{background-color:#fff;color:#000;font-size:18px;', $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return the original jQuery when site is not in development mode, + * but "minify_js" is disabled. + */ + public function test_should_return_original_jquery_when_minify_js_disabled() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ), + 'dependencies' => array( 'jquery' ), + ) ); + + // Set up the mocks. + $this->mock_filesystem_for_fragments( $compiler ); + $this->mock_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->jquery, $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return the original jQuery when "minify_js" is enabled, + * but the site is in development mode. + */ + public function test_should_return_original_jquery_when_not_in_not_dev_mode() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ), + 'dependencies' => array( 'jquery' ), + ) ); + + // Set up the mocks. + $this->mock_filesystem_for_fragments( $compiler ); + $this->mock_dev_mode( true ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->jquery, $compiler->compiled_content ); + } + + /** + * Test format_content() should return minified jQuery. + */ + public function test_should_return_minified_jquery() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ), + 'dependencies' => array( 'jquery' ), + ) ); + + // Set up the mocks. + $this->mock_filesystem_for_fragments( $compiler ); + $this->mock_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->get_compiled_jquery(), $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return the original JavaScript when site is not in development mode, + * but "minify_js" is disabled. + */ + public function test_should_return_original_js_when_minify_js_disabled() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ), + ) ); + + // Set up the mocks. + $this->mock_filesystem_for_fragments( $compiler ); + $this->mock_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->js, $compiler->compiled_content ); + } + + /** + * Test combine_fragments() should return the original JavaScript when "minify_js" is enabled, + * but the site is in development mode. + */ + public function test_should_return_original_js_when_not_in_not_dev_mode() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ), + ) ); + + // Set up the mocks. + $this->mock_filesystem_for_fragments( $compiler ); + $this->mock_dev_mode( true ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->js, $compiler->compiled_content ); + } + + /** + * Test format_content() should return minified JavaScript. + */ + public function test_should_return_minified_javascript() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ), + ) ); + + // Set up the mocks. + $this->mock_filesystem_for_fragments( $compiler ); + $this->mock_dev_mode( false ); + + // Run the test. + $compiler->combine_fragments(); + $this->assertSame( $this->get_compiled_js(), $compiler->compiled_content ); + } +} From 8bffdd877b1c691de01b5e5839aa43c39318cf97 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 09:13:38 -0600 Subject: [PATCH 203/800] Refactored & added tests for cache_file(). 1. Moved combine_fragments task out of this method and put it into the run_compiler. Why? It is a separate task from caching the file. 2. Using the new compiled_content property. 3. Added tests. --- lib/api/compiler/class-beans-compiler.php | 6 +- .../api/compiler/beans-compiler/cacheFile.php | 199 +++++++++++++++++ .../api/compiler/beans-compiler/cacheFile.php | 203 ++++++++++++++++++ 3 files changed, 406 insertions(+), 2 deletions(-) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 8a0a2f44..1bec98ac 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -84,6 +84,7 @@ public function run_compiler() { if ( ! $this->cache_file_exist() ) { $this->filesystem(); $this->maybe_make_dir(); + $this->combine_fragments(); $this->cache_file(); } @@ -243,7 +244,6 @@ public function get_filename() { * @return bool */ public function cache_file() { - $content = $this->combine_fragments(); $filename = $this->get_filename(); if ( empty( $filename ) ) { @@ -251,7 +251,7 @@ public function cache_file() { } // Safe to access filesystem since we made sure it was set. - return $GLOBALS['wp_filesystem']->put_contents( $filename, $content, FS_CHMOD_FILE ); + return $GLOBALS['wp_filesystem']->put_contents( $filename, $this->compiled_content, FS_CHMOD_FILE ); } /** @@ -499,6 +499,8 @@ public function add_content_media_query( $content ) { /** * Formal CSS, LESS and JS content. * + * @since 1.0.0 + * * @param string $content Given content to process. * * @return string diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php new file mode 100644 index 00000000..5fcfd688 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php @@ -0,0 +1,199 @@ + 'test-script', + 'type' => 'script', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + ) ); + + // Set up the tests. + $this->set_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler ); + + // Run the tests. + $this->assertFalse( $compiler->cache_file() ); + $this->assertFileNotExists( $compiler->get_filename() ); + } + + /** + * Test cache_file() should create the compiled jQuery file. + */ + public function test_should_create_compiled_jquery_file() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test-jquery', + 'type' => 'script', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + ) ); + + // Set up the tests. + $this->set_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler, true ); + + // Run the tests. + $this->assertTrue( $compiler->cache_file() ); + $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should create the compiled JavaScript file. + */ + public function test_should_create_compiled_javascript_file() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test-js', + 'type' => 'script', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ), + 'in_footer' => true, + 'minify_js' => true, + ) ); + + // Set up the tests. + $this->set_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler, true ); + + // Run the tests. + $this->assertTrue( $compiler->cache_file() ); + $this->assertSame( $this->get_compiled_js(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should create the compiled CSS file. + */ + public function test_should_create_compiled_css_file() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test-css', + 'type' => 'style', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/style.css' ) ), + ) ); + + // Set up the tests. + $this->set_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler, true ); + + // Run the tests. + $this->assertTrue( $compiler->cache_file() ); + $this->assertSame( $this->get_compiled_css(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should create the compiled LESS file. + */ + public function test_should_create_compiled_less_file() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test-css', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + ) ); + + // Set up the tests. + $this->set_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler, true ); + + // Run the tests. + $this->assertTrue( $compiler->cache_file() ); + $this->assertSame( $this->get_compiled_less(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Mock creating the file. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * @param bool $should_create Optional. When true, mock creating the file. Default is false. + * + * @return void + */ + private function mock_creating_file( $compiler, $should_create = false ) { + $GLOBALS['wp_filesystem']->shouldReceive( 'put_contents' ) + ->once() + ->andReturn( $should_create ); + + if ( ! $should_create ) { + return; + } + + vfsStream::newFile( $compiler->config['filename'] ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $compiler->config['id'] ) ) + ->setContent( $compiler->compiled_content ); + } + + /** + * Get the file's content. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * + * @return string + */ + private function get_cached_file_contents( $compiler ) { + return $this->mock_filesystem + ->getChild( 'beans/compiler/' . $compiler->config['id'] ) + ->getChild( $compiler->config['filename'] ) + ->getcontent(); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php new file mode 100644 index 00000000..b420a23b --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php @@ -0,0 +1,203 @@ + 'test-script', + 'type' => 'script', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + ) ); + + // Set up the tests. + $this->mock_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler ); + + // Run the tests. + $this->assertFalse( $compiler->cache_file() ); + $this->assertFileNotExists( $compiler->get_filename() ); + } + + /** + * Test cache_file() should create the compiled jQuery file. + */ + public function test_should_create_compiled_jquery_file() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test-jquery', + 'type' => 'script', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + ) ); + + // Set up the tests. + $this->mock_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler, true ); + + // Run the tests. + $this->assertTrue( $compiler->cache_file() ); + $this->assertFileExists( $compiler->get_filename() ); + $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should create the compiled JavaScript file. + */ + public function test_should_create_compiled_javascript_file() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test-js', + 'type' => 'script', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ), + 'in_footer' => true, + 'minify_js' => true, + ) ); + + // Set up the tests. + $this->mock_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler, true ); + + // Run the tests. + $this->assertTrue( $compiler->cache_file() ); + $this->assertFileExists( $compiler->get_filename() ); + $this->assertSame( $this->get_compiled_js(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should create the compiled CSS file. + */ + public function test_should_create_compiled_css_file() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test-css', + 'type' => 'style', + 'format' => 'css', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/style.css' ) ), + ) ); + + // Set up the tests. + $this->mock_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler, true ); + + // Run the tests. + $this->assertTrue( $compiler->cache_file() ); + $this->assertFileExists( $compiler->get_filename() ); + $this->assertSame( $this->get_compiled_css(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should create the compiled LESS file. + */ + public function test_should_create_compiled_less_file() { + $compiler = new _Beans_Compiler( array( + 'id' => 'test-css', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + ) ); + + // Set up the tests. + $this->mock_dev_mode( false ); + $this->mock_filesystem_for_fragments( $compiler ); + $this->add_virtual_directory( $compiler->config['id'] ); + $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + $this->mock_creating_file( $compiler, true ); + + // Run the tests. + $this->assertTrue( $compiler->cache_file() ); + $this->assertFileExists( $compiler->get_filename() ); + $this->assertSame( $this->get_compiled_less(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Mock creating the file. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * @param bool $should_create Optional. When true, mock creating the file. Default is false. + * + * @return void + */ + private function mock_creating_file( $compiler, $should_create = false ) { + $GLOBALS['wp_filesystem']->shouldReceive( 'put_contents' ) + ->once() + ->andReturn( $should_create ); + + if ( ! $should_create ) { + return; + } + + vfsStream::newFile( $compiler->config['filename'] ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $compiler->config['id'] ) ) + ->setContent( $compiler->compiled_content ); + } + + /** + * Get the file's content. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * + * @return string + */ + private function get_cached_file_contents( $compiler ) { + return $this->mock_filesystem + ->getChild( 'beans/compiler/' . $compiler->config['id'] ) + ->getChild( $compiler->config['filename'] ) + ->getcontent(); + } +} From bf632f80b9427ba91eeaad87c3de0da8786a8601 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 09:17:55 -0600 Subject: [PATCH 204/800] Added run_compiler() tests. Fixed enqueue. 1. Added tests for run_compiler(). 2. Fixed "depedencies" key in the enqueue method. --- lib/api/compiler/class-beans-compiler.php | 15 +- .../compiler/beans-compiler/runCompiler.php | 394 +++++++++++++++++ .../compiler/beans-compiler/runCompiler.php | 396 ++++++++++++++++++ 3 files changed, 803 insertions(+), 2 deletions(-) create mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php create mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 1bec98ac..08092fad 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -265,12 +265,23 @@ public function enqueue_file() { // Enqueue css. if ( 'style' === $this->config['type'] ) { - return wp_enqueue_style( $this->config['id'], $this->get_url(), $this->config['depedencies'], $this->config['version'] ); + return wp_enqueue_style( + $this->config['id'], + $this->get_url(), + $this->config['dependencies'], + $this->config['version'] + ); } // Enqueue js file. if ( 'script' === $this->config['type'] ) { - return wp_enqueue_script( $this->config['id'], $this->get_url(), $this->config['depedencies'], $this->config['version'], $this->config['in_footer'] ); + return wp_enqueue_script( + $this->config['id'], + $this->get_url(), + $this->config['dependencies'], + $this->config['version'], + $this->config['in_footer'] + ); } return false; diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php new file mode 100644 index 00000000..a6f54a71 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -0,0 +1,394 @@ + array(), + 'less' => array(), + 'js' => array(), + ); + + $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); + $this->css = $fixtures->getChild( 'style.css' )->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) + ->getContent(); + $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); + $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); + } + + /** + * Test cache_file() should enqueue the existing cached file when no modifications (no fragments + * have changed to warrant re-compiling the file). + */ + public function test_should_enqueue_existing_cached_file_when_no_modifications() { + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $config = array( + 'id' => 'test-jquery', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => '1.5.0', + ); + $compiler = $this->create_compiler( $config ); + + // Store the cached file into the virtual filesystem. + $this->add_virtual_directory( $config['id'] ); + $original_filename = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); + $original_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $original_filename ); + vfsStream::newFile( $original_filename ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) + ->setContent( $this->get_compiled_jquery() ); + $this->assertFileExists( $original_file ); + + // Set up the mocks. + $this->set_up_mocks( $compiler, $config, $original_file ); + + // Run the compiler. + $compiler->run_compiler(); + $actual_filename = $compiler->get_filename(); + + // Check that the "compiled" filename did not change. + $this->assertSame( $original_file, $actual_filename ); + + // Check that the file still exists. + $this->assertFileExists( $actual_filename ); + } + + /** + * Test cache_file() should recompile when a fragment(s) changes. When this happens, the existing cached file + * is removed and the new one is stored in the filesystem. + */ + public function test_should_recompile_when_fragments_change() { + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $config = array( + 'id' => 'test-script', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( $fragment ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = $this->create_compiler( $config ); + + /** + * Set up the original "compiled" file. This is the file that should get removed during this + * test. We add the file into the virtual filesystem. + */ + $this->add_virtual_directory( $config['id'] ); + $original_filemtime = filemtime( $fragment ); + $original_filename = $this->get_filename( $compiler, $config, $original_filemtime ); + $original_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $original_filename ); + vfsStream::newFile( $original_filename ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) + ->setContent( $this->get_compiled_jquery() ); + $original_hashes = explode( '-', pathinfo( $original_filename, PATHINFO_FILENAME ) ); + $this->assertFileExists( $original_file ); + + /** + * Next step is to modify the fragment, which will change it's modification time. Let's add an opening + * comment to the fragment's content and then set up the modified file for our tests. + */ + $compiled_content = $this->get_compiled_jquery() . "console.log('Beans rocks!');"; + $this->mock_filesystem->getChild( 'fixtures' ) + ->getChild( 'jquery.test.js' ) + ->write( $this->jquery . "\n console.log( 'Beans rocks!' ); \n" ); + $modified_filemtime = filemtime( $fragment ); + $modified_filename = $this->get_filename( $compiler, $config, $modified_filemtime ); + $modified_hashes = explode( '-', pathinfo( $modified_filename, PATHINFO_FILENAME ) ); + $modified_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $modified_filename ); + $this->assertFileNotExists( $modified_file ); + + /** + * We've now completed the set up process. Let's test that the original fragment has changed by + * testing that it is not equal to the modification time, filename, and hashes. + */ + $this->assertNotEquals( $modified_filemtime, $original_filemtime ); + $this->assertNotEquals( $modified_filename, $original_filename ); + $this->assertSame( $modified_hashes[0], $original_hashes[0] ); + $this->assertNotEquals( $modified_hashes[1], $original_hashes[1] ); + + // Set up the mocks. + $this->set_up_mocks( $compiler, $config, $modified_file, $compiled_content ); + + // Run the compiler. + $compiler->run_compiler(); + $actual_filename = $compiler->get_filename(); + + // Check that the "compiled" filename is different. + $this->assertNotEquals( $original_file, $actual_filename ); + $this->assertSame( $modified_file, $actual_filename ); + + // Check that the original cached file was removed. + $this->assertFileNotExists( $original_file ); + + // Check that a new file was cached. + $this->assertFileExists( $modified_file ); + $this->assertFileExists( $actual_filename ); + } + + /** + * Test cache_file() should compile jQuery, saving it to the virtual filesystem and enqueuing it WordPress. + */ + public function test_should_compile_jquery() { + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $config = array( + 'id' => 'test-jquery', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( $fragment ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = $this->create_compiler( $config ); + + // Set up the mocks. + $this->add_virtual_directory( $config['id'] ); + $expected_file = vfsStream::url( + 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) + ); + + $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_jquery() ); + + // Run the compiler. Test. + $compiler->run_compiler(); + $actual_filename = $compiler->get_filename(); + $this->assertFileExists( $actual_filename ); + $this->assertSame( $expected_file, $actual_filename ); + $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should compile JavaScript, saving it to the virtual filesystem and enqueuing it WordPress. + */ + public function test_should_compile_js() { + $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); + $config = array( + 'id' => 'test-js', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( $fragment ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = $this->create_compiler( $config ); + + // Set up the mocks. + $this->add_virtual_directory( $config['id'] ); + $expected_file = vfsStream::url( + 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) + ); + $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_js() ); + + // Run the compiler. Test. + $compiler->run_compiler(); + $actual_filename = $compiler->get_filename(); + $this->assertFileExists( $actual_filename ); + $this->assertSame( $expected_file, $actual_filename ); + $this->assertSame( $this->get_compiled_js(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should compile CSS, saving it to the virtual filesystem and enqueuing it WordPress. + */ + public function test_should_compile_css() { + $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); + $config = array( + 'id' => 'test-css', + 'type' => 'style', + 'format' => 'css', + 'fragments' => array( $fragment ), + 'dependencies' => false, + 'in_footer' => false, + 'minify_js' => false, + 'version' => '1.5.0', + ); + $compiler = $this->create_compiler( $config ); + + // Set up the mocks. + $this->add_virtual_directory( $config['id'] ); + $expected_file = vfsStream::url( + 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) + ); + $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_css() ); + + // Run the compiler. Test. + $compiler->run_compiler(); + $actual_filename = $compiler->get_filename(); + $this->assertFileExists( $actual_filename ); + $this->assertSame( $expected_file, $actual_filename ); + $this->assertSame( $this->get_compiled_css(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should compile Less, saving it to the virtual filesystem and enqueuing it WordPress. + */ + public function test_should_compile_less() { + $config = array( + 'id' => 'test-css', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + 'dependencies' => false, + 'in_footer' => false, + 'minify_js' => false, + 'version' => '1.5.0', + ); + $compiler = $this->create_compiler( $config ); + + // Set up the mocks. + $this->add_virtual_directory( $config['id'] ); + $expected_file = vfsStream::url( + 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config ) + ); + $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_less() ); + + // Run the compiler. Test. + $compiler->run_compiler(); + $actual_filename = $compiler->get_filename(); + $this->assertFileExists( $actual_filename ); + $this->assertSame( $expected_file, $actual_filename ); + $this->assertSame( $this->get_compiled_less(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Set up the mocks for this test. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * @param array $config The compiler's configuration. + * @param string $file The absolute path to the compiled file. + * @param string $content Optional. The expected compiled content. + * @param bool $in_dev_mode Optional. When true, turns on dev mode. Default is false. + * + * @return void + */ + private function set_up_mocks( $compiler, $config, $file, $content = '', $in_dev_mode = false ) { + $this->set_dev_mode( $in_dev_mode ); + + if ( empty( $content ) ) { + return; + } + + // Set the WP Filesystem. + $this->mock_filesystem_for_fragments( $compiler, 1, 'WP_Filesystem_Direct' ); + $GLOBALS['wp_filesystem']->shouldReceive( 'put_contents' ) + ->once() + ->with( $file, $content, FS_CHMOD_FILE ) + ->andReturnUsing( function( $file, $content ) use ( $compiler, $config ) { + $pathinfo = pathinfo( $file ); + + // Add the new file into the virtual filesystem. + vfsStream::newFile( $pathinfo['basename'] ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) + ->setContent( $content ); + + return true; + } ); + } + + /** + * Get the file's content. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * + * @return string + */ + private function get_cached_file_contents( $compiler ) { + return $this->mock_filesystem + ->getChild( 'beans/compiler/' . $compiler->config['id'] ) + ->getChild( $compiler->config['filename'] ) + ->getContent(); + } + + /** + * Get the filename from the compiler. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * + * @return string + */ + protected function get_actual_filename( $compiler ) { + $path = $compiler->get_filename(); + + if ( substr( $path, 0, 6 ) === 'vfs://' ) { + return $path; + } + + return str_replace( 'vfs:/', 'vfs://', $path ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php new file mode 100644 index 00000000..b599fe60 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -0,0 +1,396 @@ + array(), + 'less' => array(), + 'js' => array(), + ); + + $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); + $this->css = $fixtures->getChild( 'style.css' )->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) + ->getContent(); + $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); + $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); + } + + /** + * Test cache_file() should enqueue the existing cached file when no modifications (no fragments + * have changed to warrant re-compiling the file). + */ + public function test_should_enqueue_existing_cached_file_when_no_modifications() { + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $config = array( + 'id' => 'test-jquery', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => '1.5.0', + ); + $compiler = new _Beans_Compiler( $config ); + + // Store the cached file into the virtual filesystem. + $this->add_virtual_directory( $config['id'] ); + $original_filename = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); + $original_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $original_filename ); + vfsStream::newFile( $original_filename ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) + ->setContent( $this->get_compiled_jquery() ); + $this->assertFileExists( $original_file ); + + // Set up the mocks. + $this->set_up_mocks( $compiler, $config, $original_file ); + + // Run the compiler. + $compiler->run_compiler(); + + // Check that the "compiled" filename did not change. + $this->assertSame( $original_file, $compiler->get_filename() ); + + // Check that the file still exists. + $this->assertFileExists( $compiler->get_filename() ); + } + + /** + * Test cache_file() should recompile when a fragment(s) changes. When this happens, the existing cached file + * is removed and the new one is stored in the filesystem. + */ + public function test_should_recompile_when_fragments_change() { + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $config = array( + 'id' => 'test-script', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( $fragment ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = new _Beans_Compiler( $config ); + + /** + * Set up the original "compiled" file. This is the file that should get removed during this + * test. We add the file into the virtual filesystem. + */ + $this->add_virtual_directory( $config['id'] ); + $original_filemtime = filemtime( $fragment ); + $original_filename = $this->get_filename( $compiler, $config, $original_filemtime ); + $original_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $original_filename ); + vfsStream::newFile( $original_filename ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) + ->setContent( $this->get_compiled_jquery() ); + $original_hashes = explode( '-', pathinfo( $original_filename, PATHINFO_FILENAME ) ); + $this->assertFileExists( $original_file ); + + /** + * Next step is to modify the fragment, which will change it's modification time. Let's add an opening + * comment to the fragment's content and then set up the modified file for our tests. + */ + $compiled_content = $this->get_compiled_jquery() . "console.log('Beans rocks!');"; + $this->mock_filesystem->getChild( 'fixtures' ) + ->getChild( 'jquery.test.js' ) + ->write( $this->jquery . "\n console.log( 'Beans rocks!' ); \n" ); + $modified_filemtime = filemtime( $fragment ); + $modified_filename = $this->get_filename( $compiler, $config, $modified_filemtime ); + $modified_hashes = explode( '-', pathinfo( $modified_filename, PATHINFO_FILENAME ) ); + $modified_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $modified_filename ); + $this->assertFileNotExists( $modified_file ); + + /** + * We've now completed the set up process. Let's test that the original fragment has changed by + * testing that it is not equal to the modification time, filename, and hashes. + */ + $this->assertNotEquals( $modified_filemtime, $original_filemtime ); + $this->assertNotEquals( $modified_filename, $original_filename ); + $this->assertSame( $modified_hashes[0], $original_hashes[0] ); + $this->assertNotEquals( $modified_hashes[1], $original_hashes[1] ); + + // Set up the mocks. + $this->set_up_mocks( $compiler, $config, $modified_file, $compiled_content ); + + // Run the compiler. + $compiler->run_compiler(); + + // Check that the "compiled" filename is different. + $this->assertNotEquals( $compiler->get_filename(), $original_file ); + $this->assertSame( $modified_file, $compiler->get_filename() ); + + // Check that the original cached file was removed. + $this->assertFileNotExists( $original_file ); + + // Check that a new file was cached. + $this->assertFileExists( $modified_file ); + $this->assertFileExists( $compiler->get_filename() ); + } + + /** + * Test cache_file() should compile jQuery, saving it to the virtual filesystem and enqueuing it WordPress. + */ + public function test_should_compile_jquery() { + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $config = array( + 'id' => 'test-jquery', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( $fragment ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = new _Beans_Compiler( $config ); + + // Set up the mocks. + $this->add_virtual_directory( $config['id'] ); + $expected_file = vfsStream::url( + 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) + ); + + $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_jquery() ); + + // Run the compiler. Test. + $compiler->run_compiler(); + $this->assertFileExists( $compiler->get_filename() ); + $this->assertSame( $expected_file, $compiler->get_filename() ); + $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should compile JavaScript, saving it to the virtual filesystem and enqueuing it WordPress. + */ + public function test_should_compile_js() { + $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); + $config = array( + 'id' => 'test-js', + 'type' => 'script', + 'format' => 'js', + 'fragments' => array( $fragment ), + 'dependencies' => array( 'jquery' ), + 'in_footer' => true, + 'minify_js' => true, + 'version' => null, + ); + $compiler = new _Beans_Compiler( $config ); + + // Set up the mocks. + $this->add_virtual_directory( $config['id'] ); + $expected_file = vfsStream::url( + 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) + ); + $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_js() ); + + // Run the compiler. Test. + $compiler->run_compiler(); + $this->assertFileExists( $compiler->get_filename() ); + $this->assertSame( $expected_file, $compiler->get_filename() ); + $this->assertSame( $this->get_compiled_js(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should compile CSS, saving it to the virtual filesystem and enqueuing it WordPress. + */ + public function test_should_compile_css() { + $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); + $config = array( + 'id' => 'test-css', + 'type' => 'style', + 'format' => 'css', + 'fragments' => array( $fragment ), + 'dependencies' => false, + 'in_footer' => false, + 'minify_js' => false, + 'version' => '1.5.0', + ); + $compiler = new _Beans_Compiler( $config ); + + // Set up the mocks. + $this->add_virtual_directory( $config['id'] ); + $expected_file = vfsStream::url( + 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) + ); + $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_css() ); + + // Run the compiler. Test. + $compiler->run_compiler(); + $this->assertFileExists( $compiler->get_filename() ); + $this->assertSame( $expected_file, $compiler->get_filename() ); + $this->assertSame( $this->get_compiled_css(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Test cache_file() should compile Less, saving it to the virtual filesystem and enqueuing it WordPress. + */ + public function test_should_compile_less() { + $config = array( + 'id' => 'test-css', + 'type' => 'style', + 'format' => 'less', + 'fragments' => array( + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ), + 'dependencies' => false, + 'in_footer' => false, + 'minify_js' => false, + 'version' => '1.5.0', + ); + $compiler = new _Beans_Compiler( $config ); + + // Set up the mocks. + $this->add_virtual_directory( $config['id'] ); + $expected_file = vfsStream::url( + 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config ) + ); + $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_less() ); + + // Run the compiler. Test. + $compiler->run_compiler(); + $this->assertFileExists( $compiler->get_filename() ); + $this->assertSame( $expected_file, $compiler->get_filename() ); + $this->assertSame( $this->get_compiled_less(), $this->get_cached_file_contents( $compiler ) ); + } + + /** + * Set up the mocks for this test. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * @param array $config The compiler's configuration. + * @param string $file The absolute path to the compiled file. + * @param string $content Optional. The expected compiled content. + * @param bool $in_dev_mode Optional. When true, turns on dev mode. Default is false. + * + * @return void + */ + private function set_up_mocks( $compiler, $config, $file, $content = '', $in_dev_mode = false ) { + $this->mock_dev_mode( $in_dev_mode ); + Functions\when( 'is_ssl' )->justReturn( false ); + + if ( 'script' === $config['type'] ) { + Functions\expect( 'wp_enqueue_script' ) + ->once() + ->with( + $config['id'], + str_replace( 'vfs://compiled/', $this->compiled_url, $file ), + $config['dependencies'], + $config['version'], + $config['in_footer'] + ) + ->andReturnNull(); + } + + if ( 'style' === $config['type'] ) { + Functions\expect( 'wp_enqueue_style' ) + ->once() + ->with( + $config['id'], + str_replace( 'vfs://compiled/', $this->compiled_url, $file ), + $config['dependencies'], + $config['version'] + ) + ->andReturnNull(); + } + + if ( empty( $content ) ) { + return; + } + + $this->mock_filesystem_for_fragments( $compiler ); + + $GLOBALS['wp_filesystem']->shouldReceive( 'put_contents' ) + ->once() + ->with( $file, $content, FS_CHMOD_FILE ) + ->andReturnUsing( function( $file, $content ) use ( $compiler, $config ) { + $pathinfo = pathinfo( $file ); + + // Add the new file into the virtual filesystem. + vfsStream::newFile( $pathinfo['basename'] ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) + ->setContent( $content ); + + return true; + } ); + } + + /** + * Get the file's content. + * + * @since 1.5.0 + * + * @param _Beans_Compiler $compiler Instance of the compiler. + * + * @return string + */ + private function get_cached_file_contents( $compiler ) { + return $this->mock_filesystem + ->getChild( 'beans/compiler/' . $compiler->config['id'] ) + ->getChild( $compiler->config['filename'] ) + ->getContent(); + } +} From 0ba81d354cc461dc2602203119707a0b1dececfc Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 09:37:50 -0600 Subject: [PATCH 205/800] Changed enqueue_file() access to private. There should not be a need to provide external access to this method, as it is the last step in the run compiler process. It is an internal task. --- lib/api/compiler/class-beans-compiler.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 08092fad..23c721c6 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -258,10 +258,11 @@ public function cache_file() { * Enqueue cached file. * * @since 1.0.0 + * @since 1.5.0 Changed access to private. * * @return void|bool */ - public function enqueue_file() { + private function enqueue_file() { // Enqueue css. if ( 'style' === $this->config['type'] ) { From bf12d17ba2e47658929487acb152fcddfc6c0121 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 09:46:11 -0600 Subject: [PATCH 206/800] Removed filename from config. The configuration property holds the initial runtime configuration parameters. It is used for the hashing the filename. We want to retain its state. Moved filename to a separate property. --- lib/api/compiler/class-beans-compiler.php | 18 ++++++++++++------ .../api/compiler/beans-compiler/cacheFile.php | 4 ++-- .../compiler/beans-compiler/runCompiler.php | 2 +- .../compiler/beans-compiler/setFilename.php | 6 +++--- .../api/compiler/beans-compiler/cacheFile.php | 4 ++-- .../compiler/beans-compiler/cacheFileExist.php | 6 +++--- .../compiler/beans-compiler/runCompiler.php | 2 +- .../compiler/beans-compiler/setFilename.php | 10 +++++----- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 23c721c6..678273ee 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -53,6 +53,13 @@ final class _Beans_Compiler { */ protected $compiled_content; + /** + * Compiled content's filename. + * + * @var string + */ + protected $filename; + /** * Create a new Compiler. * @@ -179,7 +186,7 @@ public function set_fragments() { * Set the filename for the compiled asset. * * @since 1.0.0 - * @since 1.5.0 Renamed method. + * @since 1.5.0 Renamed method. Changed storage location to $filename property. * * @return void */ @@ -187,8 +194,7 @@ public function set_filename() { $hash = $this->hash( $this->config ); $fragments_filemtime = $this->get_fragments_filemtime(); $hash = $this->get_new_hash( $hash, $fragments_filemtime ); - - $this->config['filename'] = $hash . '.' . $this->get_extension(); + $this->filename = $hash . '.' . $this->get_extension(); } /** @@ -229,8 +235,8 @@ public function cache_file_exist() { * @return string */ public function get_filename() { - if ( isset( $this->config['filename'] ) ) { - return $this->dir . '/' . $this->config['filename']; + if ( isset( $this->filename ) ) { + return $this->dir . '/' . $this->filename; } return ''; @@ -296,7 +302,7 @@ private function enqueue_file() { * @return string */ public function get_url() { - $url = trailingslashit( $this->url ) . beans_get( 'filename', $this->config ); + $url = trailingslashit( $this->url ) . $this->filename; if ( is_ssl() ) { $url = str_replace( 'http://', 'https://', $url ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php index 5fcfd688..0fb30615 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php @@ -176,7 +176,7 @@ private function mock_creating_file( $compiler, $should_create = false ) { return; } - vfsStream::newFile( $compiler->config['filename'] ) + vfsStream::newFile( $compiler->filename ) ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $compiler->config['id'] ) ) ->setContent( $compiler->compiled_content ); } @@ -193,7 +193,7 @@ private function mock_creating_file( $compiler, $should_create = false ) { private function get_cached_file_contents( $compiler ) { return $this->mock_filesystem ->getChild( 'beans/compiler/' . $compiler->config['id'] ) - ->getChild( $compiler->config['filename'] ) + ->getChild( $compiler->filename ) ->getcontent(); } } diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php index a6f54a71..8ae14730 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -369,7 +369,7 @@ private function set_up_mocks( $compiler, $config, $file, $content = '', $in_dev private function get_cached_file_contents( $compiler ) { return $this->mock_filesystem ->getChild( 'beans/compiler/' . $compiler->config['id'] ) - ->getChild( $compiler->config['filename'] ) + ->getChild( $compiler->filename ) ->getContent(); } diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php index 0f33c63a..06e91dd4 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php @@ -47,7 +47,7 @@ public function test_should_return_hash_created_with_fragments_filemtime() { // Set the filename. Test. $compiler->set_filename(); $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); - $this->assertSame( $expected, $compiler->config['filename'] ); + $this->assertSame( $expected, $compiler->filename ); } /** @@ -82,7 +82,7 @@ public function test_should_exclude_external_fragments() { // Set the filename. Test. $compiler->set_filename(); $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); - $this->assertSame( $expected, $compiler->config['filename'] ); + $this->assertSame( $expected, $compiler->filename ); } /** @@ -144,7 +144,7 @@ public function test_should_remove_old_file() { * 2. The original "compiled" file was removed. */ $compiler->set_filename(); - $this->assertSame( $modified_filename, $compiler->config['filename'] ); + $this->assertSame( $modified_filename, $compiler->filename ); $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); } } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php index b420a23b..c4da4ead 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php @@ -180,7 +180,7 @@ private function mock_creating_file( $compiler, $should_create = false ) { return; } - vfsStream::newFile( $compiler->config['filename'] ) + vfsStream::newFile( $compiler->filename ) ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $compiler->config['id'] ) ) ->setContent( $compiler->compiled_content ); } @@ -197,7 +197,7 @@ private function mock_creating_file( $compiler, $should_create = false ) { private function get_cached_file_contents( $compiler ) { return $this->mock_filesystem ->getChild( 'beans/compiler/' . $compiler->config['id'] ) - ->getChild( $compiler->config['filename'] ) + ->getChild( $compiler->filename ) ->getcontent(); } } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php index 4e700563..14633ab9 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php @@ -60,7 +60,7 @@ public function test_should_return_false_when_file_does_not_exist() { $compiler->set_filename(); // Check that the cached file does not exist in the virtual filesystem. - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $compiler->config['filename'] ) ); + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $compiler->filename ) ); // Run cache_file_exist(). $this->assertFalse( $compiler->cache_file_exist() ); @@ -83,11 +83,11 @@ public function test_should_return_true_when_file_exists() { // Add the cached file to the virtual filesystem. $compiler->set_filename(); - vfsStream::newFile( $compiler->config['filename'] ) + vfsStream::newFile( $compiler->filename ) ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/test-script' ) ); // Check that the filename exists. - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $compiler->config['filename'] ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $compiler->filename ) ); // Run cache_file_exist(). $this->assertTrue( $compiler->cache_file_exist() ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index b599fe60..263ebfb2 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -390,7 +390,7 @@ private function set_up_mocks( $compiler, $config, $file, $content = '', $in_dev private function get_cached_file_contents( $compiler ) { return $this->mock_filesystem ->getChild( 'beans/compiler/' . $compiler->config['id'] ) - ->getChild( $compiler->config['filename'] ) + ->getChild( $compiler->filename ) ->getContent(); } } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php index 3606bbb0..da5879d8 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php @@ -46,7 +46,7 @@ class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { // // // Set the filename. // $compiler->set_filename(); -// $filename = $compiler->config['filename']; +// $filename = $compiler->filename; // $pathinfo = pathinfo( $filename ); // $expected = $compiler->hash( $config ); // @@ -82,7 +82,7 @@ class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { // // // Set the filename. // $compiler->set_filename(); -// $filename = $compiler->config['filename']; +// $filename = $compiler->filename; // $pathinfo = pathinfo( $filename ); // $expected = $compiler->hash( $config ); // @@ -116,7 +116,7 @@ public function test_should_return_hash_created_with_fragments_filemtime() { // Set the filename. Test. $compiler->set_filename(); $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); - $this->assertSame( $expected, $compiler->config['filename'] ); + $this->assertSame( $expected, $compiler->filename ); } /** @@ -151,7 +151,7 @@ public function test_should_exclude_external_fragments() { // Set the filename. Test. $compiler->set_filename(); $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); - $this->assertSame( $expected, $compiler->config['filename'] ); + $this->assertSame( $expected, $compiler->filename ); } /** @@ -213,7 +213,7 @@ public function test_should_remove_old_file() { * 2. The original "compiled" file was removed. */ $compiler->set_filename(); - $this->assertSame( $modified_filename, $compiler->config['filename'] ); + $this->assertSame( $modified_filename, $compiler->filename ); $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); } } From 9704ce75364107d47b7eb3dd0a07713a7dc1fef0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 09:52:17 -0600 Subject: [PATCH 207/800] Made tests wpcs compliant. --- .../compiler/beans-compiler/replaceCssUrl.php | 2 +- .../includes/class-compiler-test-case.php | 5 +- .../compiler/beans-compiler/replaceCssUrl.php | 4 +- .../compiler/beans-compiler/runCompiler.php | 6 +- .../compiler/beans-compiler/setFilename.php | 69 ------------------- .../includes/class-compiler-test-case.php | 5 +- 6 files changed, 10 insertions(+), 81 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php index 21244fc3..7f14057f 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php @@ -188,7 +188,7 @@ public function test_should_convert_deeper_relative_url() { * @since 1.5.0 * * @param _Beans_Compiler $compiler The Compiler instance. - * @param mixed $fragment The given value to set. + * @param mixed $fragment The given value to set. * * @return void */ diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index e30e6364..42f88ae1 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -99,10 +99,9 @@ private function set_up_virtual_filesystem() { ? __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR : dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR; - // Load the fixture files and content into the virtual filesystem. foreach ( $filenames as $filename ) { - $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); + $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - valid edge case. } // Set up the "compiled" directory's virtual filesystem. @@ -217,7 +216,7 @@ protected function mock_filesystem_for_fragments( ) { if ( ! defined( 'FS_CHMOD_FILE' ) ) { - define( 'FS_CHMOD_FILE', 0644 ); + define( 'FS_CHMOD_FILE', 0644 ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - valid constant. } unset( $GLOBALS['wp_filesystem'] ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php index 3696a819..a9154c70 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php @@ -29,7 +29,7 @@ class Tests_Beans_Compiler_Replace_Css_Url extends Compiler_Test_Case { */ public function test_should_return_original_content_when_no_url() { $compiler = new _Beans_Compiler( array() ); - $css = <<add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( + $expected_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) ); $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_js() ); @@ -270,7 +270,7 @@ public function test_should_compile_css() { // Set up the mocks. $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( + $expected_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) ); $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_css() ); @@ -303,7 +303,7 @@ public function test_should_compile_less() { // Set up the mocks. $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( + $expected_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config ) ); $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_less() ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php index da5879d8..7f533093 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php @@ -23,75 +23,6 @@ */ class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { -// /** -// * Test set_filename() should return the base hash when not in development mode. -// */ -// public function test_should_return_base_hash_when_not_in_dev_mode() { -// $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); -// $config = array( -// 'id' => 'test-script', -// 'type' => 'script', -// 'format' => false, -// 'fragments' => array( $fragment ), -// 'dependencies' => false, -// 'in_footer' => true, -// 'minify_js' => true, -// 'version' => null, -// ); -// $compiler = new \_Beans_Compiler( $config ); -// -// // Test that we are not in development mode. -// $this->mock_dev_mode( false ); -// $this->assertFalse( _beans_is_compiler_dev_mode() ); -// -// // Set the filename. -// $compiler->set_filename(); -// $filename = $compiler->filename; -// $pathinfo = pathinfo( $filename ); -// $expected = $compiler->hash( $config ); -// -// // Run the tests. -// $this->assertSame( 'js', $pathinfo['extension'] ); -// $this->assertEquals( 7, strlen( $pathinfo['filename'] ) ); -// $this->assertSame( $expected, $pathinfo['filename'] ); -// $this->assertSame( $expected . '.js', $filename ); -// } - -// /** -// * Test set_filename() should return the base hash when not in development mode. -// */ -// public function test_should_return_base_hash_when_dir_does_not_exist() { -// $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); -// $config = array( -// 'id' => 'test-script', -// 'type' => 'script', -// 'format' => false, -// 'fragments' => array( $fragment ), -// 'dependencies' => false, -// 'in_footer' => true, -// 'minify_js' => true, -// 'version' => null, -// ); -// $compiler = new \_Beans_Compiler( $config ); -// -// // Test that we are in dev mode & the cache directory does not exist. -// $this->mock_dev_mode( true ); -// $this->assertTrue( _beans_is_compiler_dev_mode() ); -// $this->assertFalse( is_dir( vfsStream::url( 'compiled/beans/compiler/test-script' ) ) ); -// $this->assertFalse( is_dir( $compiler->dir ) ); -// -// // Set the filename. -// $compiler->set_filename(); -// $filename = $compiler->filename; -// $pathinfo = pathinfo( $filename ); -// $expected = $compiler->hash( $config ); -// -// // Run the tests. -// $this->assertSame( 'js', $pathinfo['extension'] ); -// $this->assertSame( $expected, $pathinfo['filename'] ); -// $this->assertSame( $expected . '.js', $filename ); -// } - /** * Test set_filename() should return the hash created with the modification time from each of the fragments. */ diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index ccdeebd4..8da795d4 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -68,7 +68,7 @@ public static function setUpBeforeClass() { require_once BEANS_TESTS_LIB_DIR . 'api/compiler/functions.php'; if ( ! defined( 'FS_CHMOD_FILE' ) ) { - define( 'FS_CHMOD_FILE', 0644 ); + define( 'FS_CHMOD_FILE', 0644 ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - valid constant. } } @@ -134,10 +134,9 @@ private function set_up_virtual_filesystem() { ? __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR : dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR; - // Load the fixture files and content into the virtual filesystem. foreach ( $filenames as $filename ) { - $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); + $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - valid edge case. } // Set up the "compiled" directory's virtual filesystem. From db6f79eb952b9e2be26bbdd1b7e5b2cf71af685e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 10:25:04 -0600 Subject: [PATCH 208/800] Improved filesystem(). After initializing, we now check: 1. the response from WordPress. 2. the filesystem is set to direct. --- lib/api/compiler/class-beans-compiler.php | 27 ++++++++++++++----- .../api/compiler/beans-compiler/fileystem.php | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 678273ee..b2baa272 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -126,18 +126,33 @@ public function filesystem() { require_once ABSPATH . '/wp-admin/includes/file.php'; } - // If WP_Filesystem is not initialized or it's not set to WP_Filesystem_Direct, initialize it. - if ( ! isset( $GLOBALS['wp_filesystem'] ) || ! is_a( $GLOBALS['wp_filesystem'], 'WP_Filesystem_Direct' ) ) { + // If WP_Filesystem is not initialized or it's not set to WP_Filesystem_Direct, then initialize it. + if ( $this->is_wp_filesystem_direct() ) { + return true; + } - // Fail-safe. If something happens, generate a report and then exit. - if ( true !== WP_Filesystem() ) { - return $this->kill(); - } + // Initialize the filesystem. + $response = WP_Filesystem(); + + // If it did not initialize, then generate a report and then exit. + if ( true !== $response || ! $this->is_wp_filesystem_direct() ) { + return $this->kill(); } return true; } + /** + * Checks if the filesystem is set to "direct". + * + * @since 1.5.0 + * + * @return bool + */ + private function is_wp_filesystem_direct() { + return isset( $GLOBALS['wp_filesystem'] ) && is_a( $GLOBALS['wp_filesystem'], 'WP_Filesystem_Direct' ); + } + /** * Make directory. * diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php index c19785aa..843e8835 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php @@ -39,6 +39,7 @@ public function test_wp_filesystem_is_not_initialized() { * Test filesystem() should render a report and die when no filesystem is selected. */ public function test_should_render_report_and_die_when_no_filesystem_selected() { + unset( $GLOBALS['wp_filesystem'] ); $compiler = new _Beans_Compiler( array() ); Functions\expect( __NAMESPACE__ . '\set_wp_die_handler' ) From 26a8a39ed0aaad0bf02cb9cd4244b785ef5b7b58 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 10:41:48 -0600 Subject: [PATCH 209/800] Fixed filesystem integration test. --- .../api/compiler/beans-compiler/fileystem.php | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php index 843e8835..304e03ca 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php @@ -24,28 +24,24 @@ */ class Tests_Beans_Compiler_Filesystem extends Compiler_Test_Case { - /** - * Test WP Filesystem is not initialized...yet. - */ - public function test_wp_filesystem_is_not_initialized() { - $this->assertTrue( function_exists( 'WP_Filesystem' ) ); - $this->assertArrayNotHasKey( 'wp_filesystem', $GLOBALS ); - - global $wp_filesystem; - $this->assertFalse( isset( $wp_filesystem ) ); - } - /** * Test filesystem() should render a report and die when no filesystem is selected. */ public function test_should_render_report_and_die_when_no_filesystem_selected() { - unset( $GLOBALS['wp_filesystem'] ); $compiler = new _Beans_Compiler( array() ); + // Let's just make sure we start without the WP Filesystem being initialized. + unset( $GLOBALS['wp_filesystem'] ); + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + add_filter( 'filesystem_method', __NAMESPACE__ . '\set_filesystem_method_to_base' ); + + // Set up the mocks. + Functions\expect( __NAMESPACE__ . '\set_filesystem_method_to_base' ) + ->once() + ->andReturn( 'base' ); Functions\expect( __NAMESPACE__ . '\set_wp_die_handler' ) ->once() ->andReturn( __NAMESPACE__ . '\mock_wp_die_handler' ); - Functions\when( __NAMESPACE__ . '\mock_wp_die_handler' ) ->alias( function( $message ) { $this->assertContains( 'Beans cannot work its magic', $message ); @@ -56,7 +52,10 @@ public function test_should_render_report_and_die_when_no_filesystem_selected() // Initialize the WP Filesystem. $this->assertNull( $compiler->filesystem() ); + // Clean up. + unset( $GLOBALS['wp_filesystem'] ); remove_filter( 'wp_die_handler', __NAMESPACE__ . '\set_wp_die_handler' ); + remove_filter( 'filesystem_method', __NAMESPACE__ . '\set_filesystem_method_to_base' ); } /** From f00c23181099946c3a1e2db1aa554c288f90a3be Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 11:40:31 -0600 Subject: [PATCH 210/800] Changed "protected" to "private" since this is a final class. --- lib/api/compiler/class-beans-compiler.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index b2baa272..36c30deb 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -23,42 +23,42 @@ final class _Beans_Compiler { * * @var array */ - protected $config; + private $config; /** * Cache dir. * * @var string */ - protected $dir; + private $dir; /** * Cache url. * * @var string */ - protected $url; + private $url; /** * Set during in fragments loop. * * @var string */ - protected $current_fragment; + private $current_fragment; /** * The compiled content. * * @var string */ - protected $compiled_content; + private $compiled_content; /** * Compiled content's filename. * * @var string */ - protected $filename; + private $filename; /** * Create a new Compiler. From 248afcb35991f21a2ec187519971eb69d53a847f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 30 Jan 2018 11:48:24 -0600 Subject: [PATCH 211/800] Changed access to "private" on several internal methods. --- lib/api/compiler/class-beans-compiler.php | 249 +++++++++++----------- 1 file changed, 128 insertions(+), 121 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 36c30deb..3d4d08a3 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -157,10 +157,11 @@ private function is_wp_filesystem_direct() { * Make directory. * * @since 1.0.0 + * @since 1.5.0 Changed access to private. * * @return bool */ - public function maybe_make_dir() { + private function maybe_make_dir() { if ( ! @is_dir( $this->dir ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. wp_mkdir_p( $this->dir ); @@ -631,126 +632,6 @@ public function replace_css_url_callback( $matches ) { return 'url("' . $url . '")'; } - /** - * Minify the CSS. - * - * @param string $content Given content to process. - * - * @return string - */ - public function strip_whitespace( $content ) { - $replace = array( - '#/\*.*?\*/#s' => '', // Strip comments. - '#\s\s+#' => ' ', // Strip excess whitespace. - ); - - $search = array_keys( $replace ); - $content = preg_replace( $search, $replace, $content ); - - $replace = array( - ': ' => ':', - '; ' => ';', - ' {' => '{', - ' }' => '}', - ', ' => ',', - '{ ' => '{', - ';}' => '}', // Strip optional semicolons. - ',\n' => ',', // Don't wrap multiple selectors. - '\n}' => '}', // Don't wrap closing braces. - '} ' => "}\n", // Put each rule on it's own line. - '\n' => '', // Take out all line breaks. - ); - - $search = array_keys( $replace ); - - return trim( str_replace( $search, $replace, $content ) ); - } - - /** - * Checks if the given fragment is a callable. - * - * @since 1.0.0 - * - * @param mixed $fragment Given fragment to check. - * - * @return bool - */ - public function is_function( $fragment ) { - return ( is_array( $fragment ) || is_callable( $fragment ) ); - } - - /** - * Kill it :( - * - * @since 1.0.0 - * - * @return void - */ - public function kill() { - - // Send report if set. - if ( beans_get( 'beans_send_compiler_report' ) ) { - $this->report(); - } - - $html = beans_output( 'beans_compiler_error_title_text', sprintf( - '

    %s

    ', - __( 'Not cool, Beans cannot work its magic :(', 'tm-beans' ) - ) ); - - $html .= beans_output( 'beans_compiler_error_message_text', sprintf( - '

    %s

    ', - __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support, we will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' ) - ) ); - - $html .= beans_output( 'beans_compiler_error_contact_text', sprintf( - '%s', - __( 'Contact Beans Support', 'tm-beans' ) - ) ); - - $html .= beans_output( 'beans_compiler_error_report_text', sprintf( - '

    %1$s. %2$s

    ', - __( 'Send us an automatic report', 'tm-beans' ), - __( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' ) - ) ); - - wp_die( wp_kses_post( $html ) ); - } - - /** - * Send report. - * - * @since 1.0.0 - * - * @return void - */ - public function report() { - // Send report. - wp_mail( - 'hello@getbeans.io', - 'Compiler error', - 'Compiler error reported by ' . home_url(), - array( - 'MIME-Version: 1.0' . "\r\n", - 'Content-type: text/html; charset=utf-8' . "\r\n", - "X-Mailer: PHP \r\n", - 'From: ' . wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) . ' < ' . get_option( 'admin_email' ) . '>' . "\r\n", - 'Reply-To: ' . get_option( 'admin_email' ) . "\r\n", - ) - ); - - // Die and display message. - $message = beans_output( - 'beans_compiler_report_error_text', - sprintf( - '

    %s

    ', - __( 'Thanks for your contribution by reporting this issue. We hope to hear from you again.', 'tm-beans' ) - ) - ); - - wp_die( wp_kses_post( $message ) ); - } - /** * Initialize the configuration. * @@ -887,6 +768,132 @@ private function remove_modified_files( $hash, $filemtime_hash ) { } } + /** + * Minify the CSS. + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @param string $content Given content to process. + * + * @return string + */ + private function strip_whitespace( $content ) { + $replace = array( + '#/\*.*?\*/#s' => '', // Strip comments. + '#\s\s+#' => ' ', // Strip excess whitespace. + ); + + $search = array_keys( $replace ); + $content = preg_replace( $search, $replace, $content ); + + $replace = array( + ': ' => ':', + '; ' => ';', + ' {' => '{', + ' }' => '}', + ', ' => ',', + '{ ' => '{', + ';}' => '}', // Strip optional semicolons. + ',\n' => ',', // Don't wrap multiple selectors. + '\n}' => '}', // Don't wrap closing braces. + '} ' => "}\n", // Put each rule on it's own line. + '\n' => '', // Take out all line breaks. + ); + + $search = array_keys( $replace ); + + return trim( str_replace( $search, $replace, $content ) ); + } + + /** + * Checks if the given fragment is a callable. + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @param mixed $fragment Given fragment to check. + * + * @return bool + */ + private function is_function( $fragment ) { + return ( is_array( $fragment ) || is_callable( $fragment ) ); + } + + /** + * Kill it :( + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @return void + */ + private function kill() { + + // Send report if set. + if ( beans_get( 'beans_send_compiler_report' ) ) { + $this->report(); + } + + $html = beans_output( 'beans_compiler_error_title_text', sprintf( + '

    %s

    ', + __( 'Not cool, Beans cannot work its magic :(', 'tm-beans' ) + ) ); + + $html .= beans_output( 'beans_compiler_error_message_text', sprintf( + '

    %s

    ', + __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support, we will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' ) + ) ); + + $html .= beans_output( 'beans_compiler_error_contact_text', sprintf( + '%s', + __( 'Contact Beans Support', 'tm-beans' ) + ) ); + + $html .= beans_output( 'beans_compiler_error_report_text', sprintf( + '

    %1$s. %2$s

    ', + __( 'Send us an automatic report', 'tm-beans' ), + __( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' ) + ) ); + + wp_die( wp_kses_post( $html ) ); + } + + /** + * Send report. + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @return void + */ + private function report() { + // Send report. + wp_mail( + 'hello@getbeans.io', + 'Compiler error', + 'Compiler error reported by ' . home_url(), + array( + 'MIME-Version: 1.0' . "\r\n", + 'Content-type: text/html; charset=utf-8' . "\r\n", + "X-Mailer: PHP \r\n", + 'From: ' . wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) . ' < ' . get_option( 'admin_email' ) . '>' . "\r\n", + 'Reply-To: ' . get_option( 'admin_email' ) . "\r\n", + ) + ); + + // Die and display message. + $message = beans_output( + 'beans_compiler_report_error_text', + sprintf( + '

    %s

    ', + __( 'Thanks for your contribution by reporting this issue. We hope to hear from you again.', 'tm-beans' ) + ) + ); + + wp_die( wp_kses_post( $message ) ); + } + /** * Set the filename for the compiled asset. * From a1ad44bc0995639f19f162591f5e797096d92cc1 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 30 Jan 2018 15:15:32 -0500 Subject: [PATCH 212/800] Changes to class-beans-compiler.php --- lib/api/compiler/class-beans-compiler.php | 58 +++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 3d4d08a3..e95fc174 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -2,7 +2,7 @@ /** * This class compiles and minifies CSS, LESS and JS. * - * @package Beans\Framework\API\Complier + * @package Beans\Framework\API\Compiler * * @since 1.5.0 */ @@ -14,7 +14,7 @@ * @ignore * @access private * - * @package Beans\Framework\API\Complier + * @package Beans\Framework\API\Compiler */ final class _Beans_Compiler { @@ -40,7 +40,7 @@ final class _Beans_Compiler { private $url; /** - * Set during in fragments loop. + * The fragment currently being processed. * * @var string */ @@ -97,12 +97,12 @@ public function run_compiler() { $this->enqueue_file(); - // Keep it safe and reset WP Filesystem method. + // Keep it safe and reset the WP Filesystem method. remove_filter( 'filesystem_method', array( $this, 'modify_filesystem_method' ) ); } /** - * Callback to set WP Filesystem method. + * Callback to set the WP Filesystem method. * * @since 1.0.0 * @@ -113,7 +113,7 @@ public function modify_filesystem_method() { } /** - * Initialise WP Filesystem. + * Initialise the WP Filesystem. * * @since 1.0.0 * @@ -121,12 +121,12 @@ public function modify_filesystem_method() { */ public function filesystem() { - // WP_Filesystem is not already loaded, load it. + // If the WP_Filesystem is not already loaded, load it. if ( ! function_exists( 'WP_Filesystem' ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; } - // If WP_Filesystem is not initialized or it's not set to WP_Filesystem_Direct, then initialize it. + // If the WP_Filesystem is not initialized or is not set to WP_Filesystem_Direct, then initialize it. if ( $this->is_wp_filesystem_direct() ) { return true; } @@ -134,7 +134,7 @@ public function filesystem() { // Initialize the filesystem. $response = WP_Filesystem(); - // If it did not initialize, then generate a report and then exit. + // If the filesystem did not initialize, then generate a report and exit. if ( true !== $response || ! $this->is_wp_filesystem_direct() ) { return $this->kill(); } @@ -143,7 +143,7 @@ public function filesystem() { } /** - * Checks if the filesystem is set to "direct". + * Check if the filesystem is set to "direct". * * @since 1.5.0 * @@ -272,7 +272,7 @@ public function cache_file() { return false; } - // Safe to access filesystem since we made sure it was set. + // It is safe to access the filesystem because we made sure it was set. return $GLOBALS['wp_filesystem']->put_contents( $filename, $this->compiled_content, FS_CHMOD_FILE ); } @@ -286,7 +286,7 @@ public function cache_file() { */ private function enqueue_file() { - // Enqueue css. + // Enqueue CSS file. if ( 'style' === $this->config['type'] ) { return wp_enqueue_style( $this->config['id'], @@ -296,7 +296,7 @@ private function enqueue_file() { ); } - // Enqueue js file. + // Enqueue JS file. if ( 'script' === $this->config['type'] ) { return wp_enqueue_script( $this->config['id'], @@ -346,7 +346,7 @@ public function get_extension() { } /** - * Combine fragments content. + * Combine content of the fragments. * * @since 1.0.0 * @@ -427,7 +427,7 @@ public function get_internal_content() { if ( ! file_exists( $fragment ) ) { - // Replace url with path. + // Replace URL with path. $fragment = beans_url_to_path( $fragment ); // Stop here if it isn't a valid file. @@ -436,7 +436,7 @@ public function get_internal_content() { } } - // Safe to access filesystem since we made sure it was set. + // It is safe to access the filesystem because we made sure it was set. return $GLOBALS['wp_filesystem']->get_contents( $fragment ); } @@ -454,7 +454,7 @@ public function get_remote_content() { return false; } - // For a relative URL, add the http: to it. + // For a relative URL, add http: to it. if ( substr( $fragment, 0, 2 ) === '//' ) { $fragment = 'http:' . $fragment; } elseif ( substr( $fragment, 0, 1 ) === '/' ) { // Add domain if it is local but could not be fetched as a file. @@ -467,7 +467,7 @@ public function get_remote_content() { return ''; } - // If no content received and the URL is not https, then convert the URL to SSL and retry. + // If no content was received and the URL is not https, then convert the URL to SSL and retry. if ( ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) && ( substr( $fragment, 0, 8 ) !== 'https://' ) @@ -574,7 +574,7 @@ public function format_content( $content ) { } /** - * Replace CSS url shortcuts with a valid url. + * Replace CSS URL shortcuts with a valid URL. * * @since 1.0.0 * @@ -591,11 +591,11 @@ public function replace_css_url( $content ) { } /** - * Convert any CSS url relative paths to absolute URLs. + * Convert any CSS URL relative paths to absolute URLs. * * @since 1.0.0 * - * @param array $matches Matches to process, where 0 is the CSS' url() and 1 is the URI. + * @param array $matches Matches to process, where 0 is the CSS' URL() and 1 is the URI. * * @return string */ @@ -625,10 +625,10 @@ public function replace_css_url_callback( $matches ) { $base = ''; } - // Rebuild url and make sure it is a valid one using the beans_path_to_url function. + // Rebuild the URL and make sure it is valid using the beans_path_to_url function. $url = beans_path_to_url( trailingslashit( $base ) . ltrim( end( $paths ), '/' ) ); - // Return the rebuilt path converted to url. + // Return the rebuilt path converted to an URL. return 'url("' . $url . '")'; } @@ -708,7 +708,7 @@ private function get_new_hash( $hash, array $fragments_filemtime ) { $this->remove_modified_files( $hash, $_hash ); - // Set the new hash which will trigger to new compiling. + // Set the new hash which will trigger a new compiling. return $hash . '-' . $_hash; } @@ -717,7 +717,7 @@ private function get_new_hash( $hash, array $fragments_filemtime ) { * * 1. It has both a base hash and filemtime hash, separated by '-'. * 2. Its base hash matches the given hash. - * 3. Its filemtime hash has does not match the given filemtime hash. + * 3. Its filemtime hash does not match the given filemtime hash. * * @since 1.5.0 * @@ -746,7 +746,7 @@ private function remove_modified_files( $hash, $filemtime_hash ) { continue; } - // Skip this one if it does not a '-' in the filename. + // Skip this one if it does not have a '-' in the filename. if ( strpos( $item, '-' ) === false ) { continue; } @@ -798,7 +798,7 @@ private function strip_whitespace( $content ) { ',\n' => ',', // Don't wrap multiple selectors. '\n}' => '}', // Don't wrap closing braces. '} ' => "}\n", // Put each rule on it's own line. - '\n' => '', // Take out all line breaks. + '\n' => '', // Remove all line breaks. ); $search = array_keys( $replace ); @@ -807,7 +807,7 @@ private function strip_whitespace( $content ) { } /** - * Checks if the given fragment is a callable. + * Check if the given fragment is a callable. * * @since 1.0.0 * @since 1.5.0 Changed access to private. @@ -842,7 +842,7 @@ private function kill() { $html .= beans_output( 'beans_compiler_error_message_text', sprintf( '

    %s

    ', - __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support, we will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' ) + __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support. We will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' ) ) ); $html .= beans_output( 'beans_compiler_error_contact_text', sprintf( From d57cf2da2dd76e7ef3268a325943c060c9d3507c Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 30 Jan 2018 20:11:12 -0500 Subject: [PATCH 213/800] Changes to \lib\api\compiler\functions.php --- lib/api/compiler/functions.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index f2fa8dd6..c651b35d 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -2,11 +2,11 @@ /** * Compile and cache CSS, LESS and JS files. * - * The Beans Compiler is there to compile multiple internal or external CSS, LESS and JS files on a + * The Beans Compiler compiles multiple internal or external CSS, LESS and JS files on a * per page basis. LESS content will automatically be converted to CSS. * - * When development mode is enabled, internal files changes will automatically be detected. Third party enqueued - * styles and scripts can be compiled and cached into a single file. + * Internal file changes are automatically detected if development mode is enabled. + * Third party enqueued styles and scripts can be compiled and cached into a single file. * * @package API\Compiler */ @@ -99,13 +99,12 @@ function beans_compile_less_fragments( $id, $fragments, $args = array() ) { * @since 1.0.0 * * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * @param string|array $fragments File(s) absolute path. Internal or external file(s) URL accepted but may increase * compiling time. * @param array $args { * Optional. Array of arguments used by the compiler. * * @type array $depedencies An array of registered handles this script depends on. Default false. - * @type array $depedencies An array of registered handles this script depends on. Default false. * @type bool $in_footer Whether to enqueue the script before or before . Default false. * @type bool $minify_js Whether the JavaScript should be minified or not. Be aware that minifying * the JavaScript can considerably slow down the process of compiling files. @@ -162,7 +161,7 @@ function beans_compiler_add_fragment( $id, $fragments, $format ) { continue; } - // Register new compiler id if it doesn't exist and add fragment. + // Register a new compiler ID if it doesn't exist and add fragment. if ( ! isset( $_beans_compiler_added_fragments[ $format ][ $id ] ) ) { $_beans_compiler_added_fragments[ $format ][ $id ] = array( $fragment ); } else { // Add fragment to existing compiler. @@ -174,13 +173,13 @@ function beans_compiler_add_fragment( $id, $fragments, $format ) { /** * Flush cached compiler files. * - * Each compiler has its own folder which contains the cached CSS and JS files. Cached files format - * can be specified if needed. + * Each compiler has its own folder which contains the cached CSS and JS files. The file format + * of the cached file can be specified if needed. * * @since 1.0.0 * * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|bool $file_format Optional. Define which files format should be removed. Both CSS and JS + * @param string|bool $file_format Optional. Define which file format(s) should be removed. Both CSS and JS * files will be removed if set to false. Accepts 'false', 'css' or 'js'. * @param bool $admin Optional. Whether it is an admin compiler or not. * @@ -191,7 +190,7 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { $cache_dir = beans_get_compiler_dir( $admin ); - // Always flush beans global cache. + // Always flush Beans' global cache. if ( ! $beans_flushed ) { $beans_flushed = true; @@ -205,7 +204,7 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { return; } - // Remove only specified format files. + // Remove only the specified file format. if ( $file_format ) { $items = scandir( $dir ); unset( $items[0], $items[1] ); @@ -219,7 +218,7 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { return; } - // Remove all format files. + // Remove all file formats. beans_remove_dir( $dir ); } @@ -231,7 +230,7 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { * @since 1.0.0 * * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|bool $file_format Optional. Define which files format should be removed. Both CSS and JS + * @param string|bool $file_format Optional. Define which file formats should be removed. Both CSS and JS * files will be removed if set to false. Accepts 'false', 'css' or 'js'. * * @return void @@ -254,7 +253,7 @@ function beans_get_compiler_dir( $is_admin = false ) { $suffix = $is_admin ? 'beans/admin-compiler/' : 'beans/compiler/'; /** - * Deprecated. Filter the beans compiler directory. + * Deprecated. Filter the Beans compiler directory. * * This filter is deprecated for security and compatibility purposes. * @@ -283,7 +282,9 @@ function beans_get_compiler_url( $is_admin = false ) { } /** - * Check if development mode is enabled, taking in consideration legacy constant. + * Check if development mode is enabled. + * + * Takes legacy constant into consideration. * * @since 1.0.0 * @ignore From 3040265965015b2a8a1e9a8c1c2004061c5727ec Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 30 Jan 2018 21:05:35 -0500 Subject: [PATCH 214/800] Changes to /integration/api/compiler/beans-compiler/cacheFile.php --- .../integration/api/compiler/beans-compiler/cacheFile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php index 0fb30615..e2e5d5f2 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php @@ -20,7 +20,7 @@ * Class Tests_Beans_Compiler_Cache_File * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group unit-tests + * @group integration-tests * @group api */ class Tests_Beans_Compiler_Cache_File extends Compiler_Test_Case { From 2e673f50253d8984272a7c8e4e7a5dbfba4adc2f Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 30 Jan 2018 21:47:15 -0500 Subject: [PATCH 215/800] Changes to /integration/api/compiler/beans-compiler/combineFragments.php --- .../api/compiler/beans-compiler/combineFragments.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php index 98db693d..ab4f9e01 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php @@ -67,7 +67,7 @@ public function setUp() { } /** - * Test combine_fragments() should return empty string when there are no fragments to combine. + * Test combine_fragments() should return an empty string when there are no fragments to combine. */ public function test_should_return_empty_string_when_no_fragments() { $compiler = new _Beans_Compiler( array() ); @@ -78,7 +78,7 @@ public function test_should_return_empty_string_when_no_fragments() { } /** - * Test combine_fragments() should return empty string when the fragment does not exist. + * Test combine_fragments() should return an empty string when the fragment does not exist. */ public function test_should_return_empty_string_when_fragment_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; @@ -172,7 +172,7 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * Test combine_fragments() should return the original jQuery when "minify_js" is enabled, * but the site is in development mode. */ - public function test_should_return_original_jquery_when_not_in_not_dev_mode() { + public function test_should_always_return_original_jquery_when_in_dev_mode() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'script', @@ -246,7 +246,7 @@ public function test_should_return_original_js_when_minify_js_disabled() { * Test combine_fragments() should return the original JavaScript when "minify_js" is enabled, * but the site is in development mode. */ - public function test_should_return_original_js_when_not_in_not_dev_mode() { + public function test_should_always_return_original_js_when_in_dev_mode() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'script', From 98cd051533ed4bc0f7dca8a0fdd4cbe38d822fb4 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 30 Jan 2018 23:16:34 -0500 Subject: [PATCH 216/800] Changes to /integration/api/compiler/beans-compiler/formatContent.php --- .../api/compiler/beans-compiler/formatContent.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php index 36c15932..e78c8759 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -131,7 +131,7 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * Test format_content() should return the original jQuery when "minify_js" is enabled, * but the site is in development mode. */ - public function test_should_return_original_jquery_when_not_in_not_dev_mode() { + public function test_should_always_return_original_jquery_when_in_dev_mode() { $compiler = new \_Beans_Compiler( array( 'id' => 'test', 'type' => 'script', @@ -144,9 +144,10 @@ public function test_should_return_original_jquery_when_not_in_not_dev_mode() { } /** - * Test format_content() should return minified jQuery. + * Test format_content() should return minified jQuery when "minify_js" is enabled + * and the site is not in development mode. */ - public function test_should_return_minified_jquery() { + public function test_should_return_minified_jquery_when_not_in_dev_mode_and_minify_js_enabled() { $compiler = new \_Beans_Compiler( array( 'id' => 'test', 'type' => 'script', @@ -183,7 +184,7 @@ public function test_should_return_original_js_when_minify_js_disabled() { * Test format_content() should return the original JavaScript when "minify_js" is enabled, * but the site is in development mode. */ - public function test_should_return_original_js_when_not_in_not_dev_mode() { + public function test_should_always_return_original_js_when_in_dev_mode() { $compiler = new \_Beans_Compiler( array( 'id' => 'test', 'type' => 'script', @@ -196,9 +197,10 @@ public function test_should_return_original_js_when_not_in_not_dev_mode() { } /** - * Test format_content() should return minified JavaScript. + * Test format_content() should return minified JavaScript when "minify_js" is enabled + * and the site is not in development mode. */ - public function test_should_return_minified_javascript() { + public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_js_enabled() { $compiler = new \_Beans_Compiler( array( 'id' => 'test', 'type' => 'script', From 2bd0ade8ae5cac998f084d89faf85f38a1afa019 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 14:51:43 -0500 Subject: [PATCH 217/800] Changes to /integration/api/compiler/beans-compiler/getInternalContent.php --- .../api/compiler/beans-compiler/getInternalContent.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php index fe568bbd..855e9aa0 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php @@ -29,6 +29,8 @@ class Tests_Beans_Compiler_Get_Internal_Content extends Compiler_Test_Case { */ public function test_should_return_false_when_fragment_is_empty() { $compiler = new _Beans_Compiler( array() ); + + // Run the test. $this->assertfalse( $compiler->get_internal_content( '' ) ); } @@ -48,7 +50,7 @@ public function test_should_return_false_when_file_does_not_exist() { } /** - * Test get_internal_content() should fragment's contents. + * Test get_internal_content() should return a fragment's contents. */ public function test_should_return_fragment_contents() { // Set up the compiler. @@ -68,6 +70,7 @@ public function test_should_return_fragment_contents() { $this->assertContains( 'body {', $contents ); $this->assertContains( 'color: @body-color;', $contents ); + // Clean up. remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); } } From f03ee220230d041fad8155baae0839c5e196d186 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 15:00:10 -0500 Subject: [PATCH 218/800] Changes to /integration/api/compiler/beans-compiler/getRemoteContent.php --- .../compiler/beans-compiler/getRemoteContent.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php index 75878ab9..4f9e76b6 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php @@ -28,6 +28,8 @@ class Tests_Beans_Compiler_Get_Remote_Content extends Compiler_Test_Case { */ public function test_should_return_false_when_fragment_is_empty() { $compiler = new _Beans_Compiler( array() ); + + // Run the test. $this->assertfalse( $compiler->get_remote_content( '' ) ); } @@ -41,13 +43,14 @@ public function test_should_return_empty_string_when_remote_does_not_exist() { ) ); $this->set_current_fragment( $compiler, $fragment ); + // Run the test. $this->assertSame( '', $compiler->get_remote_content( $fragment ) ); } /** * Test get_remote_content() should return the content when fragment is a relative url. */ - public function test_should_return_content_when_relative_url() { + public function test_should_return_content_when_fragment_is_relative_url() { $fragment = '//fonts.googleapis.com/css?family=Lato'; $compiler = new _Beans_Compiler( array( 'fragments' => array( $fragment ), @@ -56,6 +59,7 @@ public function test_should_return_content_when_relative_url() { $content = $compiler->get_remote_content( $fragment ); + // Run the tests. $this->assertContains( "font-family: 'Lato';", $content ); $this->assertContains( 'font-style: normal;', $content ); $this->assertContains( 'font-weight: 400;', $content ); @@ -63,9 +67,9 @@ public function test_should_return_content_when_relative_url() { } /** - * Test get_remote_content() should return the content when fragment is http URL. + * Test get_remote_content() should return the content when fragment is an http URL. */ - public function test_should_return_content_when_http() { + public function test_should_return_content_when_fragment_is_http() { $fragment = 'http://fonts.googleapis.com/css?family=Roboto'; $compiler = new _Beans_Compiler( array( 'fragments' => array( $fragment ), @@ -74,6 +78,7 @@ public function test_should_return_content_when_http() { $content = $compiler->get_remote_content( $fragment ); + // Run the tests. $this->assertContains( "font-family: 'Roboto';", $content ); $this->assertContains( 'font-style: normal;', $content ); $this->assertContains( 'font-weight: 400;', $content ); @@ -81,9 +86,9 @@ public function test_should_return_content_when_http() { } /** - * Test get_remote_content() should return the content when fragment is https URL. + * Test get_remote_content() should return the content when fragment is an https URL. */ - public function test_should_return_content_when_https() { + public function test_should_return_content_when_fragment_is_https() { $fragment = 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'; $compiler = new _Beans_Compiler( array( 'fragments' => array( $fragment ), @@ -92,6 +97,7 @@ public function test_should_return_content_when_https() { $content = $compiler->get_remote_content( $fragment ); + // Run the tests. $this->assertContains( 'Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome', $content ); $this->assertContains( "@font-face{font-family:'FontAwesome';", $content ); $this->assertContains( "src:url('../fonts/fontawesome-webfont.eot?v=4.7.0');", $content ); From dc20c44076abda185402ef9aeff252a0082d3b63 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 15:05:54 -0500 Subject: [PATCH 219/800] More changes to /integration/api/compiler/beans-compiler/formatContent.php --- .../compiler/beans-compiler/formatContent.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php index e78c8759..0ba62f7d 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -65,6 +65,7 @@ public function test_should_return_original_content_when_type_not_style_or_scrip 'type' => 'foo', ) ); + // Run the tests. $this->assertSame( $this->less, $compiler->format_content( $this->less ) ); $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); @@ -80,6 +81,7 @@ public function test_should_return_compiled_css() { 'format' => 'less', ) ); + // Turn on development mode. update_option( 'beans_dev_mode', true ); $expected_css = <<assertSame( $expected_css, $compiler->format_content( $this->less ) ); } @@ -103,8 +105,10 @@ public function test_should_return_minified_compiled_css() { 'format' => 'less', ) ); + // Turn off development mode. update_option( 'beans_dev_mode', false ); + // Run the test. $this->assertContains( 'body{background-color:#fff;color:#000;font-size:18px;', $compiler->format_content( $this->less ) @@ -122,8 +126,10 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { 'minify_js' => false, ) ); + // Turn off development mode. update_option( 'beans_dev_mode', false ); + // Run the test. $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); } @@ -138,8 +144,10 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { 'minify_js' => true, ) ); + // Turn on development mode. update_option( 'beans_dev_mode', true ); + // Run the test. $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); } @@ -154,6 +162,7 @@ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_mini 'minify_js' => true, ) ); + // Turn off development mode. update_option( 'beans_dev_mode', false ); $expected = <<assertSame( str_replace( '/$', '$', $expected ), $compiler->format_content( $this->jquery ) ); } @@ -175,8 +185,10 @@ public function test_should_return_original_js_when_minify_js_disabled() { 'minify_js' => false, ) ); + // Turn off development mode. update_option( 'beans_dev_mode', false ); + // Run the test. $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); } @@ -191,8 +203,10 @@ public function test_should_always_return_original_js_when_in_dev_mode() { 'minify_js' => true, ) ); + // Turn on development mode. update_option( 'beans_dev_mode', true ); + // Run the test. $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); } @@ -207,12 +221,14 @@ public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_j 'minify_js' => true, ) ); + // Turn off development mode. update_option( 'beans_dev_mode', false ); $expected = <<assertSame( $expected, $compiler->format_content( $this->js ) ); } } From abcefe13203dc4d3fd121139ffc7d787538ba2c2 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 15:15:42 -0500 Subject: [PATCH 220/800] Changes to /integration/api/compiler/beans-compiler/replaceCssUrl.php --- .../api/compiler/beans-compiler/replaceCssUrl.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php index 7f14057f..eb2a2635 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php @@ -41,6 +41,7 @@ public function test_should_return_original_content_when_no_url() { box-shadow: inset 0px -3px 20px rgba(0,0,0,0.04); } EOB; + // Run the test. $this->assertSame( $css, $compiler->replace_css_url( $css ) ); } @@ -51,13 +52,14 @@ public function test_should_return_original_content_when_valid_uri() { $compiler = new _Beans_Compiler( array() ); $css = <<assertSame( $css, $compiler->replace_css_url( $css ) ); } @@ -81,6 +83,7 @@ public function test_should_convert_relative_url_when_no_up_levels() { $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); } @@ -104,6 +107,7 @@ public function test_should_convert_relative_url() { '"http://foo.com/assets/images/hero-2.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); // Test with spaces and single quotes. @@ -117,6 +121,7 @@ public function test_should_convert_relative_url() { '"http://foo.com/assets/images/hero-2.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); // Test with spaces and double quotes. @@ -130,6 +135,7 @@ public function test_should_convert_relative_url() { '"http://foo.com/assets/images/hero-2.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); } @@ -153,6 +159,7 @@ public function test_should_convert_deeper_relative_url() { '"http://example.com/assets/images/hero-1.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); // Test with spaces and single quotes. @@ -166,6 +173,7 @@ public function test_should_convert_deeper_relative_url() { '"http://example.com/assets/images/hero-1.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); // Test with spaces and double quotes. @@ -179,6 +187,7 @@ public function test_should_convert_deeper_relative_url() { '"http://example.com/assets/images/hero-1.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); } From 9f02f3d4a9b631864ccdb8b5c2c1e4c95fb77291 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 15:17:47 -0500 Subject: [PATCH 221/800] Fix test broken in previous commit for /integration/api/compiler/beans-compiler/formatContent.php --- .../integration/api/compiler/beans-compiler/formatContent.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php index 0ba62f7d..4a2e0073 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -84,12 +84,14 @@ public function test_should_return_compiled_css() { // Turn on development mode. update_option( 'beans_dev_mode', true ); + // Don't remove empty line before EOB; ! $expected_css = <<assertSame( $expected_css, $compiler->format_content( $this->less ) ); From 2b18f3a6195737e9b3289b3e1968d9799009a1ae Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 15:27:39 -0500 Subject: [PATCH 222/800] Changes to /integration/api/compiler/beans-compiler/runCompiler.php --- .../api/compiler/beans-compiler/runCompiler.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php index 8ae14730..fcb97d15 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -190,9 +190,9 @@ public function test_should_recompile_when_fragments_change() { } /** - * Test cache_file() should compile jQuery, saving it to the virtual filesystem and enqueuing it WordPress. + * Test cache_file() should compile jQuery, saving it to the virtual filesystem and enqueuing it in WordPress. */ - public function test_should_compile_jquery() { + public function test_should_compile_save_and_enqueue_jquery() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); $config = array( 'id' => 'test-jquery', @@ -225,7 +225,7 @@ public function test_should_compile_jquery() { /** * Test cache_file() should compile JavaScript, saving it to the virtual filesystem and enqueuing it WordPress. */ - public function test_should_compile_js() { + public function test_should_compile_save_and_enqueue_js() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); $config = array( 'id' => 'test-js', @@ -257,7 +257,7 @@ public function test_should_compile_js() { /** * Test cache_file() should compile CSS, saving it to the virtual filesystem and enqueuing it WordPress. */ - public function test_should_compile_css() { + public function test_should_compile_save_and_enqueue_css() { $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); $config = array( 'id' => 'test-css', @@ -289,7 +289,7 @@ public function test_should_compile_css() { /** * Test cache_file() should compile Less, saving it to the virtual filesystem and enqueuing it WordPress. */ - public function test_should_compile_less() { + public function test_should_compile_save_and_enqueue_less() { $config = array( 'id' => 'test-css', 'type' => 'style', From 0688447f18ed5646a4ffe8d28c3b70c0859c46d2 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 15:32:31 -0500 Subject: [PATCH 223/800] Changes to /integration/api/compiler/beans-compiler/setFilename.php --- .../integration/api/compiler/beans-compiler/runCompiler.php | 2 +- .../integration/api/compiler/beans-compiler/setFilename.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php index fcb97d15..9271e97e 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -148,7 +148,7 @@ public function test_should_recompile_when_fragments_change() { $this->assertFileExists( $original_file ); /** - * Next step is to modify the fragment, which will change it's modification time. Let's add an opening + * Next step is to modify the fragment, which will change its modification time. Let's add an opening * comment to the fragment's content and then set up the modified file for our tests. */ $compiled_content = $this->get_compiled_jquery() . "console.log('Beans rocks!');"; diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php index 06e91dd4..a308dc68 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php @@ -18,7 +18,7 @@ * Class Tests_Beans_Compiler_Set_Filename * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group unit-tests + * @group integration-tests * @group api */ class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { @@ -51,7 +51,7 @@ public function test_should_return_hash_created_with_fragments_filemtime() { } /** - * Test set_filename() should return the hash created with the modification time from each of the fragments. + * Test set_filename() should exclude external fragments. */ public function test_should_exclude_external_fragments() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); @@ -119,7 +119,7 @@ public function test_should_remove_old_file() { $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); /** - * Next step is to modify the fragment, which will change it's modification time. Let's add an opening + * Next step is to modify the fragment, which will change its modification time. Let's add an opening * comment to the fragment's content and then set up the modified file for our tests. */ $file = $this->mock_filesystem->getChild( 'fixtures' )->getChild( 'jquery.test.js' ); From b02515e77993232e6421168f910466f14ffb8001 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 16:13:50 -0500 Subject: [PATCH 224/800] Changes to combineFragments.php --- .../compiler/beans-compiler/combineFragments.php | 6 +++--- .../compiler/beans-compiler/combineFragments.php | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php index ab4f9e01..2fc742b6 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php @@ -93,7 +93,7 @@ public function test_should_return_empty_string_when_fragment_does_not_exist() { /** * Test combine_fragments() should compile the Less fragments and return the compiled CSS. */ - public function test_should_compiled_less_and_return_css() { + public function test_should_compile_less_and_return_css() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'style', @@ -193,7 +193,7 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { } /** - * Test format_content() should return minified jQuery. + * Test combine_fragments() should return minified jQuery. */ public function test_should_return_minified_jquery() { $compiler = new _Beans_Compiler( array( @@ -269,7 +269,7 @@ public function test_should_always_return_original_js_when_in_dev_mode() { } /** - * Test format_content() should return minified JavaScript. + * Test combine_fragments() should return minified JavaScript. */ public function test_should_return_minified_javascript() { $compiler = new _Beans_Compiler( array( diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php index 673cd88f..cc4144b9 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -67,7 +67,7 @@ protected function setUp() { } /** - * Test combine_fragments() should return empty string when there are no fragments to combine. + * Test combine_fragments() should return an empty string when there are no fragments to combine. */ public function test_should_return_empty_string_when_no_fragments() { $compiler = new _Beans_Compiler( array() ); @@ -78,7 +78,7 @@ public function test_should_return_empty_string_when_no_fragments() { } /** - * Test combine_fragments() should return empty string when the fragment does not exist. + * Test combine_fragments() should return an empty string when the fragment does not exist. */ public function test_should_return_empty_string_when_fragment_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; @@ -93,7 +93,7 @@ public function test_should_return_empty_string_when_fragment_does_not_exist() { /** * Test combine_fragments() should compile the LESS fragments and return the compiled CSS. */ - public function test_should_compiled_less_and_return_css() { + public function test_should_compile_less_and_return_css() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'style', @@ -172,7 +172,7 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * Test combine_fragments() should return the original jQuery when "minify_js" is enabled, * but the site is in development mode. */ - public function test_should_return_original_jquery_when_not_in_not_dev_mode() { + public function test_should_always_return_original_jquery_when_in_dev_mode() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'script', @@ -193,7 +193,7 @@ public function test_should_return_original_jquery_when_not_in_not_dev_mode() { } /** - * Test format_content() should return minified jQuery. + * Test combine_fragments() should return minified jQuery. */ public function test_should_return_minified_jquery() { $compiler = new _Beans_Compiler( array( @@ -242,7 +242,7 @@ public function test_should_return_original_js_when_minify_js_disabled() { * Test combine_fragments() should return the original JavaScript when "minify_js" is enabled, * but the site is in development mode. */ - public function test_should_return_original_js_when_not_in_not_dev_mode() { + public function test_should_always_return_original_js_when_in_dev_mode() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'script', @@ -262,7 +262,7 @@ public function test_should_return_original_js_when_not_in_not_dev_mode() { } /** - * Test format_content() should return minified JavaScript. + * Test combine_fragments() should return minified JavaScript. */ public function test_should_return_minified_javascript() { $compiler = new _Beans_Compiler( array( From 8bca8c970091f8f418546bed8ac07eae263276dd Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 16:20:31 -0500 Subject: [PATCH 225/800] Changes to /unit/api/compiler/beans-compiler/filesystem.php --- tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php index caa38804..99e396c1 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php @@ -25,7 +25,7 @@ class Tests_Beans_Compiler_Filesystem extends Compiler_Test_Case { /** - * Test filesystem() should return true when WP Filesystem is initialized to WP_Filesystem_Direct. + * Test filesystem() should return true when the WP Filesystem is initialized to WP_Filesystem_Direct. */ public function test_should_return_true_when_wp_filesystem_is_init() { // Initialize the wp_filesystem global variable. @@ -34,7 +34,7 @@ public function test_should_return_true_when_wp_filesystem_is_init() { Functions\when( 'WP_Filesystem' )->justReturn( true ); - // Test that WP Filesystem is not loaded yet. + // Test that the WP Filesystem is not loaded yet. $compiler = new \_Beans_Compiler( array() ); $this->assertTrue( $compiler->filesystem() ); From c516aab7f84efe27da45fe8a145d740cb080866e Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 16:31:38 -0500 Subject: [PATCH 226/800] Changes to /unit/api/compiler/beans-compiler/formatContent.php --- .../compiler/beans-compiler/formatContent.php | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php index 192b3808..650b22a5 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -67,6 +67,7 @@ public function test_should_return_original_content_when_type_not_style_or_scrip 'type' => 'foo', ) ); + // Run the tests. $this->assertSame( $this->less, $compiler->format_content( $this->less ) ); $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); @@ -82,6 +83,7 @@ public function test_should_return_compiled_css() { 'format' => 'less', ) ); + // Turn on development mode. $this->mock_dev_mode( true ); $expected_css = <<assertSame( $expected_css, $compiler->format_content( $this->less ) ); } @@ -105,8 +108,10 @@ public function test_should_return_minified_compiled_css() { 'format' => 'less', ) ); + // Turn off development mode. $this->mock_dev_mode( false ); + // Run the test. $this->assertContains( 'body{background-color:#fff;color:#000;font-size:18px;', $compiler->format_content( $this->less ) @@ -124,8 +129,10 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { 'minify_js' => false, ) ); + // Turn off development mode. $this->mock_dev_mode( false ); + // Run the test. $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); } @@ -133,28 +140,32 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * Test format_content() should return the original jQuery when "minify_js" is enabled, * but the site is in development mode. */ - public function test_should_return_original_jquery_when_not_in_not_dev_mode() { + public function test_should_always_return_original_jquery_when_in_dev_mode() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, ) ); + // Turn on development mode. $this->mock_dev_mode( true ); + // Run the test. $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); } /** - * Test format_content() should return minified jQuery. + * Test format_content() should return minified jQuery when "minify_js" is enabled + * and the site is not in development mode. */ - public function test_should_return_minified_jquery() { + public function test_should_return_minified_jquery_when_not_in_dev_mode_and_minify_js_enabled() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, ) ); + // Turn off development mode. $this->mock_dev_mode( false ); $expected = <<assertSame( str_replace( '/$', '$', $expected ), $compiler->format_content( $this->jquery ) ); } @@ -176,8 +188,10 @@ public function test_should_return_original_js_when_minify_js_disabled() { 'minify_js' => false, ) ); + // Turn off development mode. $this->mock_dev_mode( false ); + // Run the test. $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); } @@ -185,34 +199,39 @@ public function test_should_return_original_js_when_minify_js_disabled() { * Test format_content() should return the original JavaScript when "minify_js" is enabled, * but the site is in development mode. */ - public function test_should_return_original_js_when_not_in_not_dev_mode() { + public function test_should_always_return_original_js_when_in_dev_mode() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, ) ); + // Turn on development mode. $this->mock_dev_mode( true ); + // Run the test. $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); } /** - * Test format_content() should return minified JavaScript. + * Test format_content() should return minified JavaScript when "minify_js" is enabled + * and the site is not in development mode. */ - public function test_should_return_minified_javascript() { + public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_js_enabled() { $compiler = new _Beans_Compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, ) ); + // Turn off development mode. $this->mock_dev_mode( false ); $expected = <<assertSame( $expected, $compiler->format_content( $this->js ) ); } } From 025f6ab587daa9881fcaf15c0677c916337dc86f Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 19:20:08 -0500 Subject: [PATCH 227/800] Changes to /unit/api/compiler/beans-compiler/get.php --- tests/phpunit/unit/api/compiler/beans-compiler/get.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/get.php b/tests/phpunit/unit/api/compiler/beans-compiler/get.php index 7ac9b01c..e08c06a0 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/get.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/get.php @@ -35,6 +35,7 @@ public function test_should_fix_configuration_dependency_key() { $compiler = new \_Beans_Compiler( $config ); + // Run the tests. $this->assertArrayNotHasKey( 'depedencies', $compiler->config ); $this->assertArrayHasKey( 'dependencies', $compiler->config ); $this->assertSame( array( 'jquery' ), $compiler->config['dependencies'] ); @@ -88,7 +89,7 @@ public function test_should_return_configuration() { /** * Test should return the absolute path to the compiled files directory. */ - public function test_should_return_dir() { + public function test_should_return_absolute_path_to_compiled_files_dir() { $config = array( 'id' => 'test', 'type' => 'style', @@ -97,13 +98,14 @@ public function test_should_return_dir() { $compiler = new \_Beans_Compiler( $config ); + // Run the test. $this->assertSame( vfsStream::url( 'compiled/beans/compiler/test' ), $compiler->dir ); } /** - * Test should return compiled files directory's URL. + * Test should return URL to the compiled files directory. */ - public function test_should_return_url() { + public function test_should_return_url_to_compiled_files_dir() { $config = array( 'id' => 'test_scripts', 'type' => 'script', @@ -111,6 +113,7 @@ public function test_should_return_url() { $compiler = new \_Beans_Compiler( $config ); + // Run the test. $this->assertSame( $this->compiled_url . 'beans/compiler/test_scripts', $compiler->url ); } } From 093c4a1c8a9bcf85e6519e4d157e435ff56764e0 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 19:23:14 -0500 Subject: [PATCH 228/800] Changes to /unit/api/compiler/beans-compiler/getExtension.php --- .../unit/api/compiler/beans-compiler/getExtension.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php index 7e137b30..1fffb367 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php @@ -23,7 +23,7 @@ class Tests_Beans_Compiler_Get_Extension extends Compiler_Test_Case { /** - * Test should return "css" when the type is "style". + * Test get_extension() should return "css" when the type is "style". */ public function test_should_return_css_when_style() { $compiler = new \_Beans_Compiler( array( 'type' => 'style' ) ); @@ -32,7 +32,7 @@ public function test_should_return_css_when_style() { } /** - * Test should return "js" when the type is "script". + * Test get_extension() should return "js" when the type is "script". */ public function test_should_return_js_when_script() { $compiler = new \_Beans_Compiler( array( 'type' => 'script' ) ); @@ -41,7 +41,7 @@ public function test_should_return_js_when_script() { } /** - * Test should return "js" when the type is "script". + * Test get_extension() should return null when the type is invalid. */ public function test_should_return_null_when_invalid_type() { $compiler = new \_Beans_Compiler( array( 'type' => 'invalid' ) ); From 41dac237e40a3d076ac255f8c88cf7709b815c15 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 19:26:16 -0500 Subject: [PATCH 229/800] Changes to /unit/api/compiler/beans-compiler/getFunctionContent.php --- .../api/compiler/beans-compiler/getFunctionContent.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php index 96398138..7a85b1d0 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php @@ -30,17 +30,20 @@ class Tests_Beans_Compiler_Get_Function_Content extends Compiler_Test_Case { public function test_should_return_false_when_fragment_not_callable() { $compiler = new \_Beans_Compiler( array() ); + // Run the tests. $this->assertfalse( $compiler->get_function_content() ); + $this->set_current_fragment( $compiler, 'function_does_not_exists' ); $this->assertfalse( $compiler->get_function_content() ); + $this->set_current_fragment( $compiler, array( $this, 'method_does_not_exist' ) ); $this->assertfalse( $compiler->get_function_content() ); } /** - * Test get_function_content() should return content from function. + * Test get_function_content() should return content from a function. */ - public function test_should_return_return_content_from_function() { + public function test_should_return_content_from_function() { $fragment = 'beans_test_get_function_content_callback'; $compiler = new \_Beans_Compiler( array() ); @@ -55,7 +58,7 @@ public function test_should_return_return_content_from_function() { /** * Test get_function_content() should return content from an object's method. */ - public function test_should_return_return_content_from_method() { + public function test_should_return_content_from_method() { $compiler = new \_Beans_Compiler( array() ); // Set up the mock. From da699998f9dfe9df8d06d41abaaa6257213bf5eb Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 19:28:31 -0500 Subject: [PATCH 230/800] Changes to /unit/api/compiler/beans-compiler/getInternalContent.php --- .../unit/api/compiler/beans-compiler/getInternalContent.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php index b49a85f3..6ce98d1c 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php @@ -29,6 +29,8 @@ class Tests_Beans_Compiler_Get_Internal_Content extends Compiler_Test_Case { */ public function test_should_return_false_when_fragment_is_empty() { $compiler = new _Beans_Compiler( array() ); + + // Run the test. $this->assertfalse( $compiler->get_internal_content() ); } @@ -48,7 +50,7 @@ public function test_should_return_false_when_file_does_not_exist() { } /** - * Test get_internal_content() should fragment's contents. + * Test get_internal_content() should return a fragment's contents. */ public function test_should_return_fragment_contents() { // Set up the compiler. From 942bc846dd4b026300d10295728c219e4cf248c1 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 19:34:24 -0500 Subject: [PATCH 231/800] Changes to /unit/api/compiler/beans-compiler/getRemoteContent.php --- .../compiler/beans-compiler/getRemoteContent.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index 91edce96..6e7af76b 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -25,20 +25,23 @@ class Tests_Beans_Compiler_Get_Remote_Content extends Compiler_Test_Case { /** - * Test get_remote_content() should return false when fragment is empty. + * Test get_remote_content() should return false when the fragment is empty. */ public function test_should_return_false_when_fragment_is_empty() { $compiler = new _Beans_Compiler( array() ); + // Run the tests. $this->assertfalse( $compiler->get_remote_content() ); + $this->set_current_fragment( $compiler, false ); $this->assertfalse( $compiler->get_remote_content() ); + $this->set_current_fragment( $compiler, '' ); $this->assertfalse( $compiler->get_remote_content() ); } /** - * Test get_remote_content() should return empty string when the remote site or file does not exist. + * Test get_remote_content() should return an empty string when the remote site or file does not exist. */ public function test_should_return_empty_string_when_remote_does_not_exist() { // Set up the compiler. @@ -57,7 +60,7 @@ public function test_should_return_empty_string_when_remote_does_not_exist() { /** * Test get_remote_content() should retry and then return false when the remote file does not exist. */ - public function test_should_return_retry_and_return_false() { + public function test_should_retry_and_return_false_when_remote_file_does_not_exist() { // Set up the compiler. $fragment = 'http://beans.local/invalid-file.js'; $compiler = new _Beans_Compiler( array() ); @@ -88,7 +91,7 @@ public function test_should_return_retry_and_return_false() { } /** - * Test get_remote_content() should return the content when fragment is a relative url. + * Test get_remote_content() should return the content when the fragment has a relative url. */ public function test_should_return_content_when_relative_url() { // Set up the compiler. @@ -124,7 +127,7 @@ public function test_should_return_content_when_relative_url() { } /** - * Test get_remote_content() should return the content when fragment is http URL. + * Test get_remote_content() should return the content when the fragment has an http URL. */ public function test_should_return_content_when_http() { // Set up the compiler. @@ -160,7 +163,7 @@ public function test_should_return_content_when_http() { } /** - * Test get_remote_content() should return the content when fragment is https URL. + * Test get_remote_content() should return the content when the fragment has an https URL. */ public function test_should_return_content_when_https() { // Set up the compiler. From 08a7a815c3b24c0e13e7e63f0fe816503dc16d25 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 19:44:49 -0500 Subject: [PATCH 232/800] Changes to /unit/api/compiler/beans-compiler/replaceCssUrl.php --- .../api/compiler/beans-compiler/replaceCssUrl.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php index a9154c70..a5913c17 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php @@ -42,23 +42,25 @@ public function test_should_return_original_content_when_no_url() { box-shadow: inset 0px -3px 20px rgba(0,0,0,0.04); } EOB; + // Run the test. $this->assertSame( $css, $compiler->replace_css_url( $css ) ); } /** - * Test replace_css_url() should return original content when it has a valid URI. + * Test replace_css_url() should return original content when the CSS source has a valid URI. */ public function test_should_return_original_content_when_valid_uri() { $compiler = new _Beans_Compiler( array() ); $css = <<assertSame( $css, $compiler->replace_css_url( $css ) ); } @@ -84,6 +86,7 @@ public function test_should_convert_relative_url_when_no_up_levels() { $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); } @@ -109,6 +112,7 @@ public function test_should_convert_relative_url() { '"http://foo.com/assets/images/hero-2.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); // Test with spaces and single quotes. @@ -122,6 +126,7 @@ public function test_should_convert_relative_url() { '"http://foo.com/assets/images/hero-2.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); // Test with spaces and double quotes. @@ -135,6 +140,7 @@ public function test_should_convert_relative_url() { '"http://foo.com/assets/images/hero-2.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); } @@ -160,6 +166,7 @@ public function test_should_convert_deeper_relative_url() { '"http://example.com/assets/images/hero-1.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); // Test with spaces and single quotes. @@ -173,6 +180,7 @@ public function test_should_convert_deeper_relative_url() { '"http://example.com/assets/images/hero-1.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); // Test with spaces and double quotes. @@ -186,6 +194,7 @@ public function test_should_convert_deeper_relative_url() { '"http://example.com/assets/images/hero-1.jpg"', $css ); + // Run the test. $this->assertSame( $expected, $compiler->replace_css_url( $css ) ); } } From 7bd598aa9e3c103f32a6cf096006d76fbceb5e9b Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 19:59:14 -0500 Subject: [PATCH 233/800] Changes to both runCompiler.php --- .../compiler/beans-compiler/runCompiler.php | 10 ++++----- .../compiler/beans-compiler/runCompiler.php | 22 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php index 9271e97e..6de9ba79 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -117,7 +117,7 @@ public function test_should_enqueue_existing_cached_file_when_no_modifications() /** * Test cache_file() should recompile when a fragment(s) changes. When this happens, the existing cached file - * is removed and the new one is stored in the filesystem. + * is removed and the new file is stored in the filesystem. */ public function test_should_recompile_when_fragments_change() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); @@ -162,7 +162,7 @@ public function test_should_recompile_when_fragments_change() { $this->assertFileNotExists( $modified_file ); /** - * We've now completed the set up process. Let's test that the original fragment has changed by + * We've now completed the setup process. Let's test that the original fragment has changed by * testing that it is not equal to the modification time, filename, and hashes. */ $this->assertNotEquals( $modified_filemtime, $original_filemtime ); @@ -223,7 +223,7 @@ public function test_should_compile_save_and_enqueue_jquery() { } /** - * Test cache_file() should compile JavaScript, saving it to the virtual filesystem and enqueuing it WordPress. + * Test cache_file() should compile JavaScript, saving it to the virtual filesystem and enqueuing it in WordPress. */ public function test_should_compile_save_and_enqueue_js() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); @@ -255,7 +255,7 @@ public function test_should_compile_save_and_enqueue_js() { } /** - * Test cache_file() should compile CSS, saving it to the virtual filesystem and enqueuing it WordPress. + * Test cache_file() should compile CSS, saving it to the virtual filesystem and enqueuing it in WordPress. */ public function test_should_compile_save_and_enqueue_css() { $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); @@ -287,7 +287,7 @@ public function test_should_compile_save_and_enqueue_css() { } /** - * Test cache_file() should compile Less, saving it to the virtual filesystem and enqueuing it WordPress. + * Test cache_file() should compile Less, saving it to the virtual filesystem and enqueuing it in WordPress. */ public function test_should_compile_save_and_enqueue_less() { $config = array( diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index b01a7b5e..e8c4c065 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -117,7 +117,7 @@ public function test_should_enqueue_existing_cached_file_when_no_modifications() /** * Test cache_file() should recompile when a fragment(s) changes. When this happens, the existing cached file - * is removed and the new one is stored in the filesystem. + * is removed and the new file is stored in the filesystem. */ public function test_should_recompile_when_fragments_change() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); @@ -148,7 +148,7 @@ public function test_should_recompile_when_fragments_change() { $this->assertFileExists( $original_file ); /** - * Next step is to modify the fragment, which will change it's modification time. Let's add an opening + * Next step is to modify the fragment, which will change its modification time. Let's add an opening * comment to the fragment's content and then set up the modified file for our tests. */ $compiled_content = $this->get_compiled_jquery() . "console.log('Beans rocks!');"; @@ -162,7 +162,7 @@ public function test_should_recompile_when_fragments_change() { $this->assertFileNotExists( $modified_file ); /** - * We've now completed the set up process. Let's test that the original fragment has changed by + * We've now completed the setup process. Let's test that the original fragment has changed by * testing that it is not equal to the modification time, filename, and hashes. */ $this->assertNotEquals( $modified_filemtime, $original_filemtime ); @@ -189,9 +189,9 @@ public function test_should_recompile_when_fragments_change() { } /** - * Test cache_file() should compile jQuery, saving it to the virtual filesystem and enqueuing it WordPress. + * Test cache_file() should compile jQuery, saving it to the virtual filesystem and enqueuing it in WordPress. */ - public function test_should_compile_jquery() { + public function test_should_compile_save_and_enqueue_jquery() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); $config = array( 'id' => 'test-jquery', @@ -221,9 +221,9 @@ public function test_should_compile_jquery() { } /** - * Test cache_file() should compile JavaScript, saving it to the virtual filesystem and enqueuing it WordPress. + * Test cache_file() should compile JavaScript, saving it to the virtual filesystem and enqueuing it in WordPress. */ - public function test_should_compile_js() { + public function test_should_compile_save_and_enqueue_js() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); $config = array( 'id' => 'test-js', @@ -252,9 +252,9 @@ public function test_should_compile_js() { } /** - * Test cache_file() should compile CSS, saving it to the virtual filesystem and enqueuing it WordPress. + * Test cache_file() should compile CSS, saving it to the virtual filesystem and enqueuing it in WordPress. */ - public function test_should_compile_css() { + public function test_should_compile_save_and_enqueue_css() { $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); $config = array( 'id' => 'test-css', @@ -283,9 +283,9 @@ public function test_should_compile_css() { } /** - * Test cache_file() should compile Less, saving it to the virtual filesystem and enqueuing it WordPress. + * Test cache_file() should compile Less, saving it to the virtual filesystem and enqueuing it in WordPress. */ - public function test_should_compile_less() { + public function test_should_compile_save_and_enqueue_less() { $config = array( 'id' => 'test-css', 'type' => 'style', From 77f277ff9bb290d2569e9cff9c436f3d6f015850 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 20:03:35 -0500 Subject: [PATCH 234/800] Changes to /unit/api/compiler/beans-compiler/setFilename.php --- .../phpunit/unit/api/compiler/beans-compiler/setFilename.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php index 7f533093..339a6d6b 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php @@ -51,7 +51,7 @@ public function test_should_return_hash_created_with_fragments_filemtime() { } /** - * Test set_filename() should return the hash created with the modification time from each of the fragments. + * Test set_filename() should exclude external fragments. */ public function test_should_exclude_external_fragments() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); @@ -119,7 +119,7 @@ public function test_should_remove_old_file() { $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); /** - * Next step is to modify the fragment, which will change it's modification time. Let's add an opening + * Next step is to modify the fragment, which will change its modification time. Let's add an opening * comment to the fragment's content and then set up the modified file for our tests. */ $file = $this->mock_filesystem->getChild( 'fixtures' )->getChild( 'jquery.test.js' ); From 76dde913ef895bb02da10d7c9d7a2f6bc70f7995 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 31 Jan 2018 20:07:55 -0500 Subject: [PATCH 235/800] Changes to /unit/api/compiler/beans-compiler/setFragments.php --- .../unit/api/compiler/beans-compiler/setFragments.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php index 118632bf..d0fa04e1 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php @@ -25,7 +25,7 @@ class Tests_Beans_Compiler_Set_Fragments extends Compiler_Test_Case { /** - * Test should return unchanged fragments, meaning no fragments were added or removed. + * Test set_fragments() should return unchanged fragments, meaning no fragments were added or removed. */ public function test_should_return_unchanged_fragments() { $config = array( @@ -49,7 +49,7 @@ public function test_should_return_unchanged_fragments() { } /** - * Test should return fragments merged with the fragments stored in the global variable. + * Test set_fragments() should return fragments merged with the fragments stored in the global variable. */ public function test_should_return_fragments_merged_with_global() { $config = array( @@ -81,7 +81,7 @@ public function test_should_return_fragments_merged_with_global() { } /** - * Test should fire the "beans_compiler_fragments_{id}" event. + * Test set_fragments() should fire the "beans_compiler_fragments_{id}" event. */ public function test_should_fire_event() { $config = array( @@ -96,7 +96,7 @@ public function test_should_fire_event() { $compiler = new \_Beans_Compiler( $config ); - // Set up the expectation first before firing the event. + // Set up the expectation before firing the event. Monkey\Filters\expectApplied( 'beans_compiler_fragments_test' ) ->once() ->with( $config['fragments'] ) From 9e71153707c16856f59d5d54c70ca3ae543ed9de Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 2 Feb 2018 15:51:26 -0600 Subject: [PATCH 236/800] Fixed virtual path due to inconsistencies on Windows.' --- .../api/compiler/beansGetCompilerDir.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php index 4947b053..104e798b 100644 --- a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php +++ b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php @@ -28,8 +28,8 @@ class Test_BeansGetCompilerDir extends Compiler_Test_Case { */ public function test_should_return_absolute_path_to_compiler_folder() { $this->assertSame( - $this->get_virtual_dir( 'compiled/beans/compiler/' ), - beans_get_compiler_dir() + vfsStream::url( 'compiled/beans/compiler/' ), + $this->fix_virtual_dir( beans_get_compiler_dir() ) ); } @@ -38,21 +38,24 @@ public function test_should_return_absolute_path_to_compiler_folder() { */ public function test_should_return_absolute_path_to_compiler_admin_folder() { $this->assertSame( - $this->get_virtual_dir( 'compiled/beans/admin-compiler/' ), - beans_get_compiler_dir( true ) + vfsStream::url( 'compiled/beans/admin-compiler/' ), + $this->fix_virtual_dir( beans_get_compiler_dir( true ) ) ); } /** - * Get the virtual directory. Modify the root, as wp_normalize_path changes it. + * Fix the virtual directory. Modify the root, as wp_normalize_path changes it. * * @since 1.5.0 * - * @param string $path The path to get. + * @param string $path The path to fix. * * @return string */ - protected function get_virtual_dir( $path ) { - return str_replace( 'vfs://', 'vfs:/', vfsStream::url( $path ) ); + protected function fix_virtual_dir( $path ) { + if ( substr( $path, 0, 6 ) === 'vfs://' ) { + return $path; + } + return str_replace( 'vfs:/', 'vfs://', $path ); } } From a0f945da341a70fe161d9ceadc842c85dfa6455f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 09:15:47 -0600 Subject: [PATCH 237/800] Fixed tests @group. --- .../api/compiler/beans-compiler/addContentMediaQuery.php | 2 +- .../integration/api/compiler/beans-compiler/cacheFile.php | 2 +- .../api/compiler/beans-compiler/combineFragments.php | 2 +- .../integration/api/compiler/beans-compiler/fileystem.php | 2 +- .../integration/api/compiler/beans-compiler/formatContent.php | 2 +- .../api/compiler/beans-compiler/getInternalContent.php | 2 +- .../api/compiler/beans-compiler/getRemoteContent.php | 2 +- .../integration/api/compiler/beans-compiler/replaceCssUrl.php | 2 +- .../integration/api/compiler/beans-compiler/runCompiler.php | 2 +- .../integration/api/compiler/beans-compiler/setFilename.php | 2 +- tests/phpunit/integration/api/compiler/beansGetCompilerDir.php | 2 +- tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php | 2 +- .../unit/api/compiler/beans-compiler/addContentMediaQuery.php | 2 +- tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php | 2 +- .../phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php | 2 +- .../unit/api/compiler/beans-compiler/combineFragments.php | 2 +- tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php | 2 +- .../phpunit/unit/api/compiler/beans-compiler/formatContent.php | 2 +- tests/phpunit/unit/api/compiler/beans-compiler/get.php | 2 +- tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php | 2 +- .../unit/api/compiler/beans-compiler/getFunctionContent.php | 2 +- .../unit/api/compiler/beans-compiler/getInternalContent.php | 2 +- .../unit/api/compiler/beans-compiler/getRemoteContent.php | 2 +- .../phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php | 2 +- tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php | 2 +- tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php | 2 +- tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php | 2 +- tests/phpunit/unit/api/compiler/beansGetCompilerDir.php | 2 +- tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php | 2 +- 29 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php index cedef7f4..741753b4 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php @@ -18,8 +18,8 @@ * Class Tests_Beans_Compiler_Add_Content_Media_Query * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Add_Content_Media_Query extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php index e2e5d5f2..ba15fd89 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php @@ -20,8 +20,8 @@ * Class Tests_Beans_Compiler_Cache_File * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Cache_File extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php index 2fc742b6..3eef3eaa 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Combine_Fragments * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Combine_Fragments extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php index 304e03ca..d900a5e9 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Filesystem * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Filesystem extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php index 4a2e0073..4c19bf5e 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -17,8 +17,8 @@ * Class Tests_Beans_Compiler_Format_Content * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Format_Content extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php index 855e9aa0..895570f2 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Get_Internal_Content * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Get_Internal_Content extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php index 4f9e76b6..58e81b5d 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php @@ -18,8 +18,8 @@ * Class Tests_Beans_Compiler_Get_Remote_Content * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Get_Remote_Content extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php index eb2a2635..3d8c1e37 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php @@ -18,8 +18,8 @@ * Class Tests_Beans_Compiler_Replace_Css_Url * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Replace_Css_Url extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php index 6de9ba79..acc358a8 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Run_Compiler * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Run_Compiler extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php index a308dc68..da8db3fd 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php @@ -18,8 +18,8 @@ * Class Tests_Beans_Compiler_Set_Filename * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php index 104e798b..2dc6c2d9 100644 --- a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php +++ b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php @@ -18,8 +18,8 @@ * Class Test_BeansGetCompilerDir * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Test_BeansGetCompilerDir extends Compiler_Test_Case { diff --git a/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php b/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php index 492b7337..00249d0a 100644 --- a/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php +++ b/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php @@ -17,8 +17,8 @@ * Class Test_BeansGetCompilerUrl * * @package Beans\Framework\Tests\Integration\API\Compiler - * @group integration-tests * @group api + * @group api-compiler */ class Test_BeansGetCompilerUrl extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php index edf0f5c1..656e91d9 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Add_Content_Media_Query * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Add_Content_Media_Query extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php index c4da4ead..30f3ddb2 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Cache_File * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Cache_File extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php index 14633ab9..0d068e70 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php @@ -18,8 +18,8 @@ * Class Tests_Beans_Compiler_CacheFileExist * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_CacheFileExist extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php index cc4144b9..a70a28ff 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Combine_Fragments * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Combine_Fragments extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php index 99e396c1..2c2bc484 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Filesystem * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Filesystem extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php index 650b22a5..8be96ae8 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Format_Content * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Format_Content extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/get.php b/tests/phpunit/unit/api/compiler/beans-compiler/get.php index e08c06a0..4f8a75d7 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/get.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/get.php @@ -18,8 +18,8 @@ * Class Tests_Beans_Compiler_Get * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Get extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php index 1fffb367..428ce3fa 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php @@ -17,8 +17,8 @@ * Class Tests_Beans_Compiler_Get_Extension * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Get_Extension extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php index 7a85b1d0..5b90fa93 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Get_Function_Content * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Get_Function_Content extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php index 6ce98d1c..38ed4e27 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Get_Internal_Content * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Get_Internal_Content extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index 6e7af76b..6ba497d5 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Get_Remote_Content * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Get_Remote_Content extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php index a5913c17..57523f48 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Replace_Css_Url * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Replace_Css_Url extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index e8c4c065..35ce32c2 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -20,8 +20,8 @@ * Class Tests_Beans_Compiler_Run_Compiler * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Run_Compiler extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php index 339a6d6b..d445a6de 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php @@ -18,8 +18,8 @@ * Class Tests_Beans_Compiler_Set_Filename * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php index d0fa04e1..dab86912 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Compiler_Set_Fragments * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Tests_Beans_Compiler_Set_Fragments extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beansGetCompilerDir.php b/tests/phpunit/unit/api/compiler/beansGetCompilerDir.php index b59efbcb..507638b0 100644 --- a/tests/phpunit/unit/api/compiler/beansGetCompilerDir.php +++ b/tests/phpunit/unit/api/compiler/beansGetCompilerDir.php @@ -18,8 +18,8 @@ * Class Test_BeansGetCompilerDir * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Test_BeansGetCompilerDir extends Compiler_Test_Case { diff --git a/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php b/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php index 91418289..717fbbdd 100644 --- a/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php +++ b/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php @@ -17,8 +17,8 @@ * Class Test_BeansGetCompilerUrl * * @package Beans\Framework\Tests\Unit\API\Compiler - * @group unit-tests * @group api + * @group api-compiler */ class Test_BeansGetCompilerUrl extends Compiler_Test_Case { From 2cf8bb4e85d692bb9f20ee44c6291b5a245f0b66 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 09:17:49 -0600 Subject: [PATCH 238/800] Loaded utilities in unit test setUp(). --- .../unit/api/compiler/includes/class-compiler-test-case.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 8da795d4..17fb571f 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -63,7 +63,6 @@ abstract class Compiler_Test_Case extends Test_Case { public static function setUpBeforeClass() { parent::setUpBeforeClass(); - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; require_once BEANS_TESTS_LIB_DIR . 'api/compiler/class-beans-compiler.php'; require_once BEANS_TESTS_LIB_DIR . 'api/compiler/functions.php'; @@ -93,6 +92,10 @@ protected function setUp() { Functions\expect( 'is_admin' )->andReturn( $this->is_admin ); Functions\expect( 'site_url' )->andReturn( 'http:://beans.local' ); + + $this->load_original_functions( array( + 'api/utilities/functions.php', + ) ); } /** From c6c934334571f7d8f803a07892eab4ba45c5cd19 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 09:23:58 -0600 Subject: [PATCH 239/800] Replaced deprecated phpcs ignore rules. --- lib/api/compiler/class-beans-compiler.php | 15 +++++++-------- lib/api/compiler/functions.php | 2 +- .../includes/class-compiler-test-case.php | 8 ++++---- .../api/compiler/beans-compiler/fileystem.php | 2 +- .../includes/class-compiler-test-case.php | 10 +++++----- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index e95fc174..2e5f8eb9 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -163,7 +163,7 @@ private function is_wp_filesystem_direct() { */ private function maybe_make_dir() { - if ( ! @is_dir( $this->dir ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + if ( ! @is_dir( $this->dir ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- This is a valid use case. wp_mkdir_p( $this->dir ); } @@ -223,7 +223,7 @@ public function set_filename() { * @return string */ public function hash( array $given_array ) { - return substr( md5( @serialize( $given_array ) ), 0, 7 ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } /** @@ -431,7 +431,7 @@ public function get_internal_content() { $fragment = beans_url_to_path( $fragment ); // Stop here if it isn't a valid file. - if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. return false; } } @@ -680,7 +680,7 @@ private function get_fragments_filemtime() { } if ( file_exists( $fragment ) ) { - $fragments_filemtime[ $index ] = @filemtime( $fragment ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $fragments_filemtime[ $index ] = @filemtime( $fragment ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } @@ -727,7 +727,7 @@ private function get_new_hash( $hash, array $fragments_filemtime ) { * @return void */ private function remove_modified_files( $hash, $filemtime_hash ) { - $items = @scandir( $this->dir ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $items = @scandir( $this->dir ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. unset( $items[0], $items[1] ); if ( empty( $items ) ) { @@ -737,7 +737,7 @@ private function remove_modified_files( $hash, $filemtime_hash ) { foreach ( $items as $item ) { // Skip this one if it's a directory. - if ( @is_dir( $item ) ) { // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + if ( @is_dir( $item ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. continue; } @@ -764,7 +764,7 @@ private function remove_modified_files( $hash, $filemtime_hash ) { } // Clean up other modified files. - @unlink( $this->dir . '/' . $item ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + @unlink( $this->dir . '/' . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } @@ -919,7 +919,6 @@ public function set_filname() { */ public function __get( $property ) { - // If the property exists, return it. if ( property_exists( $this, $property ) ) { return $this->{$property}; } diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index c651b35d..d265231f 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -211,7 +211,7 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { foreach ( $items as $item ) { if ( false !== stripos( $item, '.' . $file_format ) ) { - @unlink( trailingslashit( $dir ) . $item ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + @unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index 42f88ae1..fa850a77 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -101,7 +101,7 @@ private function set_up_virtual_filesystem() { // Load the fixture files and content into the virtual filesystem. foreach ( $filenames as $filename ) { - $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - valid edge case. + $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid edge case. } // Set up the "compiled" directory's virtual filesystem. @@ -216,7 +216,7 @@ protected function mock_filesystem_for_fragments( ) { if ( ! defined( 'FS_CHMOD_FILE' ) ) { - define( 'FS_CHMOD_FILE', 0644 ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - valid constant. + define( 'FS_CHMOD_FILE', 0644 ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Valid constant. } unset( $GLOBALS['wp_filesystem'] ); @@ -228,10 +228,10 @@ protected function mock_filesystem_for_fragments( $mock->shouldReceive( 'get_contents' ) ->times( $times_called ) ->with( $fragment ) - ->andReturn( file_get_contents( $fragment ) ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents && WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents - valid in this edge case. + ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents, WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents -- Valid in this edge case. } - $GLOBALS['wp_filesystem'] = $mock; // @codingStandardsIgnoreLine - WordPress.Variables.GlobalVariables.OverrideProhibited This is a valid use case as we are mocking the filesystem. + $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case, as we are mocking the filesystem. } /** diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php index 2c2bc484..f67d2723 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php @@ -30,7 +30,7 @@ class Tests_Beans_Compiler_Filesystem extends Compiler_Test_Case { public function test_should_return_true_when_wp_filesystem_is_init() { // Initialize the wp_filesystem global variable. Mockery::mock( 'WP_Filesystem_Direct' ); - $GLOBALS['wp_filesystem'] = new \WP_Filesystem_Direct(); // @codingStandardsIgnoreLine - WordPress.Variables.GlobalVariables.OverrideProhibited This is a valid use case as we are mocking the filesystem. + $GLOBALS['wp_filesystem'] = new \WP_Filesystem_Direct(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case as we are mocking the filesystem. Functions\when( 'WP_Filesystem' )->justReturn( true ); diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 17fb571f..4cadb624 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -67,7 +67,7 @@ public static function setUpBeforeClass() { require_once BEANS_TESTS_LIB_DIR . 'api/compiler/functions.php'; if ( ! defined( 'FS_CHMOD_FILE' ) ) { - define( 'FS_CHMOD_FILE', 0644 ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - valid constant. + define( 'FS_CHMOD_FILE', 0644 ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Valid constant. } } @@ -139,7 +139,7 @@ private function set_up_virtual_filesystem() { // Load the fixture files and content into the virtual filesystem. foreach ( $filenames as $filename ) { - $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - valid edge case. + $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid edge case. } // Set up the "compiled" directory's virtual filesystem. @@ -230,10 +230,10 @@ protected function mock_filesystem_for_fragments( $compiler, $times_called = 1 ) $mock->shouldReceive( 'get_contents' ) ->times( $times_called ) ->with( $fragment ) - ->andReturn( file_get_contents( $fragment ) ); // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents && WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents - valid in this edge case. + ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents && WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents -- Valid in this edge case. } - $GLOBALS['wp_filesystem'] = $mock; // @codingStandardsIgnoreLine - WordPress.Variables.GlobalVariables.OverrideProhibited This is a valid use case as we are mocking the filesystem. + $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case as we are mocking the filesystem. } /** @@ -241,7 +241,7 @@ protected function mock_filesystem_for_fragments( $compiler, $times_called = 1 ) * * @since 1.5.0 * - * @param bool $is_enabled Optional. When true, developement mode is enabled. Default is false. + * @param bool $is_enabled Optional. When true, development mode is enabled. Default is false. * * @return void */ From c6313abc10ec29430e865283da40b96b5a4c7165 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 09:32:09 -0600 Subject: [PATCH 240/800] Ignored rules for file_get_contents() in tests. --- .../api/compiler/includes/class-compiler-test-case.php | 2 +- .../unit/api/compiler/includes/class-compiler-test-case.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index fa850a77..62b98452 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -101,7 +101,7 @@ private function set_up_virtual_filesystem() { // Load the fixture files and content into the virtual filesystem. foreach ( $filenames as $filename ) { - $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid edge case. + $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid edge case. } // Set up the "compiled" directory's virtual filesystem. diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 4cadb624..907412f7 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -139,7 +139,7 @@ private function set_up_virtual_filesystem() { // Load the fixture files and content into the virtual filesystem. foreach ( $filenames as $filename ) { - $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid edge case. + $structure['fixtures'][ $filename ] = file_get_contents( $fixtures_dir . $filename ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid edge case. } // Set up the "compiled" directory's virtual filesystem. @@ -230,7 +230,7 @@ protected function mock_filesystem_for_fragments( $compiler, $times_called = 1 ) $mock->shouldReceive( 'get_contents' ) ->times( $times_called ) ->with( $fragment ) - ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents && WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents -- Valid in this edge case. + ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid in this edge case. } $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case as we are mocking the filesystem. From 6cd1dddff9a289df7f6f922589827c59d0d673ad Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 09:44:50 -0600 Subject: [PATCH 241/800] Fixed tests @group. --- .../api/image/beans-image-editor/createEditedImage.php | 2 +- tests/phpunit/integration/api/image/beans-image-editor/run.php | 2 +- tests/phpunit/integration/api/image/beansEditImage.php | 2 +- tests/phpunit/integration/api/image/beansGetImagesDir.php | 2 +- .../unit/api/image/beans-image-editor/createEditedImage.php | 2 +- tests/phpunit/unit/api/image/beans-image-editor/run.php | 2 +- tests/phpunit/unit/api/image/beansEditImage.php | 2 +- tests/phpunit/unit/api/image/beansGetImagesDir.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php index 844428ca..c98cf714 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Edit_Image_CreateEditedImage * * @package Beans\Framework\Tests\Integration\API\Image - * @group integration-tests * @group api + * @group api-image */ class Tests_Beans_Edit_Image_CreateEditedImage extends Image_Test_Case { diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php index df8fcf83..2bfc7603 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -19,8 +19,8 @@ * Class Tests_Beans_Edit_Image_Run * * @package Beans\Framework\Tests\Integration\API\Image - * @group integration-tests * @group api + * @group api-image */ class Tests_Beans_Edit_Image_Run extends Image_Test_Case { diff --git a/tests/phpunit/integration/api/image/beansEditImage.php b/tests/phpunit/integration/api/image/beansEditImage.php index 462782d4..0c709ea0 100644 --- a/tests/phpunit/integration/api/image/beansEditImage.php +++ b/tests/phpunit/integration/api/image/beansEditImage.php @@ -17,8 +17,8 @@ * Class Tests_BeansEditImage * * @package Beans\Framework\Tests\Integration\API\Image - * @group integration-tests * @group api + * @group api-image */ class Tests_BeansEditImage extends Image_Test_Case { diff --git a/tests/phpunit/integration/api/image/beansGetImagesDir.php b/tests/phpunit/integration/api/image/beansGetImagesDir.php index 3fd52d36..45972465 100644 --- a/tests/phpunit/integration/api/image/beansGetImagesDir.php +++ b/tests/phpunit/integration/api/image/beansGetImagesDir.php @@ -19,8 +19,8 @@ * Class Tests_BeansGetImagesDir * * @package Beans\Framework\Tests\Integration\API\Image - * @group integration-tests * @group api + * @group api-image */ class Tests_BeansGetImagesDir extends Image_Test_Case { diff --git a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php index 0b1e527a..2bfc1845 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php @@ -21,8 +21,8 @@ * Class Tests_Beans_Edit_Image_CreateEditedImage * * @package Beans\Framework\Tests\Unit\API\Image - * @group unit-tests * @group api + * @group api-image */ class Tests_Beans_Edit_Image_CreateEditedImage extends Image_Test_Case { diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php index 2c02ec73..ab0df559 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -21,8 +21,8 @@ * Class Tests_Beans_Edit_Image_Run * * @package Beans\Framework\Tests\Unit\API\Image - * @group unit-tests * @group api + * @group api-image */ class Tests_Beans_Edit_Image_Run extends Image_Test_Case { diff --git a/tests/phpunit/unit/api/image/beansEditImage.php b/tests/phpunit/unit/api/image/beansEditImage.php index 537fc49e..493fa869 100644 --- a/tests/phpunit/unit/api/image/beansEditImage.php +++ b/tests/phpunit/unit/api/image/beansEditImage.php @@ -18,8 +18,8 @@ * Class Tests_BeansEditImage * * @package Beans\Framework\Tests\Unit\API\Image - * @group unit-tests * @group api + * @group api-image */ class Tests_BeansEditImage extends Image_Test_Case { diff --git a/tests/phpunit/unit/api/image/beansGetImagesDir.php b/tests/phpunit/unit/api/image/beansGetImagesDir.php index 5e201567..cae7d9dc 100644 --- a/tests/phpunit/unit/api/image/beansGetImagesDir.php +++ b/tests/phpunit/unit/api/image/beansGetImagesDir.php @@ -19,8 +19,8 @@ * Class Tests_BeansGetImagesDir * * @package Beans\Framework\Tests\Unit\API\Image - * @group unit-tests * @group api + * @group api-image */ class Tests_BeansGetImagesDir extends Image_Test_Case { From 04697c45e405f81af74058ea6b25487c4f3c1b3a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 09:49:50 -0600 Subject: [PATCH 242/800] Fixed phpcs:ignore. Waited to load test file dependencies. --- lib/api/image/class-beans-image-editor.php | 4 ++-- .../api/image/beans-image-editor/createEditedImage.php | 2 +- .../integration/api/image/beans-image-editor/run.php | 8 ++++---- .../unit/api/image/includes/class-image-test-case.php | 9 ++++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/api/image/class-beans-image-editor.php b/lib/api/image/class-beans-image-editor.php index d9ab5e9d..5a931356 100644 --- a/lib/api/image/class-beans-image-editor.php +++ b/lib/api/image/class-beans-image-editor.php @@ -132,7 +132,7 @@ private function get_image_info( $src, $edited_image_exists = false ) { } if ( $edited_image_exists ) { - list( $width, $height ) = @getimagesize( $this->rebuilt_path ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + list( $width, $height ) = @getimagesize( $this->rebuilt_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } else { $width = null; $height = null; @@ -165,7 +165,7 @@ private function get_image_info( $src, $edited_image_exists = false ) { private function rebuild_image_path() { $upload_dir = beans_get_images_dir(); $info = pathinfo( preg_replace( '#\?.*#', '', $this->src ) ); - $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. $extension = $info['extension']; $filename = str_replace( '.' . $extension, '', $info['basename'] ); diff --git a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php index c98cf714..b67ed4f3 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php @@ -63,7 +63,7 @@ public function test_should_edit_create_and_store_image() { $this->assertTrue( $created_edited_image->invoke( $editor ) ); $this->assertFileExists( $edited_image_src ); - list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 800, $width ); $this->assertEquals( 420, $height ); } diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php index 2bfc7603..d9ab9845 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -62,7 +62,7 @@ public function test_should_edit_store_and_return_its_url() { $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info ); // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 800, $width ); $this->assertEquals( 420, $height ); } @@ -128,7 +128,7 @@ public function test_should_edit_store_and_return_indexed_array() { $this->assertSame( array( beans_path_to_url( $edited_image_src ), 800, 420 ), $image_info ); // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 800, $width ); $this->assertEquals( 420, $height ); } @@ -197,7 +197,7 @@ public function test_should_edit_store_and_return_object() { $this->assertSame( 210, $image_info->height ); // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 400, $width ); $this->assertEquals( 210, $height ); } @@ -279,7 +279,7 @@ public function test_should_edit_image_and_return_associative_array() { ); // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // @codingStandardsIgnoreLine - Generic.PHP.NoSilencedErrors.Discouraged This is a valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 600, $width ); $this->assertEquals( 315, $height ); } diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index 191f0d95..c0585191 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -61,22 +61,25 @@ abstract class Image_Test_Case extends Test_Case { public static function setUpBeforeClass() { parent::setUpBeforeClass(); - require_once BEANS_TESTS_LIB_DIR . 'api/utilities/functions.php'; require_once BEANS_TESTS_LIB_DIR . 'api/image/functions.php'; foreach ( array( 'ARRAY_N', 'ARRAY_A', 'STRING', 'OBJECT' ) as $constant ) { if ( ! defined( $constant ) ) { - define( $constant, $constant ); // @codingStandardsIgnoreLine - WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - WordPress defined constants. + define( $constant, $constant ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- WordPress defined constants. } } } /** - * Set up the test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); + $this->load_original_functions( array( + 'api/utilities/functions.php', + ) ); + $this->set_up_virtual_filesystem(); $this->images_dir = vfsStream::url( 'uploads/beans/images' ); $this->images_url = 'http:://example.com/uploads/beans/images/'; From 439955d7759a1494da25b6278d7b57cecb87ae83 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 09:56:03 -0600 Subject: [PATCH 243/800] Moved test file loads. --- .../api/image/beans-image-editor/createEditedImage.php | 10 +++++++++- .../phpunit/unit/api/image/beans-image-editor/run.php | 3 ++- .../unit/api/image/includes/class-image-test-case.php | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php index 2bfc1845..aae039e3 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php @@ -15,7 +15,6 @@ use Mockery; require_once dirname( __DIR__ ) . '/includes/class-image-test-case.php'; -require_once BEANS_TESTS_LIB_DIR . 'api/image/class-beans-image-editor.php'; /** * Class Tests_Beans_Edit_Image_CreateEditedImage @@ -42,6 +41,15 @@ public static function setUpBeforeClass() { static::$fixtures_dir = realpath( __DIR__ . '/../fixtures' ); } + /** + * Prepares the test environment before each test. + */ + public function setUp() { + parent::setUp(); + + require_once BEANS_TESTS_LIB_DIR . 'api/image/class-beans-image-editor.php'; + } + /** * Test create_edited_image() should edit the given image and then create a new "edited image", which is stored in * the diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php index ab0df559..806f6735 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -15,7 +15,6 @@ use Mockery; require_once dirname( __DIR__ ) . '/includes/class-image-test-case.php'; -require_once BEANS_TESTS_LIB_DIR . 'api/image/class-beans-image-editor.php'; /** * Class Tests_Beans_Edit_Image_Run @@ -48,6 +47,8 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); + require_once BEANS_TESTS_LIB_DIR . 'api/image/class-beans-image-editor.php'; + Monkey\Functions\when( 'is_main_site' )->justReturn( true ); } diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index c0585191..08969202 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -61,8 +61,6 @@ abstract class Image_Test_Case extends Test_Case { public static function setUpBeforeClass() { parent::setUpBeforeClass(); - require_once BEANS_TESTS_LIB_DIR . 'api/image/functions.php'; - foreach ( array( 'ARRAY_N', 'ARRAY_A', 'STRING', 'OBJECT' ) as $constant ) { if ( ! defined( $constant ) ) { define( $constant, $constant ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- WordPress defined constants. @@ -76,6 +74,8 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); + require_once BEANS_TESTS_LIB_DIR . 'api/image/functions.php'; + $this->load_original_functions( array( 'api/utilities/functions.php', ) ); From 6a5bc7394081b872c8daab451cea95ef5716b429 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 11:41:41 -0600 Subject: [PATCH 244/800] Mocked utility functions for unit tests. --- .../unit/api/image/beans-image-editor/run.php | 175 +++++++----------- .../image/includes/class-image-test-case.php | 31 ++++ 2 files changed, 102 insertions(+), 104 deletions(-) diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php index 806f6735..61a49fe8 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -25,13 +25,6 @@ */ class Tests_Beans_Edit_Image_Run extends Image_Test_Case { - /** - * Path of the fixtures directory. - * - * @var string - */ - protected static $fixtures_dir; - /** * Set up the test fixture before we start. */ @@ -49,22 +42,19 @@ protected function setUp() { require_once BEANS_TESTS_LIB_DIR . 'api/image/class-beans-image-editor.php'; - Monkey\Functions\when( 'is_main_site' )->justReturn( true ); + Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); + Monkey\Functions\when( 'beans_path_to_url' )->returnArg(); } /** * Test run() should edit the existing image, store it in the "rebuilt path", and then return its URL. */ public function test_should_edit_store_and_return_its_url() { - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + $rebuilt_path = $this->get_reflective_property(); + $args = array( 'resize' => array( 800, false ) ); - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args ); + foreach ( $this->images as $actual_path ) { + $editor = new _Beans_Image_Editor( $actual_path, $args ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); // Simulate the WordPress' Editor. @@ -73,17 +63,17 @@ public function test_should_edit_store_and_return_its_url() { $wp_editor->shouldReceive( 'save' ) ->once() ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $src ) { - imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { + imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); } ); - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); // Run the tests. $this->assertFileNotExists( $edited_image_src ); $image_info = $editor->run(); $this->assertFileExists( $edited_image_src ); - $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info ); + $this->assertSame( $edited_image_src, $image_info ); } } @@ -94,9 +84,10 @@ public function test_should_return_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ) ); - // Simulate the WordPress' Editor. + // Setup the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + Monkey\Functions\expect( 'beans_path_to_url' )->never(); // Run the tests. $this->assertFileNotExists( $src ); @@ -108,16 +99,13 @@ public function test_should_return_original_src_when_no_image() { * stored. */ public function test_should_return_url_when_edited_image_exists() { - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + $this->load_images_into_vfs(); + $rebuilt_path = $this->get_reflective_property(); + $args = array( 'resize' => array( 800, false ) ); - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $src ); + foreach ( $this->images as $virtual_path => $actual_path ) { + $editor = new _Beans_Image_Editor( $actual_path, $args ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $virtual_path ); // Check that the WordPress Editor does not get called. Monkey\Functions\expect( 'wp_get_image_editor' )->never(); @@ -125,24 +113,20 @@ public function test_should_return_url_when_edited_image_exists() { // Run the tests. $this->assertFileExists( $edited_image_src ); - $this->assertSame( beans_path_to_url( $edited_image_src ), $editor->run() ); + $this->assertSame( $edited_image_src, $editor->run() ); } } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of its - * image info. + * Test run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of + * its image info. */ public function test_should_edit_store_and_return_indexed_array() { - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + $rebuilt_path = $this->get_reflective_property(); + $args = array( 'resize' => array( 800, false ) ); - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); + foreach ( $this->images as $virtual_path => $actual_path ) { + $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_N ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); // Simulate the WordPress' Editor. @@ -151,17 +135,17 @@ public function test_should_edit_store_and_return_indexed_array() { $wp_editor->shouldReceive( 'save' ) ->once() ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $src ) { - imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { + imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); } ); - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); // Run the tests. $this->assertFileNotExists( $edited_image_src ); $image_info = $editor->run(); $this->assertFileExists( $edited_image_src ); - $this->assertSame( array( beans_path_to_url( $edited_image_src ), 1200, 630 ), $image_info ); + $this->assertSame( array( $edited_image_src, 1200, 630 ), $image_info ); } } @@ -172,9 +156,10 @@ public function test_should_return_indexed_array_with_original_src_when_no_image $src = 'path/does/not/exist/image.jpg'; $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ); - // Simulate the WordPress' Editor. + // Setup the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + Monkey\Functions\expect( 'beans_path_to_url' )->never(); // Run the tests. $this->assertFileNotExists( $src ); @@ -186,16 +171,13 @@ public function test_should_return_indexed_array_with_original_src_when_no_image * edited and stored. */ public function test_should_return_index_array_when_edited_image_exists() { - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + $this->load_images_into_vfs(); + $rebuilt_path = $this->get_reflective_property(); + $args = array( 'resize' => array( 800, false ) ); - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $src ); + foreach ( $this->images as $virtual_path => $actual_path ) { + $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_N ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $virtual_path ); // Check that the WordPress Editor does not get called. Monkey\Functions\expect( 'wp_get_image_editor' )->never(); @@ -203,7 +185,7 @@ public function test_should_return_index_array_when_edited_image_exists() { // Run the tests. $this->assertFileExists( $edited_image_src ); - $this->assertSame( array( beans_path_to_url( $edited_image_src ), 1200, 630 ), $editor->run() ); + $this->assertSame( array( $edited_image_src, 1200, 630 ), $editor->run() ); } } @@ -212,16 +194,11 @@ public function test_should_return_index_array_when_edited_image_exists() { * object. */ public function test_should_edit_store_and_return_object() { - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 400, false ) ); + $rebuilt_path = $this->get_reflective_property(); + $args = array( 'resize' => array( 400, false ) ); - // Run the tests. - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, OBJECT ); + foreach ( $this->images as $actual_path ) { + $editor = new _Beans_Image_Editor( $actual_path, $args, OBJECT ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); // Simulate the WordPress' Editor. @@ -230,17 +207,17 @@ public function test_should_edit_store_and_return_object() { $wp_editor->shouldReceive( 'save' ) ->once() ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $src ) { - imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { + imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); } ); - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); // Run the tests. $this->assertFileNotExists( $edited_image_src ); $image_info = $editor->run(); $this->assertInstanceOf( 'stdClass', $image_info ); - $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info->src ); + $this->assertSame( $edited_image_src, $image_info->src ); $this->assertSame( 1200, $image_info->width ); $this->assertSame( 630, $image_info->height ); $this->assertFileExists( $edited_image_src ); @@ -254,9 +231,10 @@ public function test_should_return_object_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), OBJECT ); - // Simulate the WordPress' Editor. + // Setup the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + Monkey\Functions\expect( 'beans_path_to_url' )->never(); // Run the tests. $this->assertFileNotExists( $src ); @@ -272,17 +250,13 @@ public function test_should_return_object_with_original_src_when_no_image() { * edited and stored. */ public function test_should_return_object_when_edited_image_exists() { - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 400, false ) ); + $this->load_images_into_vfs(); + $rebuilt_path = $this->get_reflective_property(); + $args = array( 'resize' => array( 400, false ) ); - // Run the tests. - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, OBJECT ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $src ); + foreach ( $this->images as $virtual_path => $actual_path ) { + $editor = new _Beans_Image_Editor( $actual_path, $args, OBJECT ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $virtual_path ); // Check that the WordPress Editor does not get called. Monkey\Functions\expect( 'wp_get_image_editor' )->never(); @@ -292,7 +266,7 @@ public function test_should_return_object_when_edited_image_exists() { $this->assertFileExists( $edited_image_src ); $actual = $editor->run(); $this->assertInstanceOf( 'stdClass', $actual ); - $this->assertSame( beans_path_to_url( $edited_image_src ), $actual->src ); + $this->assertSame( $edited_image_src, $actual->src ); $this->assertSame( 1200, $actual->width ); $this->assertSame( 630, $actual->height ); } @@ -303,15 +277,11 @@ public function test_should_return_object_when_edited_image_exists() { * associative array. */ public function test_should_edit_image_and_return_associative_array() { - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 600, false ) ); + $rebuilt_path = $this->get_reflective_property(); + $args = array( 'resize' => array( 600, false ) ); - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, ARRAY_A ); + foreach ( $this->images as $actual_path ) { + $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_A ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); // Simulate the WordPress' Editor. @@ -320,10 +290,10 @@ public function test_should_edit_image_and_return_associative_array() { $wp_editor->shouldReceive( 'save' ) ->once() ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $src ) { - imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { + imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); } ); - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); + Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); // Run the tests. @@ -332,7 +302,7 @@ public function test_should_edit_image_and_return_associative_array() { $this->assertFileExists( $edited_image_src ); $this->assertSame( array( - 'src' => beans_path_to_url( $edited_image_src ), + 'src' => $edited_image_src, 'width' => 1200, 'height' => 630, ), @@ -348,9 +318,10 @@ public function test_should_return_associative_array_with_original_src_when_no_i $src = 'path/does/not/exist/image.jpg'; $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ); - // Simulate the WordPress' Editor. + // Setup the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + Monkey\Functions\expect( 'beans_path_to_url' )->never(); // Run the tests. $this->assertFileNotExists( $src ); @@ -369,17 +340,13 @@ public function test_should_return_associative_array_with_original_src_when_no_i * been edited and stored. */ public function test_should_return_associatve_array_when_edited_image_exists() { - $rebuilt_path = $this->get_reflective_property(); - $image_sources = array( - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ); + $this->load_images_into_vfs(); + $rebuilt_path = $this->get_reflective_property(); $args = array( 'resize' => array( 600, false ) ); - // Run the tests. - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, ARRAY_A ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $src ); + foreach ( $this->images as $virtual_path => $actual_path ) { + $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_A ); + $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $virtual_path ); // Check that the WordPress Editor does not get called. Monkey\Functions\expect( 'wp_get_image_editor' )->never(); @@ -389,7 +356,7 @@ public function test_should_return_associatve_array_when_edited_image_exists() { $this->assertFileExists( $edited_image_src ); $this->assertSame( array( - 'src' => beans_path_to_url( $edited_image_src ), + 'src' => $edited_image_src, 'width' => 1200, 'height' => 630, ), diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index 08969202..456eb58a 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -55,12 +55,28 @@ abstract class Image_Test_Case extends Test_Case { */ protected $is_admin = false; + /** + * Array of images. + * + * @var array + */ + protected $images; + + /** + * Path of the fixtures directory. + * + * @var string + */ + protected static $fixtures_dir; + /** * Set up the test before we run the test setups. */ public static function setUpBeforeClass() { parent::setUpBeforeClass(); + static::$fixtures_dir = __DIR__ . '/fixtures'; + foreach ( array( 'ARRAY_N', 'ARRAY_A', 'STRING', 'OBJECT' ) as $constant ) { if ( ! defined( $constant ) ) { define( $constant, $constant ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- WordPress defined constants. @@ -94,6 +110,11 @@ protected function setUp() { ) ); Monkey\Functions\expect( 'site_url' )->andReturn( 'http:://example.com' ); + + $this->images = array( + $this->images_dir . '/image1.jpg' => static::$fixtures_dir . '/image1.jpg', + $this->images_dir . '/image2.jpg' => static::$fixtures_dir . '/image2.jpg', + ); } /** @@ -112,6 +133,16 @@ private function set_up_virtual_filesystem() { $this->mock_filesystem = vfsStream::setup( 'uploads', 0755, $structure ); } + /** + * Load the images into the virtual filesystem. + */ + protected function load_images_into_vfs() { + + foreach ( $this->images as $virtual_path => $actual_path ) { + imagejpeg( imagecreatefromjpeg( $actual_path ), $virtual_path ); + } + } + /** * Get reflective access to the private method. * From c6a1a26b6dc035d9540ce4ae6d2c92f72c955d2f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 11:48:45 -0600 Subject: [PATCH 245/800] Removed unit test for beans_edit_image() as the function is a proxy for same _Beans_Image_Editor::run() tests. --- .../unit/api/image/beans-image-editor/run.php | 4 +- .../phpunit/unit/api/image/beansEditImage.php | 119 ------------------ 2 files changed, 2 insertions(+), 121 deletions(-) delete mode 100644 tests/phpunit/unit/api/image/beansEditImage.php diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php index 61a49fe8..f217fdfc 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -339,10 +339,10 @@ public function test_should_return_associative_array_with_original_src_when_no_i * Test run() should return an associative array when the edited image exists, meaning that it has already * been edited and stored. */ - public function test_should_return_associatve_array_when_edited_image_exists() { + public function test_should_return_associative_array_when_edited_image_exists() { $this->load_images_into_vfs(); $rebuilt_path = $this->get_reflective_property(); - $args = array( 'resize' => array( 600, false ) ); + $args = array( 'resize' => array( 600, false ) ); foreach ( $this->images as $virtual_path => $actual_path ) { $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_A ); diff --git a/tests/phpunit/unit/api/image/beansEditImage.php b/tests/phpunit/unit/api/image/beansEditImage.php deleted file mode 100644 index 493fa869..00000000 --- a/tests/phpunit/unit/api/image/beansEditImage.php +++ /dev/null @@ -1,119 +0,0 @@ -with( $src )->once(); - Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( $src, beans_edit_image( $src, array( 'resize' => array( 800, false ) ) ) ); - } - - /** - * Test beans_edit_image() should return an indexed array with the original src when the image does not exist. - */ - public function test_should_return_indexed_array_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - - // Simulate the WordPress' Editor. - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); - Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( - array( $src, null, null ), - beans_edit_image( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ) - ); - } - - /** - * Test beans_edit_image() should return an object with the original src when the image does not exist. - */ - public function test_should_return_object_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - - // Simulate the WordPress' Editor. - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); - Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $image_info = beans_edit_image( $src, array( 'resize' => array( 800, false ) ), OBJECT ); - $this->assertInstanceOf( 'stdClass', $image_info ); - $this->assertSame( $src, $image_info->src ); - $this->assertNull( $image_info->width ); - $this->assertNull( $image_info->height ); - } - - /** - * Test beans_edit_image() should return an associative array with the original src when the image does not exist. - */ - public function test_should_return_associative_array_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - - // Simulate the WordPress' Editor. - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); - Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( - array( - 'src' => $src, - 'width' => null, - 'height' => null, - ), - beans_edit_image( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ) - ); - } -} From 9da674f73ce887a76c10998f5b158da7ad83ba9b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 3 Mar 2018 11:58:53 -0600 Subject: [PATCH 246/800] Fixed serialize rule ignore. --- lib/api/compiler/class-beans-compiler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 2e5f8eb9..75b96987 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -223,7 +223,7 @@ public function set_filename() { * @return string */ public function hash( array $given_array ) { - return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. } /** From 644dd4c890f8e59ea0567b02343b3eb78d157c89 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 3 Mar 2018 13:17:40 -0500 Subject: [PATCH 247/800] Made lib\init.php WPCS compliant (#157) --- lib/init.php | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/init.php b/lib/init.php index 0c4111b2..61599c66 100644 --- a/lib/init.php +++ b/lib/init.php @@ -2,17 +2,21 @@ /** * Prepare and initialize the Beans framework. * - * @package Initialize + * @package Beans\Framework + * + * @since 1.0.0 */ add_action( 'beans_init', 'beans_define_constants', -1 ); /** * Define constants. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_define_constants() { - // Define version. define( 'BEANS_VERSION', '1.4.1' ); @@ -49,18 +53,19 @@ function beans_define_constants() { define( 'BEANS_ADMIN_URL', BEANS_URL . 'admin/' ); define( 'BEANS_ADMIN_ASSETS_URL', BEANS_ADMIN_URL . 'assets/' ); define( 'BEANS_ADMIN_JS_URL', BEANS_ADMIN_ASSETS_URL . 'js/' ); - } add_action( 'beans_init', 'beans_load_dependencies', -1 ); /** * Load dependencies. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_load_dependencies() { - - require_once( BEANS_API_PATH . 'init.php' ); + require_once BEANS_API_PATH . 'init.php'; // Load the necessary Beans components. beans_load_api_components( array( @@ -87,17 +92,18 @@ function beans_load_dependencies() { * @since 1.0.0 */ do_action( 'beans_after_load_api' ); - } add_action( 'beans_init', 'beans_add_theme_support' ); /** * Add theme support. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_add_theme_support() { - add_theme_support( 'title-tag' ); add_theme_support( 'custom-background' ); add_theme_support( 'menus' ); @@ -115,52 +121,52 @@ function beans_add_theme_support() { // Beans specific. add_theme_support( 'offcanvas-menu' ); add_theme_support( 'beans-default-styling' ); - } add_action( 'beans_init', 'beans_includes' ); /** * Include framework files. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_includes() { // Include admin. if ( is_admin() ) { - - require_once( BEANS_ADMIN_PATH . 'options.php' ); - require_once( BEANS_ADMIN_PATH . 'updater.php' ); - + require_once BEANS_ADMIN_PATH . 'options.php'; + require_once BEANS_ADMIN_PATH . 'updater.php'; } // Include assets. - require_once( BEANS_ASSETS_PATH . 'assets.php' ); + require_once BEANS_ASSETS_PATH . 'assets.php'; // Include customizer. if ( is_customize_preview() ) { - require_once( BEANS_ADMIN_PATH . 'wp-customize.php' ); + require_once BEANS_ADMIN_PATH . 'wp-customize.php'; } // Include renderers. - require_once( BEANS_RENDER_PATH . 'template-parts.php' ); - require_once( BEANS_RENDER_PATH . 'fragments.php' ); - require_once( BEANS_RENDER_PATH . 'widget-area.php' ); - require_once( BEANS_RENDER_PATH . 'walker.php' ); - require_once( BEANS_RENDER_PATH . 'menu.php' ); - + require_once BEANS_RENDER_PATH . 'template-parts.php'; + require_once BEANS_RENDER_PATH . 'fragments.php'; + require_once BEANS_RENDER_PATH . 'widget-area.php'; + require_once BEANS_RENDER_PATH . 'walker.php'; + require_once BEANS_RENDER_PATH . 'menu.php'; } add_action( 'beans_init', 'beans_load_textdomain' ); /** * Load text domain. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_load_textdomain() { - load_theme_textdomain( 'tm-beans', BEANS_LANGUAGES_PATH ); - } /** From 26b392232251125584bb78fba105b2158b48daec Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 10:54:47 -0600 Subject: [PATCH 248/800] Mocked beans_get. Load file after Patchwork setup. --- .../actions/includes/class-actions-test-case.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index fc5487a6..d1706600 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -41,8 +41,6 @@ public static function setUpBeforeClass() { static::$test_actions = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-actions.php'; static::$test_ids = array_keys( static::$test_actions ); - - require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; } /** @@ -74,13 +72,21 @@ public static function tearDownAfterClass() { protected function setUp() { parent::setUp(); + require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; $this->load_original_functions( array( 'api/utilities/functions.php', ) ); + + Monkey\Functions\when( 'beans_get' )->alias( function ( $needle, $haystack ) { + + if ( isset( $haystack[ $needle ] ) ) { + return $haystack[ $needle ]; + } + } ); } /** - * Reset the test fixture. + * Cleans up the test environment after each test. */ protected function tearDown() { parent::tearDown(); @@ -109,10 +115,11 @@ protected function tearDown() { protected function go_to_post( $expect_added = false ) { foreach ( static::$test_actions as $beans_id => $action ) { + if ( $expect_added ) { Monkey\Actions\expectAdded( $action['hook'] ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action ) { + ->whenHappen( function ( $callback, $priority, $args ) use ( $action ) { $this->assertSame( $action['callback'], $callback ); $this->assertSame( $action['priority'], $priority ); $this->assertSame( $action['args'], $args ); From 18fc750be871aac18d9ba205f26cced6a1bfe640 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 10:59:28 -0600 Subject: [PATCH 249/800] Fixed @group. --- tests/phpunit/integration/api/actions/beansAddAction.php | 2 +- .../integration/api/actions/beansAddAnonymousAction.php | 2 +- tests/phpunit/integration/api/actions/beansModifyAction.php | 2 +- .../integration/api/actions/beansModifyActionArguments.php | 2 +- .../integration/api/actions/beansModifyActionCallback.php | 2 +- .../phpunit/integration/api/actions/beansModifyActionHook.php | 2 +- .../integration/api/actions/beansModifyActionPriority.php | 2 +- tests/phpunit/integration/api/actions/beansRemoveAction.php | 2 +- tests/phpunit/integration/api/actions/beansReplaceAction.php | 2 +- .../integration/api/actions/beansReplaceActionArguments.php | 2 +- .../integration/api/actions/beansReplaceActionCallback.php | 2 +- .../integration/api/actions/beansReplaceActionHook.php | 2 +- .../integration/api/actions/beansReplaceActionPriority.php | 2 +- tests/phpunit/integration/api/actions/beansResetAction.php | 2 +- .../api/actions/includes/class-actions-test-case.php | 2 +- .../api/actions/includes/class-replace-action-test-case.php | 4 ++-- tests/phpunit/unit/api/actions/beansAddAction.php | 2 +- tests/phpunit/unit/api/actions/beansAddAnonymousAction.php | 2 +- tests/phpunit/unit/api/actions/beansBuildActionArray.php | 2 +- tests/phpunit/unit/api/actions/beansGetAction.php | 2 +- tests/phpunit/unit/api/actions/beansGetCurrentAction.php | 2 +- tests/phpunit/unit/api/actions/beansMergeAction.php | 2 +- tests/phpunit/unit/api/actions/beansModifyAction.php | 2 +- tests/phpunit/unit/api/actions/beansModifyActionArguments.php | 2 +- tests/phpunit/unit/api/actions/beansModifyActionCallback.php | 2 +- tests/phpunit/unit/api/actions/beansModifyActionHook.php | 2 +- tests/phpunit/unit/api/actions/beansModifyActionPriority.php | 2 +- tests/phpunit/unit/api/actions/beansRemoveAction.php | 2 +- tests/phpunit/unit/api/actions/beansRenderAction.php | 2 +- tests/phpunit/unit/api/actions/beansReplaceAction.php | 2 +- .../phpunit/unit/api/actions/beansReplaceActionArguments.php | 2 +- tests/phpunit/unit/api/actions/beansReplaceActionCallback.php | 2 +- tests/phpunit/unit/api/actions/beansReplaceActionHook.php | 2 +- tests/phpunit/unit/api/actions/beansReplaceActionPriority.php | 2 +- tests/phpunit/unit/api/actions/beansResetAction.php | 2 +- tests/phpunit/unit/api/actions/beansSetAction.php | 2 +- tests/phpunit/unit/api/actions/beansUniqueActionId.php | 2 +- tests/phpunit/unit/api/actions/beansUnsetAction.php | 2 +- .../unit/api/actions/includes/class-actions-test-case.php | 2 +- 39 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansAddAction.php b/tests/phpunit/integration/api/actions/beansAddAction.php index 6fc3d472..6726af71 100644 --- a/tests/phpunit/integration/api/actions/beansAddAction.php +++ b/tests/phpunit/integration/api/actions/beansAddAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansAddAction * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansAddAction extends Actions_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php index 60628895..0f03cf8a 100644 --- a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php +++ b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php @@ -16,8 +16,8 @@ * Class Tests_BeansAddAnonymousAction * * @package Beans\Framework\Integration\Unit\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansAddAnonymousAction extends WP_UnitTestCase { diff --git a/tests/phpunit/integration/api/actions/beansModifyAction.php b/tests/phpunit/integration/api/actions/beansModifyAction.php index ea190730..4b141c80 100644 --- a/tests/phpunit/integration/api/actions/beansModifyAction.php +++ b/tests/phpunit/integration/api/actions/beansModifyAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansModifyAction * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansModifyAction extends Actions_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansModifyActionArguments.php b/tests/phpunit/integration/api/actions/beansModifyActionArguments.php index bd991eb7..fec8c9de 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionArguments.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionArguments.php @@ -17,8 +17,8 @@ * Class Tests_BeansModifyActionArguments * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansModifyActionArguments extends Actions_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansModifyActionCallback.php b/tests/phpunit/integration/api/actions/beansModifyActionCallback.php index c6cd8d45..90ab2678 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionCallback.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionCallback.php @@ -17,8 +17,8 @@ * Class Tests_BeansModifyActionCallback * * @package Beans\Framework\Tests\Unit\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansModifyActionCallback extends Actions_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansModifyActionHook.php b/tests/phpunit/integration/api/actions/beansModifyActionHook.php index c4cad3f5..d364f26d 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionHook.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionHook.php @@ -17,8 +17,8 @@ * Class Tests_BeansModifyActionHook * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansModifyActionHook extends Actions_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansModifyActionPriority.php b/tests/phpunit/integration/api/actions/beansModifyActionPriority.php index 42997165..9de1af95 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionPriority.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionPriority.php @@ -17,8 +17,8 @@ * Class Tests_BeansModifyActionPriority * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansModifyActionPriority extends Actions_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansRemoveAction.php b/tests/phpunit/integration/api/actions/beansRemoveAction.php index 7ec45cff..ffdebd3c 100644 --- a/tests/phpunit/integration/api/actions/beansRemoveAction.php +++ b/tests/phpunit/integration/api/actions/beansRemoveAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansRemoveAction * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansRemoveAction extends Actions_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansReplaceAction.php b/tests/phpunit/integration/api/actions/beansReplaceAction.php index a2fa1a76..e97aecf7 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceAction.php +++ b/tests/phpunit/integration/api/actions/beansReplaceAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansReplaceAction * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansReplaceAction extends Replace_Action_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php b/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php index 9b13aa43..728b6733 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php @@ -17,8 +17,8 @@ * Class Tests_BeansReplaceActionArguments * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansReplaceActionArguments extends Replace_Action_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php b/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php index fafd938f..00c33dd4 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php @@ -17,8 +17,8 @@ * Class Tests_BeansReplaceActionCallback * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansReplaceActionCallback extends Replace_Action_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionHook.php b/tests/phpunit/integration/api/actions/beansReplaceActionHook.php index 3e86f990..be3f9a81 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionHook.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionHook.php @@ -17,8 +17,8 @@ * Class Tests_BeansReplaceActionHook * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansReplaceActionHook extends Replace_Action_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php b/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php index 72edf018..14f353c4 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php @@ -17,8 +17,8 @@ * Class Tests_BeansReplaceActionPriority * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansReplaceActionPriority extends Replace_Action_Test_Case { diff --git a/tests/phpunit/integration/api/actions/beansResetAction.php b/tests/phpunit/integration/api/actions/beansResetAction.php index f8500aa7..6088746a 100644 --- a/tests/phpunit/integration/api/actions/beansResetAction.php +++ b/tests/phpunit/integration/api/actions/beansResetAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansResetAction * * @package Beans\Framework\Tests\Integration\API\Actions - * @group integration-tests * @group api + * @group api-actions */ class Tests_BeansResetAction extends Actions_Test_Case { diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index 9d859a92..ff19c20c 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -73,7 +73,7 @@ public static function tearDownAfterClass() { } /** - * Reset the test fixture. + * Cleans up the test environment after each test. */ public function tearDown() { parent::tearDown(); diff --git a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php index cc6de5a9..a8c9cd8f 100644 --- a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php @@ -19,7 +19,7 @@ abstract class Replace_Action_Test_Case extends Actions_Test_Case { /** - * Set up the test fixture. + * Prepares the test environment before each test. */ public function setUp() { $this->reset_beans_registry = false; @@ -31,7 +31,7 @@ public function setUp() { } /** - * Reset the test fixture. + * Cleans up the test environment after each test. */ public function tearDown() { parent::tearDown(); diff --git a/tests/phpunit/unit/api/actions/beansAddAction.php b/tests/phpunit/unit/api/actions/beansAddAction.php index 7548aa2a..aafc2e9b 100644 --- a/tests/phpunit/unit/api/actions/beansAddAction.php +++ b/tests/phpunit/unit/api/actions/beansAddAction.php @@ -18,8 +18,8 @@ * Class Tests_BeansAddAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansAddAction extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php b/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php index e67b6edd..da3fc916 100644 --- a/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php +++ b/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansAddAnonymousAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansAddAnonymousAction extends Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansBuildActionArray.php b/tests/phpunit/unit/api/actions/beansBuildActionArray.php index 1a6f9711..7db8390d 100644 --- a/tests/phpunit/unit/api/actions/beansBuildActionArray.php +++ b/tests/phpunit/unit/api/actions/beansBuildActionArray.php @@ -16,8 +16,8 @@ * Class Tests_BeansBuildActionArray * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansBuildActionArray extends Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansGetAction.php b/tests/phpunit/unit/api/actions/beansGetAction.php index e11ac2ac..88977581 100644 --- a/tests/phpunit/unit/api/actions/beansGetAction.php +++ b/tests/phpunit/unit/api/actions/beansGetAction.php @@ -15,8 +15,8 @@ * Class Tests_BeansGetAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansGetAction extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php index fda5b0d7..48c88a25 100644 --- a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansGetCurrentAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansGetCurrentAction extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansMergeAction.php b/tests/phpunit/unit/api/actions/beansMergeAction.php index 6f06d338..f0e93e27 100644 --- a/tests/phpunit/unit/api/actions/beansMergeAction.php +++ b/tests/phpunit/unit/api/actions/beansMergeAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansMergeAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansMergeAction extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansModifyAction.php b/tests/phpunit/unit/api/actions/beansModifyAction.php index 14359e3b..3ec6a636 100644 --- a/tests/phpunit/unit/api/actions/beansModifyAction.php +++ b/tests/phpunit/unit/api/actions/beansModifyAction.php @@ -18,8 +18,8 @@ * Class Tests_BeansModifyAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansModifyAction extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansModifyActionArguments.php b/tests/phpunit/unit/api/actions/beansModifyActionArguments.php index aed25675..0eb106f4 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionArguments.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionArguments.php @@ -18,8 +18,8 @@ * Class Tests_BeansModifyActionArguments * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansModifyActionArguments extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansModifyActionCallback.php b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php index 8d5ea018..7af341c7 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionCallback.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php @@ -18,8 +18,8 @@ * Class Tests_BeansModifyActionCallback * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansModifyActionCallback extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansModifyActionHook.php b/tests/phpunit/unit/api/actions/beansModifyActionHook.php index a37d18ac..2dc41eae 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionHook.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionHook.php @@ -18,8 +18,8 @@ * Class Tests_BeansModifyActionHook * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansModifyActionHook extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansModifyActionPriority.php b/tests/phpunit/unit/api/actions/beansModifyActionPriority.php index f1d5f393..9131ed30 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionPriority.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionPriority.php @@ -18,8 +18,8 @@ * Class Tests_BeansModifyActionPriority * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansModifyActionPriority extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansRemoveAction.php b/tests/phpunit/unit/api/actions/beansRemoveAction.php index 802a65f3..466d4e95 100644 --- a/tests/phpunit/unit/api/actions/beansRemoveAction.php +++ b/tests/phpunit/unit/api/actions/beansRemoveAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansRemoveAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansRemoveAction extends Replace_Action_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansRenderAction.php b/tests/phpunit/unit/api/actions/beansRenderAction.php index cc08c385..e800e89b 100644 --- a/tests/phpunit/unit/api/actions/beansRenderAction.php +++ b/tests/phpunit/unit/api/actions/beansRenderAction.php @@ -16,8 +16,8 @@ * Class Tests_BeansRenderAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansRenderAction extends Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansReplaceAction.php b/tests/phpunit/unit/api/actions/beansReplaceAction.php index 3db9b8da..4bc46892 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceAction.php +++ b/tests/phpunit/unit/api/actions/beansReplaceAction.php @@ -18,8 +18,8 @@ * Class Tests_BeansReplaceAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansReplaceAction extends Replace_Action_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php index 78688d57..9a9ab504 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php @@ -18,8 +18,8 @@ * Class Tests_BeansReplaceActionArguments * * @package Beans\Framework\Tests\Integration\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansReplaceActionArguments extends Replace_Action_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php index 41a5d969..7f7efeb1 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php @@ -18,8 +18,8 @@ * Class Tests_BeansReplaceActionCallback * * @package Beans\Framework\Tests\Integration\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansReplaceActionCallback extends Replace_Action_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php index 0c9eb94d..1c5bdcf8 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php @@ -18,8 +18,8 @@ * Class Tests_BeansReplaceActionHook * * @package Beans\Framework\Tests\Integration\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansReplaceActionHook extends Replace_Action_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php index 2f04e801..d6ac2eca 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php @@ -18,8 +18,8 @@ * Class Tests_BeansReplaceActionPriority * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansReplaceActionPriority extends Replace_Action_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansResetAction.php b/tests/phpunit/unit/api/actions/beansResetAction.php index 0a066192..60bae2bb 100644 --- a/tests/phpunit/unit/api/actions/beansResetAction.php +++ b/tests/phpunit/unit/api/actions/beansResetAction.php @@ -18,8 +18,8 @@ * Class Tests_BeansResetAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansResetAction extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansSetAction.php b/tests/phpunit/unit/api/actions/beansSetAction.php index 71328f9c..590aa5eb 100644 --- a/tests/phpunit/unit/api/actions/beansSetAction.php +++ b/tests/phpunit/unit/api/actions/beansSetAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansSetAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansSetAction extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansUniqueActionId.php b/tests/phpunit/unit/api/actions/beansUniqueActionId.php index c8a61d11..cc2eddb9 100644 --- a/tests/phpunit/unit/api/actions/beansUniqueActionId.php +++ b/tests/phpunit/unit/api/actions/beansUniqueActionId.php @@ -15,8 +15,8 @@ * Class Tests_BeansUniqueActionId * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansUniqueActionId extends Test_Case { diff --git a/tests/phpunit/unit/api/actions/beansUnsetAction.php b/tests/phpunit/unit/api/actions/beansUnsetAction.php index cb89bae1..a824af78 100644 --- a/tests/phpunit/unit/api/actions/beansUnsetAction.php +++ b/tests/phpunit/unit/api/actions/beansUnsetAction.php @@ -17,8 +17,8 @@ * Class Tests_BeansUnsetAction * * @package Beans\Framework\Tests\Unit\API\Actions - * @group unit-tests * @group api + * @group api-actions */ class Tests_BeansUnsetAction extends Actions_Test_Case { diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index d1706600..19fb6762 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -72,8 +72,8 @@ public static function tearDownAfterClass() { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . 'api/actions/functions.php'; $this->load_original_functions( array( + 'api/actions/functions.php', 'api/utilities/functions.php', ) ); From e52d97f47b763502116e645e9e2936b870431f31 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 11:01:48 -0600 Subject: [PATCH 250/800] Standardized setUp() DocBlock. --- tests/phpunit/unit/api/actions/beansAddAnonymousAction.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php b/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php index da3fc916..e2f63e54 100644 --- a/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php +++ b/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php @@ -23,7 +23,7 @@ class Tests_BeansAddAnonymousAction extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); @@ -49,9 +49,7 @@ public function test_should_register_callback_to_hook() { public function test_should_call_callback() { $object = _beans_add_anonymous_action( 'beans_test_do_foo', array( 'foo_test_callback', array( 'foo' ) ) ); - Functions\when( 'foo_test_callback' ) - ->justReturn( 'foo' ); - + Functions\when( 'foo_test_callback' )->justReturn( 'foo' ); Actions\expectDone( 'beans_test_do_foo' ) ->once() ->whenHappen( function() use ( $object ) { From 201bdf20e602701a03f20c0eab2fbb3647247b0b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 13:42:41 -0600 Subject: [PATCH 251/800] Added Integration Test Case. Whenever we use Mockery, Patchwork, or Brain Monkey, we need to ensure the packages are properly set up and torn down. These tasks are handled in the Integration Test Case. Moved the `format_the_html()` method the Test Case for use in other tests besides just the Fields API. --- .../includes/class-fields-test-case.php | 32 +------ tests/phpunit/integration/bootstrap.php | 3 + tests/phpunit/integration/class-test-case.php | 84 +++++++++++++++++++ 3 files changed, 89 insertions(+), 30 deletions(-) create mode 100644 tests/phpunit/integration/class-test-case.php diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index 8339b5d4..d6c02928 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -9,14 +9,14 @@ namespace Beans\Framework\Tests\Integration\API\Fields\Includes; -use WP_UnitTestCase; +use Beans\Framework\Tests\Integration\Test_Case; /** * Abstract Class Fields_Test_Case * * @package Beans\Framework\Tests\Integration\API\Fields\Includes */ -abstract class Fields_Test_Case extends WP_UnitTestCase { +abstract class Fields_Test_Case extends Test_Case { /** * An array of test data. @@ -137,32 +137,4 @@ protected function merge_field_with_default( array $field, $set_value = true ) { return $field; } - - /** - * Format the HTML by stripping out the whitespace between the HTML tags and then putting each tag on a separate - * line. - * - * Why? We can then compare the actual vs. expected HTML patterns without worrying about tabs, new lines, and extra - * spaces. - * - * @since 1.5.0 - * - * @param string $html HTML to strip. - * - * @return string - */ - protected function format_the_html( $html ) { - $html = trim( $html ); - - // Strip whitespace between the tags. - $html = preg_replace( '/(\>)\s*(\<)/m', '$1$2', $html ); - - // Strip whitespace at the end of a tag. - $html = preg_replace( '/(\>)\s*/m', '$1$2', $html ); - - // Strip whitespace at the start of a tag. - $html = preg_replace( '/\s*(\<)/m', '$1$2', $html ); - - return str_replace( '>', ">\n", $html ); - } } diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index 82bcba24..50cb50be 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -68,3 +68,6 @@ function beans_get_wp_tests_dir() { // Start up the WP testing environment. require_once $beans_tests_dir . '/includes/bootstrap.php'; + +// Load the Integration Test Case. +require_once BEANS_TESTS_DIR . '/class-test-case.php'; diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php new file mode 100644 index 00000000..90667033 --- /dev/null +++ b/tests/phpunit/integration/class-test-case.php @@ -0,0 +1,84 @@ +)\s*(\<)/m', '$1$2', $html ); + + // Strip whitespace at the end of a tag. + $html = preg_replace( '/(\>)\s*/m', '$1$2', $html ); + + // Strip whitespace at the start of a tag. + $html = preg_replace( '/\s*(\<)/m', '$1$2', $html ); + + return str_replace( '>', ">\n", $html ); + } +} From 087e0793322fb4c8b19186c195bbe3cfe48426a6 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 13:46:15 -0600 Subject: [PATCH 252/800] Moved file loading to setUp to ensure Patchwork and Mockery are set up first. --- .../api/fields/includes/class-fields-test-case.php | 8 ++++++++ .../integration/api/fields/types/_BeansGetImageAlt.php | 6 +++--- .../integration/api/fields/types/_BeansGetImageUrl.php | 6 +++--- .../integration/api/fields/types/_beansIsRadioImage.php | 6 +++--- .../api/fields/types/_beansStandardizeRadioImage.php | 6 +++--- tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php | 6 +++--- tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php | 6 +++--- .../phpunit/unit/api/fields/types/_beansIsRadioImage.php | 6 +++--- .../unit/api/fields/types/_beansStandardizeRadioImage.php | 6 +++--- 9 files changed, 32 insertions(+), 24 deletions(-) diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index d6c02928..e5fb2cc9 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -32,6 +32,14 @@ public static function setUpBeforeClass() { parent::setUpBeforeClass(); static::$test_data = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-fields.php'; + } + + /** + * Prepares the test environment before each test. + */ + public function setUp() { + parent::setUp(); + require_once BEANS_THEME_DIR . '/lib/api/fields/class-beans-fields.php'; } diff --git a/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php b/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php index d747763d..30d2f7ad 100644 --- a/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php +++ b/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php @@ -23,10 +23,10 @@ class Tests_BeansGetImageAlt extends Fields_Test_Case { /** - * Prepares the test environment before loading the tests. + * Prepares the test environment before each test. */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + public function setUp() { + parent::setUp(); // Load the field type. require_once BEANS_THEME_DIR . '/lib/api/fields/types/image.php'; diff --git a/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php b/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php index d7ad84e6..d1ecc5d0 100644 --- a/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php +++ b/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php @@ -23,10 +23,10 @@ class Tests_BeansGetImageUrl extends Fields_Test_Case { /** - * Prepares the test environment before loading the tests. + * Prepares the test environment before each test. */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + public function setUp() { + parent::setUp(); // Load the field type. require_once BEANS_THEME_DIR . '/lib/api/fields/types/image.php'; diff --git a/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php b/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php index b91e5292..709fcf21 100644 --- a/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php +++ b/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php @@ -23,10 +23,10 @@ class Tests_BeansIsRadioImage extends Fields_Test_Case { /** - * Prepares the test environment before loading the tests. + * Prepares the test environment before each test. */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + public function setUp() { + parent::setUp(); // Load the field type. require_once BEANS_THEME_DIR . '/lib/api/fields/types/radio.php'; diff --git a/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php b/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php index d89ab85d..42a0db56 100644 --- a/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php +++ b/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php @@ -23,10 +23,10 @@ class Tests_BeansStandardizeRadioImage extends Fields_Test_Case { /** - * Prepares the test environment before loading the tests. + * Prepares the test environment before each test. */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + public function setUp() { + parent::setUp(); // Load the field type. require_once BEANS_THEME_DIR . '/lib/api/fields/types/radio.php'; diff --git a/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php b/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php index 0e26b415..bcd4d66f 100644 --- a/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php +++ b/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php @@ -24,10 +24,10 @@ class Tests_BeansGetImageAlt extends Fields_Test_Case { /** - * Prepares the test environment before loading the tests. + * Prepares the test environment before each test. */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + public function setUp() { + parent::setUp(); // Load the field type. require_once BEANS_THEME_DIR . '/lib/api/fields/types/image.php'; diff --git a/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php b/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php index 33355cf6..7dfbd6b4 100644 --- a/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php +++ b/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php @@ -24,10 +24,10 @@ class Tests_BeansGetImageUrl extends Fields_Test_Case { /** - * Prepares the test environment before loading the tests. + * Prepares the test environment before each test. */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + public function setUp() { + parent::setUp(); // Load the field type. require_once BEANS_THEME_DIR . '/lib/api/fields/types/image.php'; diff --git a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php index d62b953b..2041d45e 100644 --- a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php @@ -23,10 +23,10 @@ class Tests_BeansIsRadioImage extends Fields_Test_Case { /** - * Prepares the test environment before loading the tests. + * Prepares the test environment before each test. */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + public function setUp() { + parent::setUp(); // Load the field type. require_once BEANS_THEME_DIR . '/lib/api/fields/types/radio.php'; diff --git a/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php b/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php index b8f72bb3..faa3e764 100644 --- a/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php @@ -23,10 +23,10 @@ class Tests_BeansStandardizeRadioImage extends Fields_Test_Case { /** - * Prepares the test environment before loading the tests. + * Prepares the test environment before each test. */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + public function setUp() { + parent::setUp(); // Load the field type. require_once BEANS_THEME_DIR . '/lib/api/fields/types/radio.php'; From 390ea8fad24de4dee18397c0554fcde688bb706a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 13:51:03 -0600 Subject: [PATCH 253/800] Replaced Monkey Actions expects with did_action. Once we set up and torn down Brain Monkey in the integration tests, the Action expects caused weird problems downstream when using the new Test Case. We got an error that the expect never happened. Switching to did_action() fixed the problem. --- .../integration/api/fields/beansField.php | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index c7e70f07..64e9358f 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -10,7 +10,6 @@ namespace Beans\Framework\Tests\Integration\API\Fields; use Beans\Framework\Tests\Integration\API\Fields\Includes\Fields_Test_Case; -use Brain\Monkey; require_once __DIR__ . '/includes/class-fields-test-case.php'; @@ -67,8 +66,6 @@ public function test_should_render_checkbox_field() { 'type' => 'checkbox', 'default' => false, ) ); - Monkey\Actions\expectDone( 'beans_field_checkbox' )->once()->with( $field ); - Monkey\Actions\expectDone( 'beans_field_group_label' )->once(); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -86,8 +83,10 @@ public function test_should_render_checkbox_field() {
    EOB; - // Run the test. + // Run the tests. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + $this->assertEquals( 1, did_action( 'beans_field_checkbox' ) ); + $this->assertEquals( 0, did_action( 'beans_field_group_label' ) ); // Clean up. beans_remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); @@ -111,7 +110,6 @@ public function test_should_render_radio_field() { 'yes' => 'Yes', ), ) ); - Monkey\Actions\expectDone( 'beans_field_radio' )->once()->with( $field ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -139,6 +137,8 @@ public function test_should_render_radio_field() { EOB; // Run the test. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + $this->assertEquals( 1, did_action( 'beans_field_radio' ) ); + $this->assertEquals( 0, did_action( 'beans_field_group_label' ) ); // Clean up. beans_remove_action( 'beans_field_radio', 'beans_field_radio' ); @@ -182,11 +182,6 @@ public function test_should_render_group_of_fields() { ), ) ); - Monkey\Actions\expectDone( 'beans_field_group_label' )->once(); - Monkey\Actions\expectDone( 'beans_field_activate' )->once()->with( $group['fields'][0] ); - Monkey\Actions\expectDone( 'beans_field_activate' )->once()->with( $group['fields'][0] ); - Monkey\Actions\expectDone( 'beans_field_select' )->once()->with( $group['fields'][1] ); - // Run the function and grab the HTML out of the buffer. ob_start(); beans_field( $group ); @@ -212,8 +207,11 @@ public function test_should_render_group_of_fields() {
    This is a group of fields.
    EOB; - // Run the test. + // Run the tests. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + $this->assertEquals( 2, did_action( 'beans_field_group_label' ) ); + $this->assertEquals( 1, did_action( 'beans_field_activation' ) ); + $this->assertEquals( 1, did_action( 'beans_field_select' ) ); // Clean up. beans_remove_action( 'beans_field_activation', 'beans_field_activation' ); From adfd91d95c9aa81bbca2367339cdae3929d5ae10 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 6 Mar 2018 14:53:07 -0500 Subject: [PATCH 254/800] Mocked beans_get(). Standardized set_up() DocBlock. --- tests/phpunit/unit/api/layout/beansGetDefaultLayout.php | 2 +- tests/phpunit/unit/api/layout/beansGetLayout.php | 2 +- tests/phpunit/unit/api/layout/beansGetLayoutClass.php | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php index be21012d..80f97e84 100644 --- a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php @@ -22,7 +22,7 @@ class Tests_BeansGetDefaultLayout extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/unit/api/layout/beansGetLayout.php b/tests/phpunit/unit/api/layout/beansGetLayout.php index 54acd067..307fee18 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetLayout.php @@ -22,7 +22,7 @@ class Tests_BeansGetLayout extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php index b25cfc20..98d417ff 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php @@ -22,7 +22,7 @@ class Tests_BeansGetLayoutClass extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); @@ -33,6 +33,13 @@ protected function setUp() { 'api/utilities/functions.php', 'api/post-meta/functions.php', ) ); + + Monkey\Functions\when( 'beans_get' )->alias( function ( $needle, $haystack ) { + + if ( isset( $haystack[ $needle ] ) ) { + return $haystack[ $needle ]; + } + } ); } /** From 3c00d832032250d79fd1d0190a7065fa5baef182 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 13:54:17 -0600 Subject: [PATCH 255/800] Updated @group. --- .../integration/api/fields/_beansPreStandardizeFields.php | 2 +- tests/phpunit/integration/api/fields/beansField.php | 2 +- tests/phpunit/integration/api/fields/beansGetFields.php | 2 +- tests/phpunit/integration/api/fields/beansRegisterFields.php | 2 +- .../phpunit/integration/api/fields/types/_BeansGetImageAlt.php | 2 +- .../phpunit/integration/api/fields/types/_BeansGetImageUrl.php | 2 +- .../phpunit/integration/api/fields/types/_beansIsRadioImage.php | 2 +- .../api/fields/types/_beansStandardizeRadioImage.php | 2 +- .../integration/api/fields/types/beansFieldActivation.php | 2 +- .../phpunit/integration/api/fields/types/beansFieldCheckbox.php | 2 +- .../integration/api/fields/types/beansFieldDescription.php | 2 +- tests/phpunit/integration/api/fields/types/beansFieldImage.php | 2 +- tests/phpunit/integration/api/fields/types/beansFieldLabel.php | 2 +- tests/phpunit/integration/api/fields/types/beansFieldRadio.php | 2 +- tests/phpunit/integration/api/fields/types/beansFieldSelect.php | 2 +- tests/phpunit/integration/api/fields/types/beansFieldSlider.php | 2 +- tests/phpunit/integration/api/fields/types/beansFieldText.php | 2 +- .../phpunit/integration/api/fields/types/beansFieldTextarea.php | 2 +- tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php | 2 +- tests/phpunit/unit/api/fields/beansGetFields.php | 2 +- tests/phpunit/unit/api/fields/beansRegisterFields.php | 2 +- tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php | 2 +- tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php | 2 +- tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php | 2 +- .../unit/api/fields/types/_beansStandardizeRadioImage.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldActivation.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldImage.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldRadio.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldSelect.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldSlider.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldText.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldTextarea.php | 2 +- 33 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php b/tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php index 5e805407..1f747974 100644 --- a/tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php +++ b/tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php @@ -17,8 +17,8 @@ * Class Tests_BeansPreStandardizeFields * * @package Beans\Framework\Tests\Integration\API\Fields - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansPreStandardizeFields extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 64e9358f..7bb4b239 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -17,8 +17,8 @@ * Class Tests_BeansField * * @package Beans\Framework\Tests\Integration\API\Fields - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansField extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/beansGetFields.php b/tests/phpunit/integration/api/fields/beansGetFields.php index 53e513c8..cdfc9b9f 100644 --- a/tests/phpunit/integration/api/fields/beansGetFields.php +++ b/tests/phpunit/integration/api/fields/beansGetFields.php @@ -17,8 +17,8 @@ * Class Tests_BeansGetFields * * @package Beans\Framework\Tests\Integration\API\Fields - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansGetFields extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/beansRegisterFields.php b/tests/phpunit/integration/api/fields/beansRegisterFields.php index bdd74926..32a9b40e 100644 --- a/tests/phpunit/integration/api/fields/beansRegisterFields.php +++ b/tests/phpunit/integration/api/fields/beansRegisterFields.php @@ -17,8 +17,8 @@ * Class Tests_BeansRegisterFields * * @package Beans\Framework\Tests\Integration\API\Fields - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansRegisterFields extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php b/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php index 30d2f7ad..3ccac780 100644 --- a/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php +++ b/tests/phpunit/integration/api/fields/types/_BeansGetImageAlt.php @@ -17,8 +17,8 @@ * Class Tests_BeansGetImageAlt * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansGetImageAlt extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php b/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php index d1ecc5d0..57dc9826 100644 --- a/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php +++ b/tests/phpunit/integration/api/fields/types/_BeansGetImageUrl.php @@ -17,8 +17,8 @@ * Class Tests_BeansGetImageUrl * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansGetImageUrl extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php b/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php index 709fcf21..fea89d1e 100644 --- a/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php +++ b/tests/phpunit/integration/api/fields/types/_beansIsRadioImage.php @@ -17,8 +17,8 @@ * Class Tests_BeansIsRadioImage * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansIsRadioImage extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php b/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php index 42a0db56..b5b8065b 100644 --- a/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php +++ b/tests/phpunit/integration/api/fields/types/_beansStandardizeRadioImage.php @@ -17,8 +17,8 @@ * Class Tests_BeansStandardizeRadioImage * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansStandardizeRadioImage extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php index c62be4bf..4f99cdac 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldActivation * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldActivation extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php index 3de7e998..24a6ab0e 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldCheckbox * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldCheckbox extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php index ffc13a9a..a3c23906 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldDescription * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldDescription extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index 0e8a6ff5..8edc49be 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldImage * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldImage extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php index 4949ffa9..429dac12 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldLabel * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldLabel extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php index 0923e902..49a679ec 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldRadio * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldRadio extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php index 63c661aa..27911715 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldSelect * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldSelect extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php index 3780a571..3a80eb44 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldSlider * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldSlider extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php index ae8ed497..44d46159 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldText.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldText.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldText * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldText extends Fields_Test_Case { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php index ec48c70b..4556d165 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldTextarea * * @package Beans\Framework\Tests\Integration\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansFieldTextarea extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php b/tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php index a1355895..fa2d7891 100644 --- a/tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php +++ b/tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php @@ -17,8 +17,8 @@ * Class Tests_BeansPreStandardizeFields * * @package Beans\Framework\Tests\Unit\API\Fields - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansPreStandardizeFields extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/beansGetFields.php b/tests/phpunit/unit/api/fields/beansGetFields.php index 2e85c909..82ea028c 100644 --- a/tests/phpunit/unit/api/fields/beansGetFields.php +++ b/tests/phpunit/unit/api/fields/beansGetFields.php @@ -17,8 +17,8 @@ * Class Tests_BeansGetFields * * @package Beans\Framework\Tests\Unit\API\Fields - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansGetFields extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/beansRegisterFields.php b/tests/phpunit/unit/api/fields/beansRegisterFields.php index 04c352b3..50f552c0 100644 --- a/tests/phpunit/unit/api/fields/beansRegisterFields.php +++ b/tests/phpunit/unit/api/fields/beansRegisterFields.php @@ -17,8 +17,8 @@ * Class Tests_BeansRegisterFields * * @package Beans\Framework\Tests\Unit\API\Fields - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansRegisterFields extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php b/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php index bcd4d66f..0fb44b1a 100644 --- a/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php +++ b/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php @@ -18,8 +18,8 @@ * Class Tests_BeansGetImageAlt * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansGetImageAlt extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php b/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php index 7dfbd6b4..4d3e0158 100644 --- a/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php +++ b/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php @@ -18,8 +18,8 @@ * Class Tests_BeansGetImageUrl * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group integration-tests * @group api + * @group api-fields */ class Tests_BeansGetImageUrl extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php index 2041d45e..c15c9aa5 100644 --- a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php @@ -17,8 +17,8 @@ * Class Tests_BeansIsRadioImage * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansIsRadioImage extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php b/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php index faa3e764..641ba206 100644 --- a/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php @@ -17,8 +17,8 @@ * Class Tests_BeansStandardizeRadioImage * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansStandardizeRadioImage extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php index 2109aada..a84bb081 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldActivation * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansFieldActivation extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php index ebee0132..9833c854 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldCheckbox * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansFieldCheckbox extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 3986f635..9b696e3b 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -18,8 +18,8 @@ * Class Tests_BeansFieldImage * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansFieldImage extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php index 6aa83d4f..6ae846a9 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldRadio * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansFieldRadio extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index eec451e6..578b9ff1 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldSelect * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansFieldSelect extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php index 2b9c2780..596d1d6a 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldSlider * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansFieldSlider extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index 1e9bfcff..f09262f4 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldText * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansFieldText extends Fields_Test_Case { diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index c87a77a8..c9ab4f98 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -17,8 +17,8 @@ * Class Tests_BeansFieldTextarea * * @package Beans\Framework\Tests\Unit\API\Fields\Types - * @group unit-tests * @group api + * @group api-fields */ class Tests_BeansFieldTextarea extends Fields_Test_Case { From 9bccc1eca0cb5b29fa1d0f79def3b539e6c7eba3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 14:06:13 -0600 Subject: [PATCH 256/800] Abstracted function mocks in Test Case. --- .../includes/class-fields-test-case.php | 60 +++++++++++-------- .../unit/api/fields/types/beansFieldImage.php | 3 +- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index ff2eac46..fea3c72c 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -48,31 +48,7 @@ public function setUp() { 'api/utilities/functions.php', ) ); - foreach ( array( 'esc_attr', 'esc_html', 'esc_textarea', 'esc_url', 'wp_kses_post', '__' ) as $wp_function ) { - Monkey\Functions\when( $wp_function )->returnArg(); - } - - foreach ( array( 'esc_attr_e', 'esc_html_e', '_e' ) as $wp_function ) { - Monkey\Functions\when( $wp_function )->echoArg(); - } - - Monkey\Functions\when( 'checked' )->alias( function( $actual, $value ) { - if ( $actual !== $value ) { - return; - } - - echo " checked='checked'"; - } ); - Monkey\Functions\when( 'selected' )->alias( function( $actual, $value ) { - if ( $actual !== $value ) { - return; - } - - echo " selected='selected'"; - } ); - Monkey\Functions\when( '_n' )->alias( function( $single, $plural, $number ) { - return $number > 1 ? $plural : $single; - } ); + $this->setup_function_mocks(); } /** @@ -200,4 +176,38 @@ protected function format_the_html( $html ) { return str_replace( '>', ">\n", $html ); } + + /** + * Set up function mocks. + */ + protected function setup_function_mocks() { + + foreach ( array( 'esc_attr', 'esc_html', 'esc_textarea', 'esc_url', 'wp_kses_post', '__' ) as $wp_function ) { + Monkey\Functions\when( $wp_function )->returnArg(); + } + + foreach ( array( 'esc_attr_e', 'esc_html_e', '_e' ) as $wp_function ) { + Monkey\Functions\when( $wp_function )->echoArg(); + } + + Monkey\Functions\when( 'checked' )->alias( function ( $actual, $value ) { + if ( $actual !== $value ) { + return; + } + + echo " checked='checked'"; + } ); + + Monkey\Functions\when( 'selected' )->alias( function ( $actual, $value ) { + if ( $actual !== $value ) { + return; + } + + echo " selected='selected'"; + } ); + + Monkey\Functions\when( '_n' )->alias( function ( $single, $plural, $number ) { + return $number > 1 ? $plural : $single; + } ); + } } diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 9b696e3b..70b7e34f 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -100,10 +100,11 @@ public function test_should_render_single_image_field() { public function test_should_render_multiple_images_field() { Monkey\Functions\expect( 'wp_get_attachment_image_src' ) ->times( 2 ) - ->andReturnUsing( function( $image_id ) { + ->andReturnUsing( function ( $image_id ) { if ( 'placeholder' === $image_id ) { return ''; } + return "image-{$image_id}.png"; } ); Monkey\Functions\expect( 'get_post_meta' ) From 4a3ee0f973411616ee8ec1fa4d1a2ad98ec865fc Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 14:06:37 -0600 Subject: [PATCH 257/800] Mocked beans_get(). --- .../api/fields/includes/class-fields-test-case.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index fea3c72c..2498d5ca 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -209,5 +209,15 @@ protected function setup_function_mocks() { Monkey\Functions\when( '_n' )->alias( function ( $single, $plural, $number ) { return $number > 1 ? $plural : $single; } ); + + Monkey\Functions\when( 'beans_get' )->alias( function ( $needle, $haystack = false, $default = null ) { + $haystack = (array) $haystack; + + if ( isset( $haystack[ $needle ] ) ) { + return $haystack[ $needle ]; + } + + return $default; + } ); } } From 8e43a7b3b0e70a9cb011e7e8c049d99f0aed10a0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 14:08:45 -0600 Subject: [PATCH 258/800] Refactored function mocks. --- .../includes/class-fields-test-case.php | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 2498d5ca..efc6aca6 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -118,6 +118,7 @@ protected function get_reflective_property( $property ) { */ protected function get_reflective_property_value( $property ) { $reflective = $this->get_reflective_property( $property ); + return $reflective->getValue( new \_Beans_Fields() ); } @@ -191,19 +192,17 @@ protected function setup_function_mocks() { } Monkey\Functions\when( 'checked' )->alias( function ( $actual, $value ) { - if ( $actual !== $value ) { - return; - } - echo " checked='checked'"; + if ( $actual === $value ) { + echo " checked='checked'"; + } } ); Monkey\Functions\when( 'selected' )->alias( function ( $actual, $value ) { - if ( $actual !== $value ) { - return; - } - echo " selected='selected'"; + if ( $actual === $value ) { + echo " selected='selected'"; + } } ); Monkey\Functions\when( '_n' )->alias( function ( $single, $plural, $number ) { @@ -213,11 +212,7 @@ protected function setup_function_mocks() { Monkey\Functions\when( 'beans_get' )->alias( function ( $needle, $haystack = false, $default = null ) { $haystack = (array) $haystack; - if ( isset( $haystack[ $needle ] ) ) { - return $haystack[ $needle ]; - } - - return $default; + return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : $default; } ); } } From b5d71ff9c41692a288a4858c0e067c1e5da9fc5b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 14:11:22 -0600 Subject: [PATCH 259/800] Mocked beans_esc_attributes. --- .../fields/includes/class-fields-test-case.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index efc6aca6..bc7fc7b7 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -214,5 +214,20 @@ protected function setup_function_mocks() { return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : $default; } ); + + Monkey\Functions\when( 'beans_esc_attributes' )->alias( function ( $attributes ) { + $string = ''; + + foreach ( (array) $attributes as $attribute => $value ) { + + if ( null === $value ) { + continue; + } + + $string .= $attribute . '="' . $value . '" '; + } + + return trim( $string ); + } ); } } From 28872f740aed48a42726c012c5fc724961c256aa Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 14:12:28 -0600 Subject: [PATCH 260/800] Fixed phpcs:ignore. --- lib/api/fields/types/field.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/fields/types/field.php b/lib/api/fields/types/field.php index 4c8dee96..92fa3c0d 100644 --- a/lib/api/fields/types/field.php +++ b/lib/api/fields/types/field.php @@ -71,7 +71,7 @@ function beans_field_description( array $field ) { beans_open_markup_e( 'beans_field_description[_' . $field['id'] . ']', 'div', array( 'class' => 'bs-field-description' ) ); - echo $description; // @codingStandardsIgnoreLine - WordPress.XSS.EscapeOutput.OutputNotEscaped - To optimize, escaping is handled above. + echo $description; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- To optimize, escaping is handled above. if ( isset( $extended ) ) { include dirname( __FILE__ ) . '/views/field-description.php'; From 9e9ac525645188969f6fbd103ef6bf1c4a2d318c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 6 Mar 2018 14:16:43 -0600 Subject: [PATCH 261/800] Moved HTML formatter to the unit Test Case, making it available to other unit tests. --- .../includes/class-fields-test-case.php | 28 ---------------- tests/phpunit/unit/class-test-case.php | 32 +++++++++++++++++-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index bc7fc7b7..b01adbd4 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -150,34 +150,6 @@ protected function merge_field_with_default( array $field, $set_value = true ) { return $merged_field; } - /** - * Format the HTML by stripping out the whitespace between the HTML tags and then putting each tag on a separate - * line. - * - * Why? We can then compare the actual vs. expected HTML patterns without worrying about tabs, new lines, and extra - * spaces. - * - * @since 1.5.0 - * - * @param string $html HTML to strip. - * - * @return string - */ - protected function format_the_html( $html ) { - $html = trim( $html ); - - // Strip whitespace between the tags. - $html = preg_replace( '/(\>)\s*(\<)/m', '$1$2', $html ); - - // Strip whitespace at the end of a tag. - $html = preg_replace( '/(\>)\s*/m', '$1$2', $html ); - - // Strip whitespace at the start of a tag. - $html = preg_replace( '/\s*(\<)/m', '$1$2', $html ); - - return str_replace( '>', ">\n", $html ); - } - /** * Set up function mocks. */ diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 46fd3568..aad96d62 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -27,7 +27,7 @@ protected function setUp() { parent::setUp(); Monkey\setUp(); - Functions\when( 'wp_normalize_path' )->alias( function( $path ) { + Functions\when( 'wp_normalize_path' )->alias( function ( $path ) { $path = str_replace( '\\', '/', $path ); $path = preg_replace( '|(?<=.)/+|', '/', $path ); @@ -38,7 +38,7 @@ protected function setUp() { return $path; } ); - Functions\when( 'wp_json_encode' )->alias( function( $array ) { + Functions\when( 'wp_json_encode' )->alias( function ( $array ) { return json_encode( $array ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode -- Required as part of our mock. } ); } @@ -69,4 +69,32 @@ protected function load_original_functions( array $files ) { require_once BEANS_TESTS_LIB_DIR . $file; } } + + /** + * Format the HTML by stripping out the whitespace between the HTML tags and then putting each tag on a separate + * line. + * + * Why? We can then compare the actual vs. expected HTML patterns without worrying about tabs, new lines, and extra + * spaces. + * + * @since 1.5.0 + * + * @param string $html HTML to strip. + * + * @return string + */ + protected function format_the_html( $html ) { + $html = trim( $html ); + + // Strip whitespace between the tags. + $html = preg_replace( '/(\>)\s*(\<)/m', '$1$2', $html ); + + // Strip whitespace at the end of a tag. + $html = preg_replace( '/(\>)\s*/m', '$1$2', $html ); + + // Strip whitespace at the start of a tag. + $html = preg_replace( '/\s*(\<)/m', '$1$2', $html ); + + return str_replace( '>', ">\n", $html ); + } } From 56e59d3aacb9926500607f39a8b35384dc4dac25 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 6 Mar 2018 23:24:10 -0500 Subject: [PATCH 262/800] Improved Image API unit tests (#163) --- .../image/beans-image-editor/createEditedImage.php | 9 --------- .../unit/api/image/beans-image-editor/run.php | 12 ------------ .../api/image/includes/class-image-test-case.php | 6 ++++-- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php index aae039e3..4ec1a41a 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php @@ -41,15 +41,6 @@ public static function setUpBeforeClass() { static::$fixtures_dir = realpath( __DIR__ . '/../fixtures' ); } - /** - * Prepares the test environment before each test. - */ - public function setUp() { - parent::setUp(); - - require_once BEANS_TESTS_LIB_DIR . 'api/image/class-beans-image-editor.php'; - } - /** * Test create_edited_image() should edit the given image and then create a new "edited image", which is stored in * the diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php index f217fdfc..bfaef8ed 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -34,18 +34,6 @@ public static function setUpBeforeClass() { static::$fixtures_dir = realpath( __DIR__ . '/../fixtures' ); } - /** - * Set up the test fixture. - */ - protected function setUp() { - parent::setUp(); - - require_once BEANS_TESTS_LIB_DIR . 'api/image/class-beans-image-editor.php'; - - Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); - Monkey\Functions\when( 'beans_path_to_url' )->returnArg(); - } - /** * Test run() should edit the existing image, store it in the "rebuilt path", and then return its URL. */ diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index 456eb58a..a5adcf5b 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -91,6 +91,7 @@ protected function setUp() { parent::setUp(); require_once BEANS_TESTS_LIB_DIR . 'api/image/functions.php'; + require_once BEANS_TESTS_LIB_DIR . 'api/image/class-beans-image-editor.php'; $this->load_original_functions( array( 'api/utilities/functions.php', @@ -100,6 +101,9 @@ protected function setUp() { $this->images_dir = vfsStream::url( 'uploads/beans/images' ); $this->images_url = 'http:://example.com/uploads/beans/images/'; + Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); + Monkey\Functions\when( 'beans_path_to_url' )->returnArg(); + Monkey\Functions\expect( 'wp_upload_dir' )->andReturn( array( 'path' => '', 'url' => '', @@ -109,8 +113,6 @@ protected function setUp() { 'error' => false, ) ); - Monkey\Functions\expect( 'site_url' )->andReturn( 'http:://example.com' ); - $this->images = array( $this->images_dir . '/image1.jpg' => static::$fixtures_dir . '/image1.jpg', $this->images_dir . '/image2.jpg' => static::$fixtures_dir . '/image2.jpg', From 75b9a4af6abb56521621a97f9408f5bfce4d3bc5 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 6 Mar 2018 23:29:56 -0500 Subject: [PATCH 263/800] Added .gitattributes file (#164) Closes #162 --- .gitattributes | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..77324a07 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +# Default behaviour +* text=auto + +# Text files +*.php eol=lf + +# Binary files +*.png binary +*.jpg binary +*.gif binary +*.ico binary From 026329fc708081e9af8cb17bc9fdfd818df4b27d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 09:42:04 -0600 Subject: [PATCH 264/800] Replaced stubs file with mocks. --- .../includes/class-filters-test-case.php | 22 ++++++- .../unit/api/filters/stubs/functions.php | 65 ------------------- 2 files changed, 19 insertions(+), 68 deletions(-) delete mode 100644 tests/phpunit/unit/api/filters/stubs/functions.php diff --git a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php index e3ee1ca5..6cf1e56f 100644 --- a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php @@ -10,7 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Filters\Includes; use Beans\Framework\Tests\Unit\Test_Case; -use Brain\Monkey\Functions; +use Brain\Monkey; /** * Abstract Class Filters_Test_Case @@ -32,8 +32,6 @@ abstract class Filters_Test_Case extends Test_Case { public static function setUpBeforeClass() { parent::setUpBeforeClass(); - require_once dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'stubs/functions.php'; - static::$test_filters = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-filters.php'; } @@ -43,8 +41,11 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); + $this->mock_filter_callbacks(); + $this->load_original_functions( array( 'api/utilities/functions.php', + 'api/filters/functions.php', ) ); } @@ -63,4 +64,19 @@ protected function tearDown() { remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); } } + + /** + * Define the mocks for the filter callbacks. + */ + protected function mock_filter_callbacks() { + Monkey\Functions\when( 'beans_test_the_content' )->alias( function ( $post_title, $post_id ) { + return $post_title . '_' . $post_id; + } ); + Monkey\Functions\when( 'beans_modify_widget_count' )->justReturn( 20 ); + Monkey\Functions\when( 'beans_loop_query_args_base' )->justReturn( array( 'base' ) ); + Monkey\Functions\when( 'beans_loop_query_args_main' )->alias( function ( $args ) { + $args[] = '_main'; + return $args; + } ); + } } diff --git a/tests/phpunit/unit/api/filters/stubs/functions.php b/tests/phpunit/unit/api/filters/stubs/functions.php deleted file mode 100644 index 6ccd2a4e..00000000 --- a/tests/phpunit/unit/api/filters/stubs/functions.php +++ /dev/null @@ -1,65 +0,0 @@ - Date: Sat, 10 Mar 2018 09:52:36 -0600 Subject: [PATCH 265/800] Replaced stubs file with mocks. --- .../api/filters/beansApplyFilters.php | 30 ++++----- .../api/filters/fixtures/test-filters.php | 14 ++-- .../includes/class-filters-test-case.php | 49 ++++++++++++-- .../api/filters/stubs/functions.php | 65 ------------------- .../api/filters/fixtures/test-filters.php | 14 ++-- .../includes/class-filters-test-case.php | 6 +- 6 files changed, 76 insertions(+), 102 deletions(-) delete mode 100644 tests/phpunit/integration/api/filters/stubs/functions.php diff --git a/tests/phpunit/integration/api/filters/beansApplyFilters.php b/tests/phpunit/integration/api/filters/beansApplyFilters.php index 6c9b3920..7c48474d 100644 --- a/tests/phpunit/integration/api/filters/beansApplyFilters.php +++ b/tests/phpunit/integration/api/filters/beansApplyFilters.php @@ -40,30 +40,30 @@ public function test_should_return_value_after_calling_hook_no_subhook() { * Test beans_apply_filters() should return value after calling one level of sub-hooks. */ public function test_should_return_value_after_calling_one_level_of_sub_hooks() { - add_filter( 'beans_loop_query_args', 'beans_loop_query_args_base' ); - add_filter( 'beans_loop_query_args[_main]', 'beans_loop_query_args_main' ); + add_filter( 'beans_test_query_args', 'beans_test_query_args_base' ); + add_filter( 'beans_test_query_args[_main]', 'beans_test_query_args_main' ); - $this->assertSame( array( 'base', '_main' ), beans_apply_filters( 'beans_loop_query_args[_main]', 'foo' ) ); + $this->assertSame( array( 'base', '_main' ), beans_apply_filters( 'beans_test_query_args[_main]', 'foo' ) ); } /** * Test beans_apply_filters() should return value after calling two levels of sub-hooks. */ public function test_should_return_value_after_calling_two_levels_of_sub_hooks() { - add_filter( 'beans_loop_query_args', 'beans_loop_query_args_base' ); - add_filter( 'beans_loop_query_args[_main]', 'beans_loop_query_args_main' ); - add_filter( 'beans_loop_query_args[_second]', function( $args ) { + add_filter( 'beans_test_query_args', 'beans_test_query_args_base' ); + add_filter( 'beans_test_query_args[_main]', 'beans_test_query_args_main' ); + add_filter( 'beans_test_query_args[_second]', function( $args ) { $args[] = '_second'; return $args; } ); - add_filter( 'beans_loop_query_args[_main][_second]', function( $args ) { + add_filter( 'beans_test_query_args[_main][_second]', function( $args ) { $args[] = '[_main][_second]'; return $args; } ); $this->assertSame( array( 'base', '_main', '_second', '[_main][_second]' ), - beans_apply_filters( 'beans_loop_query_args[_main][_second]', 'foo' ) + beans_apply_filters( 'beans_test_query_args[_main][_second]', 'foo' ) ); } @@ -71,28 +71,28 @@ public function test_should_return_value_after_calling_two_levels_of_sub_hooks() * Test beans_apply_filters() should return value after calling three levels of sub-hooks. */ public function test_should_return_value_after_calling_three_levels_of_sub_hooks() { - add_filter( 'beans_loop_query_args', 'beans_loop_query_args_base' ); - add_filter( 'beans_loop_query_args[_main]', 'beans_loop_query_args_main' ); - add_filter( 'beans_loop_query_args[_second]', function( $args ) { + add_filter( 'beans_test_query_args', 'beans_test_query_args_base' ); + add_filter( 'beans_test_query_args[_main]', 'beans_test_query_args_main' ); + add_filter( 'beans_test_query_args[_second]', function( $args ) { $args[] = '_second'; return $args; } ); - add_filter( 'beans_loop_query_args[_main][_second]', function( $args ) { + add_filter( 'beans_test_query_args[_main][_second]', function( $args ) { $args[] = '[_main][_second]'; return $args; } ); - add_filter( 'beans_loop_query_args[_third]', function( $args ) { + add_filter( 'beans_test_query_args[_third]', function( $args ) { $args[] = '_third'; return $args; } ); - add_filter( 'beans_loop_query_args[_main][_second][_third]', function( $args ) { + add_filter( 'beans_test_query_args[_main][_second][_third]', function( $args ) { $args[] = '[_main][_second][_third]'; return $args; } ); $this->assertSame( array( 'base', '_main', '_second', '[_main][_second]', '_third', '[_main][_second][_third]' ), - beans_apply_filters( 'beans_loop_query_args[_main][_second][_third]', 'foo' ) + beans_apply_filters( 'beans_test_query_args[_main][_second][_third]', 'foo' ) ); } } diff --git a/tests/phpunit/integration/api/filters/fixtures/test-filters.php b/tests/phpunit/integration/api/filters/fixtures/test-filters.php index 4a415b2b..53272d51 100644 --- a/tests/phpunit/integration/api/filters/fixtures/test-filters.php +++ b/tests/phpunit/integration/api/filters/fixtures/test-filters.php @@ -16,19 +16,19 @@ ), 'beans_widget_content_categories_output' => array( 'hook' => 'beans_widget_content_categories_output', - 'callback' => 'beans_modify_widget_count', + 'callback' => 'beans_test_modify_widget_count', 'priority' => 10, 'args' => 1, ), - 'beans_loop_query_args' => array( - 'hook' => 'beans_loop_query_args', - 'callback' => 'beans_loop_query_args_base', + 'beans_test_query_args' => array( + 'hook' => 'beans_test_query_args', + 'callback' => 'beans_test_query_args_base', 'priority' => 20, 'args' => 1, ), - 'beans_loop_query_args[_main]' => array( - 'hook' => 'beans_loop_query_args[_main]', - 'callback' => 'beans_loop_query_args_main', + 'beans_test_query_args[_main]' => array( + 'hook' => 'beans_test_query_args[_main]', + 'callback' => 'beans_test_query_args_main', 'priority' => 20, 'args' => 1, ), diff --git a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php index 6e44a9c5..89089e63 100644 --- a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php @@ -1,6 +1,6 @@ mock_filter_callbacks(); + } + + /** + * Cleans up the test environment after each test. + */ + public function tearDown() { + parent::tearDown(); + + foreach ( static::$test_filters as $beans_id => $filter ) { + + if ( ! isset( $filter['callback'] ) ) { + continue; + } + + remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); + } + } + /** * Check that the right parameters are registered in WordPress. * @@ -68,4 +92,19 @@ protected function go_to_post() { $this->go_to( get_permalink( $post_id ) ); do_action( 'template_redirect' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Valid use case as we need to fire this action as part of our tests. } + + /** + * Define the mocks for the filter callbacks. + */ + protected function mock_filter_callbacks() { + Monkey\Functions\when( 'beans_test_the_content' )->alias( function ( $post_title, $post_id ) { + return $post_title . '_' . $post_id; + } ); + Monkey\Functions\when( 'beans_test_modify_widget_count' )->justReturn( 20 ); + Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( array( 'base' ) ); + Monkey\Functions\when( 'beans_test_query_args_main' )->alias( function ( $args ) { + $args[] = '_main'; + return $args; + } ); + } } diff --git a/tests/phpunit/integration/api/filters/stubs/functions.php b/tests/phpunit/integration/api/filters/stubs/functions.php deleted file mode 100644 index 6ccd2a4e..00000000 --- a/tests/phpunit/integration/api/filters/stubs/functions.php +++ /dev/null @@ -1,65 +0,0 @@ - array( 'hook' => 'beans_widget_content_categories_output', - 'callback' => 'beans_modify_widget_count', + 'callback' => 'beans_test_modify_widget_count', 'priority' => 10, 'args' => 1, ), - 'beans_loop_query_args[_main]' => array( - 'hook' => 'beans_loop_query_args[_main]', - 'callback' => 'beans_loop_query_args_base', + 'beans_test_query_args[_main]' => array( + 'hook' => 'beans_test_query_args[_main]', + 'callback' => 'beans_test_query_args_base', 'priority' => 20, 'args' => 1, ), - 'beans_loop_query_args[_main]' => array( - 'hook' => 'beans_loop_query_args[_main]', - 'callback' => 'beans_loop_query_args_main', + 'beans_test_query_args[_main]' => array( + 'hook' => 'beans_test_query_args[_main]', + 'callback' => 'beans_test_query_args_main', 'priority' => 20, 'args' => 1, ), diff --git a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php index 6cf1e56f..bba96b91 100644 --- a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php @@ -72,9 +72,9 @@ protected function mock_filter_callbacks() { Monkey\Functions\when( 'beans_test_the_content' )->alias( function ( $post_title, $post_id ) { return $post_title . '_' . $post_id; } ); - Monkey\Functions\when( 'beans_modify_widget_count' )->justReturn( 20 ); - Monkey\Functions\when( 'beans_loop_query_args_base' )->justReturn( array( 'base' ) ); - Monkey\Functions\when( 'beans_loop_query_args_main' )->alias( function ( $args ) { + Monkey\Functions\when( 'beans_test_modify_widget_count' )->justReturn( 20 ); + Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( array( 'base' ) ); + Monkey\Functions\when( 'beans_test_query_args_main' )->alias( function ( $args ) { $args[] = '_main'; return $args; } ); From fd22c9a2e911625d22cd6bf0653363ce4f454c33 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 10:34:06 -0600 Subject: [PATCH 266/800] Improved _Beans_Anonymous_Filters. 1. Added default priority value. 2. Added default args value. 3. Added _construct() unit test. 4. Removed the _beans_add_anonymous_Filters() unit test (this is an integration test). --- .../filters/class-beans-anonymous-filters.php | 2 +- .../beans-anonymous-filters/_construct.php | 56 +++++++++++++ .../api/filters/beansAddAnonymousFilter.php | 82 ------------------- 3 files changed, 57 insertions(+), 83 deletions(-) create mode 100644 tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php delete mode 100644 tests/phpunit/unit/api/filters/beansAddAnonymousFilter.php diff --git a/lib/api/filters/class-beans-anonymous-filters.php b/lib/api/filters/class-beans-anonymous-filters.php index dd9b2a82..7c2c24d0 100644 --- a/lib/api/filters/class-beans-anonymous-filters.php +++ b/lib/api/filters/class-beans-anonymous-filters.php @@ -37,7 +37,7 @@ final class _Beans_Anonymous_Filters { * in the order in which they were added to the filter. * @param int $args Optional. The number of arguments the function accepts. Default 1. */ - public function __construct( $hook, $value_to_return, $priority, $args ) { + public function __construct( $hook, $value_to_return, $priority = 10, $args = 1 ) { $this->value_to_return = $value_to_return; add_filter( $hook, array( $this, 'callback' ), $priority, $args ); diff --git a/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php b/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php new file mode 100644 index 00000000..e6069d30 --- /dev/null +++ b/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php @@ -0,0 +1,56 @@ +assertSame( 'foo', $object->value_to_return ); + + // Clean up. + remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + } + + /** + * Test _Beans_Anonymous_Filters() should register callback to the given hook. + */ + public function test_should_register_callback_to_hook() { + $object = new _Beans_Anonymous_Filters( 'do_foo', false, 20 ); + + $this->assertTrue( has_filter( 'do_foo', array( $object, 'callback' ) ) !== false ); + + // Clean up. + remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + } +} diff --git a/tests/phpunit/unit/api/filters/beansAddAnonymousFilter.php b/tests/phpunit/unit/api/filters/beansAddAnonymousFilter.php deleted file mode 100644 index 1c72e628..00000000 --- a/tests/phpunit/unit/api/filters/beansAddAnonymousFilter.php +++ /dev/null @@ -1,82 +0,0 @@ -assertSame( 'foo', $object->value_to_return ); - - // Clean up. - remove_action( 'do_foo', array( $object, 'callback' ), 20 ); - } - - /** - * Test _beans_add_anonymous_filter() should register callback to the given hook. - */ - public function test_should_register_callback_to_hook() { - $object = _beans_add_anonymous_filter( 'do_foo', false, 20 ); - - $this->assertTrue( has_filter( 'do_foo', array( $object, 'callback' ) ) !== false ); - - // Clean up. - remove_action( 'do_foo', array( $object, 'callback' ), 20 ); - } - - /** - * Test _beans_add_anonymous_filter() should call callback on the given hook. - */ - public function test_should_call_callback() { - - foreach ( [ false, 'beans', 19, [ 'foo' ] ] as $value ) { - $object = _beans_add_anonymous_filter( 'beans_test_do_foo', $value, 20 ); - - Filters\expectApplied( 'beans_test_do_foo' ) - ->once() - ->andReturnUsing( function( $arg ) use ( $object, $value ) { - $this->assertSame( 'foo', $arg ); - $this->assertSame( $value, $object->callback() ); - return $object->callback(); - } ); - - $this->assertSame( $value, apply_filters( 'beans_test_do_foo', 'foo' ) ); - - // Clean up. - remove_action( 'beans_test_do_foo', array( $object, 'callback' ), 20 ); - } - } -} From c33682fc165f9462e4ea63af54a0b2c643cdc60f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 10:37:58 -0600 Subject: [PATCH 267/800] Fixed DocBlock. --- lib/api/filters/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/api/filters/functions.php b/lib/api/filters/functions.php index c6ba0d0a..c86446f9 100644 --- a/lib/api/filters/functions.php +++ b/lib/api/filters/functions.php @@ -45,6 +45,8 @@ function beans_add_filter( $hook, $callback_or_value, $priority = 10, $args = 1 * Sub-hooks must be set in square brackets as part of the filter id argument. Sub-hooks are cascaded * in a similar way to CSS classes. Maximum 3 sub-hooks allowed. * + * Note: You can pass additional arguments to the functions that are hooked $id. + * * @since 1.0.0 * * @param string $id A unique string used as a reference. Sub-hook(s) must be set in square brackets. Each sub- @@ -56,7 +58,6 @@ function beans_add_filter( $hook, $callback_or_value, $priority = 10, $args = 1 * always run the parent filter first, so a filter set to the parent will apply * to all sub-hooks. Maximum 3 sub-hooks allowed. * @param mixed $value The value on which the filters hooked to $id are applied to it. - * @param mixed $var Additional variables passed to the functions hooked to $id. @codingStandardsIgnoreLine - Squiz.Commenting.FunctionComment.ExtraParamComment. * * @return mixed The filtered value after all hooked functions are applied to it. */ From d421c4ec888e2a59377b9d24447a173433e1360b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 10:40:29 -0600 Subject: [PATCH 268/800] Removed utilities as dependency. --- .../unit/api/filters/includes/class-filters-test-case.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php index bba96b91..c89e9ef5 100644 --- a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php @@ -44,7 +44,6 @@ protected function setUp() { $this->mock_filter_callbacks(); $this->load_original_functions( array( - 'api/utilities/functions.php', 'api/filters/functions.php', ) ); } From 2e05524652c68d32c8db22f2e03a693e1ccace83 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 10:48:49 -0600 Subject: [PATCH 269/800] Moved file load for HTML API. --- .../phpunit/unit/api/html/includes/class-html-test-case.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index d946d930..a26ca78b 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -42,9 +42,6 @@ public static function setUpBeforeClass() { static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { return isset( $markup['attributes'] ); } ); - - require_once BEANS_TESTS_LIB_DIR . 'api/html/class-beans-attribute.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/html/functions.php'; } /** @@ -54,6 +51,8 @@ protected function setUp() { parent::setUp(); $this->load_original_functions( array( + 'api/html/class-beans-attribute.php', + 'api/html/functions.php', 'api/filters/functions.php', ) ); } From 0b25962d9b099ef9dde03b2590a75c4d00aa72b8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 10:52:04 -0600 Subject: [PATCH 270/800] Moved file load for Fields API. --- .../unit/api/fields/includes/class-fields-test-case.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index b01adbd4..f3be4359 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -33,9 +33,6 @@ public static function setUpBeforeClass() { parent::setUpBeforeClass(); static::$test_data = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-fields.php'; - - require_once BEANS_TESTS_LIB_DIR . 'api/fields/functions.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/fields/class-beans-fields.php'; } /** @@ -45,6 +42,8 @@ public function setUp() { parent::setUp(); $this->load_original_functions( array( + 'api/fields/functions.php', + 'api/fields/class-beans-fields.php', 'api/utilities/functions.php', ) ); @@ -81,6 +80,7 @@ protected function tearDown() { * @param string $method_name Method name for which to gain access. * * @return \ReflectionMethod + * @throws \ReflectionException Throws an exception if method does not exist. */ protected function get_reflective_method( $method_name ) { $class = new \ReflectionClass( '_Beans_Fields' ); @@ -98,6 +98,7 @@ protected function get_reflective_method( $method_name ) { * @param string $property Property name for which to gain access. * * @return \ReflectionProperty|string + * @throws \ReflectionException Throws an exception if property does not exist. */ protected function get_reflective_property( $property ) { $class = new \ReflectionClass( '_Beans_Fields' ); @@ -115,6 +116,7 @@ protected function get_reflective_property( $property ) { * @param string $property Property name for which to gain access. * * @return mixed + * @throws \ReflectionException Throws an exception if property does not exist. */ protected function get_reflective_property_value( $property ) { $reflective = $this->get_reflective_property( $property ); From a296b0dae1978eeb5f2f359832c69de848a7b9c7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 10:53:31 -0600 Subject: [PATCH 271/800] Moved file loads for Image API. --- .../unit/api/image/includes/class-image-test-case.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index a5adcf5b..78a1e366 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -90,10 +90,9 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . 'api/image/functions.php'; - require_once BEANS_TESTS_LIB_DIR . 'api/image/class-beans-image-editor.php'; - $this->load_original_functions( array( + 'api/image/functions.php', + 'api/image/class-beans-image-editor.php', 'api/utilities/functions.php', ) ); From 564a4d97ac6ec0e135ad33bace1ea94446c6f43a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 10:56:15 -0600 Subject: [PATCH 272/800] Refactored Images Unit Test Case. --- .../image/includes/class-image-test-case.php | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index 78a1e366..3105e7c2 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -97,20 +97,8 @@ protected function setUp() { ) ); $this->set_up_virtual_filesystem(); - $this->images_dir = vfsStream::url( 'uploads/beans/images' ); - $this->images_url = 'http:://example.com/uploads/beans/images/'; - Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); - Monkey\Functions\when( 'beans_path_to_url' )->returnArg(); - - Monkey\Functions\expect( 'wp_upload_dir' )->andReturn( array( - 'path' => '', - 'url' => '', - 'subdir' => '', - 'basedir' => vfsStream::url( 'uploads' ), - 'baseurl' => $this->images_url, - 'error' => false, - ) ); + $this->setup_mocks(); $this->images = array( $this->images_dir . '/image1.jpg' => static::$fixtures_dir . '/image1.jpg', @@ -132,6 +120,8 @@ private function set_up_virtual_filesystem() { // Set up the "beans" directory's virtual filesystem. $this->mock_filesystem = vfsStream::setup( 'uploads', 0755, $structure ); + $this->images_dir = vfsStream::url( 'uploads/beans/images' ); + $this->images_url = 'http:://example.com/uploads/beans/images/'; } /** @@ -152,6 +142,7 @@ protected function load_images_into_vfs() { * @param string $method_name Method name for which to gain access. * * @return \ReflectionMethod + * @throws \ReflectionException Throws an exception if method does not exist. */ protected function get_reflective_method( $method_name ) { $class = new \ReflectionClass( '_Beans_Image_Editor' ); @@ -169,6 +160,7 @@ protected function get_reflective_method( $method_name ) { * @param string $property Optional. Property name for which to gain access. * * @return \ReflectionProperty|string + * @throws \ReflectionException Throws an exception if property does not exist. */ protected function get_reflective_property( $property = 'rebuilt_path' ) { $class = new \ReflectionClass( '_Beans_Image_Editor' ); @@ -197,6 +189,7 @@ protected function init_virtual_image( $rebuilt_path, $editor, $path = null ) { $path = $this->fix_virtual_dir( $path ); $rebuilt_path->setValue( $editor, $path ); + return $rebuilt_path->getValue( $editor ); } @@ -234,4 +227,25 @@ protected function remove_virtual_dir_root( $path ) { return str_replace( $pattern, '', $path ); } + + /** + * Setup the mocks. + * + * @since 1.5.0 + * + * @return void + */ + protected function setup_mocks() { + Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); + Monkey\Functions\when( 'beans_path_to_url' )->returnArg(); + + Monkey\Functions\expect( 'wp_upload_dir' )->andReturn( array( + 'path' => '', + 'url' => '', + 'subdir' => '', + 'basedir' => vfsStream::url( 'uploads' ), + 'baseurl' => $this->images_url, + 'error' => false, + ) ); + } } From 7b02ffaa4f5d85fe50822b557c1e7582f565893c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 11:05:02 -0600 Subject: [PATCH 273/800] Refactored reflective methods to Test Case. --- .../includes/class-fields-test-case.php | 20 ++++------ .../image/includes/class-image-test-case.php | 20 ++++------ tests/phpunit/unit/class-test-case.php | 38 +++++++++++++++++++ 3 files changed, 52 insertions(+), 26 deletions(-) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index f3be4359..54028896 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -78,16 +78,13 @@ protected function tearDown() { * @since 1.5.0 * * @param string $method_name Method name for which to gain access. + * @param string $class_name Optional. Name of the target class. * * @return \ReflectionMethod * @throws \ReflectionException Throws an exception if method does not exist. */ - protected function get_reflective_method( $method_name ) { - $class = new \ReflectionClass( '_Beans_Fields' ); - $method = $class->getMethod( $method_name ); - $method->setAccessible( true ); - - return $method; + protected function get_reflective_method( $method_name, $class_name = '_Beans_Fields' ) { + return parent::get_reflective_method( $method_name, $class_name ); } /** @@ -95,17 +92,14 @@ protected function get_reflective_method( $method_name ) { * * @since 1.5.0 * - * @param string $property Property name for which to gain access. + * @param string $property Property name for which to gain access. + * @param string $class_name Optional. Name of the target class. * * @return \ReflectionProperty|string * @throws \ReflectionException Throws an exception if property does not exist. */ - protected function get_reflective_property( $property ) { - $class = new \ReflectionClass( '_Beans_Fields' ); - $property = $class->getProperty( $property ); - $property->setAccessible( true ); - - return $property; + protected function get_reflective_property( $property, $class_name = '_Beans_Fields' ) { + return parent::get_reflective_property( $property, $class_name ); } /** diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index 3105e7c2..416ff02d 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -140,16 +140,13 @@ protected function load_images_into_vfs() { * @since 1.5.0 * * @param string $method_name Method name for which to gain access. + * @param string $class_name Optional. Name of the target class. * * @return \ReflectionMethod * @throws \ReflectionException Throws an exception if method does not exist. */ - protected function get_reflective_method( $method_name ) { - $class = new \ReflectionClass( '_Beans_Image_Editor' ); - $method = $class->getMethod( $method_name ); - $method->setAccessible( true ); - - return $method; + protected function get_reflective_method( $method_name, $class_name = '_Beans_Image_Editor' ) { + return parent::get_reflective_method( $method_name, $class_name ); } /** @@ -157,17 +154,14 @@ protected function get_reflective_method( $method_name ) { * * @since 1.5.0 * - * @param string $property Optional. Property name for which to gain access. + * @param string $property Optional. Property name for which to gain access. + * @param string $class_name Optional. Name of the target class. * * @return \ReflectionProperty|string * @throws \ReflectionException Throws an exception if property does not exist. */ - protected function get_reflective_property( $property = 'rebuilt_path' ) { - $class = new \ReflectionClass( '_Beans_Image_Editor' ); - $property = $class->getProperty( $property ); - $property->setAccessible( true ); - - return $property; + protected function get_reflective_property( $property = 'rebuilt_path', $class_name = '_Beans_Image_Editor' ) { + return parent::get_reflective_property( $property, $class_name ); } /** diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index aad96d62..4388a9b6 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -97,4 +97,42 @@ protected function format_the_html( $html ) { return str_replace( '>', ">\n", $html ); } + + /** + * Get reflective access to the private method. + * + * @since 1.5.0 + * + * @param string $method_name Method name for which to gain access. + * @param string $class_name Name of the target class. + * + * @return \ReflectionMethod + * @throws \ReflectionException Throws an exception if method does not exist. + */ + protected function get_reflective_method( $method_name, $class_name ) { + $class = new \ReflectionClass( $class_name ); + $method = $class->getMethod( $method_name ); + $method->setAccessible( true ); + + return $method; + } + + /** + * Get reflective access to the private property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * @param string $class_name Name of the target class. + * + * @return \ReflectionProperty|string + * @throws \ReflectionException Throws an exception if property does not exist. + */ + protected function get_reflective_property( $property, $class_name ) { + $class = new \ReflectionClass( $class_name ); + $property = $class->getProperty( $property ); + $property->setAccessible( true ); + + return $property; + } } From 08b886e353e8f367eda9a0f110cefea418d8dd46 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 11:05:54 -0600 Subject: [PATCH 274/800] Standardized file load. --- tests/phpunit/unit/api/layout/beansGetDefaultLayout.php | 3 +-- tests/phpunit/unit/api/layout/beansGetLayout.php | 3 +-- tests/phpunit/unit/api/layout/beansGetLayoutClass.php | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php index 80f97e84..83d2f469 100644 --- a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php @@ -27,9 +27,8 @@ class Tests_BeansGetDefaultLayout extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . 'api/layout/functions.php'; - $this->load_original_functions( array( + 'api/layout/functions.php', 'api/widget/functions.php', ) ); } diff --git a/tests/phpunit/unit/api/layout/beansGetLayout.php b/tests/phpunit/unit/api/layout/beansGetLayout.php index 307fee18..47c70f51 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetLayout.php @@ -27,9 +27,8 @@ class Tests_BeansGetLayout extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . 'api/layout/functions.php'; - $this->load_original_functions( array( + 'api/layout/functions.php', 'api/post-meta/functions.php', 'api/term-meta/functions.php', ) ); diff --git a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php index 98d417ff..ca6c2f5e 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php @@ -27,9 +27,8 @@ class Tests_BeansGetLayoutClass extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . 'api/layout/functions.php'; - $this->load_original_functions( array( + 'api/layout/functions.php', 'api/utilities/functions.php', 'api/post-meta/functions.php', ) ); From 6ddaf92efd4888d7417a9319219b7f3646ee7974 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 11:07:30 -0600 Subject: [PATCH 275/800] Standardized Post Meta API unit test file load. --- tests/phpunit/unit/api/post-meta/beansGetPostMeta.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php index ce5983df..0e4be772 100644 --- a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php +++ b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php @@ -27,9 +27,8 @@ class Tests_BeansGetPostMeta extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . 'api/post-meta/functions.php'; - $this->load_original_functions( array( + 'api/post-meta/functions.php', 'api/utilities/functions.php', ) ); } From 239914b4f41e90e528ad4498194948aca81cf36f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 11:08:21 -0600 Subject: [PATCH 276/800] Standardized Template API unit test file load. --- .../api/template/includes/class-template-test-case.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/phpunit/unit/api/template/includes/class-template-test-case.php b/tests/phpunit/unit/api/template/includes/class-template-test-case.php index 0a5d91a8..fcfb93b8 100644 --- a/tests/phpunit/unit/api/template/includes/class-template-test-case.php +++ b/tests/phpunit/unit/api/template/includes/class-template-test-case.php @@ -33,15 +33,6 @@ abstract class Template_Test_Case extends Test_Case { */ protected $mock_filesystem; - /** - * Set up the test before we run the test setups. - */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); - - require_once BEANS_TESTS_LIB_DIR . 'api/template/functions.php'; - } - /** * Set up the test fixture. */ @@ -49,6 +40,7 @@ protected function setUp() { parent::setUp(); $this->load_original_functions( array( + 'api/template/functions.php', 'api/utilities/functions.php', ) ); From a879a6bb67057b4e8710316fdcaabe2d8c0c2f6c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 11:08:44 -0600 Subject: [PATCH 277/800] Standardized Term Meta API unit test file load. --- tests/phpunit/unit/api/term-meta/beansGetTermMeta.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php index cf48f3b7..4738e276 100644 --- a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php +++ b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php @@ -26,9 +26,8 @@ class Tests_BeansGetTermMeta extends Test_Case { protected function setUp() { parent::setUp(); - require_once BEANS_TESTS_LIB_DIR . 'api/term-meta/functions.php'; - $this->load_original_functions( array( + 'api/term-meta/functions.php', 'api/utilities/functions.php', ) ); } From dd16c5d0fb3b7093dddeb546c43f491c0040b0f1 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 11:21:50 -0600 Subject: [PATCH 278/800] Added phpcs disable ruleset. --- .../phpunit/unit/api/fields/includes/class-fields-test-case.php | 2 ++ tests/phpunit/unit/api/image/includes/class-image-test-case.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 54028896..267ceda4 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -5,6 +5,8 @@ * @package Beans\Framework\Tests\Unit\API\Fields\Includes * * @since 1.5.0 + * + * phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found -- Valid use cases to minimize work in tests. */ namespace Beans\Framework\Tests\Unit\API\Fields\Includes; diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index 416ff02d..f450d466 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -5,6 +5,8 @@ * @package Beans\Framework\Tests\Unit\API\Image\Includes * * @since 1.5.0 + * + * phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found -- Valid use cases to minimize work in tests. */ namespace Beans\Framework\Tests\Unit\API\Image\Includes; From 6262e7ac0a897be066ca40a785d92d66e418140f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 13:35:02 -0600 Subject: [PATCH 279/800] Fixed images url. --- tests/phpunit/unit/api/image/includes/class-image-test-case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index f450d466..e79036b3 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -123,7 +123,7 @@ private function set_up_virtual_filesystem() { // Set up the "beans" directory's virtual filesystem. $this->mock_filesystem = vfsStream::setup( 'uploads', 0755, $structure ); $this->images_dir = vfsStream::url( 'uploads/beans/images' ); - $this->images_url = 'http:://example.com/uploads/beans/images/'; + $this->images_url = 'http://example.com/uploads/beans/images/'; } /** From c7e04fe54a4d7aff557916d87949207780ed7bfa Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 14:01:29 -0600 Subject: [PATCH 280/800] Fixed DocBlock and @group. --- lib/api/filters/functions.php | 2 +- .../unit/api/filters/beans-anonymous-filters/_construct.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/filters/functions.php b/lib/api/filters/functions.php index c86446f9..66ecd1d7 100644 --- a/lib/api/filters/functions.php +++ b/lib/api/filters/functions.php @@ -45,7 +45,7 @@ function beans_add_filter( $hook, $callback_or_value, $priority = 10, $args = 1 * Sub-hooks must be set in square brackets as part of the filter id argument. Sub-hooks are cascaded * in a similar way to CSS classes. Maximum 3 sub-hooks allowed. * - * Note: You can pass additional arguments to the functions that are hooked $id. + * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * diff --git a/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php b/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php index e6069d30..6a10966a 100644 --- a/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php +++ b/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php @@ -16,8 +16,8 @@ * Class Tests_Beans_Anonymous_Filters_Construct. * * @package Beans\Framework\Tests\Unit\API\Filters - * @group unit-tests * @group api + * @group api-filters */ class Tests_Beans_Anonymous_Filters_Construct extends Test_Case { From aeafa1b021ba6c0b0e2732a207249c194cdbf11c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 19:29:15 -0600 Subject: [PATCH 281/800] Added resets in Test Case. --- .../includes/class-fields-test-case.php | 17 ++-------- tests/phpunit/integration/class-test-case.php | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index e5fb2cc9..81f220ae 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -49,20 +49,9 @@ public function setUp() { public function tearDown() { parent::tearDown(); - // Reset the "registered" container. - $registered = $this->get_reflective_property( 'registered' ); - $registered->setValue( new \_Beans_Fields(), array( - 'option' => array(), - 'post_meta' => array(), - 'term_meta' => array(), - 'wp_customize' => array(), - ) ); - - // Reset the other static properties. - foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { - $property = $this->get_reflective_property( $property_name ); - $property->setValue( new \_Beans_Fields(), array() ); - } + $this->reset_fields_container(); + + $this->reset_actions_container(); } /** diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index 90667033..46c28a84 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -81,4 +81,37 @@ protected function format_the_html( $html ) { return str_replace( '>', ">\n", $html ); } + + /** + * Reset the Actions API container. + */ + protected function reset_actions_container() { + global $_beans_registered_actions; + $_beans_registered_actions = array( + 'added' => array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + } + + /** + * Reset the Fields API container, i.e. static memories. + */ + protected function reset_fields_container() { + // Reset the "registered" container. + $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); + $registered->setValue( new \_Beans_Fields(), array( + 'option' => array(), + 'post_meta' => array(), + 'term_meta' => array(), + 'wp_customize' => array(), + ) ); + + // Reset the other static properties. + foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { + $property = $this->get_reflective_property( $property_name, '_Beans_Fields' ); + $property->setValue( new \_Beans_Fields(), array() ); + } + } } From d14c6843727198a2e3b06095a5b1a52a738a4dce Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 20:02:35 -0600 Subject: [PATCH 282/800] Added full integration tests. To make sure there are no timing issues, these tests do a full integration test of registering the fields and then rendering. --- .../integration/api/fields/beansField.php | 100 ++++++++++++++++++ .../includes/class-fields-test-case.php | 4 + 2 files changed, 104 insertions(+) diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 7bb4b239..157c12f0 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -217,4 +217,104 @@ public function test_should_render_group_of_fields() { beans_remove_action( 'beans_field_activation', 'beans_field_activation' ); beans_remove_action( 'beans_field_select', 'beans_field_select' ); } + + /** + * Test should render the single field. This is a full integration test for the Fields API. + */ + public function test_full_integration_should_render_single_field() { + $test_data = static::$test_data['single_fields']; + + // Register the fields. + beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ); + $fields = beans_get_fields( 'beans_tests', $test_data['section'] ); + + // Register the checkbox, label, and description callbacks (as they've been unregistered in previous tests). + add_action( 'beans_field_checkbox', 'beans_field_checkbox' ); + add_action( 'beans_field_group_label', 'beans_field_label' ); + add_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + add_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); + + // Run the function and grab the HTML out of the buffer. + ob_start(); + beans_field( $fields[1] ); + $html = ob_get_clean(); + + $expected = << +
    +
    + + + Enable the checkbox test +
    +
    +
    +EOB; + // Check the HTML. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + + // Clean up. + remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); + remove_action( 'beans_field_group_label', 'beans_field_label' ); + remove_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + remove_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); + } + + /** + * Test should render the single field. This is a full integration test for the Fields API. + */ + public function test_full_integration_should_render_group_of_fields() { + $test_data = static::$test_data['group']; + + // Register the fields. + beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ); + $fields = beans_get_fields( 'beans_tests', $test_data['section'] ); + + // Register each field's callback (as it's been unregistered in previous tests). + foreach ( $test_data['fields'][0]['fields'] as $field ) { + add_action( 'beans_field_' . $field['type'], 'beans_field_' . $field['type'] ); + } + add_action( 'beans_field_group_label', 'beans_field_label' ); + add_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + add_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); + + // Run the function and grab the HTML out of the buffer. + ob_start(); + beans_field( $fields[0] ); + $html = ob_get_clean(); + + $expected = << +

    Group of fields

    +
    +
    + + +
    +
    + +
    +
    + + + Enable the checkbox test +
    +
    +
    This is a group of fields.
    +
    +EOB; + // Check the HTML. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + + // Clean up. + foreach ( $test_data['fields'][0]['fields'] as $field ) { + remove_action( 'beans_field_' . $field['type'], 'beans_field_' . $field['type'] ); + } + remove_action( 'beans_field_group_label', 'beans_field_label' ); + remove_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + remove_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); + } } diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index 81f220ae..598373f2 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -41,6 +41,10 @@ public function setUp() { parent::setUp(); require_once BEANS_THEME_DIR . '/lib/api/fields/class-beans-fields.php'; + + $this->reset_fields_container(); + + $this->reset_actions_container(); } /** From e028d85218cca58b001656d0d41390b2065c89a6 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 20:04:08 -0600 Subject: [PATCH 283/800] Moved label and description actions to Test Case. --- tests/phpunit/integration/api/fields/beansField.php | 6 ------ .../api/fields/includes/class-fields-test-case.php | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 157c12f0..64937c4e 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -274,9 +274,6 @@ public function test_full_integration_should_render_group_of_fields() { foreach ( $test_data['fields'][0]['fields'] as $field ) { add_action( 'beans_field_' . $field['type'], 'beans_field_' . $field['type'] ); } - add_action( 'beans_field_group_label', 'beans_field_label' ); - add_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); - add_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -313,8 +310,5 @@ public function test_full_integration_should_render_group_of_fields() { foreach ( $test_data['fields'][0]['fields'] as $field ) { remove_action( 'beans_field_' . $field['type'], 'beans_field_' . $field['type'] ); } - remove_action( 'beans_field_group_label', 'beans_field_label' ); - remove_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); - remove_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); } } diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index 598373f2..4d508932 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -45,6 +45,10 @@ public function setUp() { $this->reset_fields_container(); $this->reset_actions_container(); + + add_action( 'beans_field_group_label', 'beans_field_label' ); + add_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + add_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); } /** @@ -56,6 +60,10 @@ public function tearDown() { $this->reset_fields_container(); $this->reset_actions_container(); + + remove_action( 'beans_field_group_label', 'beans_field_label' ); + remove_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + remove_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); } /** From 2fb9842403cf6fba7c51126135b57a8be5428925 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 20:09:05 -0600 Subject: [PATCH 284/800] Moved reflective to Integration Test Case. --- .../integration/api/fields/beansGetFields.php | 2 +- .../includes/class-fields-test-case.php | 37 +----------------- tests/phpunit/integration/class-test-case.php | 38 +++++++++++++++++++ 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/tests/phpunit/integration/api/fields/beansGetFields.php b/tests/phpunit/integration/api/fields/beansGetFields.php index cdfc9b9f..3504eb84 100644 --- a/tests/phpunit/integration/api/fields/beansGetFields.php +++ b/tests/phpunit/integration/api/fields/beansGetFields.php @@ -35,7 +35,7 @@ public function test_should_return_registered_fields() { ); // Register the fields first. - $registered = $this->get_reflective_property( 'registered' ); + $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); $registered->setValue( new \_Beans_Fields(), $data_set ); $this->assertSame( $data_set['beans_tests'][ $test_data['section'] ], beans_get_fields( 'beans_tests', $test_data['section'] ) ); diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index 4d508932..80579d21 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -66,40 +66,6 @@ public function tearDown() { remove_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); } - /** - * Get reflective access to the private method. - * - * @since 1.5.0 - * - * @param string $method_name Method name for which to gain access. - * - * @return \ReflectionMethod - */ - protected function get_reflective_method( $method_name ) { - $class = new \ReflectionClass( '_Beans_Fields' ); - $method = $class->getMethod( $method_name ); - $method->setAccessible( true ); - - return $method; - } - - /** - * Get reflective access to the private property. - * - * @since 1.5.0 - * - * @param string $property Property name for which to gain access. - * - * @return \ReflectionProperty|string - */ - protected function get_reflective_property( $property ) { - $class = new \ReflectionClass( '_Beans_Fields' ); - $property = $class->getProperty( $property ); - $property->setAccessible( true ); - - return $property; - } - /** * Get the value of the private or protected property. * @@ -108,9 +74,10 @@ protected function get_reflective_property( $property ) { * @param string $property Property name for which to gain access. * * @return mixed + * @throws \ReflectionException Throws an exception if property does not exist. */ protected function get_reflective_property_value( $property ) { - $reflective = $this->get_reflective_property( $property ); + $reflective = $this->get_reflective_property( $property, '_Beans_Fields' ); return $reflective->getValue( new \_Beans_Fields() ); } diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index 46c28a84..42c8d73a 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -114,4 +114,42 @@ protected function reset_fields_container() { $property->setValue( new \_Beans_Fields(), array() ); } } + + /** + * Get reflective access to the private method. + * + * @since 1.5.0 + * + * @param string $method_name Method name for which to gain access. + * @param string $class_name Name of the target class. + * + * @return \ReflectionMethod + * @throws \ReflectionException Throws an exception if method does not exist. + */ + protected function get_reflective_method( $method_name, $class_name ) { + $class = new \ReflectionClass( $class_name ); + $method = $class->getMethod( $method_name ); + $method->setAccessible( true ); + + return $method; + } + + /** + * Get reflective access to the private property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * @param string $class_name Name of the target class. + * + * @return \ReflectionProperty|string + * @throws \ReflectionException Throws an exception if property does not exist. + */ + protected function get_reflective_property( $property, $class_name ) { + $class = new \ReflectionClass( $class_name ); + $property = $class->getProperty( $property ); + $property->setAccessible( true ); + + return $property; + } } From 8d6d6270d0c4aa11e410066d7de6160b37ce3823 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 10 Mar 2018 20:27:44 -0600 Subject: [PATCH 285/800] Moved setup and tear down resets into Integration Test Case. --- .../includes/class-fields-test-case.php | 8 ------- tests/phpunit/integration/class-test-case.php | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index 80579d21..f3bff11a 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -42,10 +42,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/class-beans-fields.php'; - $this->reset_fields_container(); - - $this->reset_actions_container(); - add_action( 'beans_field_group_label', 'beans_field_label' ); add_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); add_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); @@ -57,10 +53,6 @@ public function setUp() { public function tearDown() { parent::tearDown(); - $this->reset_fields_container(); - - $this->reset_actions_container(); - remove_action( 'beans_field_group_label', 'beans_field_label' ); remove_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); remove_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index 42c8d73a..ec89845e 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -19,12 +19,25 @@ */ abstract class Test_Case extends WP_UnitTestCase { + /** + * Reset flag. + * + * @var bool + */ + protected $was_reset = false; + /** * Prepares the test environment before each test. */ public function setUp() { parent::setUp(); Monkey\setUp(); + + if ( $this->was_reset ) { + $this->reset_fields_container(); + $this->reset_actions_container(); + $this->was_reset = true; + } } /** @@ -33,6 +46,9 @@ public function setUp() { public function tearDown() { Monkey\tearDown(); parent::tearDown(); + + $this->reset_fields_container(); + $this->reset_actions_container(); } /** @@ -99,6 +115,11 @@ protected function reset_actions_container() { * Reset the Fields API container, i.e. static memories. */ protected function reset_fields_container() { + + if ( ! class_exists( '_Beans_Fields' ) ) { + return; + } + // Reset the "registered" container. $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); $registered->setValue( new \_Beans_Fields(), array( From aba98152373f47112bc99690b482718e30e77a15 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 09:46:31 -0500 Subject: [PATCH 286/800] Fixed setup & DocBlock. --- tests/phpunit/integration/api/fields/beansField.php | 2 +- tests/phpunit/integration/class-test-case.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 64937c4e..45542260 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -261,7 +261,7 @@ public function test_full_integration_should_render_single_field() { } /** - * Test should render the single field. This is a full integration test for the Fields API. + * Test should render a group of fields. This is a full integration test for the Fields API. */ public function test_full_integration_should_render_group_of_fields() { $test_data = static::$test_data['group']; diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index ec89845e..c0e0969e 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -33,7 +33,7 @@ public function setUp() { parent::setUp(); Monkey\setUp(); - if ( $this->was_reset ) { + if ( ! $this->was_reset ) { $this->reset_fields_container(); $this->reset_actions_container(); $this->was_reset = true; From 58a2e7597ac3c0594b83a228ecd1f4039d68fefc Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 11:15:36 -0500 Subject: [PATCH 287/800] Added tests scaffolding. --- .../api/options/fixtures/test-options.php | 91 ++++++++++++++++ .../includes/class-options-test-case.php | 66 ++++++++++++ .../api/options/fixtures/test-options.php | 91 ++++++++++++++++ .../includes/class-options-test-case.php | 100 ++++++++++++++++++ 4 files changed, 348 insertions(+) create mode 100644 tests/phpunit/integration/api/options/fixtures/test-options.php create mode 100644 tests/phpunit/integration/api/options/includes/class-options-test-case.php create mode 100644 tests/phpunit/unit/api/options/fixtures/test-options.php create mode 100644 tests/phpunit/unit/api/options/includes/class-options-test-case.php diff --git a/tests/phpunit/integration/api/options/fixtures/test-options.php b/tests/phpunit/integration/api/options/fixtures/test-options.php new file mode 100644 index 00000000..62efd8cc --- /dev/null +++ b/tests/phpunit/integration/api/options/fixtures/test-options.php @@ -0,0 +1,91 @@ + array( + array( + 'id' => 'beans_compiler_items', + 'type' => 'flush_cache', + 'description' => 'Clear CSS and Javascript cached files. New cached versions will be compiled on page load.', + ), + array( + 'id' => 'beans_compile_all_styles', + 'label' => false, + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + 'description' => 'Compile and cache all the CSS files that have been enqueued to the WordPress head.', + ), + array( + 'id' => 'beans_compile_all_scripts_group', + 'label' => 'Compile all WordPress scripts', + 'type' => 'group', + 'fields' => array( + array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ), + array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), + 'options' => array( + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ), + ), + ), + 'description' => 'Compile and cache all the Javascript files that have been enqueued to the WordPress head.JavaSript is outputted in the footer if the level is set to Aggressive and might conflict with some third party plugins which are not following WordPress standards.', + ), + ), + 'menu_slug' => 'beans_settings', + 'section' => 'compiler_options', + 'args' => array( + 'title' => 'Compiler options', + 'context' => 'normal', + ), + ), + // Images Options. + array( + 'fields' => array( + array( + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + 'description' => 'Clear all edited images. New images will be created on page load.', + ), + ), + 'menu_slug' => 'beans_settings', + 'section' => 'images_options', + 'args' => array( + 'title' => 'Images options', + 'context' => 'column', + ), + ), + // Mode Options. + array( + 'fields' => array( + array( + 'id' => 'beans_dev_mode', + 'checkbox_label' => 'Enable development mode', + 'type' => 'checkbox', + 'description' => 'This option should be enabled while your website is in development.', + ), + ), + 'menu_slug' => 'beans_settings', + 'section' => 'mode_options', + 'args' => array( + 'title' => 'Mode options', + 'context' => 'column', + ), + ), +); diff --git a/tests/phpunit/integration/api/options/includes/class-options-test-case.php b/tests/phpunit/integration/api/options/includes/class-options-test-case.php new file mode 100644 index 00000000..a2b6bbba --- /dev/null +++ b/tests/phpunit/integration/api/options/includes/class-options-test-case.php @@ -0,0 +1,66 @@ +assertTrue( is_admin() ); + } +} diff --git a/tests/phpunit/unit/api/options/fixtures/test-options.php b/tests/phpunit/unit/api/options/fixtures/test-options.php new file mode 100644 index 00000000..62efd8cc --- /dev/null +++ b/tests/phpunit/unit/api/options/fixtures/test-options.php @@ -0,0 +1,91 @@ + array( + array( + 'id' => 'beans_compiler_items', + 'type' => 'flush_cache', + 'description' => 'Clear CSS and Javascript cached files. New cached versions will be compiled on page load.', + ), + array( + 'id' => 'beans_compile_all_styles', + 'label' => false, + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + 'description' => 'Compile and cache all the CSS files that have been enqueued to the WordPress head.', + ), + array( + 'id' => 'beans_compile_all_scripts_group', + 'label' => 'Compile all WordPress scripts', + 'type' => 'group', + 'fields' => array( + array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ), + array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), + 'options' => array( + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ), + ), + ), + 'description' => 'Compile and cache all the Javascript files that have been enqueued to the WordPress head.JavaSript is outputted in the footer if the level is set to Aggressive and might conflict with some third party plugins which are not following WordPress standards.', + ), + ), + 'menu_slug' => 'beans_settings', + 'section' => 'compiler_options', + 'args' => array( + 'title' => 'Compiler options', + 'context' => 'normal', + ), + ), + // Images Options. + array( + 'fields' => array( + array( + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + 'description' => 'Clear all edited images. New images will be created on page load.', + ), + ), + 'menu_slug' => 'beans_settings', + 'section' => 'images_options', + 'args' => array( + 'title' => 'Images options', + 'context' => 'column', + ), + ), + // Mode Options. + array( + 'fields' => array( + array( + 'id' => 'beans_dev_mode', + 'checkbox_label' => 'Enable development mode', + 'type' => 'checkbox', + 'description' => 'This option should be enabled while your website is in development.', + ), + ), + 'menu_slug' => 'beans_settings', + 'section' => 'mode_options', + 'args' => array( + 'title' => 'Mode options', + 'context' => 'column', + ), + ), +); diff --git a/tests/phpunit/unit/api/options/includes/class-options-test-case.php b/tests/phpunit/unit/api/options/includes/class-options-test-case.php new file mode 100644 index 00000000..570c4b88 --- /dev/null +++ b/tests/phpunit/unit/api/options/includes/class-options-test-case.php @@ -0,0 +1,100 @@ +load_original_functions( array( + 'api/utilities/functions.php', + 'api/options/class-beans-options.php', + 'api/options/functions.php', + 'api/fields/functions.php', + ) ); + + $this->setup_function_mocks(); + } + + /** + * Cleans up the test environment after each test. + */ + protected function tearDown() { + parent::tearDown(); + + global $wp_meta_boxes; + $wp_meta_boxes = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. + } + + /** + * Set up function mocks. + */ + protected function setup_function_mocks() { + Monkey\Functions\when( 'add_meta_box' )->alias( function ( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { + global $wp_meta_boxes; + + if ( empty( $screen ) ) { + $screen = 'beans'; + } + + // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Mocking global here for tests. + $wp_meta_boxes = array( + $screen => array( + $context => array( + $priority => array( + $id => array( + 'id' => $id, + 'title' => $title, + 'callback' => $callback, + 'args' => $callback_args, + ), + ), + ), + ), + ); + } ); + + foreach ( array( 'esc_attr', 'esc_html', '__' ) as $wp_function ) { + Monkey\Functions\when( $wp_function )->returnArg(); + } + + foreach ( array( 'esc_attr_e', 'esc_html_e' ) as $wp_function ) { + Monkey\Functions\when( $wp_function )->echoArg(); + } + } +} From 3c3e49e4202598af57f581f025c47b917ae9eecc Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 11:21:36 -0500 Subject: [PATCH 288/800] Renamed class to comply with WPCS. --- lib/api/options/{class.php => class-beans-options.php} | 0 lib/api/options/functions.php | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename lib/api/options/{class.php => class-beans-options.php} (100%) diff --git a/lib/api/options/class.php b/lib/api/options/class-beans-options.php similarity index 100% rename from lib/api/options/class.php rename to lib/api/options/class-beans-options.php diff --git a/lib/api/options/functions.php b/lib/api/options/functions.php index e864246f..973ec90a 100644 --- a/lib/api/options/functions.php +++ b/lib/api/options/functions.php @@ -80,7 +80,7 @@ function beans_register_options( array $fields, $menu_slug, $section, $args = ar } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once BEANS_API_PATH . 'options/class.php'; + require_once BEANS_API_PATH . 'options/class-beans-options.php'; $class = new _Beans_Options(); $class->register( $section, $args ); @@ -126,7 +126,7 @@ function _beans_options_page_actions() { } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once BEANS_API_PATH . 'options/class.php'; + require_once BEANS_API_PATH . 'options/class-beans-options.php'; $class = new _Beans_Options(); $class->actions(); From ee2c8173c0ff8864fa84e5e241c73f3733e3394a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 11:27:01 -0500 Subject: [PATCH 289/800] Added register method tests. --- .../api/options/beans-options/register.php | 72 +++++++++++++++ .../api/options/beans-options/register.php | 87 +++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 tests/phpunit/integration/api/options/beans-options/register.php create mode 100644 tests/phpunit/unit/api/options/beans-options/register.php diff --git a/tests/phpunit/integration/api/options/beans-options/register.php b/tests/phpunit/integration/api/options/beans-options/register.php new file mode 100644 index 00000000..f3ce8f90 --- /dev/null +++ b/tests/phpunit/integration/api/options/beans-options/register.php @@ -0,0 +1,72 @@ +register( $options['section'], $options['args'] ); + + // Check that the callback is registered to the hook. + $this->assertEquals( 10, has_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ) ); + + // Clean up. + remove_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ); + } + } + + /** + * Test register() should register meta box with WordPress. + */ + public function test_should_register_meta_box_with_wp() { + $instance = new _Beans_Options(); + $this->go_to_settings_page(); + + foreach ( static::$test_data as $option ) { + // Register the option. + $instance->register( $option['section'], $option['args'] ); + + // Check that the metabox is registered with WordPress. + global $wp_meta_boxes; + $this->assertArrayHasKey( 'themesphppagebeans_settings', $wp_meta_boxes ); + $this->assertArrayHasKey( $option['args']['context'], $wp_meta_boxes['themesphppagebeans_settings'] ); + $this->assertArrayHasKey( 'default', $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ] ); + $this->assertArrayHasKey( $option['section'], $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'] ); + $this->assertSame( array( + 'id' => $option['section'], + 'title' => $option['args']['title'], + 'callback' => array( $instance, 'metabox_content' ), + 'args' => null, + ), $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); + + // Clean up. + remove_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ); + } + } +} diff --git a/tests/phpunit/unit/api/options/beans-options/register.php b/tests/phpunit/unit/api/options/beans-options/register.php new file mode 100644 index 00000000..1c71e62f --- /dev/null +++ b/tests/phpunit/unit/api/options/beans-options/register.php @@ -0,0 +1,87 @@ +get_reflective_property( 'args', '_Beans_Options' ); + + $instance = new _Beans_Options(); + $instance->register( 'foo', array() ); + $this->assertSame( array( + 'title' => 'Undefined', + 'context' => 'normal', + ), $property->getValue( $instance ) ); + + $instance = new _Beans_Options(); + $instance->register( 'beans_test', array( 'title' => 'Beans Tests' ) ); + $this->assertSame( array( + 'title' => 'Beans Tests', + 'context' => 'normal', + ), $property->getValue( $instance ) ); + } + + /** + * Test register() should register callback to the 'admin_enqueue_scripts' hook. + */ + public function test_should_register_callback_to_admin_enqueue_scripts_hook() { + $instance = new _Beans_Options(); + $instance->register( 'beans_test', array( 'title' => 'Beans Tests' ) ); + + $this->assertEquals( 10, has_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ) ); + } + + /** + * Test register() should register meta box with WordPress. + */ + public function test_should_register_meta_box_with_wp() { + $instance = new _Beans_Options(); + + foreach ( static::$test_data as $option ) { + Monkey\Functions\expect( 'beans_get' )->with( 'page' )->once()->andReturn( 'beans_settings' ); + + // Register the option. + $instance->register( $option['section'], $option['args'] ); + + // Check that the metabox is registered with WordPress. + global $wp_meta_boxes; + $this->assertArrayHasKey( 'beans_settings', $wp_meta_boxes ); + $this->assertArrayHasKey( $option['args']['context'], $wp_meta_boxes['beans_settings'] ); + $this->assertArrayHasKey( 'default', $wp_meta_boxes['beans_settings'][ $option['args']['context'] ] ); + $this->assertArrayHasKey( $option['section'], $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'] ); + $this->assertSame( array( + 'id' => $option['section'], + 'title' => $option['args']['title'], + 'callback' => array( $instance, 'metabox_content' ), + 'args' => null, + ), $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); + + // Clean up. + remove_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ); + } + } +} From b453a0aaba6b29b239872cac3a4dbef697c8a3b7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 11:29:28 -0500 Subject: [PATCH 290/800] Renamed metabox render method to better describe its expected behavior. --- lib/api/options/class-beans-options.php | 10 ++++------ .../integration/api/options/beans-options/register.php | 2 +- .../unit/api/options/beans-options/register.php | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index 015ca4e9..816773fc 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -75,11 +75,9 @@ public function enqueue_assets() { } /** - * Register the Metabox. + * Register the Metabox with WordPress. * * @since 1.0.0 - * @ignore - * @access private * * @return void */ @@ -87,7 +85,7 @@ private function register_metabox() { add_meta_box( $this->section, $this->args['title'], - array( $this, 'metabox_content' ), + array( $this, 'render_metabox' ), beans_get( 'page' ), $this->args['context'], 'default' @@ -95,13 +93,13 @@ private function register_metabox() { } /** - * Metabox content. + * Render the metabox's content. Callback that is fired by WordPress. * * @since 1.0.0 * * @return void */ - public function metabox_content() { + public function render_metabox() { foreach ( beans_get_fields( 'option', $this->section ) as $field ) { beans_field( $field ); diff --git a/tests/phpunit/integration/api/options/beans-options/register.php b/tests/phpunit/integration/api/options/beans-options/register.php index f3ce8f90..61fd55c4 100644 --- a/tests/phpunit/integration/api/options/beans-options/register.php +++ b/tests/phpunit/integration/api/options/beans-options/register.php @@ -61,7 +61,7 @@ public function test_should_register_meta_box_with_wp() { $this->assertSame( array( 'id' => $option['section'], 'title' => $option['args']['title'], - 'callback' => array( $instance, 'metabox_content' ), + 'callback' => array( $instance, 'render_metabox' ), 'args' => null, ), $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); diff --git a/tests/phpunit/unit/api/options/beans-options/register.php b/tests/phpunit/unit/api/options/beans-options/register.php index 1c71e62f..cc729492 100644 --- a/tests/phpunit/unit/api/options/beans-options/register.php +++ b/tests/phpunit/unit/api/options/beans-options/register.php @@ -76,7 +76,7 @@ public function test_should_register_meta_box_with_wp() { $this->assertSame( array( 'id' => $option['section'], 'title' => $option['args']['title'], - 'callback' => array( $instance, 'metabox_content' ), + 'callback' => array( $instance, 'render_metabox' ), 'args' => null, ), $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); From 9fa5cb660684cb5e92d6f53bee40d84a6a735554 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 11:32:03 -0500 Subject: [PATCH 291/800] Improved render_metabox() & added tests. Added a bail out if no fields are registered for the section. --- lib/api/options/class-beans-options.php | 7 +- .../options/beans-options/renderMetabox.php | 74 +++++++++++++++++++ .../options/beans-options/renderMetabox.php | 64 ++++++++++++++++ 3 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/integration/api/options/beans-options/renderMetabox.php create mode 100644 tests/phpunit/unit/api/options/beans-options/renderMetabox.php diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index 816773fc..1ee8c38e 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -100,8 +100,13 @@ private function register_metabox() { * @return void */ public function render_metabox() { + $fields = beans_get_fields( 'option', $this->section ); - foreach ( beans_get_fields( 'option', $this->section ) as $field ) { + if ( empty( $fields ) ) { + return; + } + + foreach ( $fields as $field ) { beans_field( $field ); } } diff --git a/tests/phpunit/integration/api/options/beans-options/renderMetabox.php b/tests/phpunit/integration/api/options/beans-options/renderMetabox.php new file mode 100644 index 00000000..da8e415a --- /dev/null +++ b/tests/phpunit/integration/api/options/beans-options/renderMetabox.php @@ -0,0 +1,74 @@ +register( $option['section'], $option['args'] ); +// +// // Run the test. +// $this->assertNull( $instance->render_metabox() ); +// } +// } + + /** + * Test render_metabox() should render registered fields. + */ + public function test_should_render_registered_fields() { + $instance = new _Beans_Options(); + + // Register the field and option. + $option = end( static::$test_data ); + beans_register_fields( $option['fields'], 'option', $option['section'] ); + beans_add_smart_action( 'beans_field_checkbox', 'beans_field_checkbox' ); + $instance->register( $option['section'], $option['args'] ); + + // Run the method and grab the HTML out of the buffer. + ob_start(); + $instance->render_metabox(); + $html = ob_get_clean(); + + // Run the tests. + $this->assertFileExists( BEANS_THEME_DIR . '/lib/api/fields/types/checkbox.php' ); + $expected = << +
    +
    + + + Enable development mode +
    +
    + +EOB; + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} diff --git a/tests/phpunit/unit/api/options/beans-options/renderMetabox.php b/tests/phpunit/unit/api/options/beans-options/renderMetabox.php new file mode 100644 index 00000000..3a1a74fa --- /dev/null +++ b/tests/phpunit/unit/api/options/beans-options/renderMetabox.php @@ -0,0 +1,64 @@ +with( 'page' )->once()->andReturn( 'beans_settings' ); + Monkey\Functions\expect( 'beans_get_fields' )->with( 'option', $option['section'] )->once()->andReturn( false ); + + // Register the option. + $instance->register( $option['section'], $option['args'] ); + + // Run the test. + $this->assertNull( $instance->render_metabox() ); + } + } + + /** + * Test render_metabox() should render registered fields. For this test, we'll not render but rather check that + * each function is called as expected. + */ + public function test_should_render_registered_fields() { + $instance = new _Beans_Options(); + + foreach ( static::$test_data as $option ) { + Monkey\Functions\expect( 'beans_get' )->with( 'page' )->once()->andReturn( 'beans_settings' ); + Monkey\Functions\expect( 'beans_get_fields' )->with( 'option', $option['section'] )->once()->andReturn( $option['fields'] ); + + // Register the option. + $instance->register( $option['section'], $option['args'] ); + + // Run the tests. + Monkey\Functions\expect( 'beans_field' )->times( count( $option['fields'] ) )->andReturn( null ); + $this->assertNull( $instance->render_metabox() ); + } + } +} From a7dd415cba1667f9a804d2708f43672787a33e70 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 11:35:08 -0500 Subject: [PATCH 292/800] Added tests for the page method. --- lib/api/options/class-beans-options.php | 8 +- .../api/options/beans-options/renderPage.php | 145 ++++++++++++++++++ .../api/options/beans-options/renderPage.php | 120 +++++++++++++++ 3 files changed, 269 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/integration/api/options/beans-options/renderPage.php create mode 100644 tests/phpunit/unit/api/options/beans-options/renderPage.php diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index 1ee8c38e..69c835d9 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -134,10 +134,10 @@ public function page( $page ) { // Set page data which will be used by the postbox. ?> -
    + - +

    - - + +

    assertNull( ( new _Beans_Options() )->page( 'beans_settings' ) ); + } + + /** + * Test register() should return render form when "normal" context is configured. + */ + public function test_should_render_form_when_context_normal() { + $instance = new _Beans_Options(); + $this->go_to_settings_page(); + + // Register the first option. + $option = current( static::$test_data ); + $instance->register( $option['section'], $option['args'] ); + + // Run the method and grab the HTML out of the buffer. + ob_start(); + ( new _Beans_Options() )->page( 'themesphppagebeans_settings' ); + $html = ob_get_clean(); + $html = $this->format_the_html( $html ); + + // Run the tests. Exclude checking for the nonce fields. + $expected = << +EOB; + $this->assertContains( $this->format_the_html( $expected ), $html ); + + $expected = << +
    +
    + +

    Compiler options

    +
    +
    +
    + +

    + + +

    + +EOB; + $this->assertContains( $this->format_the_html( $expected ), $html ); + } + + /** + * Test register() should return render form when "column" context is configured. + */ + public function test_should_render_form_when_column_context() { + $instance = new _Beans_Options(); + $this->go_to_settings_page(); + + // Register the options. + foreach ( static::$test_data as $option ) { + $instance->register( $option['section'], $option['args'] ); + } + + global $wp_meta_boxes; + $this->assertArrayHasKey( 'themesphppagebeans_settings', $wp_meta_boxes ); + + // Run the method and grab the HTML out of the buffer. + ob_start(); + ( new _Beans_Options() )->page( 'themesphppagebeans_settings' ); + $html = ob_get_clean(); + $html = $this->format_the_html( $html ); + + // Run the tests. Exclude checking for the nonce fields. + $expected = << +EOB; + $this->assertContains( $this->format_the_html( $expected ), $html ); + + $expected = << +
    +
    + +

    Compiler options

    +
    +
    +
    +
    +
    + +

    Images options

    +
    +
    +
    + +

    Mode options

    +
    +
    +
    + +

    + + +

    + +EOB; + $this->assertContains( $this->format_the_html( $expected ), $html ); + } +} diff --git a/tests/phpunit/unit/api/options/beans-options/renderPage.php b/tests/phpunit/unit/api/options/beans-options/renderPage.php new file mode 100644 index 00000000..6010c328 --- /dev/null +++ b/tests/phpunit/unit/api/options/beans-options/renderPage.php @@ -0,0 +1,120 @@ +with( 'beans_tests', array() )->once()->andReturn( null ); + + $this->assertNull( ( new _Beans_Options() )->page( 'beans_tests' ) ); + } + + /** + * Test register() should return render form when "normal" context is configured. + */ + public function test_should_render_form_when_context_normal() { + Monkey\Functions\expect( 'beans_get' ) + ->with( 'beans_tests', array() ) + ->once() + ->andReturn( array( 'column' => '' ) ) + ->andAlsoExpectIt() + ->with( 'column', array( 'column' => '' ), array() ) + ->once() + ->andReturn( array() ) + ->andAlsoExpectIt() + ->with( 'page' ) + ->once() + ->andReturn( 'beans-test' ); + Monkey\Functions\expect( 'do_meta_boxes' )->with( 'beans_tests', 'normal', null )->once()->andReturnNull(); + Monkey\Functions\expect( 'wp_nonce_field' )->twice()->andReturnNull(); + Monkey\Functions\expect( 'wp_create_nonce' )->once()->andReturn( 'foo' ); + + // Run the method and grab the HTML out of the buffer. + ob_start(); + ( new _Beans_Options() )->page( 'beans_tests' ); + $html = ob_get_clean(); + + $expected = << + +
    +

    + + +

    + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test register() should return render form when "column" context is configured. + */ + public function test_should_render_form_when_column_context() { + Monkey\Functions\expect( 'beans_get' ) + ->with( 'beans_tests', array() ) + ->once() + ->andReturn( array( 'column' => true ) ) + ->andAlsoExpectIt() + ->with( 'column', array( 'column' => true ), array() ) + ->once() + ->andReturn( true ) + ->andAlsoExpectIt() + ->with( 'page' ) + ->once() + ->andReturn( 'beans-test' ); + Monkey\Functions\expect( 'do_meta_boxes' ) + ->with( 'beans_tests', 'normal', null ) + ->once() + ->andReturnNull() + ->andAlsoExpectIt() + ->with( 'beans_tests', 'column', null ) + ->once() + ->andReturnNull(); + Monkey\Functions\expect( 'wp_nonce_field' )->twice()->andReturnNull(); + Monkey\Functions\expect( 'wp_create_nonce' )->once()->andReturn( 'foo' ); + + // Run the method and grab the HTML out of the buffer. + ob_start(); + ( new _Beans_Options() )->page( 'beans_tests' ); + $html = ob_get_clean(); + + $expected = << + +
    +

    + + +

    + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} From 46081e4a3169382e47611c71807efff85e9be37b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 11:37:51 -0500 Subject: [PATCH 293/800] Renamed page method to better identify its expected behavior. --- lib/api/options/class-beans-options.php | 6 +++--- lib/api/options/functions.php | 2 +- .../integration/api/options/beans-options/renderPage.php | 8 ++++---- .../phpunit/unit/api/options/beans-options/renderPage.php | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index 69c835d9..8a15d9b8 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -112,15 +112,15 @@ public function render_metabox() { } /** - * Page content. + * Render the page's (screen's) content. * * @since 1.0.0 * - * @param int $page Page ID. + * @param string|WP_Screen $page The given page. * * @return void */ - public function page( $page ) { + public function render_page( $page ) { global $wp_meta_boxes; $boxes = beans_get( $page, $wp_meta_boxes ); diff --git a/lib/api/options/functions.php b/lib/api/options/functions.php index 973ec90a..016b2c80 100644 --- a/lib/api/options/functions.php +++ b/lib/api/options/functions.php @@ -106,7 +106,7 @@ function beans_options( $menu_slug ) { } $class = new _Beans_Options(); - $class->page( $menu_slug ); + $class->render_page( $menu_slug ); } add_action( 'wp_loaded', '_beans_options_page_actions' ); diff --git a/tests/phpunit/integration/api/options/beans-options/renderPage.php b/tests/phpunit/integration/api/options/beans-options/renderPage.php index 56033cf5..c0bcbcf1 100644 --- a/tests/phpunit/integration/api/options/beans-options/renderPage.php +++ b/tests/phpunit/integration/api/options/beans-options/renderPage.php @@ -1,6 +1,6 @@ assertNull( ( new _Beans_Options() )->page( 'beans_settings' ) ); + $this->assertNull( ( new _Beans_Options() )->render_page( 'beans_settings' ) ); } /** @@ -44,7 +44,7 @@ public function test_should_render_form_when_context_normal() { // Run the method and grab the HTML out of the buffer. ob_start(); - ( new _Beans_Options() )->page( 'themesphppagebeans_settings' ); + ( new _Beans_Options() )->render_page( 'themesphppagebeans_settings' ); $html = ob_get_clean(); $html = $this->format_the_html( $html ); @@ -93,7 +93,7 @@ public function test_should_render_form_when_column_context() { // Run the method and grab the HTML out of the buffer. ob_start(); - ( new _Beans_Options() )->page( 'themesphppagebeans_settings' ); + ( new _Beans_Options() )->render_page( 'themesphppagebeans_settings' ); $html = ob_get_clean(); $html = $this->format_the_html( $html ); diff --git a/tests/phpunit/unit/api/options/beans-options/renderPage.php b/tests/phpunit/unit/api/options/beans-options/renderPage.php index 6010c328..f07a6ae3 100644 --- a/tests/phpunit/unit/api/options/beans-options/renderPage.php +++ b/tests/phpunit/unit/api/options/beans-options/renderPage.php @@ -1,6 +1,6 @@ with( 'beans_tests', array() )->once()->andReturn( null ); - $this->assertNull( ( new _Beans_Options() )->page( 'beans_tests' ) ); + $this->assertNull( ( new _Beans_Options() )->render_page( 'beans_tests' ) ); } /** @@ -55,7 +55,7 @@ public function test_should_render_form_when_context_normal() { // Run the method and grab the HTML out of the buffer. ob_start(); - ( new _Beans_Options() )->page( 'beans_tests' ); + ( new _Beans_Options() )->render_page( 'beans_tests' ); $html = ob_get_clean(); $expected = <<page( 'beans_tests' ); + ( new _Beans_Options() )->render_page( 'beans_tests' ); $html = ob_get_clean(); $expected = << Date: Sun, 11 Mar 2018 11:41:00 -0500 Subject: [PATCH 294/800] Moved HTML into a view file. Separation of concerns. --- lib/api/options/class-beans-options.php | 22 +----------------- lib/api/options/views/page.php | 30 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 lib/api/options/views/page.php diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index 8a15d9b8..763c9842 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -132,27 +132,7 @@ public function render_page( $page ) { // Only add a column class if there is more than 1 metabox. $column_class = beans_get( 'column', $boxes, array() ) ? ' column' : false; - // Set page data which will be used by the postbox. - ?> -
    - - - -
    - -
    -

    - - -

    -
    - + +
    + + + +
    + +
    +

    + + +

    +
    From 497509f362b622c3a5e216b5c2b0b57883836101 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 12:02:42 -0500 Subject: [PATCH 295/800] Renamed save_notices method to match the expected behavior. --- lib/api/options/class-beans-options.php | 6 +- .../beans-options/renderSaveNotice.php | 66 +++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index 763c9842..f8cbf90f 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -146,7 +146,7 @@ public function actions() { if ( beans_post( 'beans_save_options' ) ) { $this->save(); - add_action( 'admin_notices', array( $this, 'save_notices' ) ); + add_action( 'admin_notices', array( $this, 'render_save_notice' ) ); } if ( beans_post( 'beans_reset_options' ) ) { @@ -208,13 +208,13 @@ private function reset() { } /** - * Save notice content. + * Render the save notice. * * @since 1.0.0 * * @return void */ - public function save_notices() { + public function render_save_notice() { if ( $this->success ) { ?> diff --git a/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php b/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php new file mode 100644 index 00000000..b9612a77 --- /dev/null +++ b/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php @@ -0,0 +1,66 @@ +render_save_notice(); + $html = ob_get_clean(); + + $expected = << +

    Settings could not be saved, please try again.

    + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test save_notices() should render updated message when "success" property is set. + */ + public function test_should_render_updated_message_when_success_is_set() { + $property = $this->get_reflective_property( 'success', '_Beans_Options' ); + $instance = new _Beans_Options(); + $property->setValue( $instance, true ); + + // Run the method and grab the HTML out of the buffer. + ob_start(); + $instance->render_save_notice(); + $html = ob_get_clean(); + + $expected = << +

    Settings saved successfully!

    + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} From 1ae863e8dbbedfbc5aacf8eee83373caf4cea494 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 12:12:39 -0500 Subject: [PATCH 296/800] Moved save notice HTML to view files. Separation of concerns. --- lib/api/options/class-beans-options.php | 15 ++++----------- lib/api/options/views/save-notice-error.php | 15 +++++++++++++++ lib/api/options/views/save-notice-success.php | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 lib/api/options/views/save-notice-error.php create mode 100644 lib/api/options/views/save-notice-success.php diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index f8cbf90f..f0c5acd8 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -217,18 +217,11 @@ private function reset() { public function render_save_notice() { if ( $this->success ) { - ?> -
    -

    -
    - -
    -

    -
    - + +
    +

    +
    diff --git a/lib/api/options/views/save-notice-success.php b/lib/api/options/views/save-notice-success.php new file mode 100644 index 00000000..fb53e125 --- /dev/null +++ b/lib/api/options/views/save-notice-success.php @@ -0,0 +1,15 @@ + + +
    +

    +
    From afb2418481ed7e41409fdb97a1a02950928b4922 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 12:15:35 -0500 Subject: [PATCH 297/800] Added unit tests for reset_notices(). --- .../beans-options/renderRenderNotice.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php diff --git a/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php b/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php new file mode 100644 index 00000000..597d8975 --- /dev/null +++ b/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php @@ -0,0 +1,66 @@ +reset_notices(); + $html = ob_get_clean(); + + $expected = << +

    Settings could not be reset, please try again.

    + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } + + /** + * Test reset_notices() should render updated message when "success" property is set. + */ + public function test_should_render_updated_message_when_success_is_set() { + $property = $this->get_reflective_property( 'success', '_Beans_Options' ); + $instance = new _Beans_Options(); + $property->setValue( $instance, true ); + + // Run the method and grab the HTML out of the buffer. + ob_start(); + $instance->reset_notices(); + $html = ob_get_clean(); + + $expected = << +

    Settings reset successfully!

    + +EOB; + // Run the test. + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + } +} From 2b92c201f5bb3913ae1d35befcfb9be66d5c644b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 12:16:21 -0500 Subject: [PATCH 298/800] Renamed reset_notices() to reflect its expected behavior. --- lib/api/options/class-beans-options.php | 4 ++-- .../api/options/beans-options/renderRenderNotice.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index f0c5acd8..8e8ed6e0 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -151,7 +151,7 @@ public function actions() { if ( beans_post( 'beans_reset_options' ) ) { $this->reset(); - add_action( 'admin_notices', array( $this, 'reset_notices' ) ); + add_action( 'admin_notices', array( $this, 'render_reset_notice' ) ); } } @@ -231,7 +231,7 @@ public function render_save_notice() { * * @return void */ - public function reset_notices() { + public function render_reset_notice() { if ( $this->success ) { ?> diff --git a/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php b/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php index 597d8975..230e1f8e 100644 --- a/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php +++ b/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php @@ -1,6 +1,6 @@ reset_notices(); + ( new _Beans_Options() )->render_reset_notice(); $html = ob_get_clean(); $expected = <<get_reflective_property( 'success', '_Beans_Options' ); @@ -52,7 +52,7 @@ public function test_should_render_updated_message_when_success_is_set() { // Run the method and grab the HTML out of the buffer. ob_start(); - $instance->reset_notices(); + $instance->render_reset_notice(); $html = ob_get_clean(); $expected = << Date: Sun, 11 Mar 2018 12:18:43 -0500 Subject: [PATCH 299/800] Moved reset notices HTML to view file. Separation of concerns. --- lib/api/options/class-beans-options.php | 17 +++++------------ lib/api/options/views/reset-notice-error.php | 15 +++++++++++++++ lib/api/options/views/reset-notice-success.php | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 lib/api/options/views/reset-notice-error.php create mode 100644 lib/api/options/views/reset-notice-success.php diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index 8e8ed6e0..1fa97ef4 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -225,7 +225,7 @@ public function render_save_notice() { } /** - * Reset notice content. + * Render the reset notice. * * @since 1.0.0 * @@ -234,17 +234,10 @@ public function render_save_notice() { public function render_reset_notice() { if ( $this->success ) { - ?> -
    -

    -
    - -
    -

    -
    - + +
    +

    +
    diff --git a/lib/api/options/views/reset-notice-success.php b/lib/api/options/views/reset-notice-success.php new file mode 100644 index 00000000..fc59941b --- /dev/null +++ b/lib/api/options/views/reset-notice-success.php @@ -0,0 +1,15 @@ + + +
    +

    +
    From 69d3001272333d30f683e3f053b2e3fa07ed504f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 13:03:54 -0500 Subject: [PATCH 300/800] Added save action integration tests. --- lib/api/options/class-beans-options.php | 2 +- .../api/options/beans-options/actions.php | 114 ++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/integration/api/options/beans-options/actions.php diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index 1fa97ef4..f45a1888 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -170,7 +170,7 @@ private function save() { $fields = beans_post( 'beans_fields' ); - if ( ! ( $fields ) ) { + if ( ! $fields ) { return false; } diff --git a/tests/phpunit/integration/api/options/beans-options/actions.php b/tests/phpunit/integration/api/options/beans-options/actions.php new file mode 100644 index 00000000..2a00625e --- /dev/null +++ b/tests/phpunit/integration/api/options/beans-options/actions.php @@ -0,0 +1,114 @@ +assertArrayNotHasKey( 'beans_save_options', $_POST ); + $this->assertArrayNotHasKey( 'beans_reset_options', $_POST ); + $this->assertNull( $instance->actions() ); + $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_save_notice' ) ) ); + $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_reset_notice' ) ) ); + } + + /** + * Test actions() should not save options when the nonce fails. + */ + public function test_should_not_save_options_when_nonce_fails() { + $test_data = array( + 'beans_compile_all_styles' => 1, + 'beans_compile_all_scripts' => 1, + 'beans_dev_mode' => 1, + ); + $_POST['beans_fields'] = $test_data; + $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); + $instance = new _Beans_Options(); + + // Check with no nonce. + $instance->actions(); + $this->assertFalse( $success_property->getValue( $instance ) ); + + foreach ( $test_data as $option ) { + // Check that the value was not saved. + $this->assertNull( get_option( $option, null ) ); + } + + // Check with an invalid nonce. + $_POST['beans_options_nonce'] = 'invalid-nonce'; + + $instance->actions(); + $this->assertFalse( $success_property->getValue( $instance ) ); + + foreach ( $test_data as $option ) { + // Check that the value was not saved. + $this->assertNull( get_option( $option, null ) ); + } + } + + /** + * Test actions() should save the field values when it's a save action. + */ + public function test_should_save_field_values_when_save_action() { + // Setup the test. + $nonce = wp_create_nonce( 'beans_options_nonce' ); + $_POST['beans_options_nonce'] = $nonce; + $_POST['beans_save_options'] = 1; + $test_data = array( + 'beans_compile_all_styles' => 1, + 'beans_compile_all_scripts' => 1, + 'beans_dev_mode' => 1, + ); + $_POST['beans_fields'] = $test_data; + + $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); + $instance = new _Beans_Options(); + $instance->actions(); + + // Check that the success property was set. + $this->assertTrue( $success_property->getValue( $instance ) ); + + // Check the save. + $this->assertArrayHasKey( 'beans_save_options', $_POST ); + $this->assertEquals( 10, has_action( 'admin_notices', array( $instance, 'render_save_notice' ) ) ); + + // Check the reset. + $this->assertArrayNotHasKey( 'beans_reset_options', $_POST ); + $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_reset_notice' ) ) ); + + foreach ( $test_data as $option => $value ) { + // Check that the value was saved. + $this->assertEquals( $value, get_option( $option ) ); + + // Clean up. + delete_option( $option ); + } + } +} From 1be7189a374c805320ca0c2cb51849fb8e9464ee Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 13:22:50 -0500 Subject: [PATCH 301/800] Added reset action integration tests. --- .../api/options/beans-options/actions.php | 94 ++++++++++++++++++- .../includes/class-options-test-case.php | 3 + 2 files changed, 93 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/options/beans-options/actions.php b/tests/phpunit/integration/api/options/beans-options/actions.php index 2a00625e..0c18532b 100644 --- a/tests/phpunit/integration/api/options/beans-options/actions.php +++ b/tests/phpunit/integration/api/options/beans-options/actions.php @@ -43,14 +43,15 @@ public function test_should_do_nothing_when_no_save_or_reset_action() { * Test actions() should not save options when the nonce fails. */ public function test_should_not_save_options_when_nonce_fails() { - $test_data = array( + $_POST['beans_save_options'] = 1; + $test_data = array( 'beans_compile_all_styles' => 1, 'beans_compile_all_scripts' => 1, 'beans_dev_mode' => 1, ); - $_POST['beans_fields'] = $test_data; - $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); - $instance = new _Beans_Options(); + $_POST['beans_fields'] = $test_data; + $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); + $instance = new _Beans_Options(); // Check with no nonce. $instance->actions(); @@ -111,4 +112,89 @@ public function test_should_save_field_values_when_save_action() { delete_option( $option ); } } + + /** + * Test actions() should not reset options when the nonce fails. + */ + public function test_should_not_reset_options_when_nonce_fails() { + $_POST['beans_reset_options'] = 1; + $test_data = array( + 'beans_compile_all_styles' => 1, + 'beans_compile_all_scripts' => 1, + 'beans_dev_mode' => 1, + ); + + // Add the options. + foreach ( $test_data as $option => $value ) { + add_option( $option, $value ); + } + + $_POST['beans_fields'] = $test_data; + $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); + $instance = new _Beans_Options(); + + // Check with no nonce. + $instance->actions(); + $this->assertFalse( $success_property->getValue( $instance ) ); + + foreach ( $test_data as $option => $value ) { + // Check that the value was not reset. + $this->assertEquals( $value, get_option( $option ) ); + } + + // Check with an invalid nonce. + $_POST['beans_options_nonce'] = 'invalid-nonce'; + + $instance->actions(); + $this->assertFalse( $success_property->getValue( $instance ) ); + + foreach ( $test_data as $option => $value ) { + // Check that the value was not reset. + $this->assertEquals( $value, get_option( $option ) ); + + // Clean up. + delete_option( $option ); + } + } + + /** + * Test actions() should delete the options when it's a reset action. + */ + public function test_should_delete_options_when_reset_action() { + // Setup the test. + $nonce = wp_create_nonce( 'beans_options_nonce' ); + $_POST['beans_options_nonce'] = $nonce; + $_POST['beans_reset_options'] = 1; + $test_data = array( + 'beans_compile_all_styles' => 1, + 'beans_compile_all_scripts' => 1, + 'beans_dev_mode' => 1, + ); + $_POST['beans_fields'] = $test_data; + + // Add the options. + foreach ( $test_data as $option => $value ) { + add_option( $option, $value ); + } + + $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); + $instance = new _Beans_Options(); + $instance->actions(); + + // Check that the success property was set. + $this->assertTrue( $success_property->getValue( $instance ) ); + + // Check the reset. + $this->assertArrayHasKey( 'beans_options_nonce', $_POST ); + $this->assertEquals( 10, has_action( 'admin_notices', array( $instance, 'render_reset_notice' ) ) ); + + // Check the save. + $this->assertArrayNotHasKey( 'beans_save_options', $_POST ); + $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_save_notice' ) ) ); + + // Check that the option was deleted. + foreach ( $test_data as $option ) { + $this->assertNull( get_option( $option, null ) ); + } + } } diff --git a/tests/phpunit/integration/api/options/includes/class-options-test-case.php b/tests/phpunit/integration/api/options/includes/class-options-test-case.php index a2b6bbba..7715dfd4 100644 --- a/tests/phpunit/integration/api/options/includes/class-options-test-case.php +++ b/tests/phpunit/integration/api/options/includes/class-options-test-case.php @@ -51,6 +51,9 @@ public function setUp() { public function tearDown() { parent::tearDown(); + // Let's clean up after the test. + $this->clean_up_global_scope(); + global $wp_meta_boxes; $wp_meta_boxes = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. } From d55c6737590ab58c3728b588849e704e70e349bd Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 13:24:16 -0500 Subject: [PATCH 302/800] Renamed actions method to better reflect its expected behavior. --- lib/api/options/class-beans-options.php | 4 +-- lib/api/options/functions.php | 2 +- .../{actions.php => processActions.php} | 26 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) rename tests/phpunit/integration/api/options/beans-options/{actions.php => processActions.php} (89%) diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index f45a1888..1f412781 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -136,13 +136,13 @@ public function render_page( $page ) { } /** - * Form actions. + * Process the form's actions. * * @since 1.0.0 * * @return void */ - public function actions() { + public function process_actions() { if ( beans_post( 'beans_save_options' ) ) { $this->save(); diff --git a/lib/api/options/functions.php b/lib/api/options/functions.php index 016b2c80..8db9bcf1 100644 --- a/lib/api/options/functions.php +++ b/lib/api/options/functions.php @@ -129,5 +129,5 @@ function _beans_options_page_actions() { require_once BEANS_API_PATH . 'options/class-beans-options.php'; $class = new _Beans_Options(); - $class->actions(); + $class->process_actions(); } diff --git a/tests/phpunit/integration/api/options/beans-options/actions.php b/tests/phpunit/integration/api/options/beans-options/processActions.php similarity index 89% rename from tests/phpunit/integration/api/options/beans-options/actions.php rename to tests/phpunit/integration/api/options/beans-options/processActions.php index 0c18532b..9775685c 100644 --- a/tests/phpunit/integration/api/options/beans-options/actions.php +++ b/tests/phpunit/integration/api/options/beans-options/processActions.php @@ -1,6 +1,6 @@ assertArrayNotHasKey( 'beans_save_options', $_POST ); $this->assertArrayNotHasKey( 'beans_reset_options', $_POST ); - $this->assertNull( $instance->actions() ); + $this->assertNull( $instance->process_actions() ); $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_save_notice' ) ) ); $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_reset_notice' ) ) ); } /** - * Test actions() should not save options when the nonce fails. + * Test process_actions() should not save options when the nonce fails. */ public function test_should_not_save_options_when_nonce_fails() { $_POST['beans_save_options'] = 1; @@ -54,7 +54,7 @@ public function test_should_not_save_options_when_nonce_fails() { $instance = new _Beans_Options(); // Check with no nonce. - $instance->actions(); + $instance->process_actions(); $this->assertFalse( $success_property->getValue( $instance ) ); foreach ( $test_data as $option ) { @@ -65,7 +65,7 @@ public function test_should_not_save_options_when_nonce_fails() { // Check with an invalid nonce. $_POST['beans_options_nonce'] = 'invalid-nonce'; - $instance->actions(); + $instance->process_actions(); $this->assertFalse( $success_property->getValue( $instance ) ); foreach ( $test_data as $option ) { @@ -75,7 +75,7 @@ public function test_should_not_save_options_when_nonce_fails() { } /** - * Test actions() should save the field values when it's a save action. + * Test process_actions() should save the field values when it's a save action. */ public function test_should_save_field_values_when_save_action() { // Setup the test. @@ -91,7 +91,7 @@ public function test_should_save_field_values_when_save_action() { $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); $instance = new _Beans_Options(); - $instance->actions(); + $instance->process_actions(); // Check that the success property was set. $this->assertTrue( $success_property->getValue( $instance ) ); @@ -114,7 +114,7 @@ public function test_should_save_field_values_when_save_action() { } /** - * Test actions() should not reset options when the nonce fails. + * Test process_actions() should not reset options when the nonce fails. */ public function test_should_not_reset_options_when_nonce_fails() { $_POST['beans_reset_options'] = 1; @@ -134,7 +134,7 @@ public function test_should_not_reset_options_when_nonce_fails() { $instance = new _Beans_Options(); // Check with no nonce. - $instance->actions(); + $instance->process_actions(); $this->assertFalse( $success_property->getValue( $instance ) ); foreach ( $test_data as $option => $value ) { @@ -145,7 +145,7 @@ public function test_should_not_reset_options_when_nonce_fails() { // Check with an invalid nonce. $_POST['beans_options_nonce'] = 'invalid-nonce'; - $instance->actions(); + $instance->process_actions(); $this->assertFalse( $success_property->getValue( $instance ) ); foreach ( $test_data as $option => $value ) { @@ -158,7 +158,7 @@ public function test_should_not_reset_options_when_nonce_fails() { } /** - * Test actions() should delete the options when it's a reset action. + * Test process_actions() should delete the options when it's a reset action. */ public function test_should_delete_options_when_reset_action() { // Setup the test. @@ -179,7 +179,7 @@ public function test_should_delete_options_when_reset_action() { $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); $instance = new _Beans_Options(); - $instance->actions(); + $instance->process_actions(); // Check that the success property was set. $this->assertTrue( $success_property->getValue( $instance ) ); From 1f9dae4d12855a17a7059042fb5eb7d032153028 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 11 Mar 2018 13:29:49 -0500 Subject: [PATCH 303/800] Fixed formattiing. Uncommented a test. --- lib/api/options/class-beans-options.php | 2 +- .../options/beans-options/processActions.php | 6 ++-- .../api/options/beans-options/register.php | 4 +-- .../options/beans-options/renderMetabox.php | 30 +++++++++---------- .../api/options/beans-options/renderPage.php | 6 ++-- .../api/options/beans-options/register.php | 4 +-- .../options/beans-options/renderMetabox.php | 2 +- .../api/options/beans-options/renderPage.php | 6 ++-- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index 1f412781..de3d1e00 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -196,7 +196,7 @@ private function reset() { $fields = beans_post( 'beans_fields' ); - if ( ! ( $fields ) ) { + if ( ! $fields ) { return false; } diff --git a/tests/phpunit/integration/api/options/beans-options/processActions.php b/tests/phpunit/integration/api/options/beans-options/processActions.php index 9775685c..cc398345 100644 --- a/tests/phpunit/integration/api/options/beans-options/processActions.php +++ b/tests/phpunit/integration/api/options/beans-options/processActions.php @@ -117,8 +117,8 @@ public function test_should_save_field_values_when_save_action() { * Test process_actions() should not reset options when the nonce fails. */ public function test_should_not_reset_options_when_nonce_fails() { - $_POST['beans_reset_options'] = 1; - $test_data = array( + $_POST['beans_reset_options'] = 1; + $test_data = array( 'beans_compile_all_styles' => 1, 'beans_compile_all_scripts' => 1, 'beans_dev_mode' => 1, @@ -164,7 +164,7 @@ public function test_should_delete_options_when_reset_action() { // Setup the test. $nonce = wp_create_nonce( 'beans_options_nonce' ); $_POST['beans_options_nonce'] = $nonce; - $_POST['beans_reset_options'] = 1; + $_POST['beans_reset_options'] = 1; $test_data = array( 'beans_compile_all_styles' => 1, 'beans_compile_all_scripts' => 1, diff --git a/tests/phpunit/integration/api/options/beans-options/register.php b/tests/phpunit/integration/api/options/beans-options/register.php index 61fd55c4..983fd539 100644 --- a/tests/phpunit/integration/api/options/beans-options/register.php +++ b/tests/phpunit/integration/api/options/beans-options/register.php @@ -24,7 +24,7 @@ class Tests_Beans_Options_Register extends Options_Test_Case { /** - * Test register() should register callback to the 'admin_enqueue_scripts' hook. + * Test register() should register the callback to the 'admin_enqueue_scripts' hook. */ public function test_should_register_callback_to_admin_enqueue_scripts_hook() { $instance = new _Beans_Options(); @@ -42,7 +42,7 @@ public function test_should_register_callback_to_admin_enqueue_scripts_hook() { } /** - * Test register() should register meta box with WordPress. + * Test register() should register the meta box with WordPress. */ public function test_should_register_meta_box_with_wp() { $instance = new _Beans_Options(); diff --git a/tests/phpunit/integration/api/options/beans-options/renderMetabox.php b/tests/phpunit/integration/api/options/beans-options/renderMetabox.php index da8e415a..0ad9a95a 100644 --- a/tests/phpunit/integration/api/options/beans-options/renderMetabox.php +++ b/tests/phpunit/integration/api/options/beans-options/renderMetabox.php @@ -24,23 +24,23 @@ */ class Tests_Beans_Options_Render_Metabox extends Options_Test_Case { -// /** -// * Test render_metabox() should return null when the section does not fields registered. -// */ -// public function test_should_return_null_when_no_fields_registered() { -// $instance = new _Beans_Options(); -// -// foreach ( static::$test_data as $option ) { -// // Register the option. -// $instance->register( $option['section'], $option['args'] ); -// -// // Run the test. -// $this->assertNull( $instance->render_metabox() ); -// } -// } + /** + * Test render_metabox() should return null when the section does not fields registered. + */ + public function test_should_return_null_when_no_fields_registered() { + $instance = new _Beans_Options(); + + foreach ( static::$test_data as $option ) { + // Register the option. + $instance->register( $option['section'], $option['args'] ); + + // Run the test. + $this->assertNull( $instance->render_metabox() ); + } + } /** - * Test render_metabox() should render registered fields. + * Test render_metabox() should render the registered fields. */ public function test_should_render_registered_fields() { $instance = new _Beans_Options(); diff --git a/tests/phpunit/integration/api/options/beans-options/renderPage.php b/tests/phpunit/integration/api/options/beans-options/renderPage.php index c0bcbcf1..947941fb 100644 --- a/tests/phpunit/integration/api/options/beans-options/renderPage.php +++ b/tests/phpunit/integration/api/options/beans-options/renderPage.php @@ -25,14 +25,14 @@ class Tests_Beans_Options_Render_Page extends Options_Test_Case { /** - * Test register() should return null when the page does not have a metabox. + * Test render_page() should return null when the page does not have a metabox. */ public function test_should_return_null_when_page_does_not_have_metabox() { $this->assertNull( ( new _Beans_Options() )->render_page( 'beans_settings' ) ); } /** - * Test register() should return render form when "normal" context is configured. + * Test render_page() should render the form when "normal" context is configured. */ public function test_should_render_form_when_context_normal() { $instance = new _Beans_Options(); @@ -77,7 +77,7 @@ public function test_should_render_form_when_context_normal() { } /** - * Test register() should return render form when "column" context is configured. + * Test render_page() should render the form when "column" context is configured. */ public function test_should_render_form_when_column_context() { $instance = new _Beans_Options(); diff --git a/tests/phpunit/unit/api/options/beans-options/register.php b/tests/phpunit/unit/api/options/beans-options/register.php index cc729492..ebbe23c6 100644 --- a/tests/phpunit/unit/api/options/beans-options/register.php +++ b/tests/phpunit/unit/api/options/beans-options/register.php @@ -25,7 +25,7 @@ class Tests_Beans_Options_Register extends Options_Test_Case { /** - * Test register() should merge default arguments and set the property. + * Test register() should merge the default arguments and set the property. */ public function test_should_merge_default_args_and_set_property() { $property = $this->get_reflective_property( 'args', '_Beans_Options' ); @@ -46,7 +46,7 @@ public function test_should_merge_default_args_and_set_property() { } /** - * Test register() should register callback to the 'admin_enqueue_scripts' hook. + * Test register() should register the callback to the 'admin_enqueue_scripts' hook. */ public function test_should_register_callback_to_admin_enqueue_scripts_hook() { $instance = new _Beans_Options(); diff --git a/tests/phpunit/unit/api/options/beans-options/renderMetabox.php b/tests/phpunit/unit/api/options/beans-options/renderMetabox.php index 3a1a74fa..0f18ed0c 100644 --- a/tests/phpunit/unit/api/options/beans-options/renderMetabox.php +++ b/tests/phpunit/unit/api/options/beans-options/renderMetabox.php @@ -43,7 +43,7 @@ public function test_should_return_null_when_no_fields_registered() { } /** - * Test render_metabox() should render registered fields. For this test, we'll not render but rather check that + * Test render_metabox() should render the registered fields. For this test, we'll not render but rather check that * each function is called as expected. */ public function test_should_render_registered_fields() { diff --git a/tests/phpunit/unit/api/options/beans-options/renderPage.php b/tests/phpunit/unit/api/options/beans-options/renderPage.php index f07a6ae3..b83e1ef2 100644 --- a/tests/phpunit/unit/api/options/beans-options/renderPage.php +++ b/tests/phpunit/unit/api/options/beans-options/renderPage.php @@ -25,7 +25,7 @@ class Tests_Beans_Options_Render_Page extends Options_Test_Case { /** - * Test register() should return null when the page does not have a metabox. + * Test render_page() should return null when the page does not have a metabox. */ public function test_should_return_null_when_page_does_not_have_metabox() { Monkey\Functions\expect( 'beans_get' )->with( 'beans_tests', array() )->once()->andReturn( null ); @@ -34,7 +34,7 @@ public function test_should_return_null_when_page_does_not_have_metabox() { } /** - * Test register() should return render form when "normal" context is configured. + * Test render_page() should render the form when "normal" context is configured. */ public function test_should_render_form_when_context_normal() { Monkey\Functions\expect( 'beans_get' ) @@ -73,7 +73,7 @@ public function test_should_render_form_when_context_normal() { } /** - * Test register() should return render form when "column" context is configured. + * Test render_page() should render the form when "column" context is configured. */ public function test_should_render_form_when_column_context() { Monkey\Functions\expect( 'beans_get' ) From e5af404929c67d83d751eac9b44b04aae6fab7c0 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Mon, 12 Mar 2018 15:01:23 -0500 Subject: [PATCH 304/800] Standardized extra vars as a note instead of @param. (#169) --- lib/api/html/functions.php | 59 +++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 3d7e3abb..7314a12b 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -8,8 +8,6 @@ * @since 1.5.0 */ -// phpcs:disable Squiz.Commenting.FunctionComment.ExtraParamComment -- The extra parameter is intentional for documentation. - /** * Register output by ID. * @@ -20,11 +18,12 @@ * * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.0.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). * @param string $output Content to output. - * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return string The output. */ @@ -55,12 +54,13 @@ function beans_output( $id, $output ) { * * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.4.0 * @uses beans_output() To register output by ID. * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). * @param string $output Content to output. - * @param mixed $var Additional variables passed to the functions hooked to $id. */ function beans_output_e( $id, $output ) { $args = func_get_args(); @@ -94,6 +94,8 @@ function beans_remove_output( $id ) { * * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.0.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). @@ -106,7 +108,6 @@ function beans_remove_output( $id ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. * * @return string The output. */ @@ -141,7 +142,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { $output = call_user_func_array( '_beans_render_action', $args ); - // Don't output the tag if empty, the before and after actions still run. + // Don't output the tag if empty, the before and after actions still run. if ( $tag ) { $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_temp_beans_selfclose_markup ? '/' : '' ) . '>'; } @@ -168,6 +169,8 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { * * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.4.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). @@ -180,7 +183,6 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. * * @return void */ @@ -192,9 +194,11 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { /** * Register self-close markup and attributes by ID. * - * This function is shortuct of {@see beans_open_markup()}. It should be used for self-closing HTML markup such as + * This function is shortcut of {@see beans_open_markup()}. It should be used for self-closing HTML markup such as * images or inputs. * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.0.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). @@ -207,7 +211,6 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. * * @return string The output. */ @@ -223,9 +226,11 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { /** * Echo self-close markup and attributes registered by ID. * - * This function is shortuct of {@see beans_open_markup()}. It should be used for self-closing HTML markup such as + * This function is shortcut of {@see beans_open_markup()}. It should be used for self-closing HTML markup such as * images or inputs. * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.4.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). @@ -238,7 +243,6 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. * * @return void */ @@ -253,11 +257,12 @@ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { * This function is similar to {@see beans_open_markup()}, but does not accept HTML attributes. The $id * argument must be the identical to the opening markup. * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.0.0 * * @param string $id Identical to the opening markup ID. * @param string $tag The HTML tag. - * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return string The output. */ @@ -298,11 +303,12 @@ function beans_close_markup( $id, $tag ) { * This function is similar to {@see beans_open_markup()}, but does not accept HTML attributes. The $id * argument must be the identical to the opening markup. * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.4.0 * * @param string $id Identical to the opening markup ID. * @param string $tag The HTML tag. - * @param mixed $var Additional variables passed to the functions hooked to $id. */ function beans_close_markup_e( $id, $tag ) { $args = func_get_args(); @@ -321,8 +327,8 @@ function beans_close_markup_e( $id, $tag ) { * @since 1.0.0 * * @param string $id The markup ID. - * @param string|callback $markup The replacment HTML tag. A callback is accepted if conditions needs - * to be applied. If arguments are available, they are passed to the callback. + * @param string|callback $markup The replacement HTML tag. A callback is accepted if conditions need to be + * applied. If arguments are available, then they are passed to the callback. * @param int $priority Optional. Used to specify the order in which the functions * associated with a particular action are executed. Default 10. * Lower numbers correspond with earlier execution, @@ -385,8 +391,10 @@ function beans_reset_markup( $id ) { /** * Wrap markup. * - * This function calls {@see beans_open_markup()} before the opening markup and - * {@see beans_close_markup()} after the closing markup. + * This function calls {@see beans_open_markup()} before the opening markup and {@see beans_close_markup()} + * after the closing markup. + * + * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * @@ -399,7 +407,6 @@ function beans_reset_markup( $id ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return bool Will always return true. */ @@ -419,8 +426,10 @@ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { /** * Wrap markup inner content. * - * This function calls {@see beans_open_markup()} after the opening markup and - * {@see beans_close_markup()} before the closing markup. + * This function calls {@see beans_open_markup()} after the opening markup and {@see beans_close_markup()} + * before the closing markup. + * + * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * @@ -433,7 +442,6 @@ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return bool Will always return true. */ @@ -453,11 +461,13 @@ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { /** * Register attributes by ID. * - * The Beans HTML "attributes" functions make it really easy to modify, replace, extend, - * remove or hook into registered attributes. + * The Beans HTML "attributes" functions make it really easy to modify, replace, extend, remove or hook + * into registered attributes. * * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.0.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). @@ -467,7 +477,6 @@ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return string The HTML attributes. */ @@ -486,8 +495,6 @@ function beans_add_attributes( $id, $attributes = array() ) { return beans_esc_attributes( $attributes ); } -// phpcs:enable Squiz.Commenting.FunctionComment.ExtraParamComment -- The extra parameter is intentional for documentation. - /** * Reset markup attributes. * From 37cd98e96fe93ec7603dae7100ebcff90cac601e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 12 Mar 2018 16:12:53 -0500 Subject: [PATCH 305/800] Added first beans_add_attributes unit test. --- .../unit/api/html/beansAddAttributes.php | 61 +++++++++++++++++++ .../html/includes/class-html-test-case.php | 23 +++++++ 2 files changed, 84 insertions(+) create mode 100644 tests/phpunit/unit/api/html/beansAddAttributes.php diff --git a/tests/phpunit/unit/api/html/beansAddAttributes.php b/tests/phpunit/unit/api/html/beansAddAttributes.php new file mode 100644 index 00000000..2c9e1d38 --- /dev/null +++ b/tests/phpunit/unit/api/html/beansAddAttributes.php @@ -0,0 +1,61 @@ +alias( function ( $args ) { + + if ( is_array( $args ) ) { + return $args; + } + + if ( is_object( $args ) ) { + return get_object_vars( $args ); + } + + if ( is_string( $args ) ) { + parse_str( $args, $result ); + + return $result; + } + } ); + } + + /** + * Test beans_add_attributes() should return false when the option does not exist. + */ + public function test_should_register_attributes() { + Monkey\Filters\expectApplied( 'foo_attribute' )->once()->with( array( + 'foo_attrbutes', + array( 'data-foo' => 'beans' ), + ) ); + + $this->assertSame( 'data-foo="beans"', beans_add_attributes( 'foo', array( 'data-foo' => 'beans' ) ) ); + } +} diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index a26ca78b..bc0319b9 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\HTML\Includes; use Beans\Framework\Tests\Unit\Test_Case; +use Brain\Monkey; /** * Abstract Class HTML_Test_Case @@ -55,5 +56,27 @@ protected function setUp() { 'api/html/functions.php', 'api/filters/functions.php', ) ); + + $this->setup_mocks(); + } + + /** + * Setup dependency function mocks. + */ + protected function setup_mocks() { + Monkey\Functions\when( 'beans_esc_attributes' )->alias( function( array $attributes ) { + $string = ''; + + foreach ( (array) $attributes as $attribute => $value ) { + + if ( null === $value ) { + continue; + } + + $string .= $attribute . '="' . $value . '" '; + } + + return trim( $string ); + } ); } } From 5c7f995ae8fff0723bf5a43709a992da654971cf Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Mar 2018 15:33:46 -0500 Subject: [PATCH 306/800] Added unit and integration tests. --- lib/api/html/functions.php | 6 +-- .../api/html/beansAddAttributes.php | 45 +++++++++++++++++++ .../html/includes/class-html-test-case.php | 19 ++++++++ .../unit/api/html/beansAddAttributes.php | 33 +++++++++++--- .../html/includes/class-html-test-case.php | 30 ++++++++----- 5 files changed, 111 insertions(+), 22 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beansAddAttributes.php diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 7314a12b..9d27331c 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -459,10 +459,10 @@ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { } /** - * Register attributes by ID. + * Convert an array of attributes into a properly formatted HTML string. * - * The Beans HTML "attributes" functions make it really easy to modify, replace, extend, remove or hook - * into registered attributes. + * The attributes are registered in Beans via the given ID. Using this ID, we can hook into the filter, i.e. + * "$id_attributes", to modify, replace, extend, or remove one or more of the register attributes. * * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). * diff --git a/tests/phpunit/integration/api/html/beansAddAttributes.php b/tests/phpunit/integration/api/html/beansAddAttributes.php new file mode 100644 index 00000000..c3788571 --- /dev/null +++ b/tests/phpunit/integration/api/html/beansAddAttributes.php @@ -0,0 +1,45 @@ + $config ) { + $expected = $this->convert_attributes_into_html( $config['attributes'] ); + $this->assertSame( $expected, beans_add_attributes( $id, $config['attributes'] ) ); + } + } + + /** + * Test beans_add_attributes() should return empty string when no attributes. + */ + public function test_should_return_empty_string_when_no_attributes() { + $this->assertSame( '', beans_add_attributes( 'foo' ) ); + $this->assertSame( '', beans_add_attributes( 'foo', null ) ); + $this->assertSame( '', beans_add_attributes( 'foo', '' ) ); + $this->assertSame( '', beans_add_attributes( 'foo', false ) ); + } +} diff --git a/tests/phpunit/integration/api/html/includes/class-html-test-case.php b/tests/phpunit/integration/api/html/includes/class-html-test-case.php index 392aa82f..c63484f6 100644 --- a/tests/phpunit/integration/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/integration/api/html/includes/class-html-test-case.php @@ -43,4 +43,23 @@ public static function setUpBeforeClass() { return isset( $markup['attributes'] ); } ); } + + /** + * Convert an array of attributes into a combined HTML string. + * + * @since 1.5.0 + * + * @param array $attributes The given attributes to combine. + * + * @return string + */ + public function convert_attributes_into_html( array $attributes ) { + $html = ''; + + foreach ( $attributes as $attribute => $value ) { + $html .= $attribute . '="' . $value . '" '; + } + + return rtrim( $html ); + } } diff --git a/tests/phpunit/unit/api/html/beansAddAttributes.php b/tests/phpunit/unit/api/html/beansAddAttributes.php index 2c9e1d38..c56e2fc0 100644 --- a/tests/phpunit/unit/api/html/beansAddAttributes.php +++ b/tests/phpunit/unit/api/html/beansAddAttributes.php @@ -48,14 +48,33 @@ protected function setup_mocks() { } /** - * Test beans_add_attributes() should return false when the option does not exist. + * Test beans_add_attributes() should return the built attributes string. */ - public function test_should_register_attributes() { - Monkey\Filters\expectApplied( 'foo_attribute' )->once()->with( array( - 'foo_attrbutes', - array( 'data-foo' => 'beans' ), - ) ); + public function test_should_return_built_attributes_string() { - $this->assertSame( 'data-foo="beans"', beans_add_attributes( 'foo', array( 'data-foo' => 'beans' ) ) ); + foreach ( static::$test_attributes as $id => $config ) { + Monkey\Functions\expect( 'beans_apply_filters' ) + ->with( $id . '_attributes', $config['attributes'] ) + ->once() + ->andReturn( $config['attributes'] ); + + $expected = $this->convert_attributes_into_html( $config['attributes'] ); + $this->assertSame( $expected, beans_add_attributes( $id, $config['attributes'] ) ); + } + } + + /** + * Test beans_add_attributes() should return empty string when no attributes. + */ + public function test_should_return_empty_string_when_no_attributes() { + Monkey\Functions\expect( 'beans_apply_filters' ) + ->with( 'foo_attributes', array() ) + ->times( 4 ) + ->andReturn( array() ); + + $this->assertSame( '', beans_add_attributes( 'foo' ) ); + $this->assertSame( '', beans_add_attributes( 'foo', null ) ); + $this->assertSame( '', beans_add_attributes( 'foo', '' ) ); + $this->assertSame( '', beans_add_attributes( 'foo', false ) ); } } diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index bc0319b9..46acb3d2 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -40,7 +40,7 @@ public static function setUpBeforeClass() { parent::setUpBeforeClass(); static::$test_markup = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-markup.php'; - static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { + static::$test_attributes = array_filter( static::$test_markup, function ( $markup ) { return isset( $markup['attributes'] ); } ); } @@ -64,19 +64,25 @@ protected function setUp() { * Setup dependency function mocks. */ protected function setup_mocks() { - Monkey\Functions\when( 'beans_esc_attributes' )->alias( function( array $attributes ) { - $string = ''; - - foreach ( (array) $attributes as $attribute => $value ) { + Monkey\Functions\when( 'beans_esc_attributes' )->alias( array( $this, 'convert_attributes_into_html' ) ); + } - if ( null === $value ) { - continue; - } + /** + * Convert an array of attributes into a combined HTML string. + * + * @since 1.5.0 + * + * @param array $attributes The given attributes to combine. + * + * @return string + */ + public function convert_attributes_into_html( array $attributes ) { + $html = ''; - $string .= $attribute . '="' . $value . '" '; - } + foreach ( $attributes as $attribute => $value ) { + $html .= $attribute . '="' . $value . '" '; + } - return trim( $string ); - } ); + return rtrim( $html ); } } From 45a32675c72a70f99ffb394753f6af20ee7db3d3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Mar 2018 15:40:28 -0500 Subject: [PATCH 307/800] Replaced isset with empty for performance. --- lib/api/html/functions.php | 2 +- .../integration/api/html/beansAddAttributes.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 9d27331c..73153d46 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -484,7 +484,7 @@ function beans_add_attributes( $id, $attributes = array() ) { $args = func_get_args(); $args[0] = $id . '_attributes'; - if ( ! isset( $args[1] ) ) { + if ( empty( $args[1] ) ) { $args[1] = array(); } diff --git a/tests/phpunit/integration/api/html/beansAddAttributes.php b/tests/phpunit/integration/api/html/beansAddAttributes.php index c3788571..f8909237 100644 --- a/tests/phpunit/integration/api/html/beansAddAttributes.php +++ b/tests/phpunit/integration/api/html/beansAddAttributes.php @@ -23,9 +23,9 @@ class Tests_BeansAddAttributes extends HTML_Test_Case { /** - * Test beans_add_attributes() should return the built attributes string. + * Test beans_add_attributes() should return the built attributes string when an array of attributes is given. */ - public function test_should_return_built_attributes_string() { + public function test_should_return_built_attributes_string_when_array_given() { foreach ( static::$test_attributes as $id => $config ) { $expected = $this->convert_attributes_into_html( $config['attributes'] ); @@ -33,6 +33,15 @@ public function test_should_return_built_attributes_string() { } } + /** + * Test beans_add_attributes() should return the built attributes string when a query string of attributes is given. + */ + public function test_should_return_built_attributes_string_when_query_string_given() { + $this->assertSame( 'id="test"', beans_add_attributes( 'foo', 'id=test' ) ); + $this->assertSame( 'class="foo" data-foo="test"', beans_add_attributes( 'foo', 'class=foo&data-foo=test' ) ); + $this->assertSame( 'class="test" style="color:#fff;"', beans_add_attributes( 'beans-test', 'class=test&style=color:#fff;' ) ); + } + /** * Test beans_add_attributes() should return empty string when no attributes. */ From 2e2c3c43afa19f0f3a4952ae0a221d86fddad0d6 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 13 Mar 2018 15:51:47 -0500 Subject: [PATCH 308/800] Added additional tests. --- .../api/html/beansAddAttributes.php | 23 +++++++++++++++++++ .../unit/api/html/beansAddAttributes.php | 13 +++++++++++ 2 files changed, 36 insertions(+) diff --git a/tests/phpunit/integration/api/html/beansAddAttributes.php b/tests/phpunit/integration/api/html/beansAddAttributes.php index f8909237..40242efc 100644 --- a/tests/phpunit/integration/api/html/beansAddAttributes.php +++ b/tests/phpunit/integration/api/html/beansAddAttributes.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Integration\API\HTML; use Beans\Framework\Tests\Integration\API\HTML\Includes\HTML_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-html-test-case.php'; @@ -51,4 +52,26 @@ public function test_should_return_empty_string_when_no_attributes() { $this->assertSame( '', beans_add_attributes( 'foo', '' ) ); $this->assertSame( '', beans_add_attributes( 'foo', false ) ); } + + /** + * Test beans_add_attributes() should return filtered attributes when there is a registered callback. This test + * ensures the registration component works as expected. + */ + public function test_should_return_filtered_attributes_when_registered_callback() { + // Setup the test. + $attributes = array( 'class' => 'foo' ); + Monkey\Functions\expect( 'foo_attributes_callback' ) + ->with( $attributes ) + ->once() + ->andReturnUsing( function ( $attributes ) { + return array( 'class' => 'changed-me' ); + } ); + add_action( 'foo_attributes', 'foo_attributes_callback' ); + + // Run the test. + $this->assertSame( 'class="changed-me"', beans_add_attributes( 'foo', $attributes ) ); + + // Clean up. + remove_action( 'foo_attributes', 'foo_attributes_callback' ); + } } diff --git a/tests/phpunit/unit/api/html/beansAddAttributes.php b/tests/phpunit/unit/api/html/beansAddAttributes.php index c56e2fc0..3a3c4814 100644 --- a/tests/phpunit/unit/api/html/beansAddAttributes.php +++ b/tests/phpunit/unit/api/html/beansAddAttributes.php @@ -77,4 +77,17 @@ public function test_should_return_empty_string_when_no_attributes() { $this->assertSame( '', beans_add_attributes( 'foo', '' ) ); $this->assertSame( '', beans_add_attributes( 'foo', false ) ); } + + /** + * Test beans_add_attributes() should pass additional arguments when given. + */ + public function test_should_pass_additional_arguments_when_given() { + $attributes = array( 'class' => 'foo' ); + Monkey\Functions\expect( 'beans_apply_filters' ) + ->with( 'foo_attributes', $attributes, 14, 'hi' ) + ->once() + ->andReturn( $attributes ); + + $this->assertSame( 'class="foo"', beans_add_attributes( 'foo', $attributes, 14, 'hi' ) ); + } } From 35154ff68b90a721722230c47079eac41ed005f4 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 14 Mar 2018 10:09:40 -0500 Subject: [PATCH 309/800] Fixed documentation. --- lib/api/html/functions.php | 2 +- tests/phpunit/integration/api/html/beansAddAttributes.php | 2 +- tests/phpunit/unit/api/html/beansAddAttributes.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 73153d46..43e23614 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -462,7 +462,7 @@ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { * Convert an array of attributes into a properly formatted HTML string. * * The attributes are registered in Beans via the given ID. Using this ID, we can hook into the filter, i.e. - * "$id_attributes", to modify, replace, extend, or remove one or more of the register attributes. + * "$id_attributes", to modify, replace, extend, or remove one or more of the registered attributes. * * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). * diff --git a/tests/phpunit/integration/api/html/beansAddAttributes.php b/tests/phpunit/integration/api/html/beansAddAttributes.php index 40242efc..543a74bb 100644 --- a/tests/phpunit/integration/api/html/beansAddAttributes.php +++ b/tests/phpunit/integration/api/html/beansAddAttributes.php @@ -44,7 +44,7 @@ public function test_should_return_built_attributes_string_when_query_string_giv } /** - * Test beans_add_attributes() should return empty string when no attributes. + * Test beans_add_attributes() should return an empty string when no attributes are given. */ public function test_should_return_empty_string_when_no_attributes() { $this->assertSame( '', beans_add_attributes( 'foo' ) ); diff --git a/tests/phpunit/unit/api/html/beansAddAttributes.php b/tests/phpunit/unit/api/html/beansAddAttributes.php index 3a3c4814..068d8895 100644 --- a/tests/phpunit/unit/api/html/beansAddAttributes.php +++ b/tests/phpunit/unit/api/html/beansAddAttributes.php @@ -29,7 +29,7 @@ class Tests_BeansAddAttributes extends HTML_Test_Case { protected function setup_mocks() { parent::setup_mocks(); - Monkey\Functions\when( 'wp_parse_args' )->alias( function ( $args ) { + Monkey\Functions\when( 'wp_parse_args' )->alias( function( $args ) { if ( is_array( $args ) ) { return $args; @@ -64,7 +64,7 @@ public function test_should_return_built_attributes_string() { } /** - * Test beans_add_attributes() should return empty string when no attributes. + * Test beans_add_attributes() should return an empty string when no attributes are given. */ public function test_should_return_empty_string_when_no_attributes() { Monkey\Functions\expect( 'beans_apply_filters' ) From 634247033a7ea0dea7c2a3089c9ea56507ec0b57 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 14 Mar 2018 10:32:04 -0500 Subject: [PATCH 310/800] Fixed formatting --- tests/phpunit/unit/api/html/includes/class-html-test-case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index 46acb3d2..e19f33c4 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -40,7 +40,7 @@ public static function setUpBeforeClass() { parent::setUpBeforeClass(); static::$test_markup = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-markup.php'; - static::$test_attributes = array_filter( static::$test_markup, function ( $markup ) { + static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { return isset( $markup['attributes'] ); } ); } From 98c1042cb24b1a2b869a72c69d2b866cdbc0908c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 11:17:59 -0500 Subject: [PATCH 311/800] Improved documentation. --- lib/api/options/class-beans-options.php | 2 +- lib/api/options/views/reset-notice-error.php | 2 +- lib/api/options/views/reset-notice-success.php | 2 +- lib/api/options/views/save-notice-error.php | 2 +- lib/api/options/views/save-notice-success.php | 2 +- .../integration/api/options/beans-options/renderMetabox.php | 2 +- .../phpunit/unit/api/options/beans-options/renderMetabox.php | 2 +- .../unit/api/options/beans-options/renderRenderNotice.php | 4 ++-- .../unit/api/options/beans-options/renderSaveNotice.php | 4 ++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php index de3d1e00..79723982 100644 --- a/lib/api/options/class-beans-options.php +++ b/lib/api/options/class-beans-options.php @@ -93,7 +93,7 @@ private function register_metabox() { } /** - * Render the metabox's content. Callback that is fired by WordPress. + * Render the metabox's content. The callback is fired by WordPress. * * @since 1.0.0 * diff --git a/lib/api/options/views/reset-notice-error.php b/lib/api/options/views/reset-notice-error.php index 8ff434eb..9da244b6 100644 --- a/lib/api/options/views/reset-notice-error.php +++ b/lib/api/options/views/reset-notice-error.php @@ -1,6 +1,6 @@ get_reflective_property( 'success', '_Beans_Options' ); diff --git a/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php b/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php index b9612a77..a1c0176e 100644 --- a/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php +++ b/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php @@ -25,7 +25,7 @@ class Tests_Beans_Options_Render_Save_Notice extends Options_Test_Case { /** - * Test save_notices() should render error message when "success" property is not set. + * Test save_notices() should render the error message when the "success" property is not set. */ public function test_should_render_error_message_when_success_not_set() { // Run the method and grab the HTML out of the buffer. @@ -43,7 +43,7 @@ public function test_should_render_error_message_when_success_not_set() { } /** - * Test save_notices() should render updated message when "success" property is set. + * Test save_notices() should render the updated message when the "success" property is set. */ public function test_should_render_updated_message_when_success_is_set() { $property = $this->get_reflective_property( 'success', '_Beans_Options' ); From 8180b5e4b3a8b4b44f5ecd9efa67300a75e3aa7c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 11:24:58 -0500 Subject: [PATCH 312/800] Improved documentation. Standardized on metabox. --- .../integration/api/options/beans-options/processActions.php | 2 +- .../integration/api/options/beans-options/register.php | 4 ++-- tests/phpunit/unit/api/options/beans-options/register.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/integration/api/options/beans-options/processActions.php b/tests/phpunit/integration/api/options/beans-options/processActions.php index cc398345..01e48680 100644 --- a/tests/phpunit/integration/api/options/beans-options/processActions.php +++ b/tests/phpunit/integration/api/options/beans-options/processActions.php @@ -75,7 +75,7 @@ public function test_should_not_save_options_when_nonce_fails() { } /** - * Test process_actions() should save the field values when it's a save action. + * Test process_actions() should save the field values when a save action is passed. */ public function test_should_save_field_values_when_save_action() { // Setup the test. diff --git a/tests/phpunit/integration/api/options/beans-options/register.php b/tests/phpunit/integration/api/options/beans-options/register.php index 983fd539..cb48fb98 100644 --- a/tests/phpunit/integration/api/options/beans-options/register.php +++ b/tests/phpunit/integration/api/options/beans-options/register.php @@ -42,9 +42,9 @@ public function test_should_register_callback_to_admin_enqueue_scripts_hook() { } /** - * Test register() should register the meta box with WordPress. + * Test register() should register the metabox with WordPress. */ - public function test_should_register_meta_box_with_wp() { + public function test_should_register_metabox_with_wp() { $instance = new _Beans_Options(); $this->go_to_settings_page(); diff --git a/tests/phpunit/unit/api/options/beans-options/register.php b/tests/phpunit/unit/api/options/beans-options/register.php index ebbe23c6..54795c8e 100644 --- a/tests/phpunit/unit/api/options/beans-options/register.php +++ b/tests/phpunit/unit/api/options/beans-options/register.php @@ -56,9 +56,9 @@ public function test_should_register_callback_to_admin_enqueue_scripts_hook() { } /** - * Test register() should register meta box with WordPress. + * Test register() should register the metabox with WordPress. */ - public function test_should_register_meta_box_with_wp() { + public function test_should_register_metabox_with_wp() { $instance = new _Beans_Options(); foreach ( static::$test_data as $option ) { From 55b14a63af57e43a79b544090097c874dec4e88e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 13:30:46 -0500 Subject: [PATCH 313/800] Added unit tests for beans_wrap_markup. --- .../phpunit/unit/api/html/beansWrapMarkup.php | 88 +++++++++++++++++++ .../fixtures/class-anonymous-action-stub.php | 45 ++++++++++ 2 files changed, 133 insertions(+) create mode 100644 tests/phpunit/unit/api/html/beansWrapMarkup.php create mode 100644 tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php diff --git a/tests/phpunit/unit/api/html/beansWrapMarkup.php b/tests/phpunit/unit/api/html/beansWrapMarkup.php new file mode 100644 index 00000000..ce8e70ae --- /dev/null +++ b/tests/phpunit/unit/api/html/beansWrapMarkup.php @@ -0,0 +1,88 @@ + 'new_foo', + 2 => 'div', + 3 => array( 'class' => 'test-wrap' ), + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_before_markup', $args, 9999 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'foo_before_markup', $args, 9999 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( has_action( 'foo_before_markup', array( $anonymous_action_mock, 'callback' ) ) ); + + // Clean up. + remove_action( 'foo_before_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + } + + /** + * Test beans_wrap_markup() should register beans_close_markup() to the given ID's '_after_markup' hook. + */ + public function test_should_register_beans_close_markup_to_given_id_after_markup_hook() { + // Setup the tests. + $args = array( + 'beans_close_markup', + array( + 1 => 'new_foo', + 2 => 'div', + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_after_markup', $args, 1 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'foo_after_markup', $args, 1 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( has_action( 'foo_after_markup', array( $anonymous_action_mock, 'callback' ) ) ); + + // Clean up. + remove_action( 'foo_before_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + } +} diff --git a/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php b/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php new file mode 100644 index 00000000..c7958450 --- /dev/null +++ b/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php @@ -0,0 +1,45 @@ +callback = $callback; + + add_action( $hook, array( $this, 'callback' ), $priority ); + } + + /** + * Mocked callback. + */ + public function callback() { + // do nothing. + } +} From 93086e54ce2d919d7fc1f8121ae7c5d1683fb90a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 13:50:30 -0500 Subject: [PATCH 314/800] Added unit tests for arguments. --- .../phpunit/unit/api/html/beansWrapMarkup.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/tests/phpunit/unit/api/html/beansWrapMarkup.php b/tests/phpunit/unit/api/html/beansWrapMarkup.php index ce8e70ae..4060e23f 100644 --- a/tests/phpunit/unit/api/html/beansWrapMarkup.php +++ b/tests/phpunit/unit/api/html/beansWrapMarkup.php @@ -85,4 +85,87 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup // Clean up. remove_action( 'foo_before_markup', array( $anonymous_action_mock, 'callback' ), 1 ); } + + /** + * Test beans_wrap_markup() should not pass the given attributes to anonymous action. + */ + public function test_should_not_pass_attributes_for_after_markup_hook() { + // Setup the tests. + $args = array( + 'beans_close_markup', + array( + 1 => '', + 2 => 'div', + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'no_atts_after_markup', $args, 1 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'no_atts_after_markup', $args, 1 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertSame( $args, $anonymous_action_mock->callback ); + + // Clean up. + remove_action( 'no_atts_after_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + } + + /** + * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's '_before_markup' hook. + */ + public function test_should_pass_extra_arguments_for_before_markup_hook() { + // Setup the tests. + $args = array( + 'beans_open_markup', + array( + 1 => '', + 2 => 'div', + 3 => array( 'class' => 'test-wrap' ), + 4 => 47, + 5 => 'Beans Rocks!', + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_before_markup', $args, 9999 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'extra_args_before_markup', $args, 9999 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ) ); + $this->assertSame( $args, $anonymous_action_mock->callback ); + + // Clean up. + remove_action( 'extra_args_before_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + } + + /** + * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's '_after_markup' hook. + */ + public function test_should_pass_extra_arguments_for_after_markup_hook() { + // Setup the tests. + $args = array( + 'beans_close_markup', + array( + 1 => '', + 2 => 'div', + 4 => 'Beans Rocks!', + 5 => 47, + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_after_markup', $args, 1 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'extra_args_after_markup', $args, 1 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 47 ) ); + $this->assertSame( $args, $anonymous_action_mock->callback ); + + // Clean up. + remove_action( 'extra_args_after_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + } } From 90e46581bbd109c75c5d9c90fe056100fac922d1 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 13:51:24 -0500 Subject: [PATCH 315/800] Fixed stub namespace. --- tests/phpunit/unit/api/html/beansWrapMarkup.php | 2 +- .../unit/api/html/fixtures/class-anonymous-action-stub.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/html/beansWrapMarkup.php b/tests/phpunit/unit/api/html/beansWrapMarkup.php index 4060e23f..2f211234 100644 --- a/tests/phpunit/unit/api/html/beansWrapMarkup.php +++ b/tests/phpunit/unit/api/html/beansWrapMarkup.php @@ -9,7 +9,7 @@ namespace Beans\Framework\Tests\Unit\API\HTML; -use Beans\Framework\Tests\Unit\api\html\fixtures\Anonymous_Action_Stub; +use Beans\Framework\Tests\Unit\API\HTML\Fixtures\Anonymous_Action_Stub; use Beans\Framework\Tests\Unit\API\HTML\Includes\HTML_Test_Case; use Brain\Monkey; diff --git a/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php b/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php index c7958450..975b4016 100644 --- a/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php +++ b/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php @@ -7,12 +7,12 @@ * @since 1.5.0 */ -namespace Beans\Framework\Tests\Unit\api\html\fixtures; +namespace Beans\Framework\Tests\Unit\API\HTML\Fixtures; /** * Class Anonymous_Action_Stub * - * @package Beans\Framework\Tests\Unit\api\html\fixtures + * @package Beans\Framework\Tests\Unit\API\HTML\Fixtures */ class Anonymous_Action_Stub { From c079fa6d83777b0885f11103e13167fc8c186a9c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 14:19:17 -0500 Subject: [PATCH 316/800] Added integration tests. --- .../integration/api/html/beansWrapMarkup.php | 173 ++++++++++++++++++ .../phpunit/unit/api/html/beansWrapMarkup.php | 2 +- 2 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/integration/api/html/beansWrapMarkup.php diff --git a/tests/phpunit/integration/api/html/beansWrapMarkup.php b/tests/phpunit/integration/api/html/beansWrapMarkup.php new file mode 100644 index 00000000..6ce790fc --- /dev/null +++ b/tests/phpunit/integration/api/html/beansWrapMarkup.php @@ -0,0 +1,173 @@ +assertArrayHasKey( $hook, $wp_filter ); + $this->assertArrayHasKey( $priority, $wp_filter[ $hook ] ); + + return end( $wp_filter[ $hook ]->callbacks[ $priority ] )['function'][0]; + } + + /** + * Test beans_wrap_markup() should register beans_open_markup() to the given ID's '_before_markup' hook. + */ + public function test_should_register_beans_open_markup_to_given_id_before_markup_hook() { + $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + + // Check that it did register a callback to the hook. + $this->assertTrue( has_action( 'foo_before_markup' ) ); + + // Check that the correct arguments were stored in the instance. + $instance = $this->get_instance_from_wp( 'foo_before_markup', 9999 ); + $this->assertSame( + array( + 'beans_open_markup', + array( + 1 => 'new_foo', + 2 => 'div', + 3 => array( 'class' => 'test-wrap' ), + ), + ), + $instance->callback + ); + + // Clean up. + remove_action( 'foo_before_markup', array( $instance, 'callback' ), 9999 ); + } + + /** + * Test beans_wrap_markup() should register beans_close_markup() to the given ID's '_after_markup' hook. + */ + public function test_should_register_beans_close_markup_to_given_id_after_markup_hook() { + $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + + // Check that it did register a callback to the hook. + $this->assertTrue( has_action( 'foo_after_markup' ) ); + + // Check that the correct arguments were stored in the instance. + $instance = $this->get_instance_from_wp( 'foo_after_markup', 1 ); + $this->assertSame( + array( + 'beans_close_markup', + array( + 1 => 'new_foo', + 2 => 'div', + ), + ), + $instance->callback + ); + + // Clean up. + remove_action( 'foo_after_markup', array( $instance, 'callback' ), 1 ); + } + + /** + * Test beans_wrap_markup() should not pass the given attributes to anonymous action. + */ + public function test_should_not_pass_attributes_for_after_markup_hook() { + beans_wrap_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ); + + // Check that the correct arguments were stored in the instance. + $instance = $this->get_instance_from_wp( 'no_atts_after_markup', 1 ); + $this->assertSame( + array( + 'beans_close_markup', + array( + 1 => '', + 2 => 'div', + ), + ), + $instance->callback + ); + + // Clean up. + remove_action( 'no_atts_after_markup', array( $instance, 'callback' ), 1 ); + } + + /** + * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's + * '_before_markup' hook. + */ + public function test_should_pass_extra_arguments_for_before_markup_hook() { + beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ); + + // Check that the correct arguments were stored in the instance. + $instance = $this->get_instance_from_wp( 'extra_args_before_markup', 9999 ); + $this->assertSame( + array( + 'beans_open_markup', + array( + 1 => '', + 2 => 'div', + 3 => array( 'class' => 'test-wrap' ), + 4 => 47, + 5 => 'Beans Rocks!', + ), + ), + $instance->callback + ); + + // Clean up. + remove_action( 'extra_args_before_markup', array( $instance, 'callback' ), 9999 ); + } + + /** + * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's '_after_markup' hook. + */ + public function test_should_pass_extra_arguments_for_after_markup_hook() { + beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 47 ); + + // Check that the correct arguments were stored in the instance. + $instance = $this->get_instance_from_wp( 'extra_args_after_markup', 1 ); + $this->assertSame( + array( + 'beans_close_markup', + array( + 1 => '', + 2 => 'div', + 4 => 'Beans Rocks!', + 5 => 47, + ), + ), + $instance->callback + ); + + // Clean up. + remove_action( 'extra_args_after_markup', array( $instance, 'callback' ), 1 ); + } +} diff --git a/tests/phpunit/unit/api/html/beansWrapMarkup.php b/tests/phpunit/unit/api/html/beansWrapMarkup.php index 2f211234..2544debd 100644 --- a/tests/phpunit/unit/api/html/beansWrapMarkup.php +++ b/tests/phpunit/unit/api/html/beansWrapMarkup.php @@ -83,7 +83,7 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup $this->assertTrue( has_action( 'foo_after_markup', array( $anonymous_action_mock, 'callback' ) ) ); // Clean up. - remove_action( 'foo_before_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + remove_action( 'foo_after_markup', array( $anonymous_action_mock, 'callback' ), 1 ); } /** From 409f1d35d94be3ddc8c469c0dc12cea7dc7c947a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 14:27:17 -0500 Subject: [PATCH 317/800] Improved beans_wrap_markup documentation. --- lib/api/html/functions.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 43e23614..e41b85e6 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -389,18 +389,22 @@ function beans_reset_markup( $id ) { } /** - * Wrap markup. + * Register the wrap markup with Beans using the given markup ID. * - * This function calls {@see beans_open_markup()} before the opening markup and {@see beans_close_markup()} - * after the closing markup. + * This function registers an anonymous callback to the following action hooks: + * + * 1. `$id_before_markup`: When this hook fires, {@see beans_open_markup()} is called to build the wrap's + * opening HTML markup. + * 2. `$id_after_markup`: When this hook fires, {@see beans_close_markup()} is called to build the wrap's + * closing HTML markup. * * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * - * @param string $id The markup ID. + * @param string $id The wrap markup's ID. * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $tag The HTML wrap tag. + * @param string $tag The wrap's HTML tag. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value define the attribute value. Setting * the array value to '' will display the attribute value as empty From 79006f21aac3b0be37e989a8a2274e3f9f0da709 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 20:47:29 -0500 Subject: [PATCH 318/800] Replaced get_the_id with get_the_ID. --- lib/api/post-meta/functions.php | 2 +- tests/phpunit/unit/api/post-meta/beansGetPostMeta.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index 5c1cd665..9c213909 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -23,7 +23,7 @@ function beans_get_post_meta( $meta_key, $default = false, $post_id = false ) { if ( ! $post_id ) { - $id = get_the_id(); + $id = get_the_ID(); $post_id = ! $id ? beans_get( 'post' ) : $id; } diff --git a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php index 0e4be772..7fd18c33 100644 --- a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php +++ b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php @@ -37,7 +37,7 @@ protected function setUp() { * Test beans_get_post_meta() should return the default when the post_id cannot be resolved. */ public function test_should_return_default_when_post_id_cannot_be_resolved() { - Monkey\Functions\expect( 'get_the_id' )->twice()->andReturn( false ); + Monkey\Functions\expect( 'get_the_ID' )->twice()->andReturn( false ); Monkey\Functions\expect( 'beans_get' )->twice()->andReturn( null ); Monkey\Functions\expect( 'get_post_meta' )->never(); @@ -60,11 +60,11 @@ public function test_should_return_default_when_post_meta_does_not_exist() { * Test beans_get_post_meta() should get the post ID when none is provided. */ public function test_should_get_post_id_when_none_is_provided() { - Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 47 ); + Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 47 ); Monkey\Functions\expect( 'get_post_meta' )->with( 47 )->once()->andReturn( array() ); $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); - Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 0 ); + Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 0 ); Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 18 ); Monkey\Functions\expect( 'get_post_meta' )->with( '18' )->once()->andReturn( array() ); $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); @@ -86,7 +86,7 @@ public function test_should_return_post_meta_value() { ->andReturn( 'c_sp' ); $this->assertSame( 'c_sp', beans_get_post_meta( 'beans_layout', false, 521 ) ); - Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 47 ); + Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 47 ); Monkey\Functions\expect( 'get_post_meta' ) ->with( 47 ) ->once() @@ -99,7 +99,7 @@ public function test_should_return_post_meta_value() { ->andReturn( 'sp_c' ); $this->assertSame( 'sp_c', beans_get_post_meta( 'beans_layout' ) ); - Monkey\Functions\expect( 'get_the_id' )->once()->andReturn( 0 ); + Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 0 ); Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 18 ); Monkey\Functions\expect( 'get_post_meta' ) ->with( '18' ) From e6df2ce9c19842f6ff8b429993d6bccf2412099c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 21:08:01 -0500 Subject: [PATCH 319/800] Bails out if an empty $tag is given. --- lib/api/html/functions.php | 8 +++++++- tests/phpunit/unit/api/html/beansWrapMarkup.php | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index e41b85e6..f5ac9f39 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -401,6 +401,7 @@ function beans_reset_markup( $id ) { * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 + * @since 1.5.0 Bails out if an empty $tag is given. * * @param string $id The wrap markup's ID. * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). @@ -412,9 +413,14 @@ function beans_reset_markup( $id ) { * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. * - * @return bool Will always return true. + * @return bool */ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { + + if ( ! $tag ) { + return false; + } + $args = func_get_args(); unset( $args[0] ); diff --git a/tests/phpunit/unit/api/html/beansWrapMarkup.php b/tests/phpunit/unit/api/html/beansWrapMarkup.php index 2544debd..becd8366 100644 --- a/tests/phpunit/unit/api/html/beansWrapMarkup.php +++ b/tests/phpunit/unit/api/html/beansWrapMarkup.php @@ -33,6 +33,15 @@ protected function setUp() { require_once __DIR__ . '/fixtures/class-anonymous-action-stub.php'; } + /** + * Test beans_wrap_markup() should false when an empty tag is given. + */ + public function test_should_return_false_when_empty_tag_is_given() { + $this->assertFalse( beans_wrap_markup( 'foo', '', null ) ); + $this->assertFalse( beans_wrap_markup( 'foo', '', '' ) ); + $this->assertFalse( beans_wrap_markup( 'foo', '', false, array( 'class' => 'test-wrap' ) ) ); + } + /** * Test beans_wrap_markup() should register beans_open_markup() to the given ID's '_before_markup' hook. */ From 71c4c483f3e6ff88092b3d827d364ef2430df434 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 22:00:48 -0500 Subject: [PATCH 320/800] Fixed documentation. --- tests/phpunit/unit/api/html/beansWrapMarkup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/html/beansWrapMarkup.php b/tests/phpunit/unit/api/html/beansWrapMarkup.php index becd8366..881438f7 100644 --- a/tests/phpunit/unit/api/html/beansWrapMarkup.php +++ b/tests/phpunit/unit/api/html/beansWrapMarkup.php @@ -34,7 +34,7 @@ protected function setUp() { } /** - * Test beans_wrap_markup() should false when an empty tag is given. + * Test beans_wrap_markup() should return false when an empty tag is given. */ public function test_should_return_false_when_empty_tag_is_given() { $this->assertFalse( beans_wrap_markup( 'foo', '', null ) ); From 23b314a090aa7607ff129b3222c1816dd2dc79a8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 23:30:56 -0500 Subject: [PATCH 321/800] Moved wp_filter tests into method. Cleaned up integration tests. --- .../integration/api/html/beansWrapMarkup.php | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansWrapMarkup.php b/tests/phpunit/integration/api/html/beansWrapMarkup.php index 6ce790fc..93a6d739 100644 --- a/tests/phpunit/integration/api/html/beansWrapMarkup.php +++ b/tests/phpunit/integration/api/html/beansWrapMarkup.php @@ -36,10 +36,6 @@ class Tests_BeansWrapMarkup extends HTML_Test_Case { protected function get_instance_from_wp( $hook, $priority ) { global $wp_filter; - // Run a couple of checks to make sure WordPress has the registration. - $this->assertArrayHasKey( $hook, $wp_filter ); - $this->assertArrayHasKey( $priority, $wp_filter[ $hook ] ); - return end( $wp_filter[ $hook ]->callbacks[ $priority ] )['function'][0]; } @@ -51,6 +47,9 @@ public function test_should_register_beans_open_markup_to_given_id_before_markup // Check that it did register a callback to the hook. $this->assertTrue( has_action( 'foo_before_markup' ) ); + global $wp_filter; + $this->assertArrayHasKey( 'foo_before_markup', $wp_filter ); + $this->assertArrayHasKey( 9999, $wp_filter['foo_before_markup'] ); // Check that the correct arguments were stored in the instance. $instance = $this->get_instance_from_wp( 'foo_before_markup', 9999 ); @@ -78,21 +77,12 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup // Check that it did register a callback to the hook. $this->assertTrue( has_action( 'foo_after_markup' ) ); - - // Check that the correct arguments were stored in the instance. - $instance = $this->get_instance_from_wp( 'foo_after_markup', 1 ); - $this->assertSame( - array( - 'beans_close_markup', - array( - 1 => 'new_foo', - 2 => 'div', - ), - ), - $instance->callback - ); + global $wp_filter; + $this->assertArrayHasKey( 'foo_after_markup', $wp_filter ); + $this->assertArrayHasKey( 1, $wp_filter['foo_after_markup'] ); // Clean up. + $instance = $this->get_instance_from_wp( 'foo_after_markup', 1 ); remove_action( 'foo_after_markup', array( $instance, 'callback' ), 1 ); } @@ -147,7 +137,8 @@ public function test_should_pass_extra_arguments_for_before_markup_hook() { } /** - * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's '_after_markup' hook. + * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's + * '_after_markup' hook. */ public function test_should_pass_extra_arguments_for_after_markup_hook() { beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 47 ); From 1b553decb6bf6f2d7ddb1ead80a411ed295a801c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 15 Mar 2018 23:45:52 -0500 Subject: [PATCH 322/800] Fixed the integration tests. 1. Put the arguments check back into the registration test. 2. Renamed the $instance to $anonomyous_action for readability. 3. Simplified the no attributes passed test for clarity. --- .../integration/api/html/beansWrapMarkup.php | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansWrapMarkup.php b/tests/phpunit/integration/api/html/beansWrapMarkup.php index 93a6d739..71ef07e2 100644 --- a/tests/phpunit/integration/api/html/beansWrapMarkup.php +++ b/tests/phpunit/integration/api/html/beansWrapMarkup.php @@ -52,7 +52,7 @@ public function test_should_register_beans_open_markup_to_given_id_before_markup $this->assertArrayHasKey( 9999, $wp_filter['foo_before_markup'] ); // Check that the correct arguments were stored in the instance. - $instance = $this->get_instance_from_wp( 'foo_before_markup', 9999 ); + $anonomyous_action = $this->get_instance_from_wp( 'foo_before_markup', 9999 ); $this->assertSame( array( 'beans_open_markup', @@ -62,11 +62,11 @@ public function test_should_register_beans_open_markup_to_given_id_before_markup 3 => array( 'class' => 'test-wrap' ), ), ), - $instance->callback + $anonomyous_action->callback ); // Clean up. - remove_action( 'foo_before_markup', array( $instance, 'callback' ), 9999 ); + remove_action( 'foo_before_markup', array( $anonomyous_action, 'callback' ), 9999 ); } /** @@ -81,32 +81,35 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup $this->assertArrayHasKey( 'foo_after_markup', $wp_filter ); $this->assertArrayHasKey( 1, $wp_filter['foo_after_markup'] ); - // Clean up. - $instance = $this->get_instance_from_wp( 'foo_after_markup', 1 ); - remove_action( 'foo_after_markup', array( $instance, 'callback' ), 1 ); - } - - /** - * Test beans_wrap_markup() should not pass the given attributes to anonymous action. - */ - public function test_should_not_pass_attributes_for_after_markup_hook() { - beans_wrap_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ); - // Check that the correct arguments were stored in the instance. - $instance = $this->get_instance_from_wp( 'no_atts_after_markup', 1 ); + $anonomyous_action = $this->get_instance_from_wp( 'foo_after_markup', 1 ); $this->assertSame( array( 'beans_close_markup', array( - 1 => '', + 1 => 'new_foo', 2 => 'div', ), ), - $instance->callback + $anonomyous_action->callback ); // Clean up. - remove_action( 'no_atts_after_markup', array( $instance, 'callback' ), 1 ); + remove_action( 'foo_after_markup', array( $anonomyous_action, 'callback' ), 1 ); + } + + /** + * Test beans_wrap_markup() should not pass the given attributes to anonymous action. + */ + public function test_should_not_pass_attributes_for_after_markup_hook() { + beans_wrap_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ); + + // Check that the attributes do not exist. + $anonomyous_action = $this->get_instance_from_wp( 'no_atts_after_markup', 1 ); + $this->assertNotContains( array( 'class' => 'test-wrap' ), $anonomyous_action->callback[1] ); + + // Clean up. + remove_action( 'no_atts_after_markup', array( $anonomyous_action, 'callback' ), 1 ); } /** @@ -117,7 +120,7 @@ public function test_should_pass_extra_arguments_for_before_markup_hook() { beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ); // Check that the correct arguments were stored in the instance. - $instance = $this->get_instance_from_wp( 'extra_args_before_markup', 9999 ); + $anonomyous_action = $this->get_instance_from_wp( 'extra_args_before_markup', 9999 ); $this->assertSame( array( 'beans_open_markup', @@ -129,11 +132,11 @@ public function test_should_pass_extra_arguments_for_before_markup_hook() { 5 => 'Beans Rocks!', ), ), - $instance->callback + $anonomyous_action->callback ); // Clean up. - remove_action( 'extra_args_before_markup', array( $instance, 'callback' ), 9999 ); + remove_action( 'extra_args_before_markup', array( $anonomyous_action, 'callback' ), 9999 ); } /** @@ -144,7 +147,7 @@ public function test_should_pass_extra_arguments_for_after_markup_hook() { beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 47 ); // Check that the correct arguments were stored in the instance. - $instance = $this->get_instance_from_wp( 'extra_args_after_markup', 1 ); + $anonomyous_action = $this->get_instance_from_wp( 'extra_args_after_markup', 1 ); $this->assertSame( array( 'beans_close_markup', @@ -155,10 +158,10 @@ public function test_should_pass_extra_arguments_for_after_markup_hook() { 5 => 47, ), ), - $instance->callback + $anonomyous_action->callback ); // Clean up. - remove_action( 'extra_args_after_markup', array( $instance, 'callback' ), 1 ); + remove_action( 'extra_args_after_markup', array( $anonomyous_action, 'callback' ), 1 ); } } From 11e2ba58ef45976c5a6076d2a657d3545a02102b Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 16 Mar 2018 15:06:35 -0400 Subject: [PATCH 323/800] Added command to composer scripts to run both test suites --- composer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1d0d9e30..c12051e0 100644 --- a/composer.json +++ b/composer.json @@ -66,6 +66,10 @@ "@phpcs-tests" ], "test-unit": "\"vendor/bin/phpunit\" --testsuite unit --color=always", - "test-integration": "\"vendor/bin/phpunit\" --testsuite integration --configuration tests/phpunit/integration/phpunit.xml.dist --color=always" + "test-integration": "\"vendor/bin/phpunit\" --testsuite integration --configuration tests/phpunit/integration/phpunit.xml.dist --color=always", + "test": [ + "@test-unit", + "@test-integration" + ] } } From d2e88a1cdc5ea201b7711068afec39e415c9e0c9 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 16 Mar 2018 16:27:09 -0400 Subject: [PATCH 324/800] Added requested change --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c12051e0..b87d97fa 100644 --- a/composer.json +++ b/composer.json @@ -67,7 +67,7 @@ ], "test-unit": "\"vendor/bin/phpunit\" --testsuite unit --color=always", "test-integration": "\"vendor/bin/phpunit\" --testsuite integration --configuration tests/phpunit/integration/phpunit.xml.dist --color=always", - "test": [ + "run-tests": [ "@test-unit", "@test-integration" ] From bb315c859b8cb6293c441efcd86b9d42fb35f361 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 16 Mar 2018 16:33:20 -0400 Subject: [PATCH 325/800] Changed composer script for grouped sniffers for consistency --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b87d97fa..21d15829 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ ], "phpcs-src": "\"vendor/bin/phpcs\"", "phpcs-tests": "\"vendor/bin/phpcs\" --runtime-set testVersion 5.6 tests/phpunit/", - "phpcs": [ + "run-phpcs": [ "@phpcs-src", "@phpcs-tests" ], From 3274d73b3b1f11b54de6eaf2b5370d898e9c2dbd Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Mar 2018 11:45:47 -0500 Subject: [PATCH 326/800] Added unit tests for beans_wrap_inner_markup. --- .../unit/api/html/beansWrapInnerMarkup.php | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 tests/phpunit/unit/api/html/beansWrapInnerMarkup.php diff --git a/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php b/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php new file mode 100644 index 00000000..6b63f120 --- /dev/null +++ b/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php @@ -0,0 +1,180 @@ +assertFalse( beans_wrap_inner_markup( 'foo', 'new_foo', null ) ); + $this->assertFalse( beans_wrap_inner_markup( 'bar', 'new_bar', '' ) ); + $this->assertFalse( beans_wrap_inner_markup( 'baz', 'new_baz', false, array( 'class' => 'test-wrap' ) ) ); + } + + /** + * Test beans_wrap_inner_markup() should register beans_open_markup() to the given ID's '_prepend_markup' hook. + */ + public function test_should_register_beans_open_markup_to_given_id_prepend_markup_hook() { + // Setup the tests. + $args = array( + 'beans_open_markup', + array( + 1 => 'new_foo', + 2 => 'div', + 3 => array( 'class' => 'test-wrap' ), + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_prepend_markup', $args, 1 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'foo_prepend_markup', $args, 1 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( has_action( 'foo_prepend_markup', array( $anonymous_action_mock, 'callback' ) ) ); + + // Clean up. + remove_action( 'foo_prepend_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + } + + /** + * Test beans_wrap_inner_markup() should register beans_close_markup() to the given ID's '_append_markup' hook. + */ + public function test_should_register_beans_close_markup_to_given_id_append_markup_hook() { + // Setup the tests. + $args = array( + 'beans_close_markup', + array( + 1 => 'new_foo', + 2 => 'div', + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_append_markup', $args, 9999 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'foo_append_markup', $args, 9999 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( has_action( 'foo_append_markup', array( $anonymous_action_mock, 'callback' ) ) ); + + // Clean up. + remove_action( 'foo_append_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + } + + /** + * Test beans_wrap_inner_markup() should not pass the given attributes to anonymous action. + */ + public function test_should_not_pass_attributes_for_append_markup_hook() { + // Setup the tests. + $args = array( + 'beans_close_markup', + array( + 1 => 'new_no_atts', + 2 => 'div', + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'no_atts_append_markup', $args, 9999 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'no_atts_append_markup', $args, 9999 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_inner_markup( 'no_atts', 'new_no_atts', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertSame( $args, $anonymous_action_mock->callback ); + + // Clean up. + remove_action( 'no_atts_append_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + } + + /** + * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's '_prepend_markup' hook. + */ + public function test_should_pass_extra_arguments_for_prepend_markup_hook() { + // Setup the tests. + $args = array( + 'beans_open_markup', + array( + 1 => 'new_extra_args', + 2 => 'div', + 3 => array( 'class' => 'test-wrap' ), + 4 => 47, + 5 => 'Beans Rocks!', + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_prepend_markup', $args, 1 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'extra_args_prepend_markup', $args, 1 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ) ); + $this->assertSame( $args, $anonymous_action_mock->callback ); + + // Clean up. + remove_action( 'extra_args_prepend_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + } + + /** + * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's '_append_markup' hook. + */ + public function test_should_pass_extra_arguments_for_append_markup_hook() { + // Setup the tests. + $args = array( + 'beans_close_markup', + array( + 1 => 'new_extra_args', + 2 => 'div', + 4 => 'Beans Rocks!', + 5 => 47, + ), + ); + $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_append_markup', $args, 9999 ); + Monkey\Functions\expect( '_beans_add_anonymous_action' ) + ->once() + ->with( 'extra_args_append_markup', $args, 9999 ) + ->andReturn( $anonymous_action_mock ); + + // Run the tests. + $this->assertTrue( beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 47 ) ); + $this->assertSame( $args, $anonymous_action_mock->callback ); + + // Clean up. + remove_action( 'extra_args_append_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + } +} From dec333606d0a11c1141480dc8eb30d86c1e9a1f0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Mar 2018 11:46:30 -0500 Subject: [PATCH 327/800] Added empty tag bail out. --- lib/api/html/functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index f5ac9f39..775beff1 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -456,6 +456,11 @@ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { * @return bool Will always return true. */ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { + + if ( ! $tag ) { + return false; + } + $args = func_get_args(); unset( $args[0] ); From 2978acb640504a58763a8ef41f04893a827aa942 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Mar 2018 11:57:40 -0500 Subject: [PATCH 328/800] Improved the function documentation. --- lib/api/html/functions.php | 17 +- .../api/html/beansWrapInnerMarkup.php | 167 ++++++++++++++++++ 2 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beansWrapInnerMarkup.php diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 775beff1..ee64fe77 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -434,18 +434,23 @@ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { } /** - * Wrap markup inner content. + * Register the wrap inner content's markup with Beans using the given markup ID. * - * This function calls {@see beans_open_markup()} after the opening markup and {@see beans_close_markup()} - * before the closing markup. + * This function registers an anonymous callback to the following action hooks: + * + * 1. `$id_prepend_markup`: When this hook fires, {@see beans_open_markup()} is called to build the wrap inner + * content's HTML markup just after the wrap's opening tag. + * 2. `$id_append_markup`: When this hook fires, {@see beans_close_markup()} is called to build the wrap inner + * content's HTML markup just before the wrap's closing tag. * * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 + * @since 1.5.0 Bails out if an empty $tag is given. * - * @param string $id The markup ID. + * @param string $id The wrap markup's ID. * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $tag The HTML wrap tag. + * @param string $tag The wrap inner content's HTML tag. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value define the attribute value. Setting * the array value to '' will display the attribute value as empty @@ -453,7 +458,7 @@ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. * - * @return bool Will always return true. + * @return bool */ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { diff --git a/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php b/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php new file mode 100644 index 00000000..f212c09c --- /dev/null +++ b/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php @@ -0,0 +1,167 @@ +callbacks[ $priority ] )['function'][0]; + } + + /** + * Test beans_wrap_inner_markup() should register beans_open_markup() to the given ID's '_prepend_markup' hook. + */ + public function test_should_register_beans_open_markup_to_given_id_prepend_markup_hook() { + $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + + // Check that it did register a callback to the hook. + $this->assertTrue( has_action( 'foo_prepend_markup' ) ); + global $wp_filter; + $this->assertArrayHasKey( 'foo_prepend_markup', $wp_filter ); + $this->assertArrayHasKey( 1, $wp_filter['foo_prepend_markup'] ); + + // Check that the correct arguments were stored in the instance. + $anonomyous_action = $this->get_instance_from_wp( 'foo_prepend_markup', 1 ); + $this->assertSame( + array( + 'beans_open_markup', + array( + 1 => 'new_foo', + 2 => 'div', + 3 => array( 'class' => 'test-wrap' ), + ), + ), + $anonomyous_action->callback + ); + + // Clean up. + remove_action( 'foo_prepend_markup', array( $anonomyous_action, 'callback' ), 1 ); + } + + /** + * Test beans_wrap_inner_markup() should register beans_close_markup() to the given ID's '_append_markup' hook. + */ + public function test_should_register_beans_close_markup_to_given_id_append_markup_hook() { + $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + + // Check that it did register a callback to the hook. + $this->assertTrue( has_action( 'foo_append_markup' ) ); + global $wp_filter; + $this->assertArrayHasKey( 'foo_append_markup', $wp_filter ); + $this->assertArrayHasKey( 9999, $wp_filter['foo_append_markup'] ); + + // Check that the correct arguments were stored in the instance. + $anonomyous_action = $this->get_instance_from_wp( 'foo_append_markup', 9999 ); + $this->assertSame( + array( + 'beans_close_markup', + array( + 1 => 'new_foo', + 2 => 'div', + ), + ), + $anonomyous_action->callback + ); + + // Clean up. + remove_action( 'foo_append_markup', array( $anonomyous_action, 'callback' ), 9999 ); + } + + /** + * Test beans_wrap_inner_markup() should not pass the given attributes to anonymous action. + */ + public function test_should_not_pass_attributes_for_append_markup_hook() { + beans_wrap_inner_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ); + + // Check that the attributes do not exist. + $anonomyous_action = $this->get_instance_from_wp( 'no_atts_append_markup', 9999 ); + $this->assertNotContains( array( 'class' => 'test-wrap' ), $anonomyous_action->callback[1] ); + + // Clean up. + remove_action( 'no_atts_append_markup', array( $anonomyous_action, 'callback' ), 9999 ); + } + + /** + * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's + * '_prepend_markup' hook. + */ + public function test_should_pass_extra_arguments_for_prepend_markup_hook() { + beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ); + + // Check that the correct arguments were stored in the instance. + $anonomyous_action = $this->get_instance_from_wp( 'extra_args_prepend_markup', 1 ); + $this->assertSame( + array( + 'beans_open_markup', + array( + 1 => 'new_extra_args', + 2 => 'div', + 3 => array( 'class' => 'test-wrap' ), + 4 => 47, + 5 => 'Beans Rocks!', + ), + ), + $anonomyous_action->callback + ); + + // Clean up. + remove_action( 'extra_args_prepend_markup', array( $anonomyous_action, 'callback' ), 1 ); + } + + /** + * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's + * '_append_markup' hook. + */ + public function test_should_pass_extra_arguments_for_append_markup_hook() { + beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 'and so does WordPress!' ); + + // Check that the correct arguments were stored in the instance. + $anonomyous_action = $this->get_instance_from_wp( 'extra_args_append_markup', 9999 ); + $this->assertSame( + array( + 'beans_close_markup', + array( + 1 => 'new_extra_args', + 2 => 'div', + 4 => 'Beans Rocks!', + 5 => 'and so does WordPress!', + ), + ), + $anonomyous_action->callback + ); + + // Clean up. + remove_action( 'extra_args_append_markup', array( $anonomyous_action, 'callback' ), 9999 ); + } +} From 8541b37af12566bbe28fda8e580bcabcd1115ba3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Mar 2018 14:10:40 -0500 Subject: [PATCH 329/800] Refactored, moving common WP stubs to Test Case. To keep it DRY, moved the common WP escaping and internationalization function stubs to the Test Case. --- .../includes/class-fields-test-case.php | 14 ++++------- .../html/includes/class-html-test-case.php | 5 ++-- .../includes/class-options-test-case.php | 13 +++------- tests/phpunit/unit/class-test-case.php | 25 +++++++++++++++++-- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 267ceda4..3e0a74bf 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -153,39 +153,35 @@ protected function merge_field_with_default( array $field, $set_value = true ) { */ protected function setup_function_mocks() { - foreach ( array( 'esc_attr', 'esc_html', 'esc_textarea', 'esc_url', 'wp_kses_post', '__' ) as $wp_function ) { - Monkey\Functions\when( $wp_function )->returnArg(); - } - foreach ( array( 'esc_attr_e', 'esc_html_e', '_e' ) as $wp_function ) { Monkey\Functions\when( $wp_function )->echoArg(); } - Monkey\Functions\when( 'checked' )->alias( function ( $actual, $value ) { + Monkey\Functions\when( 'checked' )->alias( function( $actual, $value ) { if ( $actual === $value ) { echo " checked='checked'"; } } ); - Monkey\Functions\when( 'selected' )->alias( function ( $actual, $value ) { + Monkey\Functions\when( 'selected' )->alias( function( $actual, $value ) { if ( $actual === $value ) { echo " selected='selected'"; } } ); - Monkey\Functions\when( '_n' )->alias( function ( $single, $plural, $number ) { + Monkey\Functions\when( '_n' )->alias( function( $single, $plural, $number ) { return $number > 1 ? $plural : $single; } ); - Monkey\Functions\when( 'beans_get' )->alias( function ( $needle, $haystack = false, $default = null ) { + Monkey\Functions\when( 'beans_get' )->alias( function( $needle, $haystack = false, $default = null ) { $haystack = (array) $haystack; return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : $default; } ); - Monkey\Functions\when( 'beans_esc_attributes' )->alias( function ( $attributes ) { + Monkey\Functions\when( 'beans_esc_attributes' )->alias( function( $attributes ) { $string = ''; foreach ( (array) $attributes as $attribute => $value ) { diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index e19f33c4..e1cfcab2 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -57,13 +57,14 @@ protected function setUp() { 'api/filters/functions.php', ) ); - $this->setup_mocks(); + $this->setup_function_mocks(); + $this->setup_common_wp_stubs(); } /** * Setup dependency function mocks. */ - protected function setup_mocks() { + protected function setup_function_mocks() { Monkey\Functions\when( 'beans_esc_attributes' )->alias( array( $this, 'convert_attributes_into_html' ) ); } diff --git a/tests/phpunit/unit/api/options/includes/class-options-test-case.php b/tests/phpunit/unit/api/options/includes/class-options-test-case.php index 570c4b88..cad9e9bf 100644 --- a/tests/phpunit/unit/api/options/includes/class-options-test-case.php +++ b/tests/phpunit/unit/api/options/includes/class-options-test-case.php @@ -49,6 +49,7 @@ public function setUp() { ) ); $this->setup_function_mocks(); + $this->setup_common_wp_stubs(); } /** @@ -62,10 +63,10 @@ protected function tearDown() { } /** - * Set up function mocks. + * Setup dependency function mocks. */ protected function setup_function_mocks() { - Monkey\Functions\when( 'add_meta_box' )->alias( function ( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { + Monkey\Functions\when( 'add_meta_box' )->alias( function( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { global $wp_meta_boxes; if ( empty( $screen ) ) { @@ -88,13 +89,5 @@ protected function setup_function_mocks() { ), ); } ); - - foreach ( array( 'esc_attr', 'esc_html', '__' ) as $wp_function ) { - Monkey\Functions\when( $wp_function )->returnArg(); - } - - foreach ( array( 'esc_attr_e', 'esc_html_e' ) as $wp_function ) { - Monkey\Functions\when( $wp_function )->echoArg(); - } } } diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 4388a9b6..9f505f4c 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -27,7 +27,7 @@ protected function setUp() { parent::setUp(); Monkey\setUp(); - Functions\when( 'wp_normalize_path' )->alias( function ( $path ) { + Functions\when( 'wp_normalize_path' )->alias( function( $path ) { $path = str_replace( '\\', '/', $path ); $path = preg_replace( '|(?<=.)/+|', '/', $path ); @@ -38,11 +38,32 @@ protected function setUp() { return $path; } ); - Functions\when( 'wp_json_encode' )->alias( function ( $array ) { + Functions\when( 'wp_json_encode' )->alias( function( $array ) { return json_encode( $array ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode -- Required as part of our mock. } ); } + /** + * Setup the stubs for the common WordPress escaping and internationalization functions. + */ + protected function setup_common_wp_stubs() { + Monkey\Functions\stubs( array( + 'esc_attr', + 'esc_html', + 'esc_textarea', + 'esc_url', + 'wp_kses_post', + '__', + 'esc_html__', + 'esc_html_x', + 'esc_attr_x', + ) ); + + foreach ( array( 'esc_attr_e', 'esc_html_e', '_e' ) as $wp_function ) { + Monkey\Functions\when( $wp_function )->echoArg(); + } + } + /** * Cleans up the test environment after each test. */ From 184d2c4f39ab68bc1fb46c1e76d61e5c2590b05e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Mar 2018 14:17:13 -0500 Subject: [PATCH 330/800] Split out the escaping and internationalization stubs. --- .../unit/api/fields/includes/class-fields-test-case.php | 6 +----- .../unit/api/image/includes/class-image-test-case.php | 4 ++-- tests/phpunit/unit/class-test-case.php | 5 +++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 3e0a74bf..a02ab2c5 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -50,6 +50,7 @@ public function setUp() { ) ); $this->setup_function_mocks(); + $this->setup_common_wp_stubs(); } /** @@ -152,11 +153,6 @@ protected function merge_field_with_default( array $field, $set_value = true ) { * Set up function mocks. */ protected function setup_function_mocks() { - - foreach ( array( 'esc_attr_e', 'esc_html_e', '_e' ) as $wp_function ) { - Monkey\Functions\when( $wp_function )->echoArg(); - } - Monkey\Functions\when( 'checked' )->alias( function( $actual, $value ) { if ( $actual === $value ) { diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index e79036b3..5c2e15e9 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -100,7 +100,7 @@ protected function setUp() { $this->set_up_virtual_filesystem(); - $this->setup_mocks(); + $this->setup_function_mocks(); $this->images = array( $this->images_dir . '/image1.jpg' => static::$fixtures_dir . '/image1.jpg', @@ -231,7 +231,7 @@ protected function remove_virtual_dir_root( $path ) { * * @return void */ - protected function setup_mocks() { + protected function setup_function_mocks() { Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); Monkey\Functions\when( 'beans_path_to_url' )->returnArg(); diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 9f505f4c..9194dd99 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -47,12 +47,17 @@ protected function setUp() { * Setup the stubs for the common WordPress escaping and internationalization functions. */ protected function setup_common_wp_stubs() { + // Common escaping functions. Monkey\Functions\stubs( array( 'esc_attr', 'esc_html', 'esc_textarea', 'esc_url', 'wp_kses_post', + ) ); + + // Common internationalization functions. + Monkey\Functions\stubs( array( '__', 'esc_html__', 'esc_html_x', From 051e67e14bfc795d213c96b9be71b002f862e7f7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 17 Mar 2018 14:21:29 -0500 Subject: [PATCH 331/800] Refactored beansAddAttributes mock setup. --- tests/phpunit/unit/api/html/beansAddAttributes.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/html/beansAddAttributes.php b/tests/phpunit/unit/api/html/beansAddAttributes.php index 068d8895..47f37a52 100644 --- a/tests/phpunit/unit/api/html/beansAddAttributes.php +++ b/tests/phpunit/unit/api/html/beansAddAttributes.php @@ -24,10 +24,10 @@ class Tests_BeansAddAttributes extends HTML_Test_Case { /** - * Setup dependency function mocks. + * Prepares the test environment before each test. */ - protected function setup_mocks() { - parent::setup_mocks(); + protected function setup() { + parent::setUp(); Monkey\Functions\when( 'wp_parse_args' )->alias( function( $args ) { From e9caa611c48201ebf7c3b1048e3a35165d1e8ffe Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 17 Mar 2018 15:37:02 -0400 Subject: [PATCH 332/800] Fixed typo in HTML API integration tests (#179) --- .../api/html/beansWrapInnerMarkup.php | 30 +++++++++---------- .../integration/api/html/beansWrapMarkup.php | 30 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php b/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php index f212c09c..fbcd8b8f 100644 --- a/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php +++ b/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php @@ -52,7 +52,7 @@ public function test_should_register_beans_open_markup_to_given_id_prepend_marku $this->assertArrayHasKey( 1, $wp_filter['foo_prepend_markup'] ); // Check that the correct arguments were stored in the instance. - $anonomyous_action = $this->get_instance_from_wp( 'foo_prepend_markup', 1 ); + $anonymous_action = $this->get_instance_from_wp( 'foo_prepend_markup', 1 ); $this->assertSame( array( 'beans_open_markup', @@ -62,11 +62,11 @@ public function test_should_register_beans_open_markup_to_given_id_prepend_marku 3 => array( 'class' => 'test-wrap' ), ), ), - $anonomyous_action->callback + $anonymous_action->callback ); // Clean up. - remove_action( 'foo_prepend_markup', array( $anonomyous_action, 'callback' ), 1 ); + remove_action( 'foo_prepend_markup', array( $anonymous_action, 'callback' ), 1 ); } /** @@ -82,7 +82,7 @@ public function test_should_register_beans_close_markup_to_given_id_append_marku $this->assertArrayHasKey( 9999, $wp_filter['foo_append_markup'] ); // Check that the correct arguments were stored in the instance. - $anonomyous_action = $this->get_instance_from_wp( 'foo_append_markup', 9999 ); + $anonymous_action = $this->get_instance_from_wp( 'foo_append_markup', 9999 ); $this->assertSame( array( 'beans_close_markup', @@ -91,11 +91,11 @@ public function test_should_register_beans_close_markup_to_given_id_append_marku 2 => 'div', ), ), - $anonomyous_action->callback + $anonymous_action->callback ); // Clean up. - remove_action( 'foo_append_markup', array( $anonomyous_action, 'callback' ), 9999 ); + remove_action( 'foo_append_markup', array( $anonymous_action, 'callback' ), 9999 ); } /** @@ -105,11 +105,11 @@ public function test_should_not_pass_attributes_for_append_markup_hook() { beans_wrap_inner_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ); // Check that the attributes do not exist. - $anonomyous_action = $this->get_instance_from_wp( 'no_atts_append_markup', 9999 ); - $this->assertNotContains( array( 'class' => 'test-wrap' ), $anonomyous_action->callback[1] ); + $anonymous_action = $this->get_instance_from_wp( 'no_atts_append_markup', 9999 ); + $this->assertNotContains( array( 'class' => 'test-wrap' ), $anonymous_action->callback[1] ); // Clean up. - remove_action( 'no_atts_append_markup', array( $anonomyous_action, 'callback' ), 9999 ); + remove_action( 'no_atts_append_markup', array( $anonymous_action, 'callback' ), 9999 ); } /** @@ -120,7 +120,7 @@ public function test_should_pass_extra_arguments_for_prepend_markup_hook() { beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ); // Check that the correct arguments were stored in the instance. - $anonomyous_action = $this->get_instance_from_wp( 'extra_args_prepend_markup', 1 ); + $anonymous_action = $this->get_instance_from_wp( 'extra_args_prepend_markup', 1 ); $this->assertSame( array( 'beans_open_markup', @@ -132,11 +132,11 @@ public function test_should_pass_extra_arguments_for_prepend_markup_hook() { 5 => 'Beans Rocks!', ), ), - $anonomyous_action->callback + $anonymous_action->callback ); // Clean up. - remove_action( 'extra_args_prepend_markup', array( $anonomyous_action, 'callback' ), 1 ); + remove_action( 'extra_args_prepend_markup', array( $anonymous_action, 'callback' ), 1 ); } /** @@ -147,7 +147,7 @@ public function test_should_pass_extra_arguments_for_append_markup_hook() { beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 'and so does WordPress!' ); // Check that the correct arguments were stored in the instance. - $anonomyous_action = $this->get_instance_from_wp( 'extra_args_append_markup', 9999 ); + $anonymous_action = $this->get_instance_from_wp( 'extra_args_append_markup', 9999 ); $this->assertSame( array( 'beans_close_markup', @@ -158,10 +158,10 @@ public function test_should_pass_extra_arguments_for_append_markup_hook() { 5 => 'and so does WordPress!', ), ), - $anonomyous_action->callback + $anonymous_action->callback ); // Clean up. - remove_action( 'extra_args_append_markup', array( $anonomyous_action, 'callback' ), 9999 ); + remove_action( 'extra_args_append_markup', array( $anonymous_action, 'callback' ), 9999 ); } } diff --git a/tests/phpunit/integration/api/html/beansWrapMarkup.php b/tests/phpunit/integration/api/html/beansWrapMarkup.php index 71ef07e2..a179f450 100644 --- a/tests/phpunit/integration/api/html/beansWrapMarkup.php +++ b/tests/phpunit/integration/api/html/beansWrapMarkup.php @@ -52,7 +52,7 @@ public function test_should_register_beans_open_markup_to_given_id_before_markup $this->assertArrayHasKey( 9999, $wp_filter['foo_before_markup'] ); // Check that the correct arguments were stored in the instance. - $anonomyous_action = $this->get_instance_from_wp( 'foo_before_markup', 9999 ); + $anonymous_action = $this->get_instance_from_wp( 'foo_before_markup', 9999 ); $this->assertSame( array( 'beans_open_markup', @@ -62,11 +62,11 @@ public function test_should_register_beans_open_markup_to_given_id_before_markup 3 => array( 'class' => 'test-wrap' ), ), ), - $anonomyous_action->callback + $anonymous_action->callback ); // Clean up. - remove_action( 'foo_before_markup', array( $anonomyous_action, 'callback' ), 9999 ); + remove_action( 'foo_before_markup', array( $anonymous_action, 'callback' ), 9999 ); } /** @@ -82,7 +82,7 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup $this->assertArrayHasKey( 1, $wp_filter['foo_after_markup'] ); // Check that the correct arguments were stored in the instance. - $anonomyous_action = $this->get_instance_from_wp( 'foo_after_markup', 1 ); + $anonymous_action = $this->get_instance_from_wp( 'foo_after_markup', 1 ); $this->assertSame( array( 'beans_close_markup', @@ -91,11 +91,11 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup 2 => 'div', ), ), - $anonomyous_action->callback + $anonymous_action->callback ); // Clean up. - remove_action( 'foo_after_markup', array( $anonomyous_action, 'callback' ), 1 ); + remove_action( 'foo_after_markup', array( $anonymous_action, 'callback' ), 1 ); } /** @@ -105,11 +105,11 @@ public function test_should_not_pass_attributes_for_after_markup_hook() { beans_wrap_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ); // Check that the attributes do not exist. - $anonomyous_action = $this->get_instance_from_wp( 'no_atts_after_markup', 1 ); - $this->assertNotContains( array( 'class' => 'test-wrap' ), $anonomyous_action->callback[1] ); + $anonymous_action = $this->get_instance_from_wp( 'no_atts_after_markup', 1 ); + $this->assertNotContains( array( 'class' => 'test-wrap' ), $anonymous_action->callback[1] ); // Clean up. - remove_action( 'no_atts_after_markup', array( $anonomyous_action, 'callback' ), 1 ); + remove_action( 'no_atts_after_markup', array( $anonymous_action, 'callback' ), 1 ); } /** @@ -120,7 +120,7 @@ public function test_should_pass_extra_arguments_for_before_markup_hook() { beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ); // Check that the correct arguments were stored in the instance. - $anonomyous_action = $this->get_instance_from_wp( 'extra_args_before_markup', 9999 ); + $anonymous_action = $this->get_instance_from_wp( 'extra_args_before_markup', 9999 ); $this->assertSame( array( 'beans_open_markup', @@ -132,11 +132,11 @@ public function test_should_pass_extra_arguments_for_before_markup_hook() { 5 => 'Beans Rocks!', ), ), - $anonomyous_action->callback + $anonymous_action->callback ); // Clean up. - remove_action( 'extra_args_before_markup', array( $anonomyous_action, 'callback' ), 9999 ); + remove_action( 'extra_args_before_markup', array( $anonymous_action, 'callback' ), 9999 ); } /** @@ -147,7 +147,7 @@ public function test_should_pass_extra_arguments_for_after_markup_hook() { beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 47 ); // Check that the correct arguments were stored in the instance. - $anonomyous_action = $this->get_instance_from_wp( 'extra_args_after_markup', 1 ); + $anonymous_action = $this->get_instance_from_wp( 'extra_args_after_markup', 1 ); $this->assertSame( array( 'beans_close_markup', @@ -158,10 +158,10 @@ public function test_should_pass_extra_arguments_for_after_markup_hook() { 5 => 47, ), ), - $anonomyous_action->callback + $anonymous_action->callback ); // Clean up. - remove_action( 'extra_args_after_markup', array( $anonomyous_action, 'callback' ), 1 ); + remove_action( 'extra_args_after_markup', array( $anonymous_action, 'callback' ), 1 ); } } From e8165abd2f792936f7befcec8a1a2e6934ec51fa Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 18 Mar 2018 07:31:39 -0500 Subject: [PATCH 333/800] Improved url build. --- lib/api/compiler/class-beans-compiler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 75b96987..f08c207e 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -626,7 +626,7 @@ public function replace_css_url_callback( $matches ) { } // Rebuild the URL and make sure it is valid using the beans_path_to_url function. - $url = beans_path_to_url( trailingslashit( $base ) . ltrim( end( $paths ), '/' ) ); + $url = beans_path_to_url( trailingslashit( $base ) . ltrim( end( $paths ), '/\\' ) ); // Return the rebuilt path converted to an URL. return 'url("' . $url . '")'; From f517f78ec9293e2b7322101b442e8a5e0b1101a2 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 18 Mar 2018 09:25:02 -0500 Subject: [PATCH 334/800] Refactored to avoid added assignments. When 0able to resolve post ID with get_the_ID(), we can avoid a double assignment by separating out the beans_get() code. --- lib/api/post-meta/functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index 9c213909..2ab670ba 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -23,8 +23,11 @@ function beans_get_post_meta( $meta_key, $default = false, $post_id = false ) { if ( ! $post_id ) { - $id = get_the_ID(); - $post_id = ! $id ? beans_get( 'post' ) : $id; + $post_id = get_the_ID(); + } + + if ( ! $post_id ) { + $post_id = beans_get( 'post' ); } if ( ! $post_id ) { From 193ed2eca2b62984d34ca27eeac81c1bab62208b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 18 Mar 2018 09:41:38 -0500 Subject: [PATCH 335/800] Added type casting to ensure we get an integer. --- lib/api/post-meta/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index 2ab670ba..e0f2b638 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -27,7 +27,7 @@ function beans_get_post_meta( $meta_key, $default = false, $post_id = false ) { } if ( ! $post_id ) { - $post_id = beans_get( 'post' ); + $post_id = (int) beans_get( 'post' ); } if ( ! $post_id ) { From ce327624bd2e67f27d56399dc1a785ab31d895a1 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 18 Mar 2018 09:43:09 -0500 Subject: [PATCH 336/800] Improved the return comment. --- lib/api/post-meta/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index e0f2b638..e196152e 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -18,7 +18,7 @@ * @param mixed $default Optional. The default value to return of the post meta value doesn't exist. * @param int|string|false $post_id Optional. Overwrite the current post id. * - * @return mixed Saved data if exist, otherwise default value set. + * @return mixed Returns the meta value, if it exists; else, the default value is returned. */ function beans_get_post_meta( $meta_key, $default = false, $post_id = false ) { From e3ce6b7dd8ea52d26755bf6203d05c210f17874f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 18 Mar 2018 09:51:30 -0500 Subject: [PATCH 337/800] Changed $post_id default to empty string. --- lib/api/post-meta/functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index e196152e..4c62c093 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -14,13 +14,13 @@ * * @since 1.0.0 * - * @param string $meta_key The post meta id searched. - * @param mixed $default Optional. The default value to return of the post meta value doesn't exist. - * @param int|string|false $post_id Optional. Overwrite the current post id. + * @param string $meta_key The post meta id searched. + * @param mixed $default Optional. The default value to return of the post meta value doesn't exist. + * @param int|string $post_id Optional. Overwrite the current post id. * * @return mixed Returns the meta value, if it exists; else, the default value is returned. */ -function beans_get_post_meta( $meta_key, $default = false, $post_id = false ) { +function beans_get_post_meta( $meta_key, $default = false, $post_id = '' ) { if ( ! $post_id ) { $post_id = get_the_ID(); From 69e7c4557216750d34d77780b645fde7ee1a5df0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 18 Mar 2018 09:53:35 -0500 Subject: [PATCH 338/800] Improved readability in unit test. --- .../unit/api/post-meta/beansGetPostMeta.php | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php index 7fd18c33..193fa812 100644 --- a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php +++ b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php @@ -49,7 +49,10 @@ public function test_should_return_default_when_post_id_cannot_be_resolved() { * Test beans_get_post_meta() should return the default when the post meta does not exist. */ public function test_should_return_default_when_post_meta_does_not_exist() { - Monkey\Functions\expect( 'get_post_meta' )->with( 1 )->times( 3 )->andReturn( array() ); + Monkey\Functions\expect( 'get_post_meta' ) + ->with( 1 ) + ->times( 3 ) + ->andReturn( array() ); $this->assertFalse( beans_get_post_meta( 'beans_layout', false, 1 ) ); $this->assertSame( '', beans_get_post_meta( 'beans_layout', '', 1 ) ); @@ -61,12 +64,21 @@ public function test_should_return_default_when_post_meta_does_not_exist() { */ public function test_should_get_post_id_when_none_is_provided() { Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 47 ); - Monkey\Functions\expect( 'get_post_meta' )->with( 47 )->once()->andReturn( array() ); + Monkey\Functions\expect( 'get_post_meta' ) + ->with( 47 ) + ->once() + ->andReturn( array() ); $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 0 ); - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 18 ); - Monkey\Functions\expect( 'get_post_meta' )->with( '18' )->once()->andReturn( array() ); + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'post' ) + ->andReturn( 18 ); + Monkey\Functions\expect( 'get_post_meta' ) + ->with( '18' ) + ->once() + ->andReturn( array() ); $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); } @@ -100,7 +112,10 @@ public function test_should_return_post_meta_value() { $this->assertSame( 'sp_c', beans_get_post_meta( 'beans_layout' ) ); Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 0 ); - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 18 ); + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'post' ) + ->andReturn( 18 ); Monkey\Functions\expect( 'get_post_meta' ) ->with( '18' ) ->once() From 2d4bc23597f2f4d21b7febd80294c98761ef46f7 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 18 Mar 2018 21:31:34 -0400 Subject: [PATCH 339/800] Improved accessibility and styling of Beans settings page --- lib/api/admin-menu.php | 5 +++-- lib/api/compiler/class-options.php | 11 +++++++---- lib/api/fields/assets/css/fields.css | 6 +++++- lib/api/fields/assets/css/fields.min.css | 2 +- lib/api/fields/types/field.php | 9 +++++++-- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/api/admin-menu.php b/lib/api/admin-menu.php index f741d8bb..c14c38ad 100644 --- a/lib/api/admin-menu.php +++ b/lib/api/admin-menu.php @@ -47,7 +47,7 @@ public function admin_menu() { public function display_screen() { ?>
    -

    +

    'beans_dev_mode', - 'checkbox_label' => __( 'Enable development mode', 'tm-beans' ), + 'label' => __( 'Enable development mode', 'tm-beans' ), + 'checkbox_label' => __( 'Select to activate development mode.', 'tm-beans' ), 'type' => 'checkbox', 'description' => __( 'This option should be enabled while your website is in development.', 'tm-beans' ), ), diff --git a/lib/api/compiler/class-options.php b/lib/api/compiler/class-options.php index 1f5f6748..cbaebde3 100644 --- a/lib/api/compiler/class-options.php +++ b/lib/api/compiler/class-options.php @@ -51,8 +51,8 @@ public function register() { $fields = array_merge( $fields, array( array( 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => __( 'Compile all WordPress styles', 'tm-beans' ), + 'label' => __( 'Compile all WordPress styles', 'tm-beans' ), + 'checkbox_label' => __( 'Select to compile styles.', 'tm-beans' ), 'type' => 'checkbox', 'default' => false, 'description' => __( 'Compile and cache all the CSS files that have been enqueued to the WordPress head.', 'tm-beans' ), @@ -67,24 +67,27 @@ public function register() { 'id' => 'beans_compile_all_scripts_group', 'label' => __( 'Compile all WordPress scripts', 'tm-beans' ), 'type' => 'group', + 'tag' => 'p', 'fields' => array( array( 'id' => 'beans_compile_all_scripts', 'type' => 'activation', + 'label' => __( 'Select to activate compilation.', 'tm-beans' ), 'default' => false, ), array( 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', + 'label' => 'Choose the level of compilation.', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), + 'attributes' => array( 'style' => 'margin-top: -6px;' ), 'options' => array( 'aggressive' => __( 'Aggressive', 'tm-beans' ), 'standard' => __( 'Standard', 'tm-beans' ), ), ), ), - 'description' => __( 'Compile and cache all the Javascript files that have been enqueued to the WordPress head.JavaSript is outputted in the footer if the level is set to Aggressive and might conflict with some third party plugins which are not following WordPress standards.', 'tm-beans' ), + 'description' => __( 'Compile and cache all the JavaScript files that have been enqueued to the WordPress head.
    JavaScript is outputted in the footer if the level is set to Aggressive and might conflict with some third-party plugins which are not following WordPress standards.', 'tm-beans' ), ), ) ); } diff --git a/lib/api/fields/assets/css/fields.css b/lib/api/fields/assets/css/fields.css index 1d3d3737..c1c30f13 100644 --- a/lib/api/fields/assets/css/fields.css +++ b/lib/api/fields/assets/css/fields.css @@ -44,6 +44,10 @@ color: #666; } +p.bs-fields-header { + margin-top: 0; +} + /* Label */ .bs-field-wrap label { display: block; @@ -56,7 +60,7 @@ clear: both; padding: 10px 0 0; color: #333; - font-size: 11px; + font-size: 12px; } .bs-field-description .bs-read-more { diff --git a/lib/api/fields/assets/css/fields.min.css b/lib/api/fields/assets/css/fields.min.css index d34e4868..90e111e1 100644 --- a/lib/api/fields/assets/css/fields.min.css +++ b/lib/api/fields/assets/css/fields.min.css @@ -1 +1 @@ -.bs-field,.bs-field select{width:100%;min-width:200px}.bs-field-wrap{display:inline-block;box-sizing:border-box;width:100%;padding:20px 0;border-top:1px solid #e8e8e8}.bs-field-wrap:first-of-type{padding-top:10px;border-top:0}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field{display:block;position:relative;padding:0}.bs-field input[type=text],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{max-width:280px;margin:0;color:#666}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;padding:10px 0 0;color:#333;font-size:11px}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{float:left}.bs-field.deactivated{opacity:.5}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-field .button{display:inline-block;padding:0 4px 1px;border-radius:4px;color:#555;background-color:#fff;text-align:center;-moz-transition:background-color .1s ease-in 0;-webkit-transition:background-color .1s ease-in 0;transition:background-color .1s ease-in 0}.bs-field .button:focus,.bs-field .button:hover{color:#fff}.bs-field .button.dashicons{width:auto;font-size:0}.bs-field .bs-button-edit:before,.bs-field .bs-button-menu:before,.bs-field .bs-button-trash:before{font-family:dashicons;font-size:22px;text-align:center}.bs-field .bs-button-edit:before{content:"\f464"}.bs-field .bs-button-menu:before{content:"\f333"}.bs-field .bs-button-trash{margin-left:5px}.bs-field .bs-button-trash:before{content:"\f182"}.bs-field .bs-add-image:focus,.bs-field .bs-add-image:hover,.bs-field .bs-button-edit:focus,.bs-field .bs-button-edit:hover{background-color:#76b031}.bs-field .bs-button-menu:focus,.bs-field .bs-button-menu:hover{background-color:#2991c0;cursor:move}.bs-field .bs-button-trash:focus,.bs-field .bs-button-trash:hover{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-placeholder,.bs-field .bs-image-wrap{display:inline-block;position:relative;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{width:110px;height:110px;border:1px solid #ddd;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;top:0;right:0;bottom:0;left:0;box-sizing:border-box;max-width:100%;max-height:100%;margin:auto;padding:2px}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{position:absolute;right:0;bottom:0;box-sizing:border-box;width:100%;padding:3px 0;background-color:#e6e6e6;text-align:center}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-radio fieldset{margin-left:-15px}.bs-radio fieldset label{padding-left:15px}.bs-radio .bs-has-image{display:inline-block;width:auto;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{display:inline-block;position:relative;top:2px;width:180px;height:10px;margin:2px 0 0;border:1px solid #ccc;border-radius:5px}.bs-field .ui-slider-range{height:10px;border-radius:4px;background:#ddd}.bs-field .ui-slider-handle{display:block;position:absolute;width:16px;height:16px;margin:-13px 0 0 -8px;border-radius:8px;background:#bbb;box-shadow:none;cursor:pointer}.bs-field .ui-slider-handle.ui-state-active{background:#aaa}.bs-field .bs-slider-unit,.bs-field .bs-slider-value{display:inline-block;margin:0;font-size:11px}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{display:block;clear:both;width:100%;margin:20px 0 0;padding:0}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;min-height:100px;margin:0;padding-left:20px}@media (min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type=text],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{margin-bottom:0;padding:0 0 0 5px}#customize-controls .bs-radio .bs-has-image img{width:33px;height:33px;margin-bottom:0;border-width:2px} \ No newline at end of file +.bs-field-wrap{display:inline-block;box-sizing:border-box;width:100%;padding:20px 0;border-top:1px solid #e8e8e8}.bs-field-wrap:first-of-type{padding-top:10px;border-top:0}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field{display:block;position:relative;width:100%;min-width:200px;padding:0}.bs-field input[type=text],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{width:100%;min-width:200px;max-width:280px;margin:0;color:#666}p.bs-fields-header{margin-top:0}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;padding:10px 0 0;color:#333;font-size:12px}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{float:left}.bs-field.deactivated{opacity:.5}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-field .button{display:inline-block;padding:0 4px 1px;border-radius:4px;color:#555;background-color:#fff;text-align:center;transition:background-color .1s ease-in 0}.bs-field .button:focus,.bs-field .button:hover{color:#fff}.bs-field .button.dashicons{width:auto;font-size:0}.bs-field .bs-button-edit:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f464"}.bs-field .bs-button-menu:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f333"}.bs-field .bs-button-trash{margin-left:5px}.bs-field .bs-button-trash:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f182"}.bs-field .bs-add-image:focus,.bs-field .bs-add-image:hover,.bs-field .bs-button-edit:focus,.bs-field .bs-button-edit:hover{background-color:#76b031}.bs-field .bs-button-menu:focus,.bs-field .bs-button-menu:hover{background-color:#2991c0;cursor:move}.bs-field .bs-button-trash:focus,.bs-field .bs-button-trash:hover{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-placeholder,.bs-field .bs-image-wrap{display:inline-block;position:relative;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{width:110px;height:110px;border:1px solid #ddd;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;top:0;right:0;bottom:0;left:0;box-sizing:border-box;max-width:100%;max-height:100%;margin:auto;padding:2px}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{position:absolute;right:0;bottom:0;box-sizing:border-box;width:100%;padding:3px 0;background-color:#e6e6e6;text-align:center}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-radio fieldset{margin-left:-15px}.bs-radio fieldset label{padding-left:15px}.bs-radio .bs-has-image{display:inline-block;width:auto;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{display:inline-block;position:relative;top:2px;width:180px;height:10px;margin:2px 0 0;border:1px solid #ccc;border-radius:5px}.bs-field .ui-slider-range{height:10px;border-radius:4px;background:#ddd}.bs-field .ui-slider-handle{display:block;position:absolute;width:16px;height:16px;margin:-13px 0 0 -8px;border-radius:8px;background:#bbb;box-shadow:none;cursor:pointer}.bs-field .ui-slider-handle.ui-state-active{background:#aaa}.bs-field .bs-slider-unit,.bs-field .bs-slider-value{display:inline-block;margin:0;font-size:11px}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{display:block;clear:both;width:100%;margin:0;margin-top:20px;padding:0}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;box-sizing:border-box;width:100%;min-height:100px;margin:0;padding-left:20px}@media (min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type=text],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{margin-bottom:0;padding:0 0 0 5px}#customize-controls .bs-radio .bs-has-image img{width:33px;height:33px;margin-bottom:0;border-width:2px} \ No newline at end of file diff --git a/lib/api/fields/types/field.php b/lib/api/fields/types/field.php index 92fa3c0d..fc9bafa8 100644 --- a/lib/api/fields/types/field.php +++ b/lib/api/fields/types/field.php @@ -29,8 +29,13 @@ function beans_field_label( array $field ) { // These field types do not use a label, as they are providing a header for the group of fields. if ( in_array( $field['type'], array( 'radio', 'group' ), true ) ) { - $tag = 'h3'; - $args = array( 'class' => 'bs-fields-header hndle' ); + if ( isset( $field['tag'] ) && 'p' === $field['tag'] ) { + $tag = 'p'; + $args = array( 'class' => 'bs-fields-header' ); + } else { + $tag = 'h3'; + $args = array( 'class' => 'bs-fields-header hndle' ); + } } else { $tag = 'label'; $args = array( 'for' => $field['id'] ); From d78d56255e1b929e644817d64afe01f17fc50a9d Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Mon, 19 Mar 2018 13:25:14 -0400 Subject: [PATCH 340/800] Changed wording --- lib/api/compiler/class-options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/compiler/class-options.php b/lib/api/compiler/class-options.php index cbaebde3..d20142d6 100644 --- a/lib/api/compiler/class-options.php +++ b/lib/api/compiler/class-options.php @@ -72,7 +72,7 @@ public function register() { array( 'id' => 'beans_compile_all_scripts', 'type' => 'activation', - 'label' => __( 'Select to activate compilation.', 'tm-beans' ), + 'label' => __( 'Select to compile scripts.', 'tm-beans' ), 'default' => false, ), array( From 7ed542329a7fbd21a78d931f60f80d7d5d31cb11 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 19 Mar 2018 12:37:25 -0500 Subject: [PATCH 341/800] Moved 2nd post ID resolver into first, to only run it if we post ID was not originally given. --- lib/api/post-meta/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index 4c62c093..2b6ecd7a 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -24,10 +24,10 @@ function beans_get_post_meta( $meta_key, $default = false, $post_id = '' ) { if ( ! $post_id ) { $post_id = get_the_ID(); - } - if ( ! $post_id ) { - $post_id = (int) beans_get( 'post' ); + if ( ! $post_id ) { + $post_id = (int) beans_get( 'post' ); + } } if ( ! $post_id ) { From 4bdabd7fd3438cdcaf022e059ac41ed0dd1525f6 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Mon, 19 Mar 2018 22:41:39 -0400 Subject: [PATCH 342/800] Changed group and radio fields to fieldsets with legends --- lib/api/compiler/class-options.php | 1 - lib/api/fields/functions.php | 14 ++++++++++++++ lib/api/fields/types/field.php | 26 ++++++++++---------------- lib/api/fields/types/views/radio.php | 2 +- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/lib/api/compiler/class-options.php b/lib/api/compiler/class-options.php index d20142d6..ecefdeb9 100644 --- a/lib/api/compiler/class-options.php +++ b/lib/api/compiler/class-options.php @@ -67,7 +67,6 @@ public function register() { 'id' => 'beans_compile_all_scripts_group', 'label' => __( 'Compile all WordPress scripts', 'tm-beans' ), 'type' => 'group', - 'tag' => 'p', 'fields' => array( array( 'id' => 'beans_compile_all_scripts', diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 4c998dbb..3bb4f459 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -111,6 +111,17 @@ function beans_field( array $field ) { 'class' => 'bs-field-inside', ), $fields ); + if ( 'group' === $field['type'] ) { + beans_open_markup_e( 'beans_field_group_fieldset', 'fieldset', array( + 'class' => 'bs-field-fieldset', + ), $field ); + beans_open_markup_e( 'beans_field_group_legend', 'legend', array( + 'class' => 'bs-field-legend', + ), $field ); + echo esc_html( $field['label'] ); + beans_close_markup_e( 'beans_field_group_legend', 'legend', $field ); + } + // Loop through fields. foreach ( $fields as $single_field ) { beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array( @@ -140,6 +151,9 @@ function beans_field( array $field ) { beans_close_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', $single_field ); } + if ( 'group' === $field['type'] ) { + beans_close_markup_e( 'beans_field_group_fieldset', 'fieldset', $field ); + } beans_close_markup_e( 'beans_field_inside', 'div', $fields ); beans_close_markup_e( 'beans_field_wrap', 'div', $field ); } diff --git a/lib/api/fields/types/field.php b/lib/api/fields/types/field.php index fc9bafa8..8b0c9c95 100644 --- a/lib/api/fields/types/field.php +++ b/lib/api/fields/types/field.php @@ -19,30 +19,24 @@ * } */ function beans_field_label( array $field ) { - $label = beans_get( 'label', $field ); - if ( ! $label ) { + // These field types do not use a label, as they are using fieldsets with legends. + if ( in_array( $field['type'], array( 'radio', 'group' ), true ) ) { return; } - $id = 'beans_field_label[_' . $field['id'] . ']'; + $label = beans_get( 'label', $field ); - // These field types do not use a label, as they are providing a header for the group of fields. - if ( in_array( $field['type'], array( 'radio', 'group' ), true ) ) { - if ( isset( $field['tag'] ) && 'p' === $field['tag'] ) { - $tag = 'p'; - $args = array( 'class' => 'bs-fields-header' ); - } else { - $tag = 'h3'; - $args = array( 'class' => 'bs-fields-header hndle' ); - } - } else { - $tag = 'label'; - $args = array( 'for' => $field['id'] ); + if ( ! $label ) { + return; } + $id = 'beans_field_label[_' . $field['id'] . ']'; + $tag = 'label'; + $args = array( 'for' => $field['id'] ); + beans_open_markup_e( $id, $tag, $args ); - echo esc_html( $field['label'] ); + echo esc_html( $field['label'] ); beans_close_markup_e( $id, $tag ); } diff --git a/lib/api/fields/types/views/radio.php b/lib/api/fields/types/views/radio.php index 24d347bc..1c00d5d3 100644 --- a/lib/api/fields/types/views/radio.php +++ b/lib/api/fields/types/views/radio.php @@ -12,7 +12,7 @@ ?>
    - + Date: Tue, 20 Mar 2018 11:36:07 -0500 Subject: [PATCH 343/800] Added unit tests for beans_output. --- tests/phpunit/unit/api/html/beansOutput.php | 118 ++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 tests/phpunit/unit/api/html/beansOutput.php diff --git a/tests/phpunit/unit/api/html/beansOutput.php b/tests/phpunit/unit/api/html/beansOutput.php new file mode 100644 index 00000000..5a16fc85 --- /dev/null +++ b/tests/phpunit/unit/api/html/beansOutput.php @@ -0,0 +1,118 @@ +times( 3 )->andReturnUsing( function( $hook, $output ) { + return $output; + } ); + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->never(); + + $this->assertNull( beans_output( 'beans_post_meta_item_date', null ) ); + $this->assertNull( beans_output( 'beans_post_meta_item_author', '' ) ); + $this->assertNull( beans_output( 'beans_post_meta_item_comments', false ) ); + } + + /** + * Test beans_output() should fire the "{$id}_output" filter hook. + */ + public function test_should_fire_output_filter_hook() { + // Check the applied filter. + Monkey\Filters\expectApplied( 'beans_archive_title_text_output' ) + ->once() + ->with( 'Beans rocks!' ) + ->andReturn( 'WooHoo, I fired!' ); + + // Setup beans_apply_filters() mock to fire apply_filters(). + Monkey\Functions\expect( 'beans_apply_filters' ) + ->once() + ->with( 'beans_archive_title_text_output', 'Beans rocks!' ) + ->andReturnUsing( function( $hook, $output ) { + return apply_filters( $hook, $output ); + } ); + + // Check with HTML dev mode disabled. + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); + + // Run the tests. + $this->assertSame( 'WooHoo, I fired!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); + $this->assertSame( 1, Monkey\Filters\applied( 'beans_archive_title_text_output' ) ); + } + + /** + * Test beans_output() should return output when not in HTML dev mode. + */ + public function test_should_return_output_when_not_in_html_dev_mode() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); + + $this->assertSame( 'Beans rocks!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); + } + + /** + * Test beans_output() should return "comment wrapped" HTML when in HTML dev mode. + */ + public function test_should_return_comment_wrapped_html_when_in_html_dev_mode() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( true ); + + $expected = <<Beans rocks! +EOB; + $this->assertSame( $expected, beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); + } + + /** + * Test beans_output() should pass additional arguments when firing the filter hook. + */ + public function test_should_pass_additional_args_when_firing_filter_hook() { + // Setup beans_apply_filters() mock to fire apply_filters(). + Monkey\Functions\expect( 'beans_apply_filters' ) + ->twice() + ->with( 'beans_breadcrumb_item_text_output', 'Beans rocks!', 47, 'Hello' ) + ->andReturnUsing( function( $hook, $output ) { + return $output; + }); + + // Check with HTML dev mode disabled. + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); + $this->assertSame( + 'Beans rocks!', + beans_output( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) + ); + + // Check with HTML dev mode enabled. + $expected = <<Beans rocks! +EOB; + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( true ); + $this->assertSame( + $expected, + beans_output( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) + ); + } +} From d510bb32ca901efead0dadcf02321c1fe5900932 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 20 Mar 2018 13:27:38 -0400 Subject: [PATCH 344/800] Adjusted classes and styles --- lib/api/compiler/class-options.php | 2 +- lib/api/fields/assets/css/fields.css | 46 ++++++++++++++---------- lib/api/fields/assets/css/fields.min.css | 2 +- lib/api/fields/functions.php | 8 +++-- lib/api/fields/types/views/radio.php | 4 +-- 5 files changed, 36 insertions(+), 26 deletions(-) diff --git a/lib/api/compiler/class-options.php b/lib/api/compiler/class-options.php index ecefdeb9..53d72d41 100644 --- a/lib/api/compiler/class-options.php +++ b/lib/api/compiler/class-options.php @@ -79,7 +79,7 @@ public function register() { 'type' => 'select', 'label' => 'Choose the level of compilation.', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin-top: -6px;' ), + //'attributes' => array( 'style' => 'margin-top: -6px;' ), 'options' => array( 'aggressive' => __( 'Aggressive', 'tm-beans' ), 'standard' => __( 'Standard', 'tm-beans' ), diff --git a/lib/api/fields/assets/css/fields.css b/lib/api/fields/assets/css/fields.css index c1c30f13..305e9817 100644 --- a/lib/api/fields/assets/css/fields.css +++ b/lib/api/fields/assets/css/fields.css @@ -83,20 +83,6 @@ p.bs-fields-header { opacity: 0.5; } -/* Group fields */ -.bs-group .bs-field-inside { - display: inline-block; - margin: -10px 0 0 -10px; -} - -.bs-group .bs-field-inside .bs-field { - display: inline-block; - width: auto; - min-width: 0; - max-width: 300px; - margin: 10px 0 0 10px; -} - /* Dashicons */ .bs-field .button { display: inline-block; @@ -236,13 +222,35 @@ p.bs-fields-header { .bs-field .bs-image-wrap:focus .bs-toolbar { } -/* Radio/Imageradio */ -.bs-radio fieldset { - margin-left: -15px; +/* Group fields */ +.bs-group .bs-field-inside { + display: inline-block; + margin: -10px 0 0 -10px; } -.bs-radio fieldset label { - padding-left: 15px; +.bs-group .bs-field-inside .bs-field { + display: inline-block; + width: auto; + min-width: 0; + max-width: 300px; + margin: 10px 0 0 10px; +} + +.bs-group .bs-field-inside .bs-field:first-of-type { + margin-left: 3px; +} + +.bs-group .bs-field-fieldset { + margin: 10px; +} + +.bs-group .bs-select select { + margin-top: -8px; +} + +/* Radio/Image radio */ +.bs-radio .bs-field-legend { + margin-bottom: 15px; } .bs-radio .bs-has-image { diff --git a/lib/api/fields/assets/css/fields.min.css b/lib/api/fields/assets/css/fields.min.css index 90e111e1..6474a2c4 100644 --- a/lib/api/fields/assets/css/fields.min.css +++ b/lib/api/fields/assets/css/fields.min.css @@ -1 +1 @@ -.bs-field-wrap{display:inline-block;box-sizing:border-box;width:100%;padding:20px 0;border-top:1px solid #e8e8e8}.bs-field-wrap:first-of-type{padding-top:10px;border-top:0}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field{display:block;position:relative;width:100%;min-width:200px;padding:0}.bs-field input[type=text],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{width:100%;min-width:200px;max-width:280px;margin:0;color:#666}p.bs-fields-header{margin-top:0}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;padding:10px 0 0;color:#333;font-size:12px}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{float:left}.bs-field.deactivated{opacity:.5}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-field .button{display:inline-block;padding:0 4px 1px;border-radius:4px;color:#555;background-color:#fff;text-align:center;transition:background-color .1s ease-in 0}.bs-field .button:focus,.bs-field .button:hover{color:#fff}.bs-field .button.dashicons{width:auto;font-size:0}.bs-field .bs-button-edit:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f464"}.bs-field .bs-button-menu:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f333"}.bs-field .bs-button-trash{margin-left:5px}.bs-field .bs-button-trash:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f182"}.bs-field .bs-add-image:focus,.bs-field .bs-add-image:hover,.bs-field .bs-button-edit:focus,.bs-field .bs-button-edit:hover{background-color:#76b031}.bs-field .bs-button-menu:focus,.bs-field .bs-button-menu:hover{background-color:#2991c0;cursor:move}.bs-field .bs-button-trash:focus,.bs-field .bs-button-trash:hover{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-placeholder,.bs-field .bs-image-wrap{display:inline-block;position:relative;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{width:110px;height:110px;border:1px solid #ddd;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;top:0;right:0;bottom:0;left:0;box-sizing:border-box;max-width:100%;max-height:100%;margin:auto;padding:2px}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{position:absolute;right:0;bottom:0;box-sizing:border-box;width:100%;padding:3px 0;background-color:#e6e6e6;text-align:center}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-radio fieldset{margin-left:-15px}.bs-radio fieldset label{padding-left:15px}.bs-radio .bs-has-image{display:inline-block;width:auto;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{display:inline-block;position:relative;top:2px;width:180px;height:10px;margin:2px 0 0;border:1px solid #ccc;border-radius:5px}.bs-field .ui-slider-range{height:10px;border-radius:4px;background:#ddd}.bs-field .ui-slider-handle{display:block;position:absolute;width:16px;height:16px;margin:-13px 0 0 -8px;border-radius:8px;background:#bbb;box-shadow:none;cursor:pointer}.bs-field .ui-slider-handle.ui-state-active{background:#aaa}.bs-field .bs-slider-unit,.bs-field .bs-slider-value{display:inline-block;margin:0;font-size:11px}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{display:block;clear:both;width:100%;margin:0;margin-top:20px;padding:0}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;box-sizing:border-box;width:100%;min-height:100px;margin:0;padding-left:20px}@media (min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type=text],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{margin-bottom:0;padding:0 0 0 5px}#customize-controls .bs-radio .bs-has-image img{width:33px;height:33px;margin-bottom:0;border-width:2px} \ No newline at end of file +.bs-field-wrap{display:inline-block;box-sizing:border-box;width:100%;padding:20px 0;border-top:1px solid #e8e8e8}.bs-field-wrap:first-of-type{padding-top:10px;border-top:0}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field{display:block;position:relative;width:100%;min-width:200px;padding:0}.bs-field input[type=text],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{width:100%;min-width:200px;max-width:280px;margin:0;color:#666}p.bs-fields-header{margin-top:0}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;padding:10px 0 0;color:#333;font-size:12px}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{float:left}.bs-field.deactivated{opacity:.5}.bs-field .button{display:inline-block;padding:0 4px 1px;border-radius:4px;color:#555;background-color:#fff;text-align:center;transition:background-color .1s ease-in 0}.bs-field .button:focus,.bs-field .button:hover{color:#fff}.bs-field .button.dashicons{width:auto;font-size:0}.bs-field .bs-button-edit:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f464"}.bs-field .bs-button-menu:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f333"}.bs-field .bs-button-trash{margin-left:5px}.bs-field .bs-button-trash:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f182"}.bs-field .bs-add-image:focus,.bs-field .bs-add-image:hover,.bs-field .bs-button-edit:focus,.bs-field .bs-button-edit:hover{background-color:#76b031}.bs-field .bs-button-menu:focus,.bs-field .bs-button-menu:hover{background-color:#2991c0;cursor:move}.bs-field .bs-button-trash:focus,.bs-field .bs-button-trash:hover{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-placeholder,.bs-field .bs-image-wrap{display:inline-block;position:relative;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{width:110px;height:110px;border:1px solid #ddd;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;top:0;right:0;bottom:0;left:0;box-sizing:border-box;max-width:100%;max-height:100%;margin:auto;padding:2px}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{position:absolute;right:0;bottom:0;box-sizing:border-box;width:100%;padding:3px 0;background-color:#e6e6e6;text-align:center}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-group .bs-field-inside .bs-field:first-of-type{margin-left:3px}.bs-group .bs-field-fieldset{margin:10px}.bs-group .bs-select select{margin-top:-8px}.bs-radio .bs-field-legend{margin-bottom:15px}.bs-radio .bs-has-image{display:inline-block;width:auto;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{display:inline-block;position:relative;top:2px;width:180px;height:10px;margin:2px 0 0;border:1px solid #ccc;border-radius:5px}.bs-field .ui-slider-range{height:10px;border-radius:4px;background:#ddd}.bs-field .ui-slider-handle{display:block;position:absolute;width:16px;height:16px;margin:-13px 0 0 -8px;border-radius:8px;background:#bbb;box-shadow:none;cursor:pointer}.bs-field .ui-slider-handle.ui-state-active{background:#aaa}.bs-field .bs-slider-unit,.bs-field .bs-slider-value{display:inline-block;margin:0;font-size:11px}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{display:block;clear:both;width:100%;margin:0;margin-top:20px;padding:0}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;box-sizing:border-box;width:100%;min-height:100px;margin:0;padding-left:20px}@media (min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type=text],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{margin-bottom:0;padding:0 0 0 5px}#customize-controls .bs-radio .bs-has-image img{width:33px;height:33px;margin-bottom:0;border-width:2px} \ No newline at end of file diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 3bb4f459..2cb4442d 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -96,12 +96,14 @@ function beans_field( array $field ) { return; } + $group_field_type = 'group' === $field['type']; + beans_open_markup_e( 'beans_field_wrap', 'div', array( 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], ), $field ); // Set fields loop to cater for groups. - if ( 'group' === $field['type'] ) { + if ( $group_field_type ) { $fields = $field['fields']; } else { $fields = array( $field ); @@ -111,7 +113,7 @@ function beans_field( array $field ) { 'class' => 'bs-field-inside', ), $fields ); - if ( 'group' === $field['type'] ) { + if ( $group_field_type ) { beans_open_markup_e( 'beans_field_group_fieldset', 'fieldset', array( 'class' => 'bs-field-fieldset', ), $field ); @@ -151,7 +153,7 @@ function beans_field( array $field ) { beans_close_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', $single_field ); } - if ( 'group' === $field['type'] ) { + if ( $group_field_type ) { beans_close_markup_e( 'beans_field_group_fieldset', 'fieldset', $field ); } beans_close_markup_e( 'beans_field_inside', 'div', $fields ); diff --git a/lib/api/fields/types/views/radio.php b/lib/api/fields/types/views/radio.php index 1c00d5d3..5a96d79c 100644 --- a/lib/api/fields/types/views/radio.php +++ b/lib/api/fields/types/views/radio.php @@ -11,8 +11,8 @@ // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variables are used within a function's scope. ?> -
    - +
    + Date: Tue, 20 Mar 2018 13:31:22 -0400 Subject: [PATCH 345/800] Fixed Unit tests --- tests/phpunit/unit/api/fields/types/beansFieldRadio.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php index 6ae846a9..2e2353c0 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php @@ -65,8 +65,8 @@ public function test_should_render_radio_field_with_image_options() { $html = ob_get_clean(); $expected = << - The layout settings. +
    + Layout @@ -125,8 +125,8 @@ public function test_should_render_accessible_images_when_given() { $html = ob_get_clean(); $expected = << - The layout settings. +
    + Layout From 6d5eb437abf9227958b411133ba38ec5575793ab Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 12:33:30 -0500 Subject: [PATCH 346/800] Added beans_output integration tests. --- .../integration/api/html/beansOutput.php | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 tests/phpunit/integration/api/html/beansOutput.php diff --git a/tests/phpunit/integration/api/html/beansOutput.php b/tests/phpunit/integration/api/html/beansOutput.php new file mode 100644 index 00000000..9fe300fd --- /dev/null +++ b/tests/phpunit/integration/api/html/beansOutput.php @@ -0,0 +1,97 @@ +assertNull( beans_output( 'beans_post_meta_item_date', null ) ); + $this->assertNull( beans_output( 'beans_post_meta_item_author', '' ) ); + $this->assertNull( beans_output( 'beans_post_meta_item_comments', false ) ); + } + + /** + * Test beans_output() should fire the "{$id}_output" filter hook. + */ + public function test_should_fire_output_filter_hook() { + add_option( 'beans_dev_mode', 0 ); + add_filter( 'beans_archive_title_text_output', 'return_fired_output' ); + Monkey\Functions\expect( 'return_fired_output' ) + ->with( 'Beans rocks!' ) + ->andReturn( 'WooHoo, I fired!' ); + + // Run the test. + $this->assertSame( 'WooHoo, I fired!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); + } + + /** + * Test beans_output() should return output when not in HTML dev mode. + */ + public function test_should_return_output_when_not_in_html_dev_mode() { + add_option( 'beans_dev_mode', 0 ); + + $this->assertSame( 'Beans rocks!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); + } + + /** + * Test beans_output() should return "comment wrapped" HTML when in HTML dev mode. + */ + public function test_should_return_comment_wrapped_html_when_in_html_dev_mode() { + add_option( 'beans_dev_mode', 1 ); + + $expected = <<Beans rocks! +EOB; + $this->assertSame( $expected, beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); + } + + /** + * Test beans_output() should pass additional arguments when firing the filter hook. + */ + public function test_should_pass_additional_args_when_firing_filter_hook() { + add_filter( 'beans_breadcrumb_item_text_output', 'return_fired_output', 10, 3 ); + Monkey\Functions\expect( 'return_fired_output' ) + ->twice() + ->with( 'Beans rocks!', 47, 'Hello' ) + ->andReturnFirstArg(); + + // Check with HTML dev mode disabled. + add_option( 'beans_dev_mode', 0 ); + $this->assertSame( + 'Beans rocks!', + beans_output( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) + ); + + // Check with HTML dev mode enabled. + $expected = <<Beans rocks! +EOB; + update_option( 'beans_dev_mode', 1 ); + $this->assertSame( + $expected, + beans_output( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) + ); + } +} From 8eb136886f2b355e4c316d65d01d2abb38fbaff2 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 12:46:19 -0500 Subject: [PATCH 347/800] Added beans_output_e integration tests. --- .../integration/api/html/beansOutputE.php | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 tests/phpunit/integration/api/html/beansOutputE.php diff --git a/tests/phpunit/integration/api/html/beansOutputE.php b/tests/phpunit/integration/api/html/beansOutputE.php new file mode 100644 index 00000000..428ce549 --- /dev/null +++ b/tests/phpunit/integration/api/html/beansOutputE.php @@ -0,0 +1,114 @@ + null, + 'beans_post_meta_item_author' => '', + 'beans_post_meta_item_comments' => false, + ); + + foreach ( $ids as $id => $output ) { + ob_start(); + beans_output_e( $id, $output ); + $this->assertEmpty( ob_get_clean() ); + } + } + + /** + * Test beans_output_e() should echo the filtered output. + */ + public function test_should_fire_output_filter_hook() { + add_option( 'beans_dev_mode', 0 ); + add_filter( 'beans_archive_title_text_output', 'return_fired_output' ); + Monkey\Functions\expect( 'return_fired_output' ) + ->with( 'Beans rocks!' ) + ->andReturn( 'WooHoo, I fired!' ); + + // Run the test. + ob_start(); + beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); + $this->assertSame( 'WooHoo, I fired!', ob_get_clean() ); + } + + /** + * Test beans_output_e() should echo the output when not in HTML dev mode. + */ + public function test_should_echo_output_when_not_in_html_dev_mode() { + add_option( 'beans_dev_mode', 0 ); + + ob_start(); + beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); + $this->assertSame( 'Beans rocks!', ob_get_clean() ); + } + + /** + * Test beans_output_e() should echo the "comment wrapped" HTML when in HTML dev mode. + */ + public function test_should_echo_comment_wrapped_html_when_in_html_dev_mode() { + add_option( 'beans_dev_mode', 1 ); + + ob_start(); + beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); + $actual = ob_get_clean(); + + $expected = <<Beans rocks! +EOB; + $this->assertSame( $expected, $actual ); + } + + /** + * Test beans_output() should pass the additional arguments when firing the filter hook. + */ + public function test_should_pass_additional_args_when_firing_filter_hook() { + add_filter( 'beans_breadcrumb_item_text_output', 'return_fired_output', 10, 3 ); + Monkey\Functions\expect( 'return_fired_output' ) + ->twice() + ->with( 'Beans rocks!', 47, 'Hello' ) + ->andReturnUsing( function( $output, $arg1, $arg2 ) { + return $arg2; + }); + + // Check with HTML dev mode disabled. + add_option( 'beans_dev_mode', 0 ); + ob_start(); + beans_output_e( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ); + $this->assertSame( 'Hello', ob_get_clean() ); + + // Check with HTML dev mode enabled. + update_option( 'beans_dev_mode', 1 ); + ob_start(); + beans_output_e( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ); + $actual = ob_get_clean(); + $expected = <<Hello +EOB; + $this->assertSame( $expected, $actual ); + } +} From 815d6dd6ea163b22abf3d5a485235b8e7eb43bd7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 13:09:53 -0500 Subject: [PATCH 348/800] Added beans_output_e unit tests. --- .../integration/api/html/beansOutputE.php | 8 +- tests/phpunit/unit/api/html/beansOutputE.php | 114 ++++++++++++++++++ 2 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/unit/api/html/beansOutputE.php diff --git a/tests/phpunit/integration/api/html/beansOutputE.php b/tests/phpunit/integration/api/html/beansOutputE.php index 428ce549..62601191 100644 --- a/tests/phpunit/integration/api/html/beansOutputE.php +++ b/tests/phpunit/integration/api/html/beansOutputE.php @@ -24,7 +24,7 @@ class Tests_BeansOutputE extends HTML_Test_Case { /** - * Test beans_output() should echo an empty string when the output is empty. + * Test beans_output_e() should echo an empty string when the output is empty. */ public function test_should_echo_null_when_output_is_empty() { $ids = array( @@ -43,7 +43,7 @@ public function test_should_echo_null_when_output_is_empty() { /** * Test beans_output_e() should echo the filtered output. */ - public function test_should_fire_output_filter_hook() { + public function test_should_echo_the_filtered_output() { add_option( 'beans_dev_mode', 0 ); add_filter( 'beans_archive_title_text_output', 'return_fired_output' ); Monkey\Functions\expect( 'return_fired_output' ) @@ -84,9 +84,9 @@ public function test_should_echo_comment_wrapped_html_when_in_html_dev_mode() { } /** - * Test beans_output() should pass the additional arguments when firing the filter hook. + * Test beans_output() should pass the additional arguments. */ - public function test_should_pass_additional_args_when_firing_filter_hook() { + public function test_should_pass_additional_args() { add_filter( 'beans_breadcrumb_item_text_output', 'return_fired_output', 10, 3 ); Monkey\Functions\expect( 'return_fired_output' ) ->twice() diff --git a/tests/phpunit/unit/api/html/beansOutputE.php b/tests/phpunit/unit/api/html/beansOutputE.php new file mode 100644 index 00000000..4de75b9f --- /dev/null +++ b/tests/phpunit/unit/api/html/beansOutputE.php @@ -0,0 +1,114 @@ +times( 3 )->andReturnUsing( function( $id, $output ) { + return $output; + } ); + + $ids = array( + 'beans_post_meta_item_date' => null, + 'beans_post_meta_item_author' => '', + 'beans_post_meta_item_comments' => false, + ); + + foreach ( $ids as $id => $output ) { + ob_start(); + beans_output_e( $id, $output ); + $this->assertEmpty( ob_get_clean() ); + } + } + + /** + * Test beans_output_e() should echo the filtered output. + */ + public function test_should_echo_the_filtered_output() { + Monkey\Functions\expect( 'beans_output' ) + ->once() + ->with( 'beans_archive_title_text', 'Beans rocks!' ) + ->andReturn( 'WooHoo, I fired!' ); + + // Run the tests. + ob_start(); + beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); + $this->assertSame( 'WooHoo, I fired!', ob_get_clean() ); + } + + /** + * Test beans_output_e() should echo the output when not in HTML dev mode. + */ + public function test_should_echo_output_when_not_in_html_dev_mode() { + Monkey\Functions\expect( 'beans_output' ) + ->once() + ->with( 'beans_archive_title_text', 'Beans rocks!' ) + ->andReturnUsing( function( $id, $output ) { + return $output; + } ); + + ob_start(); + beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); + $this->assertSame( 'Beans rocks!', ob_get_clean() ); + } + + /** + * Test beans_output_e() should echo the "comment wrapped" HTML when in HTML dev mode. + */ + public function test_should_echo_comment_wrapped_html_when_in_html_dev_mode() { + Monkey\Functions\expect( 'beans_output' ) + ->once() + ->with( 'beans_archive_title_text', 'Beans rocks!' ) + ->andReturnUsing( function( $id, $output ) { + return "" . $output . ""; + } ); + + ob_start(); + beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); + $actual = ob_get_clean(); + + $expected = <<Beans rocks! +EOB; + $this->assertSame( $expected, $actual ); + } + + /** + * Test beans_output_e() should pass the additional arguments when firing the filter hook. + */ + public function test_should_pass_additional_args() { + Monkey\Functions\expect( 'beans_output' ) + ->once() + ->with( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) + ->andReturnUsing( function( $id, $output, $arg1, $arg2 ) { + return $arg2; + } ); + + ob_start(); + beans_output_e( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ); + $this->assertSame( 'Hello', ob_get_clean() ); + } +} From 46af2b7b3a9fbcbbcd5f01ee1e9b56536b2bf0f3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 13:12:42 -0500 Subject: [PATCH 349/800] Improved test DocBlocks. --- tests/phpunit/integration/api/html/beansOutput.php | 10 +++++----- tests/phpunit/unit/api/html/beansOutput.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansOutput.php b/tests/phpunit/integration/api/html/beansOutput.php index 9fe300fd..942c1d3c 100644 --- a/tests/phpunit/integration/api/html/beansOutput.php +++ b/tests/phpunit/integration/api/html/beansOutput.php @@ -33,9 +33,9 @@ public function test_should_return_null_when_output_is_empty() { } /** - * Test beans_output() should fire the "{$id}_output" filter hook. + * Test beans_output() should return the filtered output after firing the "{$id}_output" filter hook. */ - public function test_should_fire_output_filter_hook() { + public function test_should_return_filtered_output_after_firing_output_filter_hook() { add_option( 'beans_dev_mode', 0 ); add_filter( 'beans_archive_title_text_output', 'return_fired_output' ); Monkey\Functions\expect( 'return_fired_output' ) @@ -47,7 +47,7 @@ public function test_should_fire_output_filter_hook() { } /** - * Test beans_output() should return output when not in HTML dev mode. + * Test beans_output() should return the output when not in HTML dev mode. */ public function test_should_return_output_when_not_in_html_dev_mode() { add_option( 'beans_dev_mode', 0 ); @@ -56,7 +56,7 @@ public function test_should_return_output_when_not_in_html_dev_mode() { } /** - * Test beans_output() should return "comment wrapped" HTML when in HTML dev mode. + * Test beans_output() should return the "comment wrapped" HTML when in HTML dev mode. */ public function test_should_return_comment_wrapped_html_when_in_html_dev_mode() { add_option( 'beans_dev_mode', 1 ); @@ -68,7 +68,7 @@ public function test_should_return_comment_wrapped_html_when_in_html_dev_mode() } /** - * Test beans_output() should pass additional arguments when firing the filter hook. + * Test beans_output() should pass the additional arguments when firing the filter hook. */ public function test_should_pass_additional_args_when_firing_filter_hook() { add_filter( 'beans_breadcrumb_item_text_output', 'return_fired_output', 10, 3 ); diff --git a/tests/phpunit/unit/api/html/beansOutput.php b/tests/phpunit/unit/api/html/beansOutput.php index 5a16fc85..4570d97e 100644 --- a/tests/phpunit/unit/api/html/beansOutput.php +++ b/tests/phpunit/unit/api/html/beansOutput.php @@ -38,9 +38,9 @@ public function test_should_return_null_when_output_is_empty() { } /** - * Test beans_output() should fire the "{$id}_output" filter hook. + * Test beans_output() should return the filtered output after firing the "{$id}_output" filter hook. */ - public function test_should_fire_output_filter_hook() { + public function test_should_return_filtered_output_after_firing_output_filter_hook() { // Check the applied filter. Monkey\Filters\expectApplied( 'beans_archive_title_text_output' ) ->once() @@ -64,7 +64,7 @@ public function test_should_fire_output_filter_hook() { } /** - * Test beans_output() should return output when not in HTML dev mode. + * Test beans_output() should return the output when not in HTML dev mode. */ public function test_should_return_output_when_not_in_html_dev_mode() { Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); @@ -74,7 +74,7 @@ public function test_should_return_output_when_not_in_html_dev_mode() { } /** - * Test beans_output() should return "comment wrapped" HTML when in HTML dev mode. + * Test beans_output() should return the "comment wrapped" HTML when in HTML dev mode. */ public function test_should_return_comment_wrapped_html_when_in_html_dev_mode() { Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); @@ -87,7 +87,7 @@ public function test_should_return_comment_wrapped_html_when_in_html_dev_mode() } /** - * Test beans_output() should pass additional arguments when firing the filter hook. + * Test beans_output() should the pass additional arguments when firing the filter hook. */ public function test_should_pass_additional_args_when_firing_filter_hook() { // Setup beans_apply_filters() mock to fire apply_filters(). From 457523650b31884d63d4b23fe63ba35299cfd5ad Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 20 Mar 2018 14:22:24 -0400 Subject: [PATCH 350/800] Fixed Integration tests and formatting --- lib/api/compiler/class-options.php | 11 ++- .../integration/api/fields/beansField.php | 71 ++++++++++--------- .../api/fields/types/beansFieldLabel.php | 15 ++-- .../api/fields/types/beansFieldRadio.php | 8 +-- 4 files changed, 50 insertions(+), 55 deletions(-) diff --git a/lib/api/compiler/class-options.php b/lib/api/compiler/class-options.php index 53d72d41..a4ed507f 100644 --- a/lib/api/compiler/class-options.php +++ b/lib/api/compiler/class-options.php @@ -75,12 +75,11 @@ public function register() { 'default' => false, ), array( - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'label' => 'Choose the level of compilation.', - 'default' => 'aggressive', - //'attributes' => array( 'style' => 'margin-top: -6px;' ), - 'options' => array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'label' => 'Choose the level of compilation.', + 'default' => 'aggressive', + 'options' => array( 'aggressive' => __( 'Aggressive', 'tm-beans' ), 'standard' => __( 'Standard', 'tm-beans' ), ), diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 45542260..41fcd20e 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -118,17 +118,16 @@ public function test_should_render_radio_field() { $expected = << -

    Having fun?

    -
    - Radio buttons +
    + Having fun? + +
    @@ -189,20 +188,22 @@ public function test_should_render_group_of_fields() { $expected = << -

    Group of fields

    -
    - - - -
    -
    - - -
    +
    + Group of fields +
    + + + +
    +
    + + +
    +
    This is a group of fields.
    @@ -282,23 +283,25 @@ public function test_full_integration_should_render_group_of_fields() { $expected = << -

    Group of fields

    -
    - - -
    -
    - -
    -
    - - - Enable the checkbox test -
    +
    + Group of fields +
    + + +
    +
    + +
    +
    + + + Enable the checkbox test +
    +
    This is a group of fields.
    diff --git a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php index 429dac12..1a412869 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php @@ -82,7 +82,7 @@ public function test_should_render_field_label() { } /** - * Test beans_field_label() should render the radio field's group header. + * Test beans_field_label() should not render the radio field's group label. */ public function test_should_render_radio_group_header() { $field = $this->merge_field_with_default( array( @@ -114,15 +114,12 @@ public function test_should_render_radio_group_header() { beans_field_label( $field ); $html = ob_get_clean(); - $expected = <<Layout -EOB; // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + $this->assertEmpty( $this->format_the_html( $html ) ); } /** - * Test beans_field_label() should render the group field's header. + * Test beans_field_label() should not render the group field's label. */ public function test_should_render_group_header() { $field = array( @@ -163,10 +160,6 @@ public function test_should_render_group_header() { beans_field_label( $field ); $html = ob_get_clean(); - $expected = <<Group of fields -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); + $this->assertEmpty( $this->format_the_html( $html ) ); } } diff --git a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php index 49a679ec..8be8f499 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php @@ -65,8 +65,8 @@ public function test_should_render_radio_field_with_image_options() { $html = ob_get_clean(); $expected = << - The layout settings. +
    + Layout @@ -125,8 +125,8 @@ public function test_should_render_accessible_images_when_given() { $html = ob_get_clean(); $expected = << - The layout settings. +
    + Layout From 4b0a7c1d8b9ef8e2d28b74ea6b2ab2473eba6e39 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 13:31:44 -0500 Subject: [PATCH 351/800] Fixed formatting. --- tests/phpunit/integration/api/html/beansOutputE.php | 4 ++-- tests/phpunit/unit/api/html/beansOutput.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansOutputE.php b/tests/phpunit/integration/api/html/beansOutputE.php index 62601191..49abc571 100644 --- a/tests/phpunit/integration/api/html/beansOutputE.php +++ b/tests/phpunit/integration/api/html/beansOutputE.php @@ -93,7 +93,7 @@ public function test_should_pass_additional_args() { ->with( 'Beans rocks!', 47, 'Hello' ) ->andReturnUsing( function( $output, $arg1, $arg2 ) { return $arg2; - }); + } ); // Check with HTML dev mode disabled. add_option( 'beans_dev_mode', 0 ); @@ -105,7 +105,7 @@ public function test_should_pass_additional_args() { update_option( 'beans_dev_mode', 1 ); ob_start(); beans_output_e( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ); - $actual = ob_get_clean(); + $actual = ob_get_clean(); $expected = <<Hello EOB; diff --git a/tests/phpunit/unit/api/html/beansOutput.php b/tests/phpunit/unit/api/html/beansOutput.php index 4570d97e..cf588882 100644 --- a/tests/phpunit/unit/api/html/beansOutput.php +++ b/tests/phpunit/unit/api/html/beansOutput.php @@ -52,7 +52,7 @@ public function test_should_return_filtered_output_after_firing_output_filter_ho ->once() ->with( 'beans_archive_title_text_output', 'Beans rocks!' ) ->andReturnUsing( function( $hook, $output ) { - return apply_filters( $hook, $output ); + return apply_filters( $hook, $output ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Prefix is in the value represented by the variable. } ); // Check with HTML dev mode disabled. @@ -96,7 +96,7 @@ public function test_should_pass_additional_args_when_firing_filter_hook() { ->with( 'beans_breadcrumb_item_text_output', 'Beans rocks!', 47, 'Hello' ) ->andReturnUsing( function( $hook, $output ) { return $output; - }); + } ); // Check with HTML dev mode disabled. Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); From 30d40c742a0b72f5891b5a1fc83a1fa36ce449ec Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 14:11:54 -0500 Subject: [PATCH 352/800] Improved documentation. --- lib/api/html/functions.php | 43 +++++++++------------ tests/phpunit/unit/api/html/beansOutput.php | 4 +- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index ee64fe77..8c26bb91 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -9,23 +9,24 @@ */ /** - * Register output by ID. + * Register the output for the given ID. This function enables the output be: * - * The output can be modified using the available Beans HTML "output" functions. + * 1. modified by registering a callback to "{$id}_output" + * 2. removed by using {@see beans_remove_output()}. * - * HTML comments containing the ID are added before and after the output if the development mode is enabled. - * This makes it very easy to find a content ID when inspecting an element in your web browser. + * When in development mode, HTML comments containing the ID are added before and after the output, i.e. making it + * easier to identify the content ID when inspecting an element in your web browser. * - * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). - * - * Note: You can pass additional arguments to the functions that are hooked to $id. + * Notes: + * 1. Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). + * 2. You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $output Content to output. + * @param string $output The given content to output. * - * @return string The output. + * @return string|void */ function beans_output( $id, $output ) { $args = func_get_args(); @@ -45,22 +46,14 @@ function beans_output( $id, $output ) { } /** - * Echo output registered by ID. - * - * The output can be modified using the available Beans HTML "output" functions. - * - * HTML comments containing the ID are added before and after the output if the development mode is enabled. - * This makes it very easy to find a content ID when inspecting an element in your web browser. - * - * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). - * - * Note: You can pass additional arguments to the functions that are hooked to $id. + * Register and then echo the output for the given ID. This function is a wrapper for {@see beans_output()}. See + * {@see beans_output()} for more details. * * @since 1.4.0 - * @uses beans_output() To register output by ID. + * @uses beans_output() To register output by ID. * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $output Content to output. + * @param string $output The given content to output. */ function beans_output_e( $id, $output ) { $args = func_get_args(); @@ -354,8 +347,8 @@ function beans_modify_markup( $id, $markup, $priority = 10, $args = 1 ) { * @since 1.0.0 * * @param string $id The markup ID. - * @param bool $remove_actions Optional. Whether elements attached to a markup should be removed or not. This must be used - * with absolute caution. + * @param bool $remove_actions Optional. Whether elements attached to a markup should be removed or not. This must be + * used with absolute caution. * * @return bool Will always return true. */ @@ -371,8 +364,8 @@ function beans_remove_markup( $id, $remove_actions = false ) { /** * Reset markup. * - * This function will automatically reset the opening and the closing HTML tag to its original value. If the markup is self-closed, - * the HTML tag will be reset accordingly. + * This function will automatically reset the opening and the closing HTML tag to its original value. If the markup is + * self-closed, the HTML tag will be reset accordingly. * * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very * easy to find the content ID when inspecting an element in a web browser. diff --git a/tests/phpunit/unit/api/html/beansOutput.php b/tests/phpunit/unit/api/html/beansOutput.php index cf588882..62c28ebe 100644 --- a/tests/phpunit/unit/api/html/beansOutput.php +++ b/tests/phpunit/unit/api/html/beansOutput.php @@ -87,10 +87,10 @@ public function test_should_return_comment_wrapped_html_when_in_html_dev_mode() } /** - * Test beans_output() should the pass additional arguments when firing the filter hook. + * Test beans_output() should pass the additional arguments when firing the filter hook. */ public function test_should_pass_additional_args_when_firing_filter_hook() { - // Setup beans_apply_filters() mock to fire apply_filters(). + // Check that beans_apply_filters() is called as expected. Monkey\Functions\expect( 'beans_apply_filters' ) ->twice() ->with( 'beans_breadcrumb_item_text_output', 'Beans rocks!', 47, 'Hello' ) From 2de7ad0f71666dda97aeaae805d0700c7d530b7d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 14:24:59 -0500 Subject: [PATCH 353/800] Fixed DocBlock. --- lib/api/html/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 8c26bb91..9913f5b3 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -9,7 +9,7 @@ */ /** - * Register the output for the given ID. This function enables the output be: + * Register the output for the given ID. This function enables the output to be: * * 1. modified by registering a callback to "{$id}_output" * 2. removed by using {@see beans_remove_output()}. From cf68d55f03054a7b2d953e0c612dbd5ed005eb98 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 15:34:07 -0500 Subject: [PATCH 354/800] Fixed #180. --- lib/templates/fragments/post.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 5218c3b2..19b7e72c 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -599,7 +599,7 @@ function beans_posts_pagination() { ) ); - // Previous. + // Previous. if ( get_previous_posts_link() ) { beans_open_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); @@ -629,8 +629,8 @@ function beans_posts_pagination() { beans_close_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); } - // Links. - foreach ( range( 1, $wp_query->max_num_pages ) as $link ) { + // Links. + foreach ( range( 1, (int) $wp_query->max_num_pages ) as $link ) { // Skip if next is set. if ( isset( $next ) && $link !== $next ) { @@ -698,7 +698,7 @@ function beans_posts_pagination() { } } - // Next. + // Next. if ( get_next_posts_link() ) { beans_open_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); From e608820affe0340369191600b27d9e509b05a492 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 15:41:27 -0500 Subject: [PATCH 355/800] Improved function documentation. --- lib/api/html/functions.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 9913f5b3..a3947e95 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -61,16 +61,13 @@ function beans_output_e( $id, $output ) { } /** - * Remove output. - * - * HTML comments containing the ID are added before and after the output if the development mode is enabled. - * This makes it very easy to find a content ID when inspecting an element in your web browser. + * Removes the HTML output for the given $id, meaning the output will not render. * * @since 1.0.0 * - * @param string $id The output ID. + * @param string $id The output's ID. * - * @return bool Will always return true. + * @return bool */ function beans_remove_output( $id ) { return beans_add_filter( $id . '_output', false ); From 11e0a730f55b8d401f5e9d790462347ddfe8e0f5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 15:44:08 -0500 Subject: [PATCH 356/800] Changes priority so that this filter fires last. To ensure the output is removed, we need this callback to fire last. --- lib/api/html/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index a3947e95..141b5f66 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -70,7 +70,7 @@ function beans_output_e( $id, $output ) { * @return bool */ function beans_remove_output( $id ) { - return beans_add_filter( $id . '_output', false ); + return beans_add_filter( $id . '_output', false, 99999999 ); } /** From bc8d94b7b7547b3f674551ff1686bd8ae8ae959c Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 20 Mar 2018 16:51:32 -0400 Subject: [PATCH 357/800] Change activation field label position --- lib/api/fields/assets/css/fields.css | 6 ++++++ lib/api/fields/assets/css/fields.min.css | 2 +- lib/api/fields/types/field.php | 2 +- lib/api/fields/types/views/activation.php | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/api/fields/assets/css/fields.css b/lib/api/fields/assets/css/fields.css index 305e9817..46e3ecdd 100644 --- a/lib/api/fields/assets/css/fields.css +++ b/lib/api/fields/assets/css/fields.css @@ -157,6 +157,11 @@ p.bs-fields-header { cursor: pointer; } +.bs-activation label { + display: inline-block; + margin-bottom: 5px; +} + /* Image */ .bs-field .bs-images-wrap { margin-left: -10px; @@ -256,6 +261,7 @@ p.bs-fields-header { .bs-radio .bs-has-image { display: inline-block; width: auto; + padding-right: 15px; line-height: 0; } diff --git a/lib/api/fields/assets/css/fields.min.css b/lib/api/fields/assets/css/fields.min.css index 6474a2c4..8b5a1e13 100644 --- a/lib/api/fields/assets/css/fields.min.css +++ b/lib/api/fields/assets/css/fields.min.css @@ -1 +1 @@ -.bs-field-wrap{display:inline-block;box-sizing:border-box;width:100%;padding:20px 0;border-top:1px solid #e8e8e8}.bs-field-wrap:first-of-type{padding-top:10px;border-top:0}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field{display:block;position:relative;width:100%;min-width:200px;padding:0}.bs-field input[type=text],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{width:100%;min-width:200px;max-width:280px;margin:0;color:#666}p.bs-fields-header{margin-top:0}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;padding:10px 0 0;color:#333;font-size:12px}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{float:left}.bs-field.deactivated{opacity:.5}.bs-field .button{display:inline-block;padding:0 4px 1px;border-radius:4px;color:#555;background-color:#fff;text-align:center;transition:background-color .1s ease-in 0}.bs-field .button:focus,.bs-field .button:hover{color:#fff}.bs-field .button.dashicons{width:auto;font-size:0}.bs-field .bs-button-edit:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f464"}.bs-field .bs-button-menu:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f333"}.bs-field .bs-button-trash{margin-left:5px}.bs-field .bs-button-trash:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f182"}.bs-field .bs-add-image:focus,.bs-field .bs-add-image:hover,.bs-field .bs-button-edit:focus,.bs-field .bs-button-edit:hover{background-color:#76b031}.bs-field .bs-button-menu:focus,.bs-field .bs-button-menu:hover{background-color:#2991c0;cursor:move}.bs-field .bs-button-trash:focus,.bs-field .bs-button-trash:hover{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-placeholder,.bs-field .bs-image-wrap{display:inline-block;position:relative;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{width:110px;height:110px;border:1px solid #ddd;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;top:0;right:0;bottom:0;left:0;box-sizing:border-box;max-width:100%;max-height:100%;margin:auto;padding:2px}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{position:absolute;right:0;bottom:0;box-sizing:border-box;width:100%;padding:3px 0;background-color:#e6e6e6;text-align:center}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-group .bs-field-inside .bs-field:first-of-type{margin-left:3px}.bs-group .bs-field-fieldset{margin:10px}.bs-group .bs-select select{margin-top:-8px}.bs-radio .bs-field-legend{margin-bottom:15px}.bs-radio .bs-has-image{display:inline-block;width:auto;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{display:inline-block;position:relative;top:2px;width:180px;height:10px;margin:2px 0 0;border:1px solid #ccc;border-radius:5px}.bs-field .ui-slider-range{height:10px;border-radius:4px;background:#ddd}.bs-field .ui-slider-handle{display:block;position:absolute;width:16px;height:16px;margin:-13px 0 0 -8px;border-radius:8px;background:#bbb;box-shadow:none;cursor:pointer}.bs-field .ui-slider-handle.ui-state-active{background:#aaa}.bs-field .bs-slider-unit,.bs-field .bs-slider-value{display:inline-block;margin:0;font-size:11px}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{display:block;clear:both;width:100%;margin:0;margin-top:20px;padding:0}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;box-sizing:border-box;width:100%;min-height:100px;margin:0;padding-left:20px}@media (min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type=text],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{margin-bottom:0;padding:0 0 0 5px}#customize-controls .bs-radio .bs-has-image img{width:33px;height:33px;margin-bottom:0;border-width:2px} \ No newline at end of file +.bs-field-wrap{display:inline-block;box-sizing:border-box;width:100%;padding:20px 0;border-top:1px solid #e8e8e8}.bs-field-wrap:first-of-type{padding-top:10px;border-top:0}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field{display:block;position:relative;width:100%;min-width:200px;padding:0}.bs-field input[type=text],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{width:100%;min-width:200px;max-width:280px;margin:0;color:#666}p.bs-fields-header{margin-top:0}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;padding:10px 0 0;color:#333;font-size:12px}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{float:left}.bs-field.deactivated{opacity:.5}.bs-field .button{display:inline-block;padding:0 4px 1px;border-radius:4px;color:#555;background-color:#fff;text-align:center;transition:background-color .1s ease-in 0}.bs-field .button:focus,.bs-field .button:hover{color:#fff}.bs-field .button.dashicons{width:auto;font-size:0}.bs-field .bs-button-edit:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f464"}.bs-field .bs-button-menu:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f333"}.bs-field .bs-button-trash{margin-left:5px}.bs-field .bs-button-trash:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f182"}.bs-field .bs-add-image:focus,.bs-field .bs-add-image:hover,.bs-field .bs-button-edit:focus,.bs-field .bs-button-edit:hover{background-color:#76b031}.bs-field .bs-button-menu:focus,.bs-field .bs-button-menu:hover{background-color:#2991c0;cursor:move}.bs-field .bs-button-trash:focus,.bs-field .bs-button-trash:hover{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-activation label{display:inline-block;margin-bottom:5px}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-placeholder,.bs-field .bs-image-wrap{display:inline-block;position:relative;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{width:110px;height:110px;border:1px solid #ddd;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;top:0;right:0;bottom:0;left:0;box-sizing:border-box;max-width:100%;max-height:100%;margin:auto;padding:2px}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{position:absolute;right:0;bottom:0;box-sizing:border-box;width:100%;padding:3px 0;background-color:#e6e6e6;text-align:center}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-group .bs-field-inside .bs-field:first-of-type{margin-left:3px}.bs-group .bs-field-fieldset{margin:10px}.bs-group .bs-select select{margin-top:-8px}.bs-radio .bs-field-legend{margin-bottom:15px}.bs-radio .bs-has-image{display:inline-block;width:auto;padding-right:15px;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{display:inline-block;position:relative;top:2px;width:180px;height:10px;margin:2px 0 0;border:1px solid #ccc;border-radius:5px}.bs-field .ui-slider-range{height:10px;border-radius:4px;background:#ddd}.bs-field .ui-slider-handle{display:block;position:absolute;width:16px;height:16px;margin:-13px 0 0 -8px;border-radius:8px;background:#bbb;box-shadow:none;cursor:pointer}.bs-field .ui-slider-handle.ui-state-active{background:#aaa}.bs-field .bs-slider-unit,.bs-field .bs-slider-value{display:inline-block;margin:0;font-size:11px}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{display:block;clear:both;width:100%;margin:0;margin-top:20px;padding:0}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;box-sizing:border-box;width:100%;min-height:100px;margin:0;padding-left:20px}@media (min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type=text],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{margin-bottom:0;padding:0 0 0 5px}#customize-controls .bs-radio .bs-has-image img{width:33px;height:33px;margin-bottom:0;border-width:2px} \ No newline at end of file diff --git a/lib/api/fields/types/field.php b/lib/api/fields/types/field.php index 8b0c9c95..be6ac166 100644 --- a/lib/api/fields/types/field.php +++ b/lib/api/fields/types/field.php @@ -21,7 +21,7 @@ function beans_field_label( array $field ) { // These field types do not use a label, as they are using fieldsets with legends. - if ( in_array( $field['type'], array( 'radio', 'group' ), true ) ) { + if ( in_array( $field['type'], array( 'radio', 'group', 'activation' ), true ) ) { return; } diff --git a/lib/api/fields/types/views/activation.php b/lib/api/fields/types/views/activation.php index 3d0ab8af..740a6833 100644 --- a/lib/api/fields/types/views/activation.php +++ b/lib/api/fields/types/views/activation.php @@ -12,3 +12,4 @@ /> + From ac3ad686c98c8ea0ec18da243a9243d181002e82 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 20 Mar 2018 16:55:45 -0400 Subject: [PATCH 358/800] Fixed unit tests --- tests/phpunit/unit/api/fields/types/beansFieldActivation.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php index a84bb081..695ac421 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php @@ -59,6 +59,7 @@ public function test_should_render_activation_field() { $expected = << + EOB; // Run the test. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); @@ -85,6 +86,7 @@ public function test_should_render_activation_field_with_attributes_when_given() $expected = << + EOB; // Run the test. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); From c1e8d2b0e2e134fd5cf2994cd445aae0aef16134 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 16:38:03 -0500 Subject: [PATCH 359/800] Added unit and integration tests. --- lib/api/filters/functions.php | 2 +- lib/api/html/functions.php | 2 +- .../api/html/beansRemoveOutput.php | 63 +++++++++++++++++ .../unit/api/html/beansRemoveOutput.php | 69 +++++++++++++++++++ .../fixtures/class-anonymous-filter-stub.php | 45 ++++++++++++ 5 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beansRemoveOutput.php create mode 100644 tests/phpunit/unit/api/html/beansRemoveOutput.php create mode 100644 tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php diff --git a/lib/api/filters/functions.php b/lib/api/filters/functions.php index 66ecd1d7..8af1d600 100644 --- a/lib/api/filters/functions.php +++ b/lib/api/filters/functions.php @@ -25,7 +25,7 @@ * the order in which they were added to the filter. * @param int $args Optional. The number of arguments the callback accepts. Default is 1. * - * @return bool + * @return bool|_Beans_Anonymous_Filters */ function beans_add_filter( $hook, $callback_or_value, $priority = 10, $args = 1 ) { diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 141b5f66..708a0c32 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -67,7 +67,7 @@ function beans_output_e( $id, $output ) { * * @param string $id The output's ID. * - * @return bool + * @return bool|_Beans_Anonymous_Filters */ function beans_remove_output( $id ) { return beans_add_filter( $id . '_output', false, 99999999 ); diff --git a/tests/phpunit/integration/api/html/beansRemoveOutput.php b/tests/phpunit/integration/api/html/beansRemoveOutput.php new file mode 100644 index 00000000..53eecf71 --- /dev/null +++ b/tests/phpunit/integration/api/html/beansRemoveOutput.php @@ -0,0 +1,63 @@ +assertInstanceOf( _Beans_Anonymous_Filters::class, beans_remove_output( 'beans_post_meta_item_date' ) ); + } + + /** + * Test beans_remove_output() should register callback to the "{$id}_output" filter hook. + */ + public function test_should_return_register_callback_to_id_output() { + $anonymous_filter = beans_remove_output( 'beans_post_meta_item_date' ); + + $this->assertSame( 99999999, has_filter( 'beans_post_meta_item_date_output', array( + $anonymous_filter, + 'callback', + ) ) ); + } + + /** + * Test beans_remove_output() should remove the output. + */ + public function test_should_return_remove_output() { + // Check that everything works before we remove it. + $this->assertSame( 'Beans rocks!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); + + // Now remove the output. + beans_remove_output( 'beans_archive_title_text' ); + + // Check when not in developer mode. + add_option( 'beans_dev_mode', 0 ); + $this->assertNull( beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); + + // Check when in developer mode. + update_option( 'beans_dev_mode', 1 ); + $this->assertNull( beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); + } +} diff --git a/tests/phpunit/unit/api/html/beansRemoveOutput.php b/tests/phpunit/unit/api/html/beansRemoveOutput.php new file mode 100644 index 00000000..0796b09a --- /dev/null +++ b/tests/phpunit/unit/api/html/beansRemoveOutput.php @@ -0,0 +1,69 @@ +alias( function( $hook, $value, $priority ) { + return new Anonymous_Filter_Stub( $hook, $value, $priority ); + } ); + + $this->assertInstanceOf( Anonymous_Filter_Stub::class, beans_remove_output( 'beans_post_meta_item_date' ) ); + } + + /** + * Test beans_remove_output() should call beans_add_filter() to register the callback for the remove process. + */ + public function test_should_call_beans_add_filter_to_register_callback() { + $ids = array( + 'beans_post_meta_item_date', + 'beans_post_meta_item_author', + 'beans_post_meta_item_comments', + ); + + foreach ( $ids as $id ) { + Monkey\Functions\expect( 'beans_add_filter' ) + ->once() + ->with( "{$id}_output", false, 99999999 ) + ->andReturn( false ); + + beans_remove_output( $id ); + } + + // Tests are focused above on ensuring beans_apply_filters() is called with the right arguments. + $this->assertTrue( true ); + } +} diff --git a/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php b/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php new file mode 100644 index 00000000..f51f04be --- /dev/null +++ b/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php @@ -0,0 +1,45 @@ +value_to_return = $value_to_return; + + add_filter( $hook, array( $this, 'callback' ), $priority ); + } + + /** + * Mocked callback. + */ + public function callback() { + return $this->value_to_return; + } +} From 24b1f1d9c00ccd52da8ada78166d07e12556d313 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 18:15:45 -0500 Subject: [PATCH 360/800] Added beans_open_markup unit tests. --- lib/api/html/functions.php | 3 +- .../phpunit/unit/api/html/beansOpenMarkup.php | 177 ++++++++++++++++++ 2 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/unit/api/html/beansOpenMarkup.php diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 9913f5b3..667130c6 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -120,9 +120,10 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { // Remove function $tag argument. unset( $attributes_args[1] ); - // Stop here if the tag is set to false, the before and after actions won't run in this case. + // Filter the tag. $tag = call_user_func_array( 'beans_apply_filters', $args ); + // Stop here if the tag is set to null, the before and after actions won't run in this case. if ( null === $tag ) { return; } diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php new file mode 100644 index 00000000..2860f06b --- /dev/null +++ b/tests/phpunit/unit/api/html/beansOpenMarkup.php @@ -0,0 +1,177 @@ +once() + ->with( 'beans_archive_title_markup', null ) + ->andReturnNull(); + + $this->assertNull( beans_open_markup( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) ); + } + + /** + * Test beans_open_markup() should fire _beans_render_action() for the "_before_markup" and "_prepend_markup" hooks. + */ + public function test_should_fire_beans_render_action_for_before_and_prepend_markup_hooks() { + Monkey\Functions\when( 'beans_add_attributes' )->justReturn( 'class="uk-article-title"' ); + Monkey\Functions\when( '_beans_is_html_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( '_beans_render_action' ) + ->once() + ->with( 'beans_archive_title_before_markup' ) + ->andReturn( 'Fired "_before_markup" hooks' ) + ->andAlsoExpectIt() + ->once() + ->with( 'beans_archive_title_prepend_markup' ) + ->andReturn( 'Fired "_prepend_markup" hooks' ); + + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertContains( 'Fired "_before_markup" hooks', $actual ); + $this->assertContains( 'Fired "_prepend_markup" hooks', $actual ); + } + + /** + * Test beans_open_markup() should fire _beans_render_action() for the "_after_markup" hooks when the global + * $_temp_beans_selfclose_markup is set to true. + */ + public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { + Monkey\Functions\when( 'beans_add_attributes' )->justReturn( 'class="uk-article-title"' ); + Monkey\Functions\when( '_beans_is_html_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( '_beans_render_action' ) + ->once() + ->with( 'beans_archive_title_after_markup' ) + ->andReturn( 'Worked!' ); + + global $_temp_beans_selfclose_markup; + $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + + $this->assertContains( 'Worked!', beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ) ); + + // Check that the global was unset. + $this->assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + } + + /** + * Test beans_open_markup() should return built HTML when no before or prepend hooks are registered. + */ + public function test_should_return_built_html_when_before_or_prepend_hooks_registered() { + Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); + Monkey\Functions\expect( 'beans_add_attributes' ) + ->once() + ->with( 'beans_archive_title', array( 'class' => 'uk-article-title' ) ) + ->andReturn( 'class="uk-article-title"' ); + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); + + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '

    ', $actual ); + } + + /** + * Test beans_open_markup() should return built HTML with the "data-markup-id" when in development mode. + */ + public function test_should_return_built_html_with_data_markup_id_when_in_dev_mode() { + Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); + Monkey\Functions\expect( 'beans_add_attributes' ) + ->once() + ->with( 'beans_archive_title', array( 'class' => 'uk-article-title' ) ) + ->andReturn( 'class="uk-article-title"' ); + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( true ); + + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '

    ', $actual ); + } + + /** + * Test beans_open_markup() should return a built HTML element when no before or prepend hooks are registered. + */ + public function test_should_return_built_html_when_before_or_prepend_hooks() { + Monkey\Functions\expect( 'beans_add_attributes' ) + ->once() + ->with( 'beans_archive_title', array( 'class' => 'uk-article-title' ) ) + ->andReturn( 'class="uk-article-title"' ); + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); + Monkey\Functions\expect( '_beans_render_action' ) + ->once() + ->with( 'beans_archive_title_before_markup' ) + ->andReturn( '' ) + ->andAlsoExpectIt() + ->once() + ->with( 'beans_archive_title_prepend_markup' ) + ->andReturn( '' ); + + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $expected = <<

    +EOB; + $this->assertSame( $expected, $actual ); + } + + /** + * Test beans_open_markup() should return a built self-closing HTML element when the global + * $_temp_beans_selfclose_markup is set to true. + */ + public function test_should_return_built_self_closing_html_when_selfclose_markup_is_true() { + $args = array( + 'width' => 800, + 'height' => 500, + 'src' => 'http://example.com/image.png', + 'alt' => 'Some image', + 'itemprop' => 'image', + ); + + Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); + Monkey\Functions\expect( 'beans_add_attributes' ) + ->twice() + ->with( 'beans_post_image_item', $args, 'http://example.com/image.png' ) + ->andReturnUsing( function( $id, $attributes ) { + return $this->convert_attributes_into_html( $attributes ); + } ); + + // Run it with development mode off. + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); + global $_temp_beans_selfclose_markup; + $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + + $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); + $expected = << +EOB; + $this->assertSame( $expected, $actual ); + + // Run it with development mode on. + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( true ); + global $_temp_beans_selfclose_markup; + $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + + $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); + $expected = << +EOB; + $this->assertSame( $expected, $actual ); + } +} From 36b24a8ca23aa792c2e850126f8832bc9413324e Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 20 Mar 2018 19:42:46 -0400 Subject: [PATCH 361/800] Fixed integration tests --- tests/phpunit/integration/api/fields/beansField.php | 3 ++- .../integration/api/fields/types/beansFieldActivation.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 41fcd20e..fb26c15a 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -192,9 +192,9 @@ public function test_should_render_group_of_fields() {
    Group of fields
    - +
    @@ -289,6 +289,7 @@ public function test_full_integration_should_render_group_of_fields() {
    +
    + EOB; // Run the test. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); @@ -85,6 +86,7 @@ public function test_should_render_activation_field_with_attributes_when_given() $expected = << + EOB; // Run the test. $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); From 29ba91af731fc9aad7d62f63daf514d7bed84977 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 19:20:26 -0500 Subject: [PATCH 362/800] Added beans_open_markup integration tests. --- .../integration/api/html/beansOpenMarkup.php | 176 ++++++++++++++++++ .../phpunit/unit/api/html/beansOpenMarkup.php | 30 ++- 2 files changed, 196 insertions(+), 10 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beansOpenMarkup.php diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php new file mode 100644 index 00000000..fd60120f --- /dev/null +++ b/tests/phpunit/integration/api/html/beansOpenMarkup.php @@ -0,0 +1,176 @@ +assertNull( beans_open_markup( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) ); + } + + /** + * Test beans_open_markup() should fire "{$id}_before_markup" hooks and include the content in the returned HTML. + */ + public function test_should_fire_before_markup_hooks_and_include_content_in_returned_html() { + Monkey\Functions\expect( '__beans_render_title_before_markup' ) + ->once() + ->with( '' ) + ->andReturnUsing( function() { + echo ''; + } ); + add_action( 'beans_archive_title_before_markup', '__beans_render_title_before_markup' ); + + // Run the tests. + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertEquals( 1, did_action( 'beans_archive_title_before_markup' ) ); + $this->assertStringStartsWith( '', $actual ); + } + + /** + * Test beans_open_markup() should fire "{$id}_prepend_markup" hooks and include the content in the returned HTML. + */ + public function test_should_fire_prepend_markup_hooks_and_include_content_in_returned_html() { + Monkey\Functions\expect( '__beans_render_title_prepend_markup' ) + ->once() + ->with( '' ) + ->andReturnUsing( function() { + echo ''; + } ); + add_action( 'beans_archive_title_prepend_markup', '__beans_render_title_prepend_markup' ); + + // Run the tests. + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertEquals( 1, did_action( 'beans_archive_title_prepend_markup' ) ); + $this->assertStringEndsWith( '', $actual ); + } + + /** + * Test beans_open_markup() should fire _beans_render_action() for the "_after_markup" hooks when the global + * $_temp_beans_selfclose_markup is set to true. + */ + public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { + Monkey\Functions\expect( '__beans_render_title_after_markup' ) + ->once() + ->with( '' ) + ->andReturnUsing( function() { + echo ''; + } ); + add_action( 'beans_archive_title_after_markup', '__beans_render_title_after_markup' ); + + global $_temp_beans_selfclose_markup; + $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + + // Run the tests. + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); + $this->assertStringEndsWith( '', $actual ); + + // Check that the global was unset. + $this->assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + } + + /** + * Test beans_open_markup() should return built HTML when no before or prepend hooks are registered. + */ + public function test_should_return_built_html_when_before_or_prepend_hooks_registered() { + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '

    ', $actual ); + $this->assertEquals( 0, did_action( 'beans_archive_title_before_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_archive_title_prepend_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); + } + + /** + * Test beans_open_markup() should return built HTML with the "data-markup-id" when in development mode. + */ + public function test_should_return_built_html_with_data_markup_id_when_in_dev_mode() { + add_option( 'beans_dev_mode', 1 ); + + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '

    ', $actual ); + } + + /** + * Test beans_open_markup() should return a built HTML element when there are before and prepend hooks are + * registered. + */ + public function test_should_return_built_html_when_before_or_prepend_hooks() { + add_action( 'beans_archive_title_before_markup', function() { + echo ''; + } ); + add_action( 'beans_archive_title_prepend_markup', function() { + echo ''; + } ); + + // Run the tests. + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $expected = <<

    +EOB; + + $this->assertSame( $expected, $actual ); + $this->assertEquals( 1, did_action( 'beans_archive_title_before_markup' ) ); + $this->assertEquals( 1, did_action( 'beans_archive_title_prepend_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); + } + + /** + * Test beans_open_markup() should return a built self-closing HTML element when the global + * $_temp_beans_selfclose_markup is set to true. + */ + public function test_should_return_built_self_closing_html_when_selfclose_markup_is_true() { + $args = array( + 'width' => 800, + 'height' => 500, + 'src' => 'http://example.com/image.png', + 'alt' => 'Some image', + 'itemprop' => 'image', + ); + + // Run it with development mode off. + global $_temp_beans_selfclose_markup; + $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + + $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); + $expected = << +EOB; + $this->assertSame( $expected, $actual ); + + // Run it with development mode on. + add_option( 'beans_dev_mode', 1 ); + global $_temp_beans_selfclose_markup; + $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + + $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); + $expected = << +EOB; + $this->assertSame( $expected, $actual ); + $this->assertEquals( 0, did_action( 'beans_post_image_item_before_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_post_image_item_prepend_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_post_image_item_after_markup' ) ); + } +} diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php index 2860f06b..94e7b7ca 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkup.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkup.php @@ -36,23 +36,33 @@ public function test_should_return_null_when_tag_set_to_false() { } /** - * Test beans_open_markup() should fire _beans_render_action() for the "_before_markup" and "_prepend_markup" hooks. + * Test beans_open_markup() should fire "{$id}_before_markup" hooks and include the content in the returned HTML. */ - public function test_should_fire_beans_render_action_for_before_and_prepend_markup_hooks() { + public function test_should_fire_before_markup_hooks_and_include_content_in_returned_html() { Monkey\Functions\when( 'beans_add_attributes' )->justReturn( 'class="uk-article-title"' ); Monkey\Functions\when( '_beans_is_html_dev_mode' )->justReturn( false ); Monkey\Functions\expect( '_beans_render_action' ) ->once() ->with( 'beans_archive_title_before_markup' ) - ->andReturn( 'Fired "_before_markup" hooks' ) - ->andAlsoExpectIt() + ->andReturn( '' ); + + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertStringStartsWith( '', $actual ); + } + + /** + * Test beans_open_markup() should fire "{$id}_prepend_markup" hooks and include the content in the returned HTML. + */ + public function test_should_fire_prepend_markup_hooks_and_include_content_in_returned_html() { + Monkey\Functions\when( 'beans_add_attributes' )->justReturn( 'class="uk-article-title"' ); + Monkey\Functions\when( '_beans_is_html_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( '_beans_render_action' ) ->once() ->with( 'beans_archive_title_prepend_markup' ) - ->andReturn( 'Fired "_prepend_markup" hooks' ); + ->andReturn( '' ); $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); - $this->assertContains( 'Fired "_before_markup" hooks', $actual ); - $this->assertContains( 'Fired "_prepend_markup" hooks', $actual ); + $this->assertStringEndsWith( '', $actual ); } /** @@ -118,15 +128,15 @@ public function test_should_return_built_html_when_before_or_prepend_hooks() { Monkey\Functions\expect( '_beans_render_action' ) ->once() ->with( 'beans_archive_title_before_markup' ) - ->andReturn( '' ) + ->andReturn( '' ) ->andAlsoExpectIt() ->once() ->with( 'beans_archive_title_prepend_markup' ) - ->andReturn( '' ); + ->andReturn( '' ); $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); $expected = <<

    +

    EOB; $this->assertSame( $expected, $actual ); } From 287fe8a5f6a027c824b15497f1d57496e6060468 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 19:29:59 -0500 Subject: [PATCH 363/800] Added tests for no tag. --- .../integration/api/html/beansOpenMarkup.php | 26 +++++++++++++++++++ .../phpunit/unit/api/html/beansOpenMarkup.php | 25 ++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php index fd60120f..55b2177a 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkup.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkup.php @@ -173,4 +173,30 @@ public function test_should_return_built_self_closing_html_when_selfclose_markup $this->assertEquals( 0, did_action( 'beans_post_image_item_prepend_markup' ) ); $this->assertEquals( 0, did_action( 'beans_post_image_item_after_markup' ) ); } + + /** + * Test beans_open_markup() should return only the output from the hooked callbacks and not the HTML element when + * the tag is empty. + */ + public function test_should_return_only_hooked_callbacks_output_and_no_html_element_when_tag_is_empty() { + add_action( 'beans_archive_title_before_markup', function() { + echo ''; + } ); + add_action( 'beans_archive_title_prepend_markup', function() { + echo ''; + } ); + + // Check with an empty string. + $actual = beans_open_markup( 'beans_archive_title', '', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '', $actual ); + + // Check with false. + $actual = beans_open_markup( 'beans_archive_title', false, array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '', $actual ); + + // Check the hooks. + $this->assertEquals( 2, did_action( 'beans_archive_title_before_markup' ) ); + $this->assertEquals( 2, did_action( 'beans_archive_title_prepend_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); + } } diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php index 94e7b7ca..36ed2272 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkup.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkup.php @@ -184,4 +184,29 @@ public function test_should_return_built_self_closing_html_when_selfclose_markup EOB; $this->assertSame( $expected, $actual ); } + + /** + * Test beans_open_markup() should return only the output from the hooked callbacks and not the HTML element when + * the tag is empty. + */ + public function test_should_return_only_hooked_callbacks_output_and_no_html_element_when_tag_is_empty() { + Monkey\Functions\expect( 'beans_add_attributes' )->never(); + Monkey\Functions\expect( '_beans_is_html_dev_mode' )->never(); + Monkey\Functions\expect( '_beans_render_action' ) + ->twice() + ->with( 'beans_archive_title_before_markup' ) + ->andReturn( '' ) + ->andAlsoExpectIt() + ->twice() + ->with( 'beans_archive_title_prepend_markup' ) + ->andReturn( '' ); + + // Check with an empty string. + $actual = beans_open_markup( 'beans_archive_title', '', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '', $actual ); + + // Check with false. + $actual = beans_open_markup( 'beans_archive_title', false, array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '', $actual ); + } } From 504377618a9f898525a7fc77d349457e926e20e4 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 19:41:41 -0500 Subject: [PATCH 364/800] Added tests for beans_open_markup_e. --- .../integration/api/html/beansOpenMarkupE.php | 85 +++++++++++++++++++ .../unit/api/html/beansOpenMarkupE.php | 54 ++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 tests/phpunit/integration/api/html/beansOpenMarkupE.php create mode 100644 tests/phpunit/unit/api/html/beansOpenMarkupE.php diff --git a/tests/phpunit/integration/api/html/beansOpenMarkupE.php b/tests/phpunit/integration/api/html/beansOpenMarkupE.php new file mode 100644 index 00000000..63a61866 --- /dev/null +++ b/tests/phpunit/integration/api/html/beansOpenMarkupE.php @@ -0,0 +1,85 @@ + 'uk-article-title' ) ); + $this->assertEquals( '', ob_get_clean() ); + } + + /** + * Test beans_open_markup_e() should echo the HTML element only when no before or prepend hooks are registered. + */ + public function test_should_echo_html_element_when_no_hooks_are_registered() { + ob_start(); + beans_open_markup_e( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = ob_get_clean(); + + $this->assertSame( '

    ', $actual ); + $this->assertEquals( 0, did_action( 'beans_archive_title_before_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_archive_title_prepend_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); + } + + /** + * Test beans_open_markup_e() should echo the HTML element with the "data-markup-id" when in development mode. + */ + public function test_should_echo_html_element_with_data_markup_id_when_in_dev_mode() { + add_option( 'beans_dev_mode', 1 ); + + ob_start(); + beans_open_markup_e( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '

    ', ob_get_clean() ); + } + + /** + * Test beans_open_markup_e() should echo the before, element, and prepend HTML when callbacks are registered to + * the "_before_markup" and "_prepend_markup" hooks. + */ + public function test_should_echo_before_element_prepend_html_when_before_or_prepend_hooks() { + add_action( 'beans_archive_title_before_markup', function() { + echo ''; + } ); + add_action( 'beans_archive_title_prepend_markup', function() { + echo ''; + } ); + + ob_start(); + beans_open_markup_e( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = ob_get_clean(); + + $expected = <<

    +EOB; + + // Run the tests. + $this->assertSame( $expected, $actual ); + $this->assertEquals( 1, did_action( 'beans_archive_title_before_markup' ) ); + $this->assertEquals( 1, did_action( 'beans_archive_title_prepend_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); + } +} diff --git a/tests/phpunit/unit/api/html/beansOpenMarkupE.php b/tests/phpunit/unit/api/html/beansOpenMarkupE.php new file mode 100644 index 00000000..7213d67c --- /dev/null +++ b/tests/phpunit/unit/api/html/beansOpenMarkupE.php @@ -0,0 +1,54 @@ +once() + ->with( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) + ->andReturn( null ); + + ob_start(); + beans_open_markup_e( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ); + $this->assertEquals( '', ob_get_clean() ); + } + + /** + * Test beans_open_markup_e() should echo the HTML element only when no before or prepend hooks are registered. + */ + public function test_should_echo_html_element_when_no_hooks_are_registered() { + Monkey\Functions\expect( 'beans_open_markup' ) + ->once() + ->with( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) + ->andReturn( '

    ' ); + + // Run the tests. + ob_start(); + beans_open_markup_e( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ); + $this->assertEquals( '

    ', ob_get_clean() ); + } +} From 0ac868a84394d3be271945f1508b0e8bbd29ee1c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 19:50:23 -0500 Subject: [PATCH 365/800] Improved documentation. --- lib/api/html/functions.php | 39 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 667130c6..05b7d4b3 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -77,17 +77,21 @@ function beans_remove_output( $id ) { } /** - * Register open markup and attributes by ID. + * Build the opening HTML's element markup. This function fires 3 separate hooks: * - * The Beans HTML "markups" and "attributes" functions make it really easy to modify, replace, extend, - * remove or hook into registered markup or attributes. + * 1. "{id}_before_markup" - which fires first before the element. + * 2. "{$id}_prepend_markup" - which fires after the element when the element is not self-closing. + * 3. "{$id}_after_markup" - which fires after the element when the element is self-closing. * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. + * These 3 hooks along with the attributes make it really easy to modify, replace, extend, remove or hook the + * markup and/or attributes. * - * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). + * When in development mode, the "data-markup-id" attribute is added to the element, i.e. making it + * easier to identify the content ID when inspecting an element in your web browser. * - * Note: You can pass additional arguments to the functions that are hooked to $id. + * Notes: + * 1. Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). + * 2. You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * @@ -102,7 +106,7 @@ function beans_remove_output( $id ) { * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. * - * @return string The output. + * @return string|void */ function beans_open_markup( $id, $tag, $attributes = array() ) { global $_temp_beans_selfclose_markup; @@ -131,7 +135,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { // Remove function $tag argument. unset( $args[1] ); - // Set before action id. + // Set before action hook. $args[0] = $id . '_before_markup'; $output = call_user_func_array( '_beans_render_action', $args ); @@ -141,29 +145,20 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_temp_beans_selfclose_markup ? '/' : '' ) . '>'; } - // Set after action id. + // Set after action hook. $args[0] = $id . ( $_temp_beans_selfclose_markup ? '_after_markup' : '_prepend_markup' ); $output .= call_user_func_array( '_beans_render_action', $args ); - // Reset temp selfclose global to reduce memory usage. + // Reset the global variable to reduce memory usage. unset( $GLOBALS['_temp_beans_selfclose_markup'] ); return $output; } /** - * Echo open markup and attributes registered by ID. - * - * The Beans HTML "markups" and "attributes" functions make it really easy to modify, replace, extend, - * remove or hook into registered markup or attributes. - * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. - * - * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). - * - * Note: You can pass additional arguments to the functions that are hooked to $id. + * Echo the opening HTML's element markup. This function is a wrapper for {@see beans_open_markup()}. See + * {@see beans_open_markup()} for more details. * * @since 1.4.0 * From 08ad606894cf8c91f17104b23e8dc10ff61f6c44 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 19:59:37 -0500 Subject: [PATCH 366/800] Refactored to optimize. --- lib/api/html/functions.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 05b7d4b3..94c00396 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -109,21 +109,17 @@ function beans_remove_output( $id ) { * @return string|void */ function beans_open_markup( $id, $tag, $attributes = array() ) { - global $_temp_beans_selfclose_markup; - $args = func_get_args(); $attributes_args = $args; // Set markup tag filter id. $args[0] = $id . '_markup'; - if ( isset( $args[2] ) ) { + // If there are attributes, remove them from $args. + if ( $attributes ) { unset( $args[2] ); } - // Remove function $tag argument. - unset( $attributes_args[1] ); - // Filter the tag. $tag = call_user_func_array( 'beans_apply_filters', $args ); @@ -132,23 +128,24 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { return; } - // Remove function $tag argument. + global $_temp_beans_selfclose_markup; + + // Remove function $tag arguments. unset( $args[1] ); + unset( $attributes_args[1] ); - // Set before action hook. + // Set and then do the before action hook. $args[0] = $id . '_before_markup'; - - $output = call_user_func_array( '_beans_render_action', $args ); + $output = call_user_func_array( '_beans_render_action', $args ); // Don't output the tag if empty, the before and after actions still run. if ( $tag ) { $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_temp_beans_selfclose_markup ? '/' : '' ) . '>'; } - // Set after action hook. + // Set and then fire the after action hook. $args[0] = $id . ( $_temp_beans_selfclose_markup ? '_after_markup' : '_prepend_markup' ); - - $output .= call_user_func_array( '_beans_render_action', $args ); + $output .= call_user_func_array( '_beans_render_action', $args ); // Reset the global variable to reduce memory usage. unset( $GLOBALS['_temp_beans_selfclose_markup'] ); From 36e824bdff306b5406946524b18a7abd27ac0627 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 20:06:27 -0500 Subject: [PATCH 367/800] Improved comments. --- tests/phpunit/integration/api/html/beansRemoveOutput.php | 4 ++-- tests/phpunit/unit/api/html/beansRemoveOutput.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansRemoveOutput.php b/tests/phpunit/integration/api/html/beansRemoveOutput.php index 53eecf71..b7afea07 100644 --- a/tests/phpunit/integration/api/html/beansRemoveOutput.php +++ b/tests/phpunit/integration/api/html/beansRemoveOutput.php @@ -24,7 +24,7 @@ class Tests_BeansRemoveOutput extends HTML_Test_Case { /** - * Test beans_remove_output() should return an _Beans_Anonymous_Filters instance. + * Test beans_remove_output() should return a _Beans_Anonymous_Filters instance. */ public function test_should_return_anonymous_filter_instance() { $this->assertInstanceOf( _Beans_Anonymous_Filters::class, beans_remove_output( 'beans_post_meta_item_date' ) ); @@ -33,7 +33,7 @@ public function test_should_return_anonymous_filter_instance() { /** * Test beans_remove_output() should register callback to the "{$id}_output" filter hook. */ - public function test_should_return_register_callback_to_id_output() { + public function test_should_return_register_callback_to_id_output_filter() { $anonymous_filter = beans_remove_output( 'beans_post_meta_item_date' ); $this->assertSame( 99999999, has_filter( 'beans_post_meta_item_date_output', array( diff --git a/tests/phpunit/unit/api/html/beansRemoveOutput.php b/tests/phpunit/unit/api/html/beansRemoveOutput.php index 0796b09a..84b15cc6 100644 --- a/tests/phpunit/unit/api/html/beansRemoveOutput.php +++ b/tests/phpunit/unit/api/html/beansRemoveOutput.php @@ -63,7 +63,7 @@ public function test_should_call_beans_add_filter_to_register_callback() { beans_remove_output( $id ); } - // Tests are focused above on ensuring beans_apply_filters() is called with the right arguments. + // Tests are focused above on ensuring beans_add_filter() is called with the right arguments. $this->assertTrue( true ); } } From 478598781aa65008e3241d8c0a34573a68d89e50 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 20:15:37 -0500 Subject: [PATCH 368/800] Fixed formatting. --- lib/api/html/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 94c00396..f5800938 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -145,7 +145,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { // Set and then fire the after action hook. $args[0] = $id . ( $_temp_beans_selfclose_markup ? '_after_markup' : '_prepend_markup' ); - $output .= call_user_func_array( '_beans_render_action', $args ); + $output .= call_user_func_array( '_beans_render_action', $args ); // Reset the global variable to reduce memory usage. unset( $GLOBALS['_temp_beans_selfclose_markup'] ); From c3af5b063cbe45fcca38667ad8a4ede353a0dba8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 20 Mar 2018 22:57:49 -0500 Subject: [PATCH 369/800] Fixed documentation and test naming. --- lib/api/html/functions.php | 6 +++--- tests/phpunit/integration/api/html/beansOpenMarkup.php | 9 ++++----- .../phpunit/integration/api/html/beansOpenMarkupE.php | 6 +++--- tests/phpunit/unit/api/html/beansOpenMarkup.php | 10 +++++----- tests/phpunit/unit/api/html/beansOpenMarkupE.php | 6 +++--- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index f5800938..d5db7b0d 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -77,7 +77,7 @@ function beans_remove_output( $id ) { } /** - * Build the opening HTML's element markup. This function fires 3 separate hooks: + * Build the opening HTML element's markup. This function fires 3 separate hooks: * * 1. "{id}_before_markup" - which fires first before the element. * 2. "{$id}_prepend_markup" - which fires after the element when the element is not self-closing. @@ -134,7 +134,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { unset( $args[1] ); unset( $attributes_args[1] ); - // Set and then do the before action hook. + // Set and then fire the before action hook. $args[0] = $id . '_before_markup'; $output = call_user_func_array( '_beans_render_action', $args ); @@ -154,7 +154,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { } /** - * Echo the opening HTML's element markup. This function is a wrapper for {@see beans_open_markup()}. See + * Echo the opening HTML element's markup. This function is a wrapper for {@see beans_open_markup()}. See * {@see beans_open_markup()} for more details. * * @since 1.4.0 diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php index 55b2177a..ea511acb 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkup.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkup.php @@ -92,9 +92,9 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { } /** - * Test beans_open_markup() should return built HTML when no before or prepend hooks are registered. + * Test beans_open_markup() should return the built HTML element when before or prepend hooks are not registered. */ - public function test_should_return_built_html_when_before_or_prepend_hooks_registered() { + public function test_should_return_built_html_when_before_or_prepend_hooks_not_registered() { $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); $this->assertSame( '

    ', $actual ); $this->assertEquals( 0, did_action( 'beans_archive_title_before_markup' ) ); @@ -103,7 +103,7 @@ public function test_should_return_built_html_when_before_or_prepend_hooks_regis } /** - * Test beans_open_markup() should return built HTML with the "data-markup-id" when in development mode. + * Test beans_open_markup() should return the built HTML element with the "data-markup-id" when in development mode. */ public function test_should_return_built_html_with_data_markup_id_when_in_dev_mode() { add_option( 'beans_dev_mode', 1 ); @@ -113,8 +113,7 @@ public function test_should_return_built_html_with_data_markup_id_when_in_dev_mo } /** - * Test beans_open_markup() should return a built HTML element when there are before and prepend hooks are - * registered. + * Test beans_open_markup() should return the built HTML when before and prepend hooks are registered. */ public function test_should_return_built_html_when_before_or_prepend_hooks() { add_action( 'beans_archive_title_before_markup', function() { diff --git a/tests/phpunit/integration/api/html/beansOpenMarkupE.php b/tests/phpunit/integration/api/html/beansOpenMarkupE.php index 63a61866..a6ef0b6d 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkupE.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkupE.php @@ -25,16 +25,16 @@ class Tests_BeansOpenMarkupE extends HTML_Test_Case { /** * Test beans_open_markup_e() should echo empty when the tag is set to null. */ - public function test_should_echo_empty_when_tag_set_to_false() { + public function test_should_echo_empty_when_tag_set_to_null() { ob_start(); beans_open_markup_e( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ); $this->assertEquals( '', ob_get_clean() ); } /** - * Test beans_open_markup_e() should echo the HTML element only when no before or prepend hooks are registered. + * Test beans_open_markup_e() should echo the HTML element only when before or prepend hooks are not registered. */ - public function test_should_echo_html_element_when_no_hooks_are_registered() { + public function test_should_echo_html_element_when_hooks_not_registered() { ob_start(); beans_open_markup_e( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); $actual = ob_get_clean(); diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php index 36ed2272..57e8e4bf 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkup.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkup.php @@ -26,7 +26,7 @@ class Tests_BeansOpenMarkup extends HTML_Test_Case { /** * Test beans_open_markup() should return null when the tag is set to null. */ - public function test_should_return_null_when_tag_set_to_false() { + public function test_should_return_null_when_tag_set_to_null() { Monkey\Functions\expect( 'beans_apply_filters' ) ->once() ->with( 'beans_archive_title_markup', null ) @@ -87,9 +87,9 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { } /** - * Test beans_open_markup() should return built HTML when no before or prepend hooks are registered. + * Test beans_open_markup() should return the built HTML element when before or prepend hooks are not registered. */ - public function test_should_return_built_html_when_before_or_prepend_hooks_registered() { + public function test_should_return_built_html_when_before_or_prepend_hooks_not_registered() { Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); Monkey\Functions\expect( 'beans_add_attributes' ) ->once() @@ -102,7 +102,7 @@ public function test_should_return_built_html_when_before_or_prepend_hooks_regis } /** - * Test beans_open_markup() should return built HTML with the "data-markup-id" when in development mode. + * Test beans_open_markup() should return the built HTML element with the "data-markup-id" when in development mode. */ public function test_should_return_built_html_with_data_markup_id_when_in_dev_mode() { Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); @@ -117,7 +117,7 @@ public function test_should_return_built_html_with_data_markup_id_when_in_dev_mo } /** - * Test beans_open_markup() should return a built HTML element when no before or prepend hooks are registered. + * Test beans_open_markup() should return a built HTML when before or prepend hooks are registered. */ public function test_should_return_built_html_when_before_or_prepend_hooks() { Monkey\Functions\expect( 'beans_add_attributes' ) diff --git a/tests/phpunit/unit/api/html/beansOpenMarkupE.php b/tests/phpunit/unit/api/html/beansOpenMarkupE.php index 7213d67c..970b37d5 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkupE.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkupE.php @@ -26,7 +26,7 @@ class Tests_BeansOpenMarkupE extends HTML_Test_Case { /** * Test beans_open_markup_e() should echo empty when the tag is set to null. */ - public function test_should_echo_empty_when_tag_set_to_false() { + public function test_should_echo_empty_when_tag_set_to_null() { Monkey\Functions\expect( 'beans_open_markup' ) ->once() ->with( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) @@ -38,9 +38,9 @@ public function test_should_echo_empty_when_tag_set_to_false() { } /** - * Test beans_open_markup_e() should echo the HTML element only when no before or prepend hooks are registered. + * Test beans_open_markup_e() should echo the HTML element only when before or prepend hooks are not registered. */ - public function test_should_echo_html_element_when_no_hooks_are_registered() { + public function test_should_echo_html_element_when_hooks_not_registered() { Monkey\Functions\expect( 'beans_open_markup' ) ->once() ->with( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) From f4d13b5764b4959957ff556d7f5ec0b9391a4a5f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 10:30:28 -0500 Subject: [PATCH 370/800] Added tests. --- .../api/html/beansRemoveMarkup.php | 73 +++++++++++++++++++ .../unit/api/html/beansRemoveMarkup.php | 64 ++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 tests/phpunit/integration/api/html/beansRemoveMarkup.php create mode 100644 tests/phpunit/unit/api/html/beansRemoveMarkup.php diff --git a/tests/phpunit/integration/api/html/beansRemoveMarkup.php b/tests/phpunit/integration/api/html/beansRemoveMarkup.php new file mode 100644 index 00000000..b1a1d09d --- /dev/null +++ b/tests/phpunit/integration/api/html/beansRemoveMarkup.php @@ -0,0 +1,73 @@ +assertInstanceOf( _Beans_Anonymous_Filters::class, beans_remove_markup( 'beans_archive_title' ) ); + } + + /** + * Test beans_remove_markup() should register callback to the "{$id}_markup" filter hook. + */ + public function test_should_return_register_callback_to_id_output_filter() { + $anonymous_filter = beans_remove_markup( 'beans_archive_title' ); + + $this->assertSame( 10, has_filter( 'beans_archive_title_markup', array( + $anonymous_filter, + 'callback', + ) ) ); + } + + /** + * Test beans_remove_markup() should remove the markup's element when $remove_actions is false (default behavior). + */ + public function test_should_remove_only_element_when_remove_actions_is_false() { + beans_remove_markup( 'beans_archive_title' ); + + // Let's test it out by running the markup for this ID. + add_action( 'beans_archive_title_before_markup', function() { + echo ''; + } ); + add_action( 'beans_archive_title_prepend_markup', function() { + echo ''; + } ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '', $actual ); + $this->assertSame( '', beans_close_markup( 'beans_archive_title', 'h1' ) ); + } + + /** + * Test beans_remove_markup() should remove the markup's element when $remove_actions is true. + */ + public function test_should_remove_html_markup_when_remove_actions_is_true() { + beans_remove_markup( 'beans_archive_title' ); + + // Let's test it out by running the markup for this ID. + $this->assertSame( '', beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ) ); + $this->assertSame( '', beans_close_markup( 'beans_archive_title', 'h1' ) ); + } +} diff --git a/tests/phpunit/unit/api/html/beansRemoveMarkup.php b/tests/phpunit/unit/api/html/beansRemoveMarkup.php new file mode 100644 index 00000000..93b48ac3 --- /dev/null +++ b/tests/phpunit/unit/api/html/beansRemoveMarkup.php @@ -0,0 +1,64 @@ +alias( function( $hook, $value ) { + return new Anonymous_Filter_Stub( $hook, $value, 10 ); + } ); + + $this->assertInstanceOf( Anonymous_Filter_Stub::class, beans_remove_markup( 'beans_archive_title' ) ); + } + + /** + * Test beans_remove_markup() should call beans_add_filter() to register the callback for the remove process. + */ + public function test_should_call_beans_add_filter_to_register_callback() { + Monkey\Functions\expect( 'beans_add_filter' ) + ->once() + ->with( 'beans_archive_title_markup', false ); + beans_remove_markup( 'beans_archive_title' ); + + Monkey\Functions\expect( 'beans_add_filter' ) + ->once() + ->with( 'beans_archive_title_markup', null ); + beans_remove_markup( 'beans_archive_title', true ); + + // Tests are focused above on ensuring beans_add_filter() is called with the right arguments. + $this->assertTrue( true ); + } +} From 272cb30b19dc5a22e1fe91b31cdbe0534c9300d1 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 10:34:33 -0500 Subject: [PATCH 371/800] Improved documentation. --- lib/api/html/functions.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 708a0c32..7e8db899 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -333,21 +333,18 @@ function beans_modify_markup( $id, $markup, $priority = 10, $args = 1 ) { } /** - * Remove markup. + * Remove the markup. * * This function will automatically remove the opening and the closing HTML tag. If the markup is self-closing, * the HTML tag will be removed accordingly. * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. - * * @since 1.0.0 * - * @param string $id The markup ID. - * @param bool $remove_actions Optional. Whether elements attached to a markup should be removed or not. This must be - * used with absolute caution. + * @param string $id The target markup's ID. + * @param bool $remove_actions Optional. When true, the markup including the before and prepend/after hooks will be + * removed. * - * @return bool Will always return true. + * @return bool|_Beans_Anonymous_Filters */ function beans_remove_markup( $id, $remove_actions = false ) { From c59f650d003d1044aacddfea47f70d09e801fa1e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 10:37:05 -0500 Subject: [PATCH 372/800] Refactored to simplify. --- lib/api/html/functions.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 7e8db899..d7c4f4a7 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -342,17 +342,12 @@ function beans_modify_markup( $id, $markup, $priority = 10, $args = 1 ) { * * @param string $id The target markup's ID. * @param bool $remove_actions Optional. When true, the markup including the before and prepend/after hooks will be - * removed. + * removed; else, only the HTML element is removed. * * @return bool|_Beans_Anonymous_Filters */ function beans_remove_markup( $id, $remove_actions = false ) { - - if ( $remove_actions ) { - return beans_add_filter( $id . '_markup', null ); - } - - return beans_add_filter( $id . '_markup', false ); + return beans_add_filter( $id . '_markup', $remove_actions ? null : false ); } /** From 31d91fc7f4cfad33339a0ead5bbecb568afe08c9 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 12:11:29 -0500 Subject: [PATCH 373/800] Refactored to optimize the function. 1. Bail out if there are no actions to render. 2. Instead of calling another function, do the rendering and buffer work here. --- lib/api/actions/functions.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 3a6a2bae..53d75b4e 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -721,16 +721,18 @@ function _beans_render_action( $hook ) { * @param array $args Array of arguments. * @param string $output The output to be updated. * - * @return string|bool + * @return string */ function _beans_when_has_action_do_render( array $args, &$output = '' ) { - if ( has_action( $args[0] ) ) { - $output .= call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); - return $output; + if ( ! has_action( $args[0] ) ) { + return false; } - return false; + ob_start(); + call_user_func_array( 'do_action', $args ); + $output .= ob_get_clean(); + return $output; } /** From e6eb621c0cda7c0f5a8df88a3272a3e49ae350b5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 12:14:04 -0500 Subject: [PATCH 374/800] Improved documentation. --- lib/api/actions/functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 53d75b4e..5d3617b1 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -134,6 +134,7 @@ function beans_modify_action( $id, $hook = null, $callback = null, $priority = n // Overwrite the modified parameters. $action = array_merge( $current_action, $action ); + return add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } @@ -712,7 +713,8 @@ function _beans_render_action( $hook ) { } /** - * Calls beans_render_function when the hook is registered. + * Render all hooked action callbacks by firing {@see do_action()}. The output is captured in the buffer and then + * returned. * * @since 1.5.0 * @ignore @@ -721,7 +723,7 @@ function _beans_render_action( $hook ) { * @param array $args Array of arguments. * @param string $output The output to be updated. * - * @return string + * @return string|bool */ function _beans_when_has_action_do_render( array $args, &$output = '' ) { @@ -732,6 +734,7 @@ function _beans_when_has_action_do_render( array $args, &$output = '' ) { ob_start(); call_user_func_array( 'do_action', $args ); $output .= ob_get_clean(); + return $output; } From 5944ba7c5b15c09de9ab6ac5a7cc3541502b4250 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 21 Mar 2018 13:41:47 -0400 Subject: [PATCH 375/800] Fixed integration test names and docblocks --- .../api/fields/types/beansFieldLabel.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php index 1a412869..a0035ea8 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php @@ -84,7 +84,7 @@ public function test_should_render_field_label() { /** * Test beans_field_label() should not render the radio field's group label. */ - public function test_should_render_radio_group_header() { + public function test_should_not_render_radio_group_label() { $field = $this->merge_field_with_default( array( 'id' => 'beans_layout', 'label' => 'Layout', @@ -121,7 +121,7 @@ public function test_should_render_radio_group_header() { /** * Test beans_field_label() should not render the group field's label. */ - public function test_should_render_group_header() { + public function test_should_not_render_group_label() { $field = array( 'id' => 'beans_group_test', 'label' => 'Group of fields', @@ -162,4 +162,23 @@ public function test_should_render_group_header() { $this->assertEmpty( $this->format_the_html( $html ) ); } + + /** + * Test beans_field_label() should not render the activation field's label. + */ + public function test_should_not_render_activation_field_label() { + $field = array( + 'id' => 'beans_group_activation_test', + 'label' => 'Activate', + 'type' => 'activation', + 'default' => false, + ); + + // Run the function and grab the HTML out of the buffer. + ob_start(); + beans_field_label( $field ); + $html = ob_get_clean(); + + $this->assertEmpty( $this->format_the_html( $html ) ); + } } From d3b33786893db3db7bae9c6c78e4bb3a1e1e725d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 12:54:28 -0500 Subject: [PATCH 376/800] Fixed documentation. --- lib/api/html/functions.php | 2 +- tests/phpunit/integration/api/html/beansRemoveMarkup.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index d7c4f4a7..51f88446 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -342,7 +342,7 @@ function beans_modify_markup( $id, $markup, $priority = 10, $args = 1 ) { * * @param string $id The target markup's ID. * @param bool $remove_actions Optional. When true, the markup including the before and prepend/after hooks will be - * removed; else, only the HTML element is removed. + * removed. When false, only the HTML element will be removed. * * @return bool|_Beans_Anonymous_Filters */ diff --git a/tests/phpunit/integration/api/html/beansRemoveMarkup.php b/tests/phpunit/integration/api/html/beansRemoveMarkup.php index b1a1d09d..1105a200 100644 --- a/tests/phpunit/integration/api/html/beansRemoveMarkup.php +++ b/tests/phpunit/integration/api/html/beansRemoveMarkup.php @@ -31,9 +31,9 @@ public function test_should_return_anonymous_filter_instance() { } /** - * Test beans_remove_markup() should register callback to the "{$id}_markup" filter hook. + * Test beans_remove_markup() should register a callback to the "{$id}_markup" filter hook. */ - public function test_should_return_register_callback_to_id_output_filter() { + public function test_should_return_register_callback_to_id_markup_filter() { $anonymous_filter = beans_remove_markup( 'beans_archive_title' ); $this->assertSame( 10, has_filter( 'beans_archive_title_markup', array( @@ -61,7 +61,7 @@ public function test_should_remove_only_element_when_remove_actions_is_false() { } /** - * Test beans_remove_markup() should remove the markup's element when $remove_actions is true. + * Test beans_remove_markup() should remove the HTML markup when $remove_actions is true. */ public function test_should_remove_html_markup_when_remove_actions_is_true() { beans_remove_markup( 'beans_archive_title' ); From 414a7daa7aaf15e3d2090c8064fb6f70f2c33b6e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 13:32:24 -0500 Subject: [PATCH 377/800] Fixed test name. --- tests/phpunit/integration/api/html/beansRemoveMarkup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/integration/api/html/beansRemoveMarkup.php b/tests/phpunit/integration/api/html/beansRemoveMarkup.php index 1105a200..1fc5c6e4 100644 --- a/tests/phpunit/integration/api/html/beansRemoveMarkup.php +++ b/tests/phpunit/integration/api/html/beansRemoveMarkup.php @@ -33,7 +33,7 @@ public function test_should_return_anonymous_filter_instance() { /** * Test beans_remove_markup() should register a callback to the "{$id}_markup" filter hook. */ - public function test_should_return_register_callback_to_id_markup_filter() { + public function test_should_register_callback_to_id_markup_filter() { $anonymous_filter = beans_remove_markup( 'beans_archive_title' ); $this->assertSame( 10, has_filter( 'beans_archive_title_markup', array( From 0504822372d13102e57c4c9dd74000f19e3f1ef0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 17:01:29 -0500 Subject: [PATCH 378/800] Added beans_close_markup unit tests. --- .../unit/api/html/beansCloseMarkup.php | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 tests/phpunit/unit/api/html/beansCloseMarkup.php diff --git a/tests/phpunit/unit/api/html/beansCloseMarkup.php b/tests/phpunit/unit/api/html/beansCloseMarkup.php new file mode 100644 index 00000000..a8ea6291 --- /dev/null +++ b/tests/phpunit/unit/api/html/beansCloseMarkup.php @@ -0,0 +1,122 @@ +once() + ->with( 'beans_archive_title_markup', null ) + ->andReturnNull(); + + $this->assertNull( beans_close_markup( 'beans_archive_title', null ) ); + } + + /** + * Test beans_close_markup() should fire "{$id}_append_markup" hooks and include the content in the returned HTML. + */ + public function test_should_fire_append_markup_hooks_and_include_content_in_returned_html() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\expect( '_beans_render_action' ) + ->once() + ->with( 'beans_archive_title_append_markup' ) + ->andReturn( '' ); + + $actual = beans_close_markup( 'beans_archive_title', 'h1' ); + $this->assertStringStartsWith( '', $actual ); + } + + /** + * Test beans_close_markup() should fire "{$id}_after_markup" hooks and include the content in the returned HTML. + */ + public function test_should_fire_after_markup_hooks_and_include_content_in_returned_html() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\expect( '_beans_render_action' ) + ->once() + ->with( 'beans_archive_title_after_markup' ) + ->andReturn( '' ); + + $actual = beans_close_markup( 'beans_archive_title', 'h1' ); + $this->assertStringEndsWith( '', $actual ); + } + + /** + * Test beans_close_markup() should return the built HTML element when append or after hooks are not registered. + */ + public function test_should_return_built_html_when_append_or_after_hooks_not_registered() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); + + $this->assertSame( '

    ', beans_close_markup( 'beans_archive_title', 'h1' ) ); + } + + /** + * Test beans_open_markup() should return a built HTML when append or after hooks are registered. + */ + public function test_should_return_built_html_when_append_or_after_hooks() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\expect( '_beans_render_action' ) + ->once() + ->with( 'beans_archive_title_append_markup' ) + ->ordered() + ->andReturn( '' ) + ->andAlsoExpectIt() + ->once() + ->with( 'beans_archive_title_after_markup' ) + ->ordered() + ->andReturn( '' ); + + $actual = beans_close_markup( 'beans_archive_title', 'h1' ); + $expected = <<

    +EOB; + $this->assertSame( $expected, $actual ); + } + + /** + * Test beans_close_markup() should return only the output from the hooked callbacks and not the HTML element when + * the tag is empty. + */ + public function test_should_return_only_hooked_callbacks_output_and_no_html_element_when_tag_is_empty() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\expect( '_beans_render_action' ) + ->twice() + ->with( 'beans_archive_title_append_markup' ) + ->andReturn( '' ) + ->andAlsoExpectIt() + ->twice() + ->with( 'beans_archive_title_after_markup' ) + ->andReturn( '' ); + + // Check with an empty string. + $actual = beans_close_markup( 'beans_archive_title', '' ); + $this->assertSame( '', $actual ); + + // Check with false. + $actual = beans_close_markup( 'beans_archive_title', false ); + $this->assertSame( '', $actual ); + } +} From 9b30357dc57ec64e959dd12634aa5625b4da72d1 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 17:07:23 -0500 Subject: [PATCH 379/800] Added beans_close_markup integration tests. --- .../integration/api/html/beansCloseMarkup.php | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 tests/phpunit/integration/api/html/beansCloseMarkup.php diff --git a/tests/phpunit/integration/api/html/beansCloseMarkup.php b/tests/phpunit/integration/api/html/beansCloseMarkup.php new file mode 100644 index 00000000..fca544b5 --- /dev/null +++ b/tests/phpunit/integration/api/html/beansCloseMarkup.php @@ -0,0 +1,125 @@ +assertNull( beans_close_markup( 'beans_archive_title', null ) ); + } + + /** + * Test beans_close_markup() should fire "{$id}_append_markup" hooks and include the content in the returned HTML. + */ + public function test_should_fire_append_markup_hooks_and_include_content_in_returned_html() { + Monkey\Functions\expect( '__beans_render_title_append_markup' ) + ->once() + ->with( '' ) + ->andReturnUsing( function() { + echo ''; + } ); + add_action( 'beans_archive_title_append_markup', '__beans_render_title_append_markup' ); + + // Run the tests. + $actual = beans_close_markup( 'beans_archive_title', 'h1' ); + $this->assertEquals( 1, did_action( 'beans_archive_title_append_markup' ) ); + $this->assertStringStartsWith( '', $actual ); + } + + /** + * Test beans_close_markup() should fire "{$id}_after_markup" hooks and include the content in the returned HTML. + */ + public function test_should_fire_after_markup_hooks_and_include_content_in_returned_html() { + Monkey\Functions\expect( '__beans_render_title_after_markup' ) + ->once() + ->with( '' ) + ->andReturnUsing( function() { + echo ''; + } ); + add_action( 'beans_archive_title_after_markup', '__beans_render_title_after_markup' ); + + // Run the tests. + $actual = beans_close_markup( 'beans_archive_title', 'h1' ); + $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); + $this->assertStringEndsWith( '', $actual ); + } + + /** + * Test beans_close_markup() should return the built HTML element when append or after hooks are not registered. + */ + public function test_should_return_built_html_when_append_or_after_hooks_not_registered() { + $actual = beans_close_markup( 'beans_archive_title', 'h1' ); + $this->assertSame( '

    ', $actual ); + $this->assertEquals( 0, did_action( 'beans_archive_title_append_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); + } + + /** + * Test beans_close_markup() should return a built HTML when append or after hooks are registered. + */ + public function test_should_return_built_html_when_append_or_after_hooks() { + add_action( 'beans_archive_title_append_markup', function() { + echo ''; + } ); + add_action( 'beans_archive_title_after_markup', function() { + echo ''; + } ); + + // Run the tests. + $actual = beans_close_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $expected = <<

    +EOB; + + $this->assertSame( $expected, $actual ); + $this->assertEquals( 1, did_action( 'beans_archive_title_append_markup' ) ); + $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); + } + + /** + * Test beans_close_markup() should return only the output from the hooked callbacks and not the HTML element when + * the tag is empty. + */ + public function test_should_return_only_hooked_callbacks_output_and_no_html_element_when_tag_is_empty() { + add_action( 'beans_archive_title_append_markup', function() { + echo ''; + } ); + add_action( 'beans_archive_title_after_markup', function() { + echo ''; + } ); + + // Check with an empty string. + $actual = beans_close_markup( 'beans_archive_title', '', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '', $actual ); + + // Check with false. + $actual = beans_close_markup( 'beans_archive_title', false, array( 'class' => 'uk-article-title' ) ); + $this->assertSame( '', $actual ); + + // Check the hooks. + $this->assertEquals( 2, did_action( 'beans_archive_title_append_markup' ) ); + $this->assertEquals( 2, did_action( 'beans_archive_title_after_markup' ) ); + } +} From db28321ba848fdeeef16834a7e23822b86205364 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 17:18:32 -0500 Subject: [PATCH 380/800] Improved documentation and formatting. --- lib/api/html/functions.php | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index f18f65f9..f1b95c10 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -120,14 +120,14 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { // Filter the tag. $tag = call_user_func_array( 'beans_apply_filters', $args ); - // Stop here if the tag is set to null, the before and after actions won't run in this case. + // If the tag is set to null, bail out. if ( null === $tag ) { return; } global $_temp_beans_selfclose_markup; - // Remove function $tag arguments. + // Remove the $tag argument. unset( $args[1] ); unset( $attributes_args[1] ); @@ -135,7 +135,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { $args[0] = $id . '_before_markup'; $output = call_user_func_array( '_beans_render_action', $args ); - // Don't output the tag if empty, the before and after actions still run. + // Skip the opening tag when it's empty. if ( $tag ) { $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_temp_beans_selfclose_markup ? '/' : '' ) . '>'; } @@ -235,46 +235,47 @@ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { } /** - * Register close markup by ID. + * Build the closing HTML element's markup. This function fires 2 separate hooks: * - * This function is similar to {@see beans_open_markup()}, but does not accept HTML attributes. The $id - * argument must be the identical to the opening markup. + * 1. "{id}_append_markup" - which fires first before the closing tag. + * 2. "{$id}_after_markup" - which fires after the closing tag. * * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * * @param string $id Identical to the opening markup ID. - * @param string $tag The HTML tag. + * @param string $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but + * the actions hook will be called. If set the Null, both markup HTML tag and actions + * hooks will be removed. * - * @return string The output. + * @return string|void */ function beans_close_markup( $id, $tag ) { - // Stop here if the tag is set to false, the before and after actions won't run in this case. + // Filter the tag. $tag = beans_apply_filters( $id . '_markup', $tag ); + // If the tag is set to null, bail out. if ( null === $tag ) { return; } $args = func_get_args(); - // Remove function $tag argument. + // Remove the $tag argument. unset( $args[1] ); - // Set before action id. + // Set and then fire the append action hook. $args[0] = $id . '_append_markup'; + $output = call_user_func_array( '_beans_render_action', $args ); - $output = call_user_func_array( '_beans_render_action', $args ); - - // Don't output the tag if empty, the before and after actions still run. + // Skip the closing tag when it's empty. if ( $tag ) { $output .= ''; } - // Set after action id. + // Set and then fire the after action hook. $args[0] = $id . '_after_markup'; - $output .= call_user_func_array( '_beans_render_action', $args ); return $output; From 55e90be2c6491c4d91995903c8749f3545710499 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 17:18:54 -0500 Subject: [PATCH 381/800] Renamed method. --- tests/phpunit/integration/api/html/beansOpenMarkup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php index ea511acb..c66d6c19 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkup.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkup.php @@ -26,7 +26,7 @@ class Tests_BeansOpenMarkup extends HTML_Test_Case { /** * Test beans_open_markup() should return null when the tag is set to null. */ - public function test_should_return_null_when_tag_set_to_false() { + public function test_should_return_null_when_tag_set_to_null() { $this->assertNull( beans_open_markup( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) ); } From f4a57f1f12bedb0ded38ef946211d6207c5267d9 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 17:30:08 -0500 Subject: [PATCH 382/800] Added beans_close_markup_e tests. --- .../integration/api/html/beansCloseMarkup.php | 6 +- .../api/html/beansCloseMarkupE.php | 74 +++++++++++++++++ .../integration/api/html/beansOpenMarkupE.php | 5 +- .../unit/api/html/beansCloseMarkupE.php | 80 +++++++++++++++++++ 4 files changed, 160 insertions(+), 5 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beansCloseMarkupE.php create mode 100644 tests/phpunit/unit/api/html/beansCloseMarkupE.php diff --git a/tests/phpunit/integration/api/html/beansCloseMarkup.php b/tests/phpunit/integration/api/html/beansCloseMarkup.php index fca544b5..22d75cbf 100644 --- a/tests/phpunit/integration/api/html/beansCloseMarkup.php +++ b/tests/phpunit/integration/api/html/beansCloseMarkup.php @@ -88,7 +88,7 @@ public function test_should_return_built_html_when_append_or_after_hooks() { } ); // Run the tests. - $actual = beans_close_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_close_markup( 'beans_archive_title', 'h1' ); $expected = <<

    EOB; @@ -111,11 +111,11 @@ public function test_should_return_only_hooked_callbacks_output_and_no_html_elem } ); // Check with an empty string. - $actual = beans_close_markup( 'beans_archive_title', '', array( 'class' => 'uk-article-title' ) ); + $actual = beans_close_markup( 'beans_archive_title', '' ); $this->assertSame( '', $actual ); // Check with false. - $actual = beans_close_markup( 'beans_archive_title', false, array( 'class' => 'uk-article-title' ) ); + $actual = beans_close_markup( 'beans_archive_title', false ); $this->assertSame( '', $actual ); // Check the hooks. diff --git a/tests/phpunit/integration/api/html/beansCloseMarkupE.php b/tests/phpunit/integration/api/html/beansCloseMarkupE.php new file mode 100644 index 00000000..df0506da --- /dev/null +++ b/tests/phpunit/integration/api/html/beansCloseMarkupE.php @@ -0,0 +1,74 @@ +assertEquals( '', ob_get_clean() ); + } + + /** + * Test beans_close_markup_e() should echo the HTML element only when neither the append nor after hooks are not + * registered. + */ + public function test_should_echo_html_element_when_hooks_not_registered() { + ob_start(); + beans_close_markup_e( 'beans_archive_title', 'h1' ); + $actual = ob_get_clean(); + + $this->assertSame( '

    ', $actual ); + $this->assertEquals( 0, did_action( 'beans_archive_title_append_markup' ) ); + $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); + } + + /** + * Test beans_close_markup_e() should echo the before, element, and prepend HTML when callbacks are registered + * the "_append_markup" and "_after_markup" hooks. + */ + public function test_should_echo_built_html_when_append_or_after_hooks() { + add_action( 'beans_archive_title_append_markup', function() { + echo ''; + } ); + add_action( 'beans_archive_title_after_markup', function() { + echo ''; + } ); + + + ob_start(); + beans_close_markup_e( 'beans_archive_title', 'h1' ); + $actual = ob_get_clean(); + $expected = <<

    +EOB; + + // Run the tests. + $this->assertSame( $expected, $actual ); + $this->assertEquals( 1, did_action( 'beans_archive_title_append_markup' ) ); + $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); + } +} diff --git a/tests/phpunit/integration/api/html/beansOpenMarkupE.php b/tests/phpunit/integration/api/html/beansOpenMarkupE.php index a6ef0b6d..7f45d3c4 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkupE.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkupE.php @@ -23,7 +23,7 @@ class Tests_BeansOpenMarkupE extends HTML_Test_Case { /** - * Test beans_open_markup_e() should echo empty when the tag is set to null. + * Test beans_open_markup_e() should echo an empty string when the tag is set to null. */ public function test_should_echo_empty_when_tag_set_to_null() { ob_start(); @@ -32,7 +32,8 @@ public function test_should_echo_empty_when_tag_set_to_null() { } /** - * Test beans_open_markup_e() should echo the HTML element only when before or prepend hooks are not registered. + * Test beans_open_markup_e() should echo the HTML element only when neither the before nor prepend hooks are not + * registered. */ public function test_should_echo_html_element_when_hooks_not_registered() { ob_start(); diff --git a/tests/phpunit/unit/api/html/beansCloseMarkupE.php b/tests/phpunit/unit/api/html/beansCloseMarkupE.php new file mode 100644 index 00000000..150c4019 --- /dev/null +++ b/tests/phpunit/unit/api/html/beansCloseMarkupE.php @@ -0,0 +1,80 @@ +once() + ->with( 'beans_archive_title_markup', null ) + ->andReturnNull(); + + ob_start(); + beans_close_markup_e( 'beans_archive_title', null ); + $this->assertEquals( '', ob_get_clean() ); + } + + /** + * Test beans_close_markup_e() should echo the HTML element only when neither the append nor after hooks are not + * registered. + */ + public function test_should_echo_html_element_when_hooks_not_registered() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); + + ob_start(); + beans_close_markup_e( 'beans_archive_title', 'h1' ); + $this->assertSame( '

    ', ob_get_clean() ); + } + + /** + * Test beans_close_markup_e() should echo the before, element, and prepend HTML when callbacks are registered + * the "_append_markup" and "_after_markup" hooks. + */ + public function test_should_echo_built_html_when_append_or_after_hooks() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\expect( '_beans_render_action' ) + ->once() + ->with( 'beans_archive_title_append_markup' ) + ->ordered() + ->andReturn( '' ) + ->andAlsoExpectIt() + ->once() + ->with( 'beans_archive_title_after_markup' ) + ->ordered() + ->andReturn( '' ); + + ob_start(); + beans_close_markup_e( 'beans_archive_title', 'h1' ); + $actual = ob_get_clean(); + + $expected = << +EOB; + // Run test. + $this->assertSame( $expected, $actual ); + } +} From a44b211a07b9ad5e548cde0e661b04ce1ae4b788 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 17:31:57 -0500 Subject: [PATCH 383/800] Improved documentation. --- lib/api/html/functions.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index f1b95c10..580e0f5d 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -151,7 +151,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { } /** - * Echo the opening HTML element's markup. This function is a wrapper for {@see beans_open_markup()}. See + * Echo the opening HTML tag's markup. This function is a wrapper for {@see beans_open_markup()}. See * {@see beans_open_markup()} for more details. * * @since 1.4.0 @@ -282,17 +282,17 @@ function beans_close_markup( $id, $tag ) { } /** - * Echo close markup registered by ID. - * - * This function is similar to {@see beans_open_markup()}, but does not accept HTML attributes. The $id - * argument must be the identical to the opening markup. - * - * Note: You can pass additional arguments to the functions that are hooked to $id. + * Echo the closing HTML tag's markup. This function is a wrapper for {@see beans_close_markup()}. See + * {@see beans_close_markup()} for more details. * * @since 1.4.0 * * @param string $id Identical to the opening markup ID. - * @param string $tag The HTML tag. + * @param string $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but + * the actions hook will be called. If set the Null, both markup HTML tag and actions + * hooks will be removed. + * + * @return void */ function beans_close_markup_e( $id, $tag ) { $args = func_get_args(); From bafcd9de71bb1a27606484fc44b3f558499d7df2 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 21 Mar 2018 17:39:14 -0500 Subject: [PATCH 384/800] Fixed formatting. --- tests/phpunit/integration/api/html/beansCloseMarkupE.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansCloseMarkupE.php b/tests/phpunit/integration/api/html/beansCloseMarkupE.php index df0506da..8edee119 100644 --- a/tests/phpunit/integration/api/html/beansCloseMarkupE.php +++ b/tests/phpunit/integration/api/html/beansCloseMarkupE.php @@ -58,14 +58,12 @@ public function test_should_echo_built_html_when_append_or_after_hooks() { echo ''; } ); - ob_start(); beans_close_markup_e( 'beans_archive_title', 'h1' ); - $actual = ob_get_clean(); + $actual = ob_get_clean(); $expected = << EOB; - // Run the tests. $this->assertSame( $expected, $actual ); $this->assertEquals( 1, did_action( 'beans_archive_title_append_markup' ) ); From 4bc907bc62327456201b1038844490d4ef4005f7 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Thu, 22 Mar 2018 09:43:26 -0400 Subject: [PATCH 385/800] Fix #190 Adds a second check/bail for WP error after second call to `wp_get_remote()` --- lib/api/compiler/class-beans-compiler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index f08c207e..4542e9bd 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -476,6 +476,10 @@ public function get_remote_content() { $request = wp_remote_get( $fragment ); } + if ( is_wp_error( $request ) ) { + return ''; + } + if ( ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) ) { return false; } From 47e36110224005835e9d3698b35e083e38352b28 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Thu, 22 Mar 2018 09:44:10 -0400 Subject: [PATCH 386/800] Update unit tests to expect second `is_wp_error()` --- .../beans-compiler/getRemoteContent.php | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index 6ba497d5..981787ca 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -41,9 +41,9 @@ public function test_should_return_false_when_fragment_is_empty() { } /** - * Test get_remote_content() should return an empty string when the remote site or file does not exist. + * Test get_remote_content() should return an empty string when the remote site or file does not exist on http. */ - public function test_should_return_empty_string_when_remote_does_not_exist() { + public function test_should_return_empty_string_when_remote_does_not_exist_on_http() { // Set up the compiler. $fragment = 'http://beans.local/invalid-file.js'; $compiler = new _Beans_Compiler( array() ); @@ -57,6 +57,23 @@ public function test_should_return_empty_string_when_remote_does_not_exist() { $this->assertSame( '', $compiler->get_remote_content() ); } + /** + * Test get_remote_content() should return an empty string when the remote site or file does not exist on https. + */ + public function test_should_return_empty_string_when_remote_does_not_exist_on_https() { + // Set up the compiler. + $fragment = 'http://beans.local/invalid-file.js'; + $compiler = new _Beans_Compiler( array() ); + $this->set_current_fragment( $compiler, $fragment ); + + // Set up the mocks. + Functions\expect( 'wp_remote_get' )->twice(); + Functions\expect( 'is_wp_error' )->twice()->andReturnValues( array( false, true ) ); + + // Run the test. + $this->assertSame( '', $compiler->get_remote_content() ); + } + /** * Test get_remote_content() should retry and then return false when the remote file does not exist. */ @@ -67,7 +84,7 @@ public function test_should_retry_and_return_false_when_remote_file_does_not_exi $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Functions\expect( 'is_wp_error' )->twice()->andReturn( false ); Functions\expect( 'wp_remote_get' ) ->with( $fragment ) ->once() @@ -106,7 +123,7 @@ public function test_should_return_content_when_relative_url() { ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Functions\expect( 'is_wp_error' )->twice()->andReturn( false ); Functions\expect( 'wp_remote_get' ) // Check that it did add http: to the relative URL. ->with( 'http:' . $fragment ) @@ -142,7 +159,7 @@ public function test_should_return_content_when_http() { ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Functions\expect( 'is_wp_error' )->twice()->andReturn( false ); Functions\expect( 'wp_remote_get' ) // Check that it did add http: to the relative URL. ->with( $fragment ) @@ -178,7 +195,7 @@ public function test_should_return_content_when_https() { ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Functions\expect( 'is_wp_error' )->twice()->andReturn( false ); Functions\expect( 'wp_remote_get' ) // Check that it did add http: to the relative URL. ->with( $fragment ) From 1577e211db30af5e354aea21c95ed39b3c09d04c Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Thu, 22 Mar 2018 13:06:15 -0400 Subject: [PATCH 387/800] Moved check into previous conditional block. Also fixed the corresponding test expectations. --- lib/api/compiler/class-beans-compiler.php | 6 +++--- .../unit/api/compiler/beans-compiler/getRemoteContent.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 4542e9bd..420c9c24 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -474,10 +474,10 @@ public function get_remote_content() { ) { $fragment = str_replace( 'http://', 'https://', $fragment ); $request = wp_remote_get( $fragment ); - } - if ( is_wp_error( $request ) ) { - return ''; + if ( is_wp_error( $request ) ) { + return ''; + } } if ( ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) ) { diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index 981787ca..7c40121c 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -123,7 +123,7 @@ public function test_should_return_content_when_relative_url() { ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->twice()->andReturn( false ); + Functions\expect( 'is_wp_error' )->once()->andReturn( false ); Functions\expect( 'wp_remote_get' ) // Check that it did add http: to the relative URL. ->with( 'http:' . $fragment ) @@ -159,7 +159,7 @@ public function test_should_return_content_when_http() { ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->twice()->andReturn( false ); + Functions\expect( 'is_wp_error' )->once()->andReturn( false ); Functions\expect( 'wp_remote_get' ) // Check that it did add http: to the relative URL. ->with( $fragment ) @@ -195,7 +195,7 @@ public function test_should_return_content_when_https() { ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->twice()->andReturn( false ); + Functions\expect( 'is_wp_error' )->once()->andReturn( false ); Functions\expect( 'wp_remote_get' ) // Check that it did add http: to the relative URL. ->with( $fragment ) From 1363d74de0baaee42f859fc369e133c22ae6e82c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 13:13:22 -0500 Subject: [PATCH 388/800] Improved documentation. --- lib/api/html/functions.php | 12 ++++++------ .../integration/api/html/beansCloseMarkup.php | 15 +++++++++------ .../integration/api/html/beansCloseMarkupE.php | 10 +++++----- tests/phpunit/unit/api/html/beansCloseMarkup.php | 14 ++++++++------ tests/phpunit/unit/api/html/beansCloseMarkupE.php | 12 ++++++------ 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 580e0f5d..7ad2d1ca 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -245,9 +245,9 @@ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { * @since 1.0.0 * * @param string $id Identical to the opening markup ID. - * @param string $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but - * the actions hook will be called. If set the Null, both markup HTML tag and actions - * hooks will be removed. + * @param string $tag The HTML tag. When set to false or an empty string, the markup HTML tag will not be built, but + * both action hooks will fire. If set to null, the function bails out, i.e. the markup HTML + * tag will not be built and neither action hook fires. * * @return string|void */ @@ -288,9 +288,9 @@ function beans_close_markup( $id, $tag ) { * @since 1.4.0 * * @param string $id Identical to the opening markup ID. - * @param string $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but - * the actions hook will be called. If set the Null, both markup HTML tag and actions - * hooks will be removed. + * @param string $tag The HTML tag. When set to false or an empty string, the markup HTML tag will not be built, but + * both action hooks will fire. If set to null, the function bails out, i.e. the markup HTML + * tag will not be built and neither action hook fires. * * @return void */ diff --git a/tests/phpunit/integration/api/html/beansCloseMarkup.php b/tests/phpunit/integration/api/html/beansCloseMarkup.php index 22d75cbf..23ff7d2d 100644 --- a/tests/phpunit/integration/api/html/beansCloseMarkup.php +++ b/tests/phpunit/integration/api/html/beansCloseMarkup.php @@ -67,9 +67,10 @@ public function test_should_fire_after_markup_hooks_and_include_content_in_retur } /** - * Test beans_close_markup() should return the built HTML element when append or after hooks are not registered. + * Test beans_close_markup() should return the closing tag only when a callback is not registered to either the + * "_append_markup" or "_after_markup" hook. */ - public function test_should_return_built_html_when_append_or_after_hooks_not_registered() { + public function test_should_return_closing_tag_when_callback_not_registered_to_either_hook() { $actual = beans_close_markup( 'beans_archive_title', 'h1' ); $this->assertSame( '', $actual ); $this->assertEquals( 0, did_action( 'beans_archive_title_append_markup' ) ); @@ -77,9 +78,10 @@ public function test_should_return_built_html_when_append_or_after_hooks_not_reg } /** - * Test beans_close_markup() should return a built HTML when append or after hooks are registered. + * Test beans_close_markup() should return the append, tag, and after HTML when callbacks are registered + * to the "_append_markup" and "_after_markup" hooks. */ - public function test_should_return_built_html_when_append_or_after_hooks() { + public function test_should_return_built_html_when_callback_registered_to_hooks() { add_action( 'beans_archive_title_append_markup', function() { echo ''; } ); @@ -99,10 +101,11 @@ public function test_should_return_built_html_when_append_or_after_hooks() { } /** - * Test beans_close_markup() should return only the output from the hooked callbacks and not the HTML element when + /** + * Test beans_close_markup() should return the hooked callbacks' output and not the closing tag when * the tag is empty. */ - public function test_should_return_only_hooked_callbacks_output_and_no_html_element_when_tag_is_empty() { + public function test_should_return_hooked_callbacks_output_and_not_closing_tag_when_tag_is_empty() { add_action( 'beans_archive_title_append_markup', function() { echo ''; } ); diff --git a/tests/phpunit/integration/api/html/beansCloseMarkupE.php b/tests/phpunit/integration/api/html/beansCloseMarkupE.php index 8edee119..4469ea90 100644 --- a/tests/phpunit/integration/api/html/beansCloseMarkupE.php +++ b/tests/phpunit/integration/api/html/beansCloseMarkupE.php @@ -33,10 +33,10 @@ public function test_should_echo_empty_when_tag_set_to_null() { } /** - * Test beans_close_markup_e() should echo the HTML element only when neither the append nor after hooks are not - * registered. + * Test beans_close_markup_e() should echo the closing tag only when a callback is not registered to either the + * "_append_markup" or "_after_markup" hook. */ - public function test_should_echo_html_element_when_hooks_not_registered() { + public function test_should_echo_closing_tag_when_callback_not_registered_to_either_hook() { ob_start(); beans_close_markup_e( 'beans_archive_title', 'h1' ); $actual = ob_get_clean(); @@ -47,8 +47,8 @@ public function test_should_echo_html_element_when_hooks_not_registered() { } /** - * Test beans_close_markup_e() should echo the before, element, and prepend HTML when callbacks are registered - * the "_append_markup" and "_after_markup" hooks. + * Test beans_close_markup_e() should echo the append, tag, and after HTML when callbacks are registered + * to the "_append_markup" and "_after_markup" hooks. */ public function test_should_echo_built_html_when_append_or_after_hooks() { add_action( 'beans_archive_title_append_markup', function() { diff --git a/tests/phpunit/unit/api/html/beansCloseMarkup.php b/tests/phpunit/unit/api/html/beansCloseMarkup.php index a8ea6291..43c49ea9 100644 --- a/tests/phpunit/unit/api/html/beansCloseMarkup.php +++ b/tests/phpunit/unit/api/html/beansCloseMarkup.php @@ -64,9 +64,10 @@ public function test_should_fire_after_markup_hooks_and_include_content_in_retur } /** - * Test beans_close_markup() should return the built HTML element when append or after hooks are not registered. + * Test beans_close_markup() should return the closing tag only when a callback is not registered to either the + * "_append_markup" or "_after_markup" hook. */ - public function test_should_return_built_html_when_append_or_after_hooks_not_registered() { + public function test_should_return_closing_tag_when_callback_not_registered_to_either_hook() { Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); @@ -74,9 +75,10 @@ public function test_should_return_built_html_when_append_or_after_hooks_not_reg } /** - * Test beans_open_markup() should return a built HTML when append or after hooks are registered. + * Test beans_close_markup() should return the append, tag, and after HTML when callbacks are registered + * to the "_append_markup" and "_after_markup" hooks. */ - public function test_should_return_built_html_when_append_or_after_hooks() { + public function test_should_return_built_html_when_callback_registered_to_hooks() { Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); Monkey\Functions\expect( '_beans_render_action' ) ->once() @@ -97,10 +99,10 @@ public function test_should_return_built_html_when_append_or_after_hooks() { } /** - * Test beans_close_markup() should return only the output from the hooked callbacks and not the HTML element when + * Test beans_close_markup() should return the hooked callbacks' output and not the closing tag when * the tag is empty. */ - public function test_should_return_only_hooked_callbacks_output_and_no_html_element_when_tag_is_empty() { + public function test_should_return_hooked_callbacks_output_and_not_closing_tag_when_tag_is_empty() { Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); Monkey\Functions\expect( '_beans_render_action' ) ->twice() diff --git a/tests/phpunit/unit/api/html/beansCloseMarkupE.php b/tests/phpunit/unit/api/html/beansCloseMarkupE.php index 150c4019..be04ea27 100644 --- a/tests/phpunit/unit/api/html/beansCloseMarkupE.php +++ b/tests/phpunit/unit/api/html/beansCloseMarkupE.php @@ -38,10 +38,10 @@ public function test_should_echo_empty_when_tag_set_to_null() { } /** - * Test beans_close_markup_e() should echo the HTML element only when neither the append nor after hooks are not - * registered. + * Test beans_close_markup_e() should echo the closing tag only when a callback is not registered to either the + * "_append_markup" or "_after_markup" hook. */ - public function test_should_echo_html_element_when_hooks_not_registered() { + public function test_should_echo_closing_tag_when_callback_not_registered_to_either_hook() { Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); @@ -51,10 +51,10 @@ public function test_should_echo_html_element_when_hooks_not_registered() { } /** - * Test beans_close_markup_e() should echo the before, element, and prepend HTML when callbacks are registered - * the "_append_markup" and "_after_markup" hooks. + * Test beans_close_markup_e() should echo the append, tag, and after HTML when callbacks are registered + * to the "_append_markup" and "_after_markup" hooks. */ - public function test_should_echo_built_html_when_append_or_after_hooks() { + public function test_should_echo_built_html_when_append_and_after_hooks() { Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); Monkey\Functions\expect( '_beans_render_action' ) ->once() From 1be2c4016ee5879cdf5f46fb97a8ae0d28d5e7bc Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 13:15:36 -0500 Subject: [PATCH 389/800] Added missing test. --- .../phpunit/integration/api/html/beansCloseMarkup.php | 8 ++++++++ tests/phpunit/unit/api/html/beansCloseMarkup.php | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/tests/phpunit/integration/api/html/beansCloseMarkup.php b/tests/phpunit/integration/api/html/beansCloseMarkup.php index 23ff7d2d..827a3cf0 100644 --- a/tests/phpunit/integration/api/html/beansCloseMarkup.php +++ b/tests/phpunit/integration/api/html/beansCloseMarkup.php @@ -100,6 +100,14 @@ public function test_should_return_built_html_when_callback_registered_to_hooks( $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); } + /** + * Test beans_close_markup() should return an empty string when (1) the tag is an empty string and (2) a callback + * is not registered to either the "_append_markup" or "_after_markup" hook. + */ + public function test_should_return_empty_string_when_empty_tag_and_callback_not_registered_to_hooks() { + $this->assertSame( '', beans_close_markup( 'beans_archive_title', '' ) ); + } + /** /** * Test beans_close_markup() should return the hooked callbacks' output and not the closing tag when diff --git a/tests/phpunit/unit/api/html/beansCloseMarkup.php b/tests/phpunit/unit/api/html/beansCloseMarkup.php index 43c49ea9..22dc98c1 100644 --- a/tests/phpunit/unit/api/html/beansCloseMarkup.php +++ b/tests/phpunit/unit/api/html/beansCloseMarkup.php @@ -98,6 +98,17 @@ public function test_should_return_built_html_when_callback_registered_to_hooks( $this->assertSame( $expected, $actual ); } + /** + * Test beans_close_markup() should return an empty string when (1) the tag is an empty string and (2) a callback + * is not registered to either the "_append_markup" or "_after_markup" hook. + */ + public function test_should_return_empty_string_when_empty_tag_and_callback_not_registered_to_hooks() { + Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); + Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); + + $this->assertSame( '', beans_close_markup( 'beans_archive_title', '' ) ); + } + /** * Test beans_close_markup() should return the hooked callbacks' output and not the closing tag when * the tag is empty. From b25f5a26a3c14effc2378b1af18baca313499537 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 14:32:29 -0500 Subject: [PATCH 390/800] Removed double comment opener. --- tests/phpunit/integration/api/html/beansCloseMarkup.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/integration/api/html/beansCloseMarkup.php b/tests/phpunit/integration/api/html/beansCloseMarkup.php index 827a3cf0..7c6ad1d4 100644 --- a/tests/phpunit/integration/api/html/beansCloseMarkup.php +++ b/tests/phpunit/integration/api/html/beansCloseMarkup.php @@ -108,7 +108,6 @@ public function test_should_return_empty_string_when_empty_tag_and_callback_not_ $this->assertSame( '', beans_close_markup( 'beans_archive_title', '' ) ); } - /** /** * Test beans_close_markup() should return the hooked callbacks' output and not the closing tag when * the tag is empty. From dd54fdef5e224e3acdebe6b13b5a6e4fa9f160b7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 16:00:28 -0500 Subject: [PATCH 391/800] Added beans_selfclose_markup tests. --- .../api/html/beansSelfcloseMarkup.php | 70 +++++++++++++++++++ .../api/html/fixtures/test-attachment.php | 50 +++++++++++++ .../html/includes/class-html-test-case.php | 24 ++++++- .../unit/api/html/beansSelfcloseMarkup.php | 60 ++++++++++++++++ .../api/html/fixtures/test-attachment.php | 50 +++++++++++++ .../html/includes/class-html-test-case.php | 13 ++++ 6 files changed, 265 insertions(+), 2 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beansSelfcloseMarkup.php create mode 100644 tests/phpunit/integration/api/html/fixtures/test-attachment.php create mode 100644 tests/phpunit/unit/api/html/beansSelfcloseMarkup.php create mode 100644 tests/phpunit/unit/api/html/fixtures/test-attachment.php diff --git a/tests/phpunit/integration/api/html/beansSelfcloseMarkup.php b/tests/phpunit/integration/api/html/beansSelfcloseMarkup.php new file mode 100644 index 00000000..14bd6309 --- /dev/null +++ b/tests/phpunit/integration/api/html/beansSelfcloseMarkup.php @@ -0,0 +1,70 @@ +assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + + beans_selfclose_markup( $attachment['id'], null, $attachment['attributes'], $attachment['attachment'] ); + + // Check after we run the function. + $this->assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + } + } + + /** + * Test beans_selfclose_markup() should return null when the tag is set to null. + */ + public function test_should_return_null_when_tag_set_to_null() { + + foreach ( static::$test_attachments as $attachment ) { + $this->assertNull( beans_selfclose_markup( $attachment['id'], null, $attachment['attributes'], $attachment['attachment'] ) ); + } + } + + /** + * Test beans_selfclose_markup() should return the built HTML self-closing element. + */ + public function test_should_return_built_html_self_closing_element() { + // Check the first attachment. + $attachment = current( static::$test_attachments ); + $expected = << +EOB; + $this->assertSame( $expected, beans_selfclose_markup( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ) ); + + // Check the next one. + $attachment = next( static::$test_attachments ); + $expected = << +EOB; + $this->assertSame( $expected, beans_selfclose_markup( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ) ); + } +} diff --git a/tests/phpunit/integration/api/html/fixtures/test-attachment.php b/tests/phpunit/integration/api/html/fixtures/test-attachment.php new file mode 100644 index 00000000..f4bbdffb --- /dev/null +++ b/tests/phpunit/integration/api/html/fixtures/test-attachment.php @@ -0,0 +1,50 @@ + 'beans_post_image_small_item', + 'tag' => 'source', + 'attributes' => array( + 'media' => '(max-width: 200px)', + 'srcset' => 'https://example.com/small-image.png', + ), + 'attachment' => (object) array( + 'id' => 47, + 'src' => 'https://example.com/small-image.png', + 'width' => 200, + 'height' => 200, + 'alt' => 'Small image', + 'title' => 'This is a post title.', + 'caption' => 'This is the caption.', + 'description' => 'This is the description.', + ), + ), + array( + 'id' => 'beans_post_image_item', + 'tag' => 'img', + 'attributes' => array( + 'width' => 1200, + 'height' => 600, + 'src' => 'https://example.com/image.png', + 'alt' => 'A background image.', + 'itemprop' => 'image', + ), + 'attachment' => (object) array( + 'id' => 1047, + 'src' => 'https://example.com/image.png', + 'width' => 1200, + 'height' => 600, + 'alt' => 'A background image.', + 'title' => 'This is a post title.', + 'caption' => 'This is the caption.', + 'description' => 'This is the description.', + ), + ), +); diff --git a/tests/phpunit/integration/api/html/includes/class-html-test-case.php b/tests/phpunit/integration/api/html/includes/class-html-test-case.php index c63484f6..4c19a8f0 100644 --- a/tests/phpunit/integration/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/integration/api/html/includes/class-html-test-case.php @@ -32,16 +32,36 @@ abstract class HTML_Test_Case extends WP_UnitTestCase { */ protected static $test_attributes; + /** + * Array of attachments to test. + * + * @var array + */ + protected static $test_attachments; + /** * Setup the test before we run the test setups. */ public static function setUpBeforeClass() { parent::setUpBeforeClass(); - static::$test_markup = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-markup.php'; - static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { + static::$test_markup = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-markup.php'; + static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { return isset( $markup['attributes'] ); } ); + static::$test_attachments = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-attachment.php'; + } + + /** + * Prepares the test environment before each test. + */ + public function setUp() { + parent::setUp(); + + // Reset the test fixtures. + reset( static::$test_markup ); + reset( static::$test_attributes ); + reset( static::$test_attachments ); } /** diff --git a/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php b/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php new file mode 100644 index 00000000..342d7d4f --- /dev/null +++ b/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php @@ -0,0 +1,60 @@ +justReturn(); + + foreach ( static::$test_attachments as $attachment ) { + // Check before we start. + $this->assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + + beans_selfclose_markup( $attachment['id'], null, $attachment['attributes'], $attachment['attachment'] ); + + // Check after we run the function. + $this->assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + } + } + + /** + * Test beans_selfclose_markup() should invoke beans_open_markup(). + */ + public function test_should_invoke_beans_open_markup() { + + foreach ( static::$test_attachments as $attachment ) { + Monkey\Functions\expect( 'beans_open_markup' ) + ->once() + ->with( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ) + ->andReturnNull(); + + beans_selfclose_markup( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ); + } + + // The assertions are above. This assertion is a placeholder, as PHPUnit requires a specific assert to run. + $this->assertTrue( true ); + } +} diff --git a/tests/phpunit/unit/api/html/fixtures/test-attachment.php b/tests/phpunit/unit/api/html/fixtures/test-attachment.php new file mode 100644 index 00000000..f31a1755 --- /dev/null +++ b/tests/phpunit/unit/api/html/fixtures/test-attachment.php @@ -0,0 +1,50 @@ + 'beans_post_image_small_item', + 'tag' => 'source', + 'attributes' => array( + 'media' => '(max-width: 200px)', + 'srcset' => 'https://example.com/small-image.png', + ), + 'attachment' => (object) array( + 'id' => 47, + 'src' => 'https://example.com/small-image.png', + 'width' => 200, + 'height' => 200, + 'alt' => 'Small image', + 'title' => 'This is a post title.', + 'caption' => 'This is the caption.', + 'description' => 'This is the description.', + ), + ), + array( + 'id' => 'beans_post_image_item', + 'tag' => 'img', + 'attributes' => array( + 'width' => 1200, + 'height' => 600, + 'src' => 'https://example.com/image.png', + 'alt' => 'A background image.', + 'itemprop' => 'image', + ), + 'attachment' => (object) array( + 'id' => 1047, + 'src' => 'https://example.com/image.png', + 'width' => 1200, + 'height' => 600, + 'alt' => 'A background image.', + 'title' => 'This is a post title.', + 'caption' => 'This is the caption.', + 'description' => 'This is the description.', + ), + ), +); diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index e1cfcab2..c65edbce 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -33,6 +33,13 @@ abstract class HTML_Test_Case extends Test_Case { */ protected static $test_attributes; + /** + * Array of attachments to test. + * + * @var array + */ + protected static $test_attachments; + /** * Setup the test before we run the test setups. */ @@ -43,6 +50,7 @@ public static function setUpBeforeClass() { static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { return isset( $markup['attributes'] ); } ); + static::$test_attachments = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-attachment.php'; } /** @@ -59,6 +67,11 @@ protected function setUp() { $this->setup_function_mocks(); $this->setup_common_wp_stubs(); + + // Reset the test fixtures. + reset( static::$test_markup ); + reset( static::$test_attributes ); + reset( static::$test_attachments ); } /** From 049f6bbd7538bc597fc222a46c9c1bbd00479835 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 16:04:47 -0500 Subject: [PATCH 392/800] Fixed #192. --- lib/api/html/functions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 7ad2d1ca..eb991a24 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -203,7 +203,12 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. $args = func_get_args(); - return call_user_func_array( 'beans_open_markup', $args ); + $html = call_user_func_array( 'beans_open_markup', $args ); + + // Reset the global variable to reduce memory usage. + unset( $GLOBALS['_temp_beans_selfclose_markup'] ); + + return $html; } /** From 913dc8df4e5dbaffb65e743a4e24f885b55654eb Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 16:06:06 -0500 Subject: [PATCH 393/800] Refactored, removing assignment for args. Will result in a tiny decrease in memory and execution time. --- lib/api/html/functions.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index eb991a24..cb2a6a96 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -201,9 +201,8 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { global $_temp_beans_selfclose_markup; $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. - $args = func_get_args(); - $html = call_user_func_array( 'beans_open_markup', $args ); + $html = call_user_func_array( 'beans_open_markup', func_get_args() ); // Reset the global variable to reduce memory usage. unset( $GLOBALS['_temp_beans_selfclose_markup'] ); From daec9ad1a9dfd37b577d86c668383d6b954c1f9e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 16:12:04 -0500 Subject: [PATCH 394/800] Improved beans_selfclose_markup documentation. --- lib/api/html/functions.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index cb2a6a96..d1275236 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -142,7 +142,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { // Set and then fire the after action hook. $args[0] = $id . ( $_temp_beans_selfclose_markup ? '_after_markup' : '_prepend_markup' ); - $output .= call_user_func_array( '_beans_render_action', $args ); + $output .= call_user_func_array( '_beans_render_action', $args ); // Reset the global variable to reduce memory usage. unset( $GLOBALS['_temp_beans_selfclose_markup'] ); @@ -175,7 +175,7 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { } /** - * Register self-close markup and attributes by ID. + * Build the self-closing HTML element's markup. * * This function is shortcut of {@see beans_open_markup()}. It should be used for self-closing HTML markup such as * images or inputs. @@ -184,10 +184,12 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { * * @since 1.0.0 * + * @global bool $_temp_beans_selfclose_markup When true, indicates a self-closing element should be built. + * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string|bool $tag The HTML self-close tag.If set to False or empty, the markup HTML tag will - * be removed but the actions hook will be called. If set the Null, both - * markup HTML tag and actions hooks will be removed. + * @param string $tag The self-closing HTML tag. When set to false or an empty string, the markup HTML tag + * will not be built, but both action hooks will fire. If set to null, the function + * bails out, i.e. the markup HTML tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value defines the attribute value. Setting * the array value to '' will display the attribute value as empty @@ -195,7 +197,7 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. * - * @return string The output. + * @return string|void */ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { global $_temp_beans_selfclose_markup; @@ -280,7 +282,7 @@ function beans_close_markup( $id, $tag ) { // Set and then fire the after action hook. $args[0] = $id . '_after_markup'; - $output .= call_user_func_array( '_beans_render_action', $args ); + $output .= call_user_func_array( '_beans_render_action', $args ); return $output; } From 360e4217fa35a81b57d4c57305c83b0c8df19ad0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 18:27:26 -0500 Subject: [PATCH 395/800] Renamed selfclose global to comply with WPCS. --- lib/api/html/functions.php | 16 ++++++++-------- .../integration/api/html/beansOpenMarkup.php | 18 +++++++++--------- .../api/html/beansSelfcloseMarkup.php | 4 ++-- .../phpunit/unit/api/html/beansOpenMarkup.php | 18 +++++++++--------- .../unit/api/html/beansSelfcloseMarkup.php | 4 ++-- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index d1275236..ab255eb5 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -125,7 +125,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { return; } - global $_temp_beans_selfclose_markup; + global $_beans_is_selfclose_markup; // Remove the $tag argument. unset( $args[1] ); @@ -137,15 +137,15 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { // Skip the opening tag when it's empty. if ( $tag ) { - $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_temp_beans_selfclose_markup ? '/' : '' ) . '>'; + $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_beans_is_selfclose_markup ? '/' : '' ) . '>'; } // Set and then fire the after action hook. - $args[0] = $id . ( $_temp_beans_selfclose_markup ? '_after_markup' : '_prepend_markup' ); + $args[0] = $id . ( $_beans_is_selfclose_markup ? '_after_markup' : '_prepend_markup' ); $output .= call_user_func_array( '_beans_render_action', $args ); // Reset the global variable to reduce memory usage. - unset( $GLOBALS['_temp_beans_selfclose_markup'] ); + unset( $GLOBALS['_beans_is_selfclose_markup'] ); return $output; } @@ -184,7 +184,7 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { * * @since 1.0.0 * - * @global bool $_temp_beans_selfclose_markup When true, indicates a self-closing element should be built. + * @global bool $_beans_is_selfclose_markup When true, indicates a self-closing element should be built. * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). * @param string $tag The self-closing HTML tag. When set to false or an empty string, the markup HTML tag @@ -200,14 +200,14 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { * @return string|void */ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { - global $_temp_beans_selfclose_markup; + global $_beans_is_selfclose_markup; - $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. $html = call_user_func_array( 'beans_open_markup', func_get_args() ); // Reset the global variable to reduce memory usage. - unset( $GLOBALS['_temp_beans_selfclose_markup'] ); + unset( $GLOBALS['_beans_is_selfclose_markup'] ); return $html; } diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php index c66d6c19..2295066d 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkup.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkup.php @@ -68,7 +68,7 @@ public function test_should_fire_prepend_markup_hooks_and_include_content_in_ret /** * Test beans_open_markup() should fire _beans_render_action() for the "_after_markup" hooks when the global - * $_temp_beans_selfclose_markup is set to true. + * $_beans_is_selfclose_markup is set to true. */ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { Monkey\Functions\expect( '__beans_render_title_after_markup' ) @@ -79,8 +79,8 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { } ); add_action( 'beans_archive_title_after_markup', '__beans_render_title_after_markup' ); - global $_temp_beans_selfclose_markup; - $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + global $_beans_is_selfclose_markup; + $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. // Run the tests. $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); @@ -88,7 +88,7 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { $this->assertStringEndsWith( '', $actual ); // Check that the global was unset. - $this->assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); } /** @@ -137,7 +137,7 @@ public function test_should_return_built_html_when_before_or_prepend_hooks() { /** * Test beans_open_markup() should return a built self-closing HTML element when the global - * $_temp_beans_selfclose_markup is set to true. + * $_beans_is_selfclose_markup is set to true. */ public function test_should_return_built_self_closing_html_when_selfclose_markup_is_true() { $args = array( @@ -149,8 +149,8 @@ public function test_should_return_built_self_closing_html_when_selfclose_markup ); // Run it with development mode off. - global $_temp_beans_selfclose_markup; - $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + global $_beans_is_selfclose_markup; + $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); $expected = <<assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); beans_selfclose_markup( $attachment['id'], null, $attachment['attributes'], $attachment['attachment'] ); // Check after we run the function. - $this->assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); } } diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php index 57e8e4bf..a7400fd0 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkup.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkup.php @@ -67,7 +67,7 @@ public function test_should_fire_prepend_markup_hooks_and_include_content_in_ret /** * Test beans_open_markup() should fire _beans_render_action() for the "_after_markup" hooks when the global - * $_temp_beans_selfclose_markup is set to true. + * $_beans_is_selfclose_markup is set to true. */ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { Monkey\Functions\when( 'beans_add_attributes' )->justReturn( 'class="uk-article-title"' ); @@ -77,13 +77,13 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { ->with( 'beans_archive_title_after_markup' ) ->andReturn( 'Worked!' ); - global $_temp_beans_selfclose_markup; - $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + global $_beans_is_selfclose_markup; + $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. $this->assertContains( 'Worked!', beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ) ); // Check that the global was unset. - $this->assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); } /** @@ -143,7 +143,7 @@ public function test_should_return_built_html_when_before_or_prepend_hooks() { /** * Test beans_open_markup() should return a built self-closing HTML element when the global - * $_temp_beans_selfclose_markup is set to true. + * $_beans_is_selfclose_markup is set to true. */ public function test_should_return_built_self_closing_html_when_selfclose_markup_is_true() { $args = array( @@ -164,8 +164,8 @@ public function test_should_return_built_self_closing_html_when_selfclose_markup // Run it with development mode off. Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); - global $_temp_beans_selfclose_markup; - $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + global $_beans_is_selfclose_markup; + $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); $expected = <<once()->andReturn( true ); - global $_temp_beans_selfclose_markup; - $_temp_beans_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + global $_beans_is_selfclose_markup; + $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); $expected = <<assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); beans_selfclose_markup( $attachment['id'], null, $attachment['attributes'], $attachment['attachment'] ); // Check after we run the function. - $this->assertArrayNotHasKey( '_temp_beans_selfclose_markup', $GLOBALS ); + $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); } } From 58cca6ce57dbbc0c0dd5b386023e9c7a995667ad Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 18:37:37 -0500 Subject: [PATCH 396/800] Added tests for beans_selfclose_markup_e. --- lib/api/html/functions.php | 48 +++++++-------- .../integration/api/html/beansOpenMarkup.php | 6 +- .../api/html/beansSelfcloseMarkupE.php | 60 +++++++++++++++++++ .../phpunit/unit/api/html/beansOpenMarkup.php | 6 +- .../unit/api/html/beansSelfcloseMarkupE.php | 45 ++++++++++++++ 5 files changed, 135 insertions(+), 30 deletions(-) create mode 100644 tests/phpunit/integration/api/html/beansSelfcloseMarkupE.php create mode 100644 tests/phpunit/unit/api/html/beansSelfcloseMarkupE.php diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index ab255eb5..0efb1c2d 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -184,25 +184,29 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { * * @since 1.0.0 * - * @global bool $_beans_is_selfclose_markup When true, indicates a self-closing element should be built. - * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $tag The self-closing HTML tag. When set to false or an empty string, the markup HTML tag - * will not be built, but both action hooks will fire. If set to null, the function - * bails out, i.e. the markup HTML tag will not be built and neither action hook fires. - * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the - * attribute name and the array value defines the attribute value. Setting - * the array value to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not - * display anything. + * @global bool $_beans_is_selfclose_markup When true, indicates a self-closing element should be built. + * + * @param string $id A unique string used as a reference. The $id argument may contain + * sub-hook(s). + * @param string $tag The self-closing HTML tag. When set to false or an empty string, the + * markup HTML tag will not be built, but both action hooks will fire. + * If set to null, the function bails out, i.e. the markup HTML tag + * will not be built and neither action hook fires. + * @param string|array $attributes Optional. Query string or array of attributes. The array key defines + * the attribute name and the array value defines the attribute value. + * Setting the array value to '' will display the attribute value as + * empty + * (e.g. class=""). Setting it to 'false' will only display + * the attribute name (e.g. data-example). Setting it to 'null' will + * not + * display anything. * * @return string|void */ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + $_beans_is_selfclose_markup = true; $html = call_user_func_array( 'beans_open_markup', func_get_args() ); @@ -213,25 +217,21 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { } /** - * Echo self-close markup and attributes registered by ID. - * - * This function is shortcut of {@see beans_open_markup()}. It should be used for self-closing HTML markup such as - * images or inputs. - * - * Note: You can pass additional arguments to the functions that are hooked to $id. + * Echo the self-closing HTML element's markup. This function is a wrapper for {@see beans_selfclose_markup()}. See + * {@see beans_selfclose_markup()} for more details. * * @since 1.4.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string|bool $tag The HTML self-close tag.If set to False or empty, the markup HTML tag will - * be removed but the actions hook will be called. If set the Null, both - * markup HTML tag and actions hooks will be removed. + * @param string $tag The self-closing HTML tag. When set to false or an empty string, the markup HTML tag + * will not be built, but both action hooks will fire. If set to null, the function + * bails out, i.e. the markup HTML tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value defines the attribute value. Setting * the array value to '' will display the attribute value as empty * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not - * display anything. + * the attribute name (e.g. data-example). Setting it to 'null' will not display + * anything. * * @return void */ diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php index 2295066d..25f4702a 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkup.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkup.php @@ -80,7 +80,7 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { add_action( 'beans_archive_title_after_markup', '__beans_render_title_after_markup' ); global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + $_beans_is_selfclose_markup = true; // Run the tests. $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); @@ -150,7 +150,7 @@ public function test_should_return_built_self_closing_html_when_selfclose_markup // Run it with development mode off. global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + $_beans_is_selfclose_markup = true; $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); $expected = <<assertSame( '', ob_get_clean() ); + } + } + + /** + * Test beans_selfclose_markup_e() should echo the built HTML self-closing element. + */ + public function test_should_return_built_html_self_closing_element() { + // Check the first attachment. + $attachment = current( static::$test_attachments ); + $expected = << +EOB; + ob_start(); + beans_selfclose_markup_e( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ); + $this->assertSame( $expected, ob_get_clean() ); + + // Check the next one. + $attachment = next( static::$test_attachments ); + $expected = << +EOB; + ob_start(); + beans_selfclose_markup_e( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ); + $this->assertSame( $expected, ob_get_clean() ); + } +} diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php index a7400fd0..95b1b4eb 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkup.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkup.php @@ -78,7 +78,7 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { ->andReturn( 'Worked!' ); global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + $_beans_is_selfclose_markup = true; $this->assertContains( 'Worked!', beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ) ); @@ -165,7 +165,7 @@ public function test_should_return_built_self_closing_html_when_selfclose_markup // Run it with development mode off. Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + $_beans_is_selfclose_markup = true; $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); $expected = <<once()->andReturn( true ); global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used in function scope. + $_beans_is_selfclose_markup = true; $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); $expected = <<once() + ->with( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ) + ->andReturnNull(); + + ob_start(); + beans_selfclose_markup_e( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ); + ob_get_clean(); + } + + // The assertions are above. This assertion is a placeholder, as PHPUnit requires a specific assert to run. + $this->assertTrue( true ); + } +} From fed73d5bb1dd7b6aba0488ffe952845750bd67e8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 18:38:51 -0500 Subject: [PATCH 397/800] Refactored to remove the unnecessary assignment. Will run a little faster and reduces memory. --- lib/api/html/functions.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 0efb1c2d..7464fb93 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -236,8 +236,7 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { * @return void */ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { - $args = func_get_args(); - echo call_user_func_array( 'beans_selfclose_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + echo call_user_func_array( 'beans_selfclose_markup', func_get_args() ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. } /** From af84ec777b800b4a7606631f5141c72f8f48004d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 18:48:33 -0500 Subject: [PATCH 398/800] Standardized param documentation. --- lib/api/html/functions.php | 57 +++++++++++++------------------------- 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 7464fb93..1c6f9aef 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -93,15 +93,11 @@ function beans_remove_output( $id ) { * @since 1.0.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but - * the actions hook will be called. If set the Null, both markup HTML tag and actions - * hooks will be removed. + * @param string|bool $tag The HTML tag. When set to false or an empty string, the markup HTML tag will not be + * built, but both action hooks will fire. If set to null, the function bails out, i.e. + * the markup HTML tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the - * attribute name and the array value defines the attribute value. Setting - * the array value to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not - * display anything. + * attribute name and the array value defines the attribute value. * * @return string|void */ @@ -157,15 +153,11 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { * @since 1.4.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but - * the actions hook will be called. If set the Null, both markup HTML tag and actions - * hooks will be removed. + * @param string|bool $tag The HTML tag. When set to false or an empty string, the markup HTML tag will not be + * built, but both action hooks will fire. If set to null, the function bails out, i.e. + * the markup HTML tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the - * attribute name and the array value defines the attribute value. Setting - * the array value to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not - * display anything. + * attribute name and the array value defines the attribute value. * * @return void */ @@ -183,23 +175,16 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 + * @since 1.5.0 Unsets the global variable. * * @global bool $_beans_is_selfclose_markup When true, indicates a self-closing element should be built. * - * @param string $id A unique string used as a reference. The $id argument may contain - * sub-hook(s). - * @param string $tag The self-closing HTML tag. When set to false or an empty string, the - * markup HTML tag will not be built, but both action hooks will fire. - * If set to null, the function bails out, i.e. the markup HTML tag - * will not be built and neither action hook fires. - * @param string|array $attributes Optional. Query string or array of attributes. The array key defines - * the attribute name and the array value defines the attribute value. - * Setting the array value to '' will display the attribute value as - * empty - * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will - * not - * display anything. + * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). + * @param string|bool $tag The self-closing HTML tag. When set to false or an empty string, the markup HTML tag + * will not be built, but both action hooks will fire. If set to null, the function + * bails out, i.e. the markup HTML tag will not be built and neither action hook fires. + * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the attribute + * name and the array value defines the attribute value. * * @return string|void */ @@ -222,16 +207,12 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { * * @since 1.4.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $tag The self-closing HTML tag. When set to false or an empty string, the markup HTML tag + * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). + * @param string|bool $tag The self-closing HTML tag. When set to false or an empty string, the markup HTML tag * will not be built, but both action hooks will fire. If set to null, the function * bails out, i.e. the markup HTML tag will not be built and neither action hook fires. - * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the - * attribute name and the array value defines the attribute value. Setting - * the array value to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not display - * anything. + * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the attribute + * name and the array value defines the attribute value. * * @return void */ From 2ddd957766fcc140241c144706b6d8d7e5455c81 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 18:51:01 -0500 Subject: [PATCH 399/800] Fixed formatting. --- lib/api/html/functions.php | 4 ++-- .../integration/api/html/fixtures/test-attachment.php | 8 ++++---- tests/phpunit/unit/api/html/fixtures/test-attachment.php | 8 ++++---- .../unit/api/html/includes/class-html-test-case.php | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 1c6f9aef..ea585337 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -138,7 +138,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { // Set and then fire the after action hook. $args[0] = $id . ( $_beans_is_selfclose_markup ? '_after_markup' : '_prepend_markup' ); - $output .= call_user_func_array( '_beans_render_action', $args ); + $output .= call_user_func_array( '_beans_render_action', $args ); // Reset the global variable to reduce memory usage. unset( $GLOBALS['_beans_is_selfclose_markup'] ); @@ -262,7 +262,7 @@ function beans_close_markup( $id, $tag ) { // Set and then fire the after action hook. $args[0] = $id . '_after_markup'; - $output .= call_user_func_array( '_beans_render_action', $args ); + $output .= call_user_func_array( '_beans_render_action', $args ); return $output; } diff --git a/tests/phpunit/integration/api/html/fixtures/test-attachment.php b/tests/phpunit/integration/api/html/fixtures/test-attachment.php index f4bbdffb..5151fca2 100644 --- a/tests/phpunit/integration/api/html/fixtures/test-attachment.php +++ b/tests/phpunit/integration/api/html/fixtures/test-attachment.php @@ -30,10 +30,10 @@ 'id' => 'beans_post_image_item', 'tag' => 'img', 'attributes' => array( - 'width' => 1200, - 'height' => 600, - 'src' => 'https://example.com/image.png', - 'alt' => 'A background image.', + 'width' => 1200, + 'height' => 600, + 'src' => 'https://example.com/image.png', + 'alt' => 'A background image.', 'itemprop' => 'image', ), 'attachment' => (object) array( diff --git a/tests/phpunit/unit/api/html/fixtures/test-attachment.php b/tests/phpunit/unit/api/html/fixtures/test-attachment.php index f31a1755..6e25b454 100644 --- a/tests/phpunit/unit/api/html/fixtures/test-attachment.php +++ b/tests/phpunit/unit/api/html/fixtures/test-attachment.php @@ -30,10 +30,10 @@ 'id' => 'beans_post_image_item', 'tag' => 'img', 'attributes' => array( - 'width' => 1200, - 'height' => 600, - 'src' => 'https://example.com/image.png', - 'alt' => 'A background image.', + 'width' => 1200, + 'height' => 600, + 'src' => 'https://example.com/image.png', + 'alt' => 'A background image.', 'itemprop' => 'image', ), 'attachment' => (object) array( diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index c65edbce..bf2a7dc8 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -46,8 +46,8 @@ abstract class HTML_Test_Case extends Test_Case { public static function setUpBeforeClass() { parent::setUpBeforeClass(); - static::$test_markup = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-markup.php'; - static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { + static::$test_markup = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-markup.php'; + static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { return isset( $markup['attributes'] ); } ); static::$test_attachments = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-attachment.php'; From 7fd656b03d4d900dbd366079b9095fdfb3c24570 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 19:34:38 -0500 Subject: [PATCH 400/800] Added tests. --- .../api/html/beansModifyMarkup.php | 88 +++++++++++++++++++ .../unit/api/html/beansModifyMarkup.php | 59 +++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 tests/phpunit/integration/api/html/beansModifyMarkup.php create mode 100644 tests/phpunit/unit/api/html/beansModifyMarkup.php diff --git a/tests/phpunit/integration/api/html/beansModifyMarkup.php b/tests/phpunit/integration/api/html/beansModifyMarkup.php new file mode 100644 index 00000000..800bf6e8 --- /dev/null +++ b/tests/phpunit/integration/api/html/beansModifyMarkup.php @@ -0,0 +1,88 @@ +assertInstanceOf( _Beans_Anonymous_Filters::class, beans_modify_markup( 'beans_archive_title', 'h2' ) ); + } + + /** + * Test beans_modify_markup() should register a callback to the "{$id}_markup" filter hook. + */ + public function test_should_register_callback_to_id_markup_filter() { + $anonymous_filter = beans_modify_markup( 'beans_archive_title', 'h2' ); + + $this->assertSame( 10, has_filter( 'beans_archive_title_markup', array( + $anonymous_filter, + 'callback', + ) ) ); + } + + /** + * Test beans_modify_markup() should modify the markup HTML tag. + */ + public function test_should_modify_markup_html_tag() { + beans_modify_markup( 'beans_archive_title', 'h2' ); + $expected = <<

    +EOB; + + // Let's test it out by running the markup for this ID. + add_action( 'beans_archive_title_before_markup', function() { + echo ''; + } ); + add_action( 'beans_archive_title_prepend_markup', function() { + echo ''; + } ); + + // Check the opening markup. + $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $this->assertSame( $expected, $actual ); + + // Check the closing markup. + $this->assertSame( '

    ', beans_close_markup( 'beans_archive_title', 'h1' ) ); + } + + /** + * Test beans_modify_markup() should modify the markup HTML self-closing tag. + */ + public function test_should_modify_markup_html_self_closing_tag() { + beans_modify_markup( 'beans_post_image_item', 'foo' ); + $expected = << +EOB; + + $actual = beans_selfclose_markup( 'beans_post_image_item', 'img', array( + 'width' => 800, + 'height' => 500, + 'src' => 'http://example.com/image.png', + 'alt' => 'Some image', + 'itemprop' => 'image', + ) ); + $this->assertSame( $expected, $actual ); + } +} diff --git a/tests/phpunit/unit/api/html/beansModifyMarkup.php b/tests/phpunit/unit/api/html/beansModifyMarkup.php new file mode 100644 index 00000000..bc8ff712 --- /dev/null +++ b/tests/phpunit/unit/api/html/beansModifyMarkup.php @@ -0,0 +1,59 @@ +alias( function( $hook, $value ) { + return new Anonymous_Filter_Stub( $hook, $value, 10 ); + } ); + + $this->assertInstanceOf( Anonymous_Filter_Stub::class, beans_modify_markup( 'beans_archive_title', 'h2' ) ); + } + + /** + * Test beans_modify_markup() should call beans_add_filter() to register the callback for the modification process. + */ + public function test_should_call_beans_add_filter_to_register_callback() { + Monkey\Functions\expect( 'beans_add_filter' ) + ->once() + ->with( 'beans_archive_title_markup', 'h2', 10, 1 ); + beans_modify_markup( 'beans_archive_title', 'h2' ); + + // Test is focused above on ensuring beans_add_filter() is called with the right arguments. + $this->assertTrue( true ); + } +} From b0e595b2417b9b8662e3f20be10910afcd5f7c1b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 19:38:00 -0500 Subject: [PATCH 401/800] Improved documentation. --- lib/api/html/functions.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 7ad2d1ca..c291005a 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -300,27 +300,18 @@ function beans_close_markup_e( $id, $tag ) { } /** - * Modify opening and closing HTML tag. Also works for self-closing markup. - * - * This function will automatically modify the opening and the closing HTML tag. If the markup is self-closing, - * the HTML tag will be modified accordingly. - * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. + * Modify the opening and closing or self-closing HTML tag. * * @since 1.0.0 * - * @param string $id The markup ID. + * @param string $id The target markup's ID. * @param string|callback $markup The replacement HTML tag. A callback is accepted if conditions need to be * applied. If arguments are available, then they are passed to the callback. * @param int $priority Optional. Used to specify the order in which the functions - * associated with a particular action are executed. Default 10. - * Lower numbers correspond with earlier execution, - * and functions with the same priority are executed - * in the order in which they were added to the action. - * @param int $args Optional. The number of arguments the function accepts. Default 1. + * associated with a particular action are executed. Default is 10. + * @param int $args Optional. The number of arguments the callback accepts. Default is 1. * - * @return bool Will always return true. + * @return bool|_Beans_Anonymous_Filters */ function beans_modify_markup( $id, $markup, $priority = 10, $args = 1 ) { return beans_add_filter( $id . '_markup', $markup, $priority, $args ); From be344fdab1bb2d4fe26e8fd7aef246d6dd57b24d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 19:42:49 -0500 Subject: [PATCH 402/800] Fixed formatting. --- tests/phpunit/integration/api/html/beansModifyMarkup.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/integration/api/html/beansModifyMarkup.php b/tests/phpunit/integration/api/html/beansModifyMarkup.php index 800bf6e8..51f5b994 100644 --- a/tests/phpunit/integration/api/html/beansModifyMarkup.php +++ b/tests/phpunit/integration/api/html/beansModifyMarkup.php @@ -75,7 +75,6 @@ public function test_should_modify_markup_html_self_closing_tag() { $expected = << EOB; - $actual = beans_selfclose_markup( 'beans_post_image_item', 'img', array( 'width' => 800, 'height' => 500, From b633154dbacc6db376861534989199ecce25bbb3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 20:02:31 -0500 Subject: [PATCH 403/800] Added integration tests. --- .../integration/api/html/beansResetMarkup.php | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 tests/phpunit/integration/api/html/beansResetMarkup.php diff --git a/tests/phpunit/integration/api/html/beansResetMarkup.php b/tests/phpunit/integration/api/html/beansResetMarkup.php new file mode 100644 index 00000000..8d5b683e --- /dev/null +++ b/tests/phpunit/integration/api/html/beansResetMarkup.php @@ -0,0 +1,84 @@ +assertEquals( 20, has_filter( 'beans_archive_title_markup', array( $anonymous_filter, 'callback' ) ) ); + + // Reset it. + beans_reset_markup( 'beans_archive_title' ); + + // Check that it did reset. + $this->assertFalse( has_filter( 'beans_archive_title_markup' ) ); + + // Double check by building the markup. + $actual = beans_open_markup( 'beans_archive_title', 'h1' ); + $this->assertSame( '

    ', $actual ); + $this->assertSame( '

    ', beans_close_markup( 'beans_archive_title', 'h1' ) ); + } + + /** + * Test beans_reset_markup() should reset the markup HTML self-closing tag. + */ + public function test_should_reset_markup_html_self_closing_tag() { + // First, register to modify the tag. + $anonymous_filter = beans_modify_markup( 'beans_post_image_item', 'foo', 20 ); + $this->assertEquals( 20, has_filter( 'beans_post_image_item_markup', array( $anonymous_filter, 'callback' ) ) ); + + // Reset it. + beans_reset_markup( 'beans_post_image_item' ); + + // Check that it did reset. + $this->assertFalse( has_filter( 'beans_post_image_item_markup' ) ); + + // Double check by building the markup. + $actual = beans_selfclose_markup( 'beans_post_image_item', 'img' ); + $this->assertSame( '', $actual ); + } + + /** + * Test beans_reset_markup() should reset sub-hooks. + */ + public function test_should_reset_sub_hooks() { + // First, register to modify the tag. + $anonymous_filter = beans_modify_markup( 'beans_title[_foo]', 'p', 20 ); + $this->assertEquals( 20, has_filter( 'beans_title[_foo]_markup', array( $anonymous_filter, 'callback' ) ) ); + + // Reset it. + beans_reset_markup( 'beans_title[_foo]' ); + + // Check that it did reset. + $this->assertFalse( has_filter( 'beans_title[_foo]_markup' ) ); + + // Double check by building the markup. + $actual = beans_open_markup( 'beans_title[_foo]', 'h4' ); + $this->assertSame( '

    ', $actual ); + $this->assertSame( '

    ', beans_close_markup( 'beans_title[_foo]', 'h4' ) ); + } +} From d81aad6d3879e3e09847838a35a6f5a9f4c4db71 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 20:05:21 -0500 Subject: [PATCH 404/800] Improved documentation. --- lib/api/html/functions.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 7ad2d1ca..2b96f98b 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -345,13 +345,8 @@ function beans_remove_markup( $id, $remove_actions = false ) { } /** - * Reset markup. - * - * This function will automatically reset the opening and the closing HTML tag to its original value. If the markup is - * self-closed, the HTML tag will be reset accordingly. - * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. + * Reset the given markup's tag. This function will automatically reset the opening and closing HTML tag or + * self-closing tag to its original value. * * @since 1.3.1 * From 0d9d2631ed348017eacd8aba1374a6715d1df011 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 20:16:01 -0500 Subject: [PATCH 405/800] Improved documentation. --- lib/api/html/functions.php | 28 +++++++++---------- .../api/html/beansSelfcloseMarkupE.php | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index ea585337..c380b0c5 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -93,9 +93,9 @@ function beans_remove_output( $id ) { * @since 1.0.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The HTML tag. When set to false or an empty string, the markup HTML tag will not be + * @param string|bool $tag The HTML tag. When set to false or an empty string, the HTML markup tag will not be * built, but both action hooks will fire. If set to null, the function bails out, i.e. - * the markup HTML tag will not be built and neither action hook fires. + * the HTML markup tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value defines the attribute value. * @@ -131,7 +131,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { $args[0] = $id . '_before_markup'; $output = call_user_func_array( '_beans_render_action', $args ); - // Skip the opening tag when it's empty. + // Build the opening tag when tag is available. if ( $tag ) { $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_beans_is_selfclose_markup ? '/' : '' ) . '>'; } @@ -153,9 +153,9 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { * @since 1.4.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The HTML tag. When set to false or an empty string, the markup HTML tag will not be + * @param string|bool $tag The HTML tag. When set to false or an empty string, the HTML markup tag will not be * built, but both action hooks will fire. If set to null, the function bails out, i.e. - * the markup HTML tag will not be built and neither action hook fires. + * the HTML markup tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value defines the attribute value. * @@ -180,9 +180,9 @@ function beans_open_markup_e( $id, $tag, $attributes = array() ) { * @global bool $_beans_is_selfclose_markup When true, indicates a self-closing element should be built. * * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The self-closing HTML tag. When set to false or an empty string, the markup HTML tag + * @param string|bool $tag The self-closing HTML tag. When set to false or an empty string, the HTML markup tag * will not be built, but both action hooks will fire. If set to null, the function - * bails out, i.e. the markup HTML tag will not be built and neither action hook fires. + * bails out, i.e. the HTML markup tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the attribute * name and the array value defines the attribute value. * @@ -208,9 +208,9 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { * @since 1.4.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The self-closing HTML tag. When set to false or an empty string, the markup HTML tag + * @param string|bool $tag The self-closing HTML tag. When set to false or an empty string, the HTML markup tag * will not be built, but both action hooks will fire. If set to null, the function - * bails out, i.e. the markup HTML tag will not be built and neither action hook fires. + * bails out, i.e. the HTML markup tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the attribute * name and the array value defines the attribute value. * @@ -231,8 +231,8 @@ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { * @since 1.0.0 * * @param string $id Identical to the opening markup ID. - * @param string $tag The HTML tag. When set to false or an empty string, the markup HTML tag will not be built, but - * both action hooks will fire. If set to null, the function bails out, i.e. the markup HTML + * @param string $tag The HTML tag. When set to false or an empty string, the HTML markup tag will not be built, but + * both action hooks will fire. If set to null, the function bails out, i.e. the HTML markup * tag will not be built and neither action hook fires. * * @return string|void @@ -255,7 +255,7 @@ function beans_close_markup( $id, $tag ) { $args[0] = $id . '_append_markup'; $output = call_user_func_array( '_beans_render_action', $args ); - // Skip the closing tag when it's empty. + // Build the closing tag when tag is available. if ( $tag ) { $output .= ''; } @@ -274,8 +274,8 @@ function beans_close_markup( $id, $tag ) { * @since 1.4.0 * * @param string $id Identical to the opening markup ID. - * @param string $tag The HTML tag. When set to false or an empty string, the markup HTML tag will not be built, but - * both action hooks will fire. If set to null, the function bails out, i.e. the markup HTML + * @param string $tag The HTML tag. When set to false or an empty string, the HTML markup tag will not be built, but + * both action hooks will fire. If set to null, the function bails out, i.e. the HTML markup * tag will not be built and neither action hook fires. * * @return void diff --git a/tests/phpunit/integration/api/html/beansSelfcloseMarkupE.php b/tests/phpunit/integration/api/html/beansSelfcloseMarkupE.php index 832cb545..9ee93dfc 100644 --- a/tests/phpunit/integration/api/html/beansSelfcloseMarkupE.php +++ b/tests/phpunit/integration/api/html/beansSelfcloseMarkupE.php @@ -26,7 +26,7 @@ class Tests_BeansSelfcloseMarkupE extends HTML_Test_Case { /** * Test beans_selfclose_markup_e() should echo an empty string when the tag is set to null. */ - public function test_should_return_null_when_tag_set_to_null() { + public function test_should_echo_empty_string_when_tag_set_to_null() { foreach ( static::$test_attachments as $attachment ) { ob_start(); @@ -38,7 +38,7 @@ public function test_should_return_null_when_tag_set_to_null() { /** * Test beans_selfclose_markup_e() should echo the built HTML self-closing element. */ - public function test_should_return_built_html_self_closing_element() { + public function test_should_echo_built_html_self_closing_element() { // Check the first attachment. $attachment = current( static::$test_attachments ); $expected = << Date: Thu, 22 Mar 2018 20:34:03 -0500 Subject: [PATCH 406/800] Fixed comments. --- tests/phpunit/integration/api/html/beansModifyMarkup.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansModifyMarkup.php b/tests/phpunit/integration/api/html/beansModifyMarkup.php index 51f5b994..18393021 100644 --- a/tests/phpunit/integration/api/html/beansModifyMarkup.php +++ b/tests/phpunit/integration/api/html/beansModifyMarkup.php @@ -43,9 +43,9 @@ public function test_should_register_callback_to_id_markup_filter() { } /** - * Test beans_modify_markup() should modify the markup HTML tag. + * Test beans_modify_markup() should modify the HTML markup tag. */ - public function test_should_modify_markup_html_tag() { + public function test_should_modify_html_markup_tag() { beans_modify_markup( 'beans_archive_title', 'h2' ); $expected = <<

    @@ -68,9 +68,9 @@ public function test_should_modify_markup_html_tag() { } /** - * Test beans_modify_markup() should modify the markup HTML self-closing tag. + * Test beans_modify_markup() should modify the HTML markup self-closing tag. */ - public function test_should_modify_markup_html_self_closing_tag() { + public function test_should_modify_html_markup_self_closing_tag() { beans_modify_markup( 'beans_post_image_item', 'foo' ); $expected = << From c9ee321d1d31256d841d0ed806d090befa2aeb8d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 22 Mar 2018 20:36:20 -0500 Subject: [PATCH 407/800] Fixed comments & test names. --- tests/phpunit/integration/api/html/beansResetMarkup.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansResetMarkup.php b/tests/phpunit/integration/api/html/beansResetMarkup.php index 8d5b683e..e3103492 100644 --- a/tests/phpunit/integration/api/html/beansResetMarkup.php +++ b/tests/phpunit/integration/api/html/beansResetMarkup.php @@ -24,9 +24,9 @@ class Tests_BeansResetMarkup extends HTML_Test_Case { /** - * Test beans_reset_markup() should reset the markup HTML opening and closing tag. + * Test beans_reset_markup() should reset the HTML markup opening and closing tag. */ - public function test_should_reset_markup_html_opening_and_closing_tag() { + public function test_should_reset_html_markup_opening_and_closing_tag() { // First, register to modify the tag. $anonymous_filter = beans_modify_markup( 'beans_archive_title', 'h2', 20 ); $this->assertEquals( 20, has_filter( 'beans_archive_title_markup', array( $anonymous_filter, 'callback' ) ) ); @@ -44,9 +44,9 @@ public function test_should_reset_markup_html_opening_and_closing_tag() { } /** - * Test beans_reset_markup() should reset the markup HTML self-closing tag. + * Test beans_reset_markup() should reset the HTML markup self-closing tag. */ - public function test_should_reset_markup_html_self_closing_tag() { + public function test_should_reset_html_markup_self_closing_tag() { // First, register to modify the tag. $anonymous_filter = beans_modify_markup( 'beans_post_image_item', 'foo', 20 ); $this->assertEquals( 20, has_filter( 'beans_post_image_item_markup', array( $anonymous_filter, 'callback' ) ) ); From 30129a1939a7432d03059aae82b1cfdfebc78142 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Thu, 22 Mar 2018 21:43:59 -0400 Subject: [PATCH 408/800] Improved WPCS compliance --- .../class-beans-wp-customize-control.php | 51 +++++++++++++++++++ ...class.php => class-beans-wp-customize.php} | 51 ++----------------- lib/api/wp-customize/functions.php | 12 ++--- 3 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 lib/api/wp-customize/class-beans-wp-customize-control.php rename lib/api/wp-customize/{class.php => class-beans-wp-customize.php} (76%) diff --git a/lib/api/wp-customize/class-beans-wp-customize-control.php b/lib/api/wp-customize/class-beans-wp-customize-control.php new file mode 100644 index 00000000..b788e598 --- /dev/null +++ b/lib/api/wp-customize/class-beans-wp-customize-control.php @@ -0,0 +1,51 @@ +beans_field = end( $args ); + } + + /** + * Field content. + * + * @since 1.0.0 + * + * @return void + */ + public function render_content() { + beans_field( $this->beans_field ); + } + } + +endif; diff --git a/lib/api/wp-customize/class.php b/lib/api/wp-customize/class-beans-wp-customize.php similarity index 76% rename from lib/api/wp-customize/class.php rename to lib/api/wp-customize/class-beans-wp-customize.php index ef828ddc..c2c49d13 100644 --- a/lib/api/wp-customize/class.php +++ b/lib/api/wp-customize/class-beans-wp-customize.php @@ -90,7 +90,7 @@ private function add() { * * @return void */ - private function add_section( $wp_customize ) { + private function add_section( WP_Customize_Manager $wp_customize ) { if ( $wp_customize->get_section( $this->section ) ) { return; @@ -117,7 +117,7 @@ private function add_section( $wp_customize ) { * * @return void */ - private function add_setting( $wp_customize, $field ) { + private function add_setting( WP_Customize_Manager $wp_customize, $field ) { $defaults = array( 'db_type' => 'theme_mod', 'capability' => 'edit_theme_options', @@ -149,7 +149,9 @@ private function add_setting( $wp_customize, $field ) { * * @return void */ - private function add_control( $wp_customize, $field ) { + private function add_control( WP_Customize_Manager $wp_customize, $field ) { + require_once 'class-beans-wp-customize-control.php'; + $class = '_Beans_WP_Customize_Control'; if ( $field['type'] !== $class && class_exists( $field['type'] ) ) { @@ -182,46 +184,3 @@ public function sanitize( $value ) { return $value; } } - -if ( class_exists( 'WP_Customize_Control' ) ) : - /** - * Render Beans fields content for WP Customize. - * - * @since 1.0.0 - * - * @ignore - * @access private - * - * @package Beans\Framework\API\WP_Customize - */ - class _Beans_WP_Customize_Control extends WP_Customize_Control { // phpcs:ignore Generic.Files.OneClassPerFile.MultipleFound, Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- Will be fixed. - - /** - * Field data. - * - * @var string - */ - private $beans_field; - - /** - * Constructor. - */ - public function __construct() { - $args = func_get_args(); - call_user_func_array( array( 'parent', '__construct' ), $args ); - $this->beans_field = end( $args ); - } - - /** - * Field content. - * - * @since 1.0.0 - * - * @return void - */ - public function render_content() { - beans_field( $this->beans_field ); - } - } - -endif; diff --git a/lib/api/wp-customize/functions.php b/lib/api/wp-customize/functions.php index e77af5bd..a24ebcf8 100644 --- a/lib/api/wp-customize/functions.php +++ b/lib/api/wp-customize/functions.php @@ -5,20 +5,20 @@ * * @package Beans\Framework\API\WP_Customize * - * @since 1.0.0 + * @since 1.0.0 */ /** * Register WP Customize Options. * - * This function should only be invoked through the 'customize_register' action. + * This function should only be called with the 'customize_register' action. * * @since 1.0.0 * * @param array $fields { * Array of fields to register. * - * @type string $id A unique id used for the field. This id will also be used to save the value in + * @type string $id A unique ID used for the field. This ID will also be used to save the value in * the database. * @type string $type The type of field to use. Please refer to the Beans core field types for more * information. Custom field types are accepted here. @@ -28,9 +28,9 @@ * @type array $attributes An array of attributes to add to the field. The array key defines the * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. - * @type array $fields Must only be used for 'group' field type. The array arguments are similary to the + * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the * {@see beans_register_fields()} $fields arguments. - * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields + * @type bool $db_group Must only be used for the 'group' field type. It defines whether the group of fields * registered should be saved as a group in the database or as individual * entries. Default false. * } @@ -72,7 +72,7 @@ function beans_register_wp_customize_options( array $fields, $section, $args = a } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once BEANS_API_PATH . 'wp-customize/class.php'; + require_once BEANS_API_PATH . 'wp-customize/class-beans-wp-customize.php'; new _Beans_WP_Customize( $section, $args ); } From 41c2aebdb157a63b99ba10f21d82717226d9505f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 10:55:28 -0500 Subject: [PATCH 409/800] Escaped in beans_open_markup. --- lib/api/html/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 14848bb6..c9f61233 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -133,7 +133,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { // Build the opening tag when tag is available. if ( $tag ) { - $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_beans_is_selfclose_markup ? '/' : '' ) . '>'; + $output .= '<' . esc_attr( $tag ) . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . esc_attr( $id ) . '"' : null ) . ( $_beans_is_selfclose_markup ? '/' : '' ) . '>'; } // Set and then fire the after action hook. @@ -163,7 +163,7 @@ function beans_open_markup( $id, $tag, $attributes = array() ) { */ function beans_open_markup_e( $id, $tag, $attributes = array() ) { $args = func_get_args(); - echo call_user_func_array( 'beans_open_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + echo call_user_func_array( 'beans_open_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped in beans_open_markup(). } /** @@ -217,7 +217,7 @@ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { * @return void */ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { - echo call_user_func_array( 'beans_selfclose_markup', func_get_args() ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + echo call_user_func_array( 'beans_selfclose_markup', func_get_args() ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped in beans_open_markup(). } /** From fcf81b2c16c96c88fd242b97d43c6456446de064 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 10:58:00 -0500 Subject: [PATCH 410/800] Escaped in beans_close_markup. --- lib/api/html/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index c9f61233..ee1e356b 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -257,7 +257,7 @@ function beans_close_markup( $id, $tag ) { // Build the closing tag when tag is available. if ( $tag ) { - $output .= ''; + $output .= ''; } // Set and then fire the after action hook. @@ -282,7 +282,7 @@ function beans_close_markup( $id, $tag ) { */ function beans_close_markup_e( $id, $tag ) { $args = func_get_args(); - echo call_user_func_array( 'beans_close_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + echo call_user_func_array( 'beans_close_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped in beans_close_markup(). } /** From f260581f9467dc2bd82d75082794c8f1b25b08dc Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 10:58:35 -0500 Subject: [PATCH 411/800] Escaped id in beans_output. --- lib/api/html/functions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index ee1e356b..a372ce5b 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -39,6 +39,7 @@ function beans_output( $id, $output ) { } if ( _beans_is_html_dev_mode() ) { + $id = esc_attr( $id ); $output = "" . $output . ""; } From 440f6e4bce45b095e4c91a28ceff9861f1ea4afb Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 10:59:29 -0500 Subject: [PATCH 412/800] Fixed comment. --- lib/api/html/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index a372ce5b..3a45e87e 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -58,7 +58,7 @@ function beans_output( $id, $output ) { */ function beans_output_e( $id, $output ) { $args = func_get_args(); - echo call_user_func_array( 'beans_output', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + echo call_user_func_array( 'beans_output', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped in beans_output. } /** From f25b3c8c8451a33976929819324719fbdde08542 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 11:47:18 -0500 Subject: [PATCH 413/800] Added escaping tests. --- lib/api/html/functions.php | 2 +- .../integration/api/html/beansCloseMarkup.php | 17 +++++++++ .../integration/api/html/beansOpenMarkup.php | 35 +++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 3a45e87e..181b4796 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -39,7 +39,7 @@ function beans_output( $id, $output ) { } if ( _beans_is_html_dev_mode() ) { - $id = esc_attr( $id ); + $id = esc_attr( $id ); $output = "" . $output . ""; } diff --git a/tests/phpunit/integration/api/html/beansCloseMarkup.php b/tests/phpunit/integration/api/html/beansCloseMarkup.php index 7c6ad1d4..60d5fcc3 100644 --- a/tests/phpunit/integration/api/html/beansCloseMarkup.php +++ b/tests/phpunit/integration/api/html/beansCloseMarkup.php @@ -132,4 +132,21 @@ public function test_should_return_hooked_callbacks_output_and_not_closing_tag_w $this->assertEquals( 2, did_action( 'beans_archive_title_append_markup' ) ); $this->assertEquals( 2, did_action( 'beans_archive_title_after_markup' ) ); } + + /** + * Test beans_close_markup() should escape the closing tag. + */ + public function test_should_escape_closing_tag() { + $expected = << +EOB; + // Check when given as the tag. + $this->assertSame( $expected, beans_close_markup( 'beans_post_title', '' ) ); + + // Check when tag is filtered. + add_filter( 'beans_post_title_markup', function() { + return ''; + }); + $this->assertSame( $expected, beans_close_markup( 'beans_post_title', 'h1' ) ); + } } diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php index 25f4702a..0743e415 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkup.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkup.php @@ -198,4 +198,39 @@ public function test_should_return_only_hooked_callbacks_output_and_no_html_elem $this->assertEquals( 2, did_action( 'beans_archive_title_prepend_markup' ) ); $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); } + + /** + * Test beans_open_markup() should escape the built HTML tag. + */ + public function test_should_escape_built_html_tag() { + $expected = << +EOB; + // Check when given as the tag. + $actual = beans_open_markup( 'beans_post_title', '', array( + 'class' => 'uk-article-title', + 'itemprop' => 'headline', + ) ); + $this->assertSame( $expected, $actual ); + + // Check when tag is filtered. + add_filter( 'beans_post_title_markup', function() { + return ''; + } ); + $actual = beans_open_markup( 'beans_post_title', 'h1', array( + 'class' => 'uk-article-title', + 'itemprop' => 'headline', + ) ); + $this->assertSame( $expected, $actual ); + + // Check the attributes too. + $expected = << +EOB; + $this->assertSame( $expected, beans_open_markup( 'beans_post_title_link', 'a', array( + 'href' => 'http://example.com/testing-ensure-safe?val=', + 'title' => 'Testing to ensure safe.', + 'rel' => 'bookmark', + ) ) ); + } } From 07e026d6bfe69fd6b300d193bc062d50a27739a5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 14:32:43 -0500 Subject: [PATCH 414/800] Mocked external functions for beans_add_action. --- .../unit/api/actions/beansAddAction.php | 172 +++++++++++++----- 1 file changed, 129 insertions(+), 43 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansAddAction.php b/tests/phpunit/unit/api/actions/beansAddAction.php index aafc2e9b..320bcb80 100644 --- a/tests/phpunit/unit/api/actions/beansAddAction.php +++ b/tests/phpunit/unit/api/actions/beansAddAction.php @@ -1,6 +1,6 @@ $action ) { // Test that the action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['added'] ); $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - // Set up the WordPress simulator before we add the action. - Monkey\Actions\expectAdded( $action['hook'] ) + // Set up the mocks. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'replaced' ) + ->ordered() + ->andReturn( false ) + ->andAlsoExpectIt() + ->once() + ->with( $beans_id, 'removed' ) + ->ordered() + ->andReturn( false ) + ->andAlsoExpectIt() + ->once() + ->with( $beans_id, 'modified' ) + ->ordered() + ->andReturn( false ); + Monkey\Functions\expect( '_beans_set_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action ) { - // Check that the parameters were added in WordPress. - $this->assertSame( $action['callback'], $callback ); - $this->assertSame( $action['priority'], $priority ); - $this->assertSame( $action['args'], $args ); + ->with( $beans_id, $action, 'added', true ) + ->andReturnUsing( function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; + + return $action; } ); + Monkey\Actions\expectAdded( $action['hook'] ) + ->once() + ->with( $action['callback'], $action['priority'], $action['args'] ); // Let's add the action. $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); // Check that it was registered in Beans and WordPress. - $this->assertEquals( $action, _beans_get_action( $beans_id, 'added' ) ); - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + $this->assertArrayHasKey( $beans_id, $_beans_registered_actions['added'] ); + $this->assertSame( $action, $_beans_registered_actions['added'][ $beans_id ] ); + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) ); } } @@ -59,6 +80,15 @@ public function test_should_add_action() { * with the exact same set of conditions. */ public function test_should_overwrite_add_action() { + global $_beans_registered_actions; + + Monkey\Functions\when( '_beans_get_action' )->justReturn( false ); + Monkey\Functions\when( '_beans_set_action' )->alias( function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; + + return $action; + } ); foreach ( static::$test_actions as $beans_id => $action ) { // Let's add it the first time. @@ -68,7 +98,8 @@ public function test_should_overwrite_add_action() { $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); // Now check that it's still registered in both Beans and WordPress. - $this->assertEquals( $action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertArrayHasKey( $beans_id, $_beans_registered_actions['added'] ); + $this->assertSame( $action, $_beans_registered_actions['added'][ $beans_id ] ); $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); } } @@ -77,40 +108,54 @@ public function test_should_overwrite_add_action() { * Test beans_add_action() should use the action configuration in "replaced" status, when it's available. */ public function test_should_use_replaced_action_when_available() { + global $_beans_registered_actions; $replaced_action = array( 'callback' => 'my_new_callback', 'priority' => 47, ); foreach ( static::$test_actions as $beans_id => $original_action ) { - // We want to store the "replaced" action first, before we add the original action. - _beans_set_action( $beans_id, $replaced_action, 'replaced', true ); + // Set up the mocks. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'replaced' ) + ->ordered() + ->andReturn( $replaced_action ) // Simulates that the replaced action is registered in Beans. + ->andAlsoExpectIt() + ->once() + ->with( $beans_id, 'removed' ) + ->ordered() + ->andReturn( false ) + ->andAlsoExpectIt() + ->once() + ->with( $beans_id, 'modified' ) + ->ordered() + ->andReturn( false ); + Monkey\Functions\expect( '_beans_set_action' ) + ->once() + ->with( $beans_id, array_merge( $original_action, $replaced_action ), 'added', true ) + ->andReturnUsing( function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; - // Set up the WordPress simulator before we add the action. + return $action; + } ); Monkey\Actions\expectAdded( $original_action['hook'] ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the callback and priority were replaced in WordPress. - $this->assertSame( $replaced_action['callback'], $callback ); - $this->assertSame( $replaced_action['priority'], $priority ); - // Check that the number of arguments remains unchanged in WordPress. - $this->assertSame( $original_action['args'], $args ); - } ); + ->with( $replaced_action['callback'], $replaced_action['priority'], $original_action['args'] ); // Next, add the original action. beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); - // Get the newly created action. - $new_action = _beans_get_action( $beans_id, 'added' ); - - // Check if the callback and priority were replaced. + // Check that the stored action has replaced the callback and priority arguments. + $new_action = $_beans_registered_actions['added'][ $beans_id ]; $this->assertEquals( $original_action['hook'], $new_action['hook'] ); $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); $this->assertEquals( $original_action['args'], $new_action['args'] ); // Now check that the action was replaced in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $replaced_action['callback'] ) !== false ); + $this->assertTrue( has_action( $original_action['hook'], $replaced_action['callback'] ) ); } } @@ -118,6 +163,7 @@ public function test_should_use_replaced_action_when_available() { * Test beans_add_action() should return false when the ID is registered to the "removed" status. */ public function test_should_return_false_when_removed() { + global $_beans_registered_actions; $empty_action = array( 'hook' => null, 'callback' => null, @@ -126,14 +172,37 @@ public function test_should_return_false_when_removed() { ); foreach ( static::$test_actions as $beans_id => $action ) { - // Store the "removed" action before we call beans_add_action(). - _beans_set_action( $beans_id, $empty_action, 'removed', true ); + // Set up the mocks. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'replaced' ) + ->ordered() + ->andReturn( false ) + ->andAlsoExpectIt() + ->once() + ->with( $beans_id, 'removed' ) + ->ordered() + ->andReturn( $empty_action ) // Simulates that the "removed" action is registered in Beans. + ->andAlsoExpectIt() + ->with( $beans_id, 'modified' ) + ->never(); + Monkey\Functions\expect( '_beans_set_action' ) + ->once() + ->with( $beans_id, $action, 'added', true ) + ->andReturnUsing( function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; + + return $action; + } ); + Monkey\Actions\expectAdded( $action['hook'] )->never(); // Next, add the action. beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ); - // Check if the action is stored as "added". - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + // Check if the action is stored as "added" in Beans. + $this->assertArrayHasKey( $beans_id, $_beans_registered_actions['added'] ); + $this->assertSame( $action, $_beans_registered_actions['added'][ $beans_id ] ); // Check that the action is not registered in WordPress. $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); @@ -144,34 +213,51 @@ public function test_should_return_false_when_removed() { * Test beans_add_action() should merge the "modified" action configuration parameters. */ public function test_should_merge_modified_action_parameters() { + global $_beans_registered_actions; $modified_action = array( 'callback' => 'foo', 'priority' => 17, ); foreach ( static::$test_actions as $beans_id => $original_action ) { - // We want to store the "modified" action first, before we add the original action. - _beans_set_action( $beans_id, $modified_action, 'modified', true ); + // Set up the mocks. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'replaced' ) + ->ordered() + ->andReturn( false ) + ->andAlsoExpectIt() + ->once() + ->with( $beans_id, 'removed' ) + ->ordered() + ->andReturn( false ) + ->andAlsoExpectIt() + ->once() + ->with( $beans_id, 'modified' ) + ->ordered() + ->andReturn( $modified_action ); // Simulates that the "modified" action is registered in Beans. + Monkey\Functions\expect( '_beans_set_action' ) + ->once() + ->with( $beans_id, $original_action, 'added', true ) + ->andReturnUsing( function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; - // Set up the WordPress simulator before we add the action. + return $action; + } ); Monkey\Actions\expectAdded( $original_action['hook'] ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { - // Check that the callback and priority were modified in WordPress. - $this->assertSame( $modified_action['callback'], $callback ); - $this->assertSame( $modified_action['priority'], $priority ); - // Check that the number of arguments remains unchanged in WordPress. - $this->assertSame( $original_action['args'], $args ); - } ); + ->with( $modified_action['callback'], $modified_action['priority'], $original_action['args'] ); // Next, add the original action. beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); // Test that the original action is stored away, which allows us to reset it (if we want). - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertArrayHasKey( $beans_id, $_beans_registered_actions['added'] ); + $this->assertSame( $original_action, $_beans_registered_actions['added'][ $beans_id ] ); // Now check that the action was modified in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); + $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) ); } } } From 2ac418978014252237a0be903d571ddf027e7dc3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 14:38:51 -0500 Subject: [PATCH 415/800] Added test for beans_add_smart_action. --- .../unit/api/actions/beansSmartAddAction.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/phpunit/unit/api/actions/beansSmartAddAction.php diff --git a/tests/phpunit/unit/api/actions/beansSmartAddAction.php b/tests/phpunit/unit/api/actions/beansSmartAddAction.php new file mode 100644 index 00000000..ac810283 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beansSmartAddAction.php @@ -0,0 +1,40 @@ +once() + ->with( $action['callback'], $action['hook'], $action['callback'], 10, 1 ) + ->andReturn( true ); + + $this->assertTrue( beans_add_smart_action( $action['hook'], $action['callback'] ) ); + } + } +} From 92091c4cc33c7f1f5916fa3e8edd4d31292168f2 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 16:55:23 -0500 Subject: [PATCH 416/800] Mocked external functions for beans_modify_action. --- .../unit/api/actions/beansModifyAction.php | 197 ++++++++++-------- 1 file changed, 107 insertions(+), 90 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansModifyAction.php b/tests/phpunit/unit/api/actions/beansModifyAction.php index 3ec6a636..e12a7c78 100644 --- a/tests/phpunit/unit/api/actions/beansModifyAction.php +++ b/tests/phpunit/unit/api/actions/beansModifyAction.php @@ -1,6 +1,6 @@ go_to_post( true ); - foreach ( static::$test_actions as $beans_id => $original_action ) { $this->assertFalse( beans_modify_action( $beans_id ) ); // Verify that the action was not stored as "modified". $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action was not replaced. - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); } } @@ -47,17 +42,35 @@ public function test_should_return_false_when_nothing_to_modify() { * Test beans_modify_action() should register with Beans as "modified", but not add the action. */ public function test_should_register_as_modified_but_not_add_action() { + global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { // Check the starting state. + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + + // Set up the mocks. + Monkey\Functions\expect( '_beans_get_current_action' ) + ->once() + ->with( $beans_id ) + ->andReturn( false ); + Monkey\Functions\expect( '_beans_merge_action' ) + ->once() + ->with( $beans_id, $action, 'modified' ) + ->andReturnUsing( function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['modified'][ $id ] = $action; + + return $action; + } ); + Monkey\Actions\expectAdded( $action['hook'] )->never(); // Check that it returns false. $this->assertFalse( beans_modify_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); // Check that it did register as "modified" in Beans. - $this->assertEquals( $action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertArrayHasKey( $beans_id, $_beans_registered_actions['modified'] ); + $this->assertSame( $action, $_beans_registered_actions['modified'][ $beans_id ] ); // Check that the action was not added in WordPress. $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); @@ -68,34 +81,33 @@ public function test_should_register_as_modified_but_not_add_action() { * Test beans_modify_action() should modify the registered action's hook. */ public function test_should_modify_the_action_hook() { - $modified_action = array( - 'hook' => 'foo', - ); - - $this->go_to_post( true ); + $modified_hook = 'foo'; foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $modified_action['hook'] ) + Monkey\Functions\expect( '_beans_get_current_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { - // Check that the parameters remain unchanged in WordPress. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); + ->with( $beans_id ) + ->andReturn( $original_action ); - // Modify the hook. - $this->assertTrue( beans_modify_action( $beans_id, $modified_action['hook'] ) ); + // Expect that the original action gets removed. + Monkey\Functions\expect( 'remove_action' ) + ->once() + ->with( $original_action['hook'], $original_action['callback'], $original_action['priority'] ); - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + // When called, return the modified action. + Monkey\Functions\expect( '_beans_merge_action' ) + ->once() + ->with( $beans_id, array( 'hook' => $modified_hook ), 'modified' ) + ->andReturn( array( 'hook' => $modified_hook ) ); - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + // Expect the modified hook is added, but not the original hook. + Monkey\Actions\expectAdded( $original_action['hook'] )->never(); + Monkey\Actions\expectAdded( $modified_hook ) + ->once() + ->with( $original_action['callback'], $original_action['priority'], $original_action['args'] ); - // Check that the modified action was added in WordPress. - $this->assertTrue( has_action( $modified_action['hook'], $original_action['callback'] ) !== false ); + // Modify the hook. + $this->assertTrue( beans_modify_action( $beans_id, $modified_hook ) ); } } @@ -103,35 +115,32 @@ public function test_should_modify_the_action_hook() { * Test beans_modify_action() should modify the registered action's callback. */ public function test_should_modify_the_action_callback() { - $modified_action = array( - 'callback' => 'my_callback', - ); - - $this->go_to_post( true ); + $modified_callback = 'my_callback'; foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + Monkey\Functions\expect( '_beans_get_current_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { - // Check that the callback was modified in WordPress. - $this->assertSame( $modified_action['callback'], $callback ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); + ->with( $beans_id ) + ->andReturn( $original_action ); - // Modify the action's callback. - $this->assertTrue( beans_modify_action( $beans_id, null, $modified_action['callback'] ) ); + // Expect that the original action gets removed. + Monkey\Functions\expect( 'remove_action' ) + ->once() + ->with( $original_action['hook'], $original_action['callback'], $original_action['priority'] ); - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + // When called, return the modified action. + Monkey\Functions\expect( '_beans_merge_action' ) + ->once() + ->with( $beans_id, array( 'callback' => $modified_callback ), 'modified' ) + ->andReturn( array( 'callback' => $modified_callback ) ); - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + // Expect the original hook with the modified callback. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->with( $modified_callback, $original_action['priority'], $original_action['args'] ); - // Check that the modified action was added in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); + // Modify the action. + $this->assertTrue( beans_modify_action( $beans_id, null, $modified_callback ) ); } } @@ -139,29 +148,32 @@ public function test_should_modify_the_action_callback() { * Test beans_modify_action() should modify the registered action's priority level. */ public function test_should_modify_the_action_priority() { - $modified_action = array( - 'priority' => 20, - ); - - $this->go_to_post( true ); + $modified_priority = 20; foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + Monkey\Functions\expect( '_beans_get_current_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { - // Check that the priority was modified in WordPress. - $this->assertSame( $modified_action['priority'], $priority ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['args'], $args ); - } ); + ->with( $beans_id ) + ->andReturn( $original_action ); - // Modify the action's priority. - $this->assertTrue( beans_modify_action( $beans_id, null, null, $modified_action['priority'] ) ); + // Expect that the original action gets removed. + Monkey\Functions\expect( 'remove_action' ) + ->once() + ->with( $original_action['hook'], $original_action['callback'], $original_action['priority'] ); - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + // When called, return the modified action. + Monkey\Functions\expect( '_beans_merge_action' ) + ->once() + ->with( $beans_id, array( 'priority' => $modified_priority ), 'modified' ) + ->andReturn( array( 'priority' => $modified_priority ) ); + + // Expect the original hook with the modified callback. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->with( $original_action['callback'], $modified_priority, $original_action['args'] ); + + // Modify the hook. + $this->assertTrue( beans_modify_action( $beans_id, null, null, $modified_priority ) ); } } @@ -169,29 +181,34 @@ public function test_should_modify_the_action_priority() { * Test beans_modify_action() should modify the registered action's number of arguments. */ public function test_should_modify_the_action_args() { - $modified_action = array( - 'args' => 7, - ); - - $this->go_to_post( true ); + $modified_args = 7; foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) - ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { - // Check that the number of arguments was modified in WordPress. - $this->assertSame( $modified_action['args'], $args ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - } ); - - // Modify the action's number of arguments. - $this->assertTrue( beans_modify_action( $beans_id, null, null, null, $modified_action['args'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + Monkey\Functions\expect( '_beans_get_current_action' ) + ->once() + ->with( $beans_id ) + ->andReturn( $original_action ); + + // Expect that the original action gets removed. + Monkey\Functions\expect( 'remove_action' ) + ->once() + ->with( $original_action['hook'], $original_action['callback'], $original_action['priority'] ); + + // When called, return the modified action. + Monkey\Functions\expect( '_beans_merge_action' ) + ->once() + ->with( $beans_id, array( 'args' => $modified_args ), 'modified' ) + ->andReturn( array( 'args' => $modified_args ) ); + + // Expect the original hook with the modified callback. + Monkey\Actions\expectAdded( $original_action['hook'] ) + ->once() + ->with( $original_action['callback'], $original_action['priority'], $modified_args ); + + // Modify the action. + $this->assertTrue( beans_modify_action( $beans_id, null, null, null, $modified_args ) ); + } } } } From 327f0d176de50c1dd93e3f1c9068865bbccb418a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 16:59:54 -0500 Subject: [PATCH 417/800] Simplified beans_modify_action sugar functions. 1. Test that it invokes beans_modify_action. 2. For _hook and _callback, check the bail out condition(s). --- .../actions/beansModifyActionArguments.php | 105 ++--------------- .../api/actions/beansModifyActionCallback.php | 80 ++----------- .../api/actions/beansModifyActionHook.php | 84 +++----------- .../api/actions/beansModifyActionPriority.php | 106 ++---------------- 4 files changed, 39 insertions(+), 336 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansModifyActionArguments.php b/tests/phpunit/unit/api/actions/beansModifyActionArguments.php index 0eb106f4..b7432ee3 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionArguments.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionArguments.php @@ -1,6 +1,6 @@ go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - - foreach ( $arguments as $number_of_args ) { - $this->assertFalse( beans_modify_action_arguments( $beans_id, $number_of_args ) ); - - // Check that the modification was not stored in Beans. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - } - } - } - - /** - * Test beans_modify_action_arguments() should modify the action's "args" when the new one is zero. - */ - public function test_should_modify_action_when_args_is_zero() { - $arguments = array( 0, 0.0, '0', '0.0' ); - - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - - foreach ( $arguments as $number_of_args ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) - ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $number_of_args ) { - // Check that the number of arguments was modified in WordPress. - $this->assertSame( (int) $number_of_args, $args ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - } ); - - // Modify the action's number of arguments. - $this->assertTrue( beans_modify_action_arguments( $beans_id, $number_of_args ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( array( 'args' => (int) $number_of_args ), _beans_get_action( $beans_id, 'modified' ) ); - } - } - } - - /** - * Test beans_modify_action() should register with Beans as "modified", but not add the action. - */ - public function test_should_register_as_modified_but_not_add_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check the starting state. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that it returns false. - $this->assertFalse( beans_modify_action_arguments( $beans_id, $action['args'] ) ); - - // Check that it did register as "modified" in Beans. - $this->assertEquals( array( 'args' => $action['args'] ), _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action was not added in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_modify_action() should modify the registered action's number of arguments. - */ - public function test_should_modify_the_action_args() { - $modified_action = array( - 'args' => 7, - ); - - $this->go_to_post( true ); + public function test_should_invoke_beans_modify_action() { foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + Monkey\Functions\expect( 'beans_modify_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { - // Check that the number of arguments was modified in WordPress. - $this->assertSame( $modified_action['args'], $args ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - } ); - - // Modify the action's number of arguments. - $this->assertTrue( beans_modify_action_arguments( $beans_id, $modified_action['args'] ) ); + ->with( $beans_id, null, null, null, $original_action['args'] ) + ->andReturn( true ); - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertTrue( beans_modify_action_arguments( $beans_id, $original_action['args'] ) ); } } } diff --git a/tests/phpunit/unit/api/actions/beansModifyActionCallback.php b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php index 7af341c7..e4ef5587 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionCallback.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php @@ -1,6 +1,6 @@ go_to_post( true ); + foreach ( static::$test_ids as $beans_id ) { + Monkey\Functions\expect( 'beans_modify_action' )->never(); - foreach ( static::$test_actions as $beans_id => $original_action ) { - - foreach ( $callbacks as $callback ) { - $this->assertFalse( beans_modify_action_callback( $beans_id, $callback ) ); - - // Check that the callback did not get stored as "modified" in Beans. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the callback did not change in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); - } + $this->assertFalse( beans_modify_action_callback( $beans_id, null ) ); } } /** - * Test beans_modify_action_callback() should register with Beans as "modified", but not add the action. + * Test beans_modify_action_callback() should invoke beans_modify_action(). */ - public function test_should_register_as_modified_but_not_add_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check the starting state. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that it returns false. - $this->assertFalse( beans_modify_action_callback( $beans_id, $action['callback'] ) ); - - // Check that it did register as "modified" in Beans. - $this->assertEquals( array( 'callback' => $action['callback'] ), _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action was not added in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_modify_action_callback() should modify the registered action's callback. - */ - public function test_should_modify_the_action_callback() { - $modified_action = array( - 'callback' => 'my_callback', - ); - - $this->go_to_post( true ); + public function test_should_invoke_beans_modify_action() { foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + Monkey\Functions\expect( 'beans_modify_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { - // Check that the callback was modified in WordPress. - $this->assertSame( $modified_action['callback'], $callback ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Modify the action's callback. - $this->assertTrue( beans_modify_action_callback( $beans_id, $modified_action['callback'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + ->with( $beans_id, null, $original_action['callback'] ) + ->andReturn( true ); - // Check that the modified action was added in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); + $this->assertTrue( beans_modify_action_callback( $beans_id, $original_action['callback'] ) ); } } } diff --git a/tests/phpunit/unit/api/actions/beansModifyActionHook.php b/tests/phpunit/unit/api/actions/beansModifyActionHook.php index 2dc41eae..cd479f6f 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionHook.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionHook.php @@ -1,6 +1,6 @@ go_to_post( true ); + foreach ( static::$test_ids as $beans_id ) { + Monkey\Functions\expect( 'beans_modify_action' )->never(); - foreach ( static::$test_actions as $beans_id => $original_action ) { - - foreach ( $hooks as $hook ) { - $this->assertFalse( beans_modify_action_hook( $beans_id, $hook ) ); - - // Check that the hook did not get stored as "modified" in Beans. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the hook did not change in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); - } + $this->assertFalse( beans_modify_action_hook( $beans_id, '' ) ); + $this->assertFalse( beans_modify_action_hook( $beans_id, array( 'not-a-string' ) ) ); } } /** - * Test beans_modify_action_hook() should register with Beans as "modified", but not add the action. + * Test beans_modify_action_hook() should invoke beans_modify_action(). */ - public function test_should_register_as_modified_but_not_add_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check the starting state. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that it returns false. - $this->assertFalse( beans_modify_action_hook( $beans_id, $action['hook'] ) ); - - // Check that it did register as "modified" in Beans. - $this->assertEquals( array( 'hook' => $action['hook'] ), _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action was not added in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_modify_action_hook() should modify the registered action's hook. - */ - public function test_should_modify_the_action_hook() { - $modified_action = array( - 'hook' => 'foo', - ); - - $this->go_to_post( true ); + public function test_should_invoke_beans_modify_action() { foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $modified_action['hook'] ) + Monkey\Functions\expect( 'beans_modify_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { - // Check that the parameters remain unchanged in WordPress. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Modify the callback. - $this->assertTrue( beans_modify_action_hook( $beans_id, $modified_action['hook'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + ->with( $beans_id, $original_action['hook'] ) + ->andReturn( true ); - // Check that the modified action was added in WordPress. - $this->assertTrue( has_action( $modified_action['hook'], $original_action['callback'] ) !== false ); + $this->assertTrue( beans_modify_action_hook( $beans_id, $original_action['hook'] ) ); } } } diff --git a/tests/phpunit/unit/api/actions/beansModifyActionPriority.php b/tests/phpunit/unit/api/actions/beansModifyActionPriority.php index 9131ed30..bcab6ca5 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionPriority.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionPriority.php @@ -1,6 +1,6 @@ go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - - foreach ( $priorities as $priority ) { - // Check that it returns false. - $this->assertFalse( beans_modify_action_priority( $beans_id, $priority ) ); - - // Check that the priority did not get stored as "modified" in Beans. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - } - } - } - - /** - * Test beans_modify_action_priority() should modify the action's priority when the new priority level is zero. - */ - public function test_should_modify_action_when_priority_is_zero() { - $priorities = array( 0, 0.0, '0', '0.0' ); - - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - - foreach ( $priorities as $modified_priority ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) - ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_priority ) { - // Check that the priority was modified in WordPress. - $this->assertSame( (int) $modified_priority, $priority ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Modify the priority. - $this->assertTrue( beans_modify_action_priority( $beans_id, $modified_priority ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( array( 'priority' => (int) $modified_priority ), _beans_get_action( $beans_id, 'modified' ) ); - } - } - } - - /** - * Test beans_modify_action_priority() should register with Beans as "modified", but not add the action. - */ - public function test_should_register_as_modified_but_not_add_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check the starting state. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that it returns false. - $this->assertFalse( beans_modify_action_priority( $beans_id, $action['priority'] ) ); - - // Check that it did register as "modified" in Beans. - $this->assertEquals( array( 'priority' => $action['priority'] ), _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action was not added in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_modify_action() should modify the registered action's priority level. - */ - public function test_should_modify_the_action_priority() { - $modified_action = array( - 'priority' => 20, - ); - - $this->go_to_post( true ); + public function test_should_invoke_beans_modify_action() { foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + Monkey\Functions\expect( 'beans_modify_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $modified_action ) { - // Check that the priority was modified in WordPress. - $this->assertSame( $modified_action['priority'], $priority ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Modify the action's priority. - $this->assertTrue( beans_modify_action_priority( $beans_id, $modified_action['priority'] ) ); + ->with( $beans_id, null, null, $original_action['priority'] ) + ->andReturn( true ); - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + $this->assertTrue( beans_modify_action_priority( $beans_id, $original_action['priority'] ) ); } } } From ab0c442577d0a74590294510b0afc03259078525 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 18:16:40 -0500 Subject: [PATCH 418/800] Simplified beans_replace_action functions tests. --- .../unit/api/actions/beansReplaceAction.php | 323 ++++++------------ .../actions/beansReplaceActionArguments.php | 124 +------ .../actions/beansReplaceActionCallback.php | 126 +------ .../api/actions/beansReplaceActionHook.php | 125 +------ .../actions/beansReplaceActionPriority.php | 124 +------ 5 files changed, 136 insertions(+), 686 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansReplaceAction.php b/tests/phpunit/unit/api/actions/beansReplaceAction.php index 4bc46892..1ea846e2 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceAction.php +++ b/tests/phpunit/unit/api/actions/beansReplaceAction.php @@ -1,6 +1,6 @@ 'my_new_callback', - ); - - foreach ( static::$test_ids as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + public function test_should_return_false_when_nothing_to_modify() { - // Now store away the "replace" hook. - $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Check that neither of these functions are called. + Monkey\Functions\expect( '_beans_merge_action' )->never(); + Monkey\Functions\expect( 'beans_modify_action' )->never(); - // Check that it was stored as "modified" and "added". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( beans_replace_action( $beans_id ) ); } } /** * Test beans_replace_action() should store the "replaced" action when the original action - * has not yet been registered. Once the original action is registered, then it should be replaced. + * has not yet been registered. * * Intent: We are testing to ensure Beans is "load order" agnostic. */ - public function test_should_store_and_then_replace_action() { - $replaced_action = array( - 'callback' => 'my_new_callback', - ); + public function test_should_store_when_action_is_not_registered() { + $replaced_callback = 'my_new_callback'; + $replaced_action = array( 'callback' => $replaced_callback ); - // Now replace the actions. foreach ( static::$test_ids as $beans_id ) { - beans_replace_action( $beans_id, null, $replaced_action['callback'] ); - } - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we add the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + Monkey\Functions\expect( '_beans_merge_action' ) + // Simulate that the replaced action gets stored in the "replaced" container. ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the callback was replaced in WordPress. - $this->assertSame( $replaced_action['callback'], $callback ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Now add the original action. - beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); - - // Check that the original action's callback was replaced in Beans. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->assertTrue( has_action( $original_action['hook'], $replaced_action['callback'] ) !== false ); - } - } - - /** - * Test beans_replace_action() should return false when there's nothing to replace, - * i.e. no arguments passed. - */ - public function test_should_return_false_when_nothing_to_replace() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check it returns false. - $this->assertFalse( beans_replace_action( $beans_id ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); + ->with( $beans_id, $replaced_action, 'replaced' ) + ->ordered() + ->andReturn( $replaced_action ) + ->andAlsoExpectIt() + // Check that it does not call it to merge with "added". + ->with( $beans_id, $replaced_action, 'added' ) + ->never(); + + Monkey\Functions\expect( 'beans_modify_action' ) + ->once() + ->with( $beans_id, null, $replaced_callback, null, null ) + ->andReturn( false ); - // Check that the original action has not been replaced. - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); + // Run the replace. + $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_callback ) ); } } @@ -116,41 +74,28 @@ public function test_should_return_false_when_nothing_to_replace() { * Test beans_replace_action() should replace the registered action's hook. */ public function test_should_replace_the_action_hook() { - $replaced_action = array( - 'hook' => 'foo', - ); + $replaced_hook = 'foo'; + $replaced_action = array( 'hook' => $replaced_hook ); - $this->go_to_post( true ); + foreach ( static::$test_ids as $beans_id ) { + Monkey\Functions\expect( '_beans_merge_action' ) + // Simulate that the replaced action gets stored in the "replaced" container. + ->once() + ->with( $beans_id, $replaced_action, 'replaced' ) + ->ordered() + ->andReturn( $replaced_action ) + ->andAlsoExpectIt() + // Simulate that the "replaced" hook overwrites the "added" hook. + ->once() + ->with( $beans_id, $replaced_action, 'added' ); - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we replace the action. - Monkey\Actions\expectAdded( $replaced_action['hook'] ) + Monkey\Functions\expect( 'beans_modify_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { - // Check that the parameters remain unchanged in WordPress. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); + ->with( $beans_id, $replaced_hook, null, null, null ) + ->andReturn( true ); // Simulate that the original action was replaced. // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, $replaced_action['hook'] ) ); - - // Check that only the hook was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - - // Check that the replace action was added in WordPress. - $this->assertTrue( has_action( $replaced_action['hook'], $original_action['callback'] ) !== false ); + $this->assertTrue( beans_replace_action( $beans_id, $replaced_hook ) ); } } @@ -158,42 +103,28 @@ public function test_should_replace_the_action_hook() { * Test beans_replace_action() should replace the registered action's callback. */ public function test_should_replace_the_action_callback() { - $replaced_action = array( - 'callback' => 'foo', - ); + $replaced_callback = 'my_replaced_callback'; + $replaced_action = array( 'callback' => $replaced_callback ); - $this->go_to_post( true ); + foreach ( static::$test_ids as $beans_id ) { + Monkey\Functions\expect( '_beans_merge_action' ) + // Simulate that the replaced action gets stored in the "replaced" container. + ->once() + ->with( $beans_id, $replaced_action, 'replaced' ) + ->ordered() + ->andReturn( $replaced_action ) + ->andAlsoExpectIt() + // Simulate that the "replaced" hook overwrites the "added" hook. + ->once() + ->with( $beans_id, $replaced_action, 'added' ); - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we replace the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + Monkey\Functions\expect( 'beans_modify_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the callback was replaced in WordPress. - $this->assertSame( $replaced_action['callback'], $callback ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); + ->with( $beans_id, null, $replaced_callback, null, null ) + ->andReturn( true ); // Simulate that the original action was replaced. // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); - - // Check that only the callback was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - - // Check that the replace action was added in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $replaced_action['callback'] ) !== false ); + $this->assertTrue( beans_replace_action( $beans_id, null, $replaced_callback ) ); } } @@ -201,36 +132,28 @@ public function test_should_replace_the_action_callback() { * Test beans_replace_action() should replace the registered action's priority level. */ public function test_should_replace_the_action_priority() { - $replaced_action = array( - 'priority' => 52, - ); + $replaced_priority = -2; + $replaced_action = array( 'priority' => $replaced_priority ); - $this->go_to_post( true ); + foreach ( static::$test_ids as $beans_id ) { + Monkey\Functions\expect( '_beans_merge_action' ) + // Simulate that the replaced action gets stored in the "replaced" container. + ->once() + ->with( $beans_id, $replaced_action, 'replaced' ) + ->ordered() + ->andReturn( $replaced_action ) + ->andAlsoExpectIt() + // Simulate that the "replaced" hook overwrites the "added" hook. + ->once() + ->with( $beans_id, $replaced_action, 'added' ); - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we replace the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + Monkey\Functions\expect( 'beans_modify_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the priority was replaced in WordPress. - $this->assertSame( $replaced_action['priority'], $priority ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['args'], $args ); - } ); + ->with( $beans_id, null, null, $replaced_priority, null ) + ->andReturn( true ); // Simulate that the original action was replaced. // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); - - // Check that only the priority was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans. - $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_priority ) ); } } @@ -238,82 +161,28 @@ public function test_should_replace_the_action_priority() { * Test beans_replace_action() should replace the registered action's number of arguments. */ public function test_should_replace_the_action_args() { - $replaced_action = array( - 'args' => 6, - ); + $replaced_args = 6; + $replaced_action = array( 'args' => $replaced_args ); - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we replace the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + foreach ( static::$test_ids as $beans_id ) { + Monkey\Functions\expect( '_beans_merge_action' ) + // Simulate that the replaced action gets stored in the "replaced" container. ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the number of arguments was replaced in WordPress. - $this->assertSame( $replaced_action['args'], $args ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - } ); - - // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); - - // Check that only the number of arguments was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $replaced_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - } - } - - /** - * Test beans_replace_action() should replace the original registered action. - */ - public function test_should_replace_the_action() { - $replaced_action = array( - 'hook' => 'new_hook', - 'callback' => 'new_callback', - 'priority' => 99, - 'args' => 10, - ); - - $this->go_to_post( true ); + ->with( $beans_id, $replaced_action, 'replaced' ) + ->ordered() + ->andReturn( $replaced_action ) + ->andAlsoExpectIt() + // Simulate that the "replaced" hook overwrites the "added" hook. + ->once() + ->with( $beans_id, $replaced_action, 'added' ); - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we replace the action. - Monkey\Actions\expectAdded( $replaced_action['hook'] ) + Monkey\Functions\expect( 'beans_modify_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $replaced_action ) { - // Check that all parameters were replaced in WordPress. - $this->assertSame( $replaced_action['callback'], $callback ); - $this->assertSame( $replaced_action['priority'], $priority ); - $this->assertSame( $replaced_action['args'], $args ); - } ); + ->with( $beans_id, null, null, null, $replaced_args ) + ->andReturn( true ); // Simulate that the original action was replaced. // Run the replace. - $this->assertTrue( beans_replace_action( - $beans_id, - $replaced_action['hook'], - $replaced_action['callback'], - $replaced_action['priority'], - $replaced_action['args'] - ) ); - - // Check that the replaced action has been stored in Beans. - $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); - $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); - $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - - // Check that the replaced action is now registered in WordPress. - $this->assertTrue( has_action( $replaced_action['hook'], $replaced_action['callback'] ) !== false ); + $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_args ) ); } } } diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php index 9a9ab504..f359d92d 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionArguments.php @@ -1,6 +1,6 @@ 10, - ); + public function test_should_invoke_beans_replace_action() { - foreach ( array_keys( static::$test_actions ) as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - - // Now store away the "replace" args. - $this->assertFalse( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); - - // Check that it was stored as "modified". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - } - } - - /** - * Test beans_replace_action_arguments() should store the "replaced" args when the original action - * has not yet been registered. Once the original action is registered, then the args should be replaced. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_replace_the_args() { - $replaced_action = array( - 'args' => 10, - ); - - // Now replace the actions. - foreach ( static::$test_ids as $beans_id ) { - beans_replace_action_arguments( $beans_id, $replaced_action['args'] ); - } - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we add the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + foreach ( static::$test_actions as $beans_id => $action ) { + Monkey\Functions\expect( 'beans_replace_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the number of arguments was replaced in WordPress. - $this->assertSame( $replaced_action['args'], $args ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - } ); - - // Now add the original action. - beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); - - // Check that only the number of arguments was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $replaced_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - } - } - - /** - * Test beans_replace_action_arguments() should return false when no args is passed. - */ - public function test_should_return_false_when_no_args() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check it returns false. - $this->assertFalse( beans_replace_action_arguments( $beans_id, '' ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action has not been replaced. - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_replace_action_arguments() should replace the registered action's args. - */ - public function test_should_replace_the_action_args() { - $replaced_action = array( - 'args' => 6, - ); - - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we replace the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) - ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the number of arguments was replaced in WordPress. - $this->assertSame( $replaced_action['args'], $args ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - } ); - - // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); - - // Check that only the number of arguments was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $replaced_action['args'], $new_action['args'] ); + ->with( $beans_id, null, null, null, $action['args'] ) + ->andReturn( true ); - // Check that the "replaced" action has been stored in Beans. - $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->assertTrue( beans_replace_action_arguments( $beans_id, $action['args'] ) ); } } } diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php index 7f7efeb1..40c16d31 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php @@ -1,6 +1,6 @@ 'my_new_callback', - ); + public function test_should_return_false_when_not_callable() { - foreach ( array_keys( static::$test_actions ) as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - - // Now store away the "replace" callback. - $this->assertFalse( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); - - // Check that it was stored as "modified". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - } - } - - /** - * Test beans_replace_action_callback() should store the "replaced" callback when the original action - * has not yet been registered. Once the original action is registered, then the callback should be replaced. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_replace_the_callback() { - $replaced_action = array( - 'callback' => 'foo', - ); - - // Now replace the actions. foreach ( static::$test_ids as $beans_id ) { - beans_replace_action_callback( $beans_id, $replaced_action['callback'] ); - } - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we add the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) - ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the callback was replaced in WordPress. - $this->assertSame( $replaced_action['callback'], $callback ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Now add the original action. - beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); - - // Check that only the callback was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); + Monkey\Functions\expect( 'beans_replace_action' )->never(); - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->assertFalse( beans_replace_action_callback( $beans_id, null ) ); } } /** - * Test beans_replace_action_callback() should return false when no callback was passed. + * Test beans_replace_action_callback() should invoke beans_replace_action(). */ - public function test_should_return_false_when_no_callback() { - $this->go_to_post(); + public function test_should_invoke_beans_replace_action() { - foreach ( static::$test_actions as $beans_id => $action_config ) { - // Check it returns false. - $this->assertFalse( beans_replace_action_callback( $beans_id, '' ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_replace_action_callback() should replace the registered action's callback. - */ - public function test_should_replace_the_action_callback() { - $replaced_action = array( - 'callback' => 'foo', - ); - - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we replace the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + foreach ( static::$test_actions as $beans_id => $action ) { + Monkey\Functions\expect( 'beans_replace_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the callback was replaced in WordPress. - $this->assertSame( $replaced_action['callback'], $callback ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); - - // Check that only the callback was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + ->with( $beans_id, null, $action['callback'] ) + ->andReturn( true ); - // Check that the replace action was added in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $replaced_action['callback'] ) !== false ); + $this->assertTrue( beans_replace_action_callback( $beans_id, $action['callback'] ) ); } } } diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php index 1c5bdcf8..cf2dca3e 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php @@ -1,6 +1,6 @@ 'my_new_hook', - ); + public function test_should_return_false_when_hook_is_empty_or_not_string() { - foreach ( array_keys( static::$test_actions ) as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - - // Now store away the "replace" hook. - $this->assertFalse( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); - - // Check that it was stored as "modified". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - } - } - - /** - * Test beans_replace_action_hook() should store the "replaced" hook when the original action - * has not yet been registered. Once the original action is registered, then the hook should be replaced. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_replace_the_hook() { - $replaced_action = array( - 'hook' => 'foo', - ); - - // Now replace the actions. foreach ( static::$test_ids as $beans_id ) { - beans_replace_action_hook( $beans_id, $replaced_action['hook'] ); - } - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we add the action. - Monkey\Actions\expectAdded( $replaced_action['hook'] ) - ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { - // Check that all of the parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Now add the original action. - beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); - - // Check that only the hook was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); + Monkey\Functions\expect( 'beans_replace_action' )->never(); - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - $this->assertTrue( has_action( $replaced_action['hook'], $original_action['callback'] ) !== false ); - } - } - - /** - * Test beans_replace_action_hook() should return false when no hook was passed. - */ - public function test_should_return_false_when_no_hook() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - // Check it returns false. $this->assertFalse( beans_replace_action_hook( $beans_id, '' ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( beans_replace_action_hook( $beans_id, array( 'not-a-string' ) ) ); } } /** - * Test beans_replace_action_hook() should replace the registered action's hook. + * Test beans_replace_action_hook() should invoke beans_replace_action(). */ - public function test_should_replace_the_action_hook() { - $replaced_action = array( - 'hook' => 'foo', - ); - - $this->go_to_post( true ); + public function test_should_invoke_beans_replace_action() { - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we replace the action. - Monkey\Actions\expectAdded( $replaced_action['hook'] ) + foreach ( static::$test_actions as $beans_id => $action ) { + Monkey\Functions\expect( 'beans_replace_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { - // Check that the parameters remain unchanged in WordPress. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Run the replace. - $this->assertTrue( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); - - // Check that only the hook was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); + ->with( $beans_id, $action['hook'] ) + ->andReturn( true ); - // Check that the replace action was added in WordPress. - $this->assertTrue( has_action( $replaced_action['hook'], $original_action['callback'] ) !== false ); + $this->assertTrue( beans_replace_action_hook( $beans_id, $action['hook'] ) ); } } } diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php index d6ac2eca..e1a3b6ce 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionPriority.php @@ -1,6 +1,6 @@ 99, - ); + public function test_should_invoke_beans_replace_action() { - foreach ( array_keys( static::$test_actions ) as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - - // Now store away the "replace" priority. - $this->assertFalse( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); - - // Check that it was stored as "modified". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - } - } - - /** - * Test beans_replace_action_priority() should store the "replaced" priority when the original action - * has not yet been registered. Once the original action is registered, then the priority should be replaced. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_replace_the_priority() { - $replaced_action = array( - 'priority' => 10000, - ); - - // Now replace the actions. - foreach ( static::$test_ids as $beans_id ) { - beans_replace_action_priority( $beans_id, $replaced_action['priority'] ); - } - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we add the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) + foreach ( static::$test_actions as $beans_id => $action ) { + Monkey\Functions\expect( 'beans_replace_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the priority was replaced in WordPress. - $this->assertSame( $replaced_action['priority'], $priority ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Now add the original action. - beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); - - // Check that only the priority was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - } - } - - /** - * Test beans_replace_action_priority() should return false when no priority is passed. - */ - public function test_should_return_false_when_no_priority() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - // Check it returns false. - $this->assertFalse( beans_replace_action_priority( $beans_id, '' ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_replace_action_priority() should replace the registered action's priority. - */ - public function test_should_replace_the_action_priority() { - $replaced_action = array( - 'priority' => 52, - ); - - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Set up the WordPress simulator before we replace the action. - Monkey\Actions\expectAdded( $original_action['hook'] ) - ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action, $replaced_action ) { - // Check that the priority was replaced in WordPress. - $this->assertSame( $replaced_action['priority'], $priority ); - // Check that the other parameters remain unchanged. - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['args'], $args ); - } ); - - // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); - - // Check that only the priority was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); + ->with( $beans_id, null, null, $action['priority'] ) + ->andReturn( true ); - // Check that the "replaced" action has been stored in Beans. - $this->check_stored_in_beans( $beans_id, $replaced_action ); + $this->assertTrue( beans_replace_action_priority( $beans_id, $action['priority'] ) ); } } } From aa9b15fc59012e76ad855bbc92328d68a6b475bf Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 18:23:51 -0500 Subject: [PATCH 419/800] Optimized by merging replaced with added only when added exists. --- lib/api/actions/functions.php | 6 +++-- .../api/actions/beansReplaceAction.php | 26 +++++++++---------- .../unit/api/actions/beansReplaceAction.php | 8 +++--- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index 5d3617b1..a50f6281 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -253,8 +253,10 @@ function beans_replace_action( $id, $hook = null, $callback = null, $priority = // Modify the action. $is_modified = beans_modify_action( $id, $hook, $callback, $priority, $args ); - // Now merge the current action with the replaced one. - _beans_merge_action( $id, $action, 'added' ); + // If there's a current action, merge it with the replaced one; else, it will be replaced when the original is added. + if ( $is_modified ) { + _beans_merge_action( $id, $action, 'added' ); + } return $is_modified; } diff --git a/tests/phpunit/integration/api/actions/beansReplaceAction.php b/tests/phpunit/integration/api/actions/beansReplaceAction.php index e97aecf7..6ee48232 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceAction.php +++ b/tests/phpunit/integration/api/actions/beansReplaceAction.php @@ -29,20 +29,21 @@ class Tests_BeansReplaceAction extends Replace_Action_Test_Case { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_when_action_is_not_registered() { - $replaced_action = array( - 'callback' => 'my_new_callback', - ); + $replaced_callback = 'my_replaced_callback'; + $replaced_action = array( 'callback' => $replaced_callback ); foreach ( static::$test_ids as $beans_id ) { // Test that the original action has not yet been added. $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); // Now store away the "replace" hook. - $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); + $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_callback ) ); - // Check that it was stored as "modified" and "added". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); + // Check that it was stored as "replaced". + $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); + + // Check that it did not store as "added". + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); } } @@ -53,13 +54,12 @@ public function test_should_store_when_action_is_not_registered() { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_and_then_replace_action() { - $replaced_action = array( - 'callback' => 'my_new_callback', - ); + $replaced_callback = 'my_replaced_callback'; + $replaced_action = array( 'callback' => $replaced_callback ); - // Now replace the actions. + // Store the "replaced" action. foreach ( static::$test_ids as $beans_id ) { - beans_replace_action( $beans_id, null, $replaced_action['callback'] ); + beans_replace_action( $beans_id, null, $replaced_callback ); } $this->go_to_post(); @@ -68,7 +68,7 @@ public function test_should_store_and_then_replace_action() { // Check that the original action's callback was replaced in Beans. $new_action = _beans_get_action( $beans_id, 'added' ); $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); + $this->assertEquals( $replaced_callback, $new_action['callback'] ); $this->assertEquals( $original_action['priority'], $new_action['priority'] ); $this->assertEquals( $original_action['args'], $new_action['args'] ); diff --git a/tests/phpunit/unit/api/actions/beansReplaceAction.php b/tests/phpunit/unit/api/actions/beansReplaceAction.php index 1ea846e2..04b5bec1 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceAction.php +++ b/tests/phpunit/unit/api/actions/beansReplaceAction.php @@ -103,8 +103,8 @@ public function test_should_replace_the_action_hook() { * Test beans_replace_action() should replace the registered action's callback. */ public function test_should_replace_the_action_callback() { - $replaced_callback = 'my_replaced_callback'; - $replaced_action = array( 'callback' => $replaced_callback ); + $replaced_callback = 'my_replaced_callback'; + $replaced_action = array( 'callback' => $replaced_callback ); foreach ( static::$test_ids as $beans_id ) { Monkey\Functions\expect( '_beans_merge_action' ) @@ -132,8 +132,8 @@ public function test_should_replace_the_action_callback() { * Test beans_replace_action() should replace the registered action's priority level. */ public function test_should_replace_the_action_priority() { - $replaced_priority = -2; - $replaced_action = array( 'priority' => $replaced_priority ); + $replaced_priority = - 2; + $replaced_action = array( 'priority' => $replaced_priority ); foreach ( static::$test_ids as $beans_id ) { Monkey\Functions\expect( '_beans_merge_action' ) From f79cb7b3e347d7a5057d1087225e31922c0e4b23 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 18:32:46 -0500 Subject: [PATCH 420/800] Simplified beans_remove_action tests. --- .../unit/api/actions/beansRemoveAction.php | 91 ++++++++----------- 1 file changed, 38 insertions(+), 53 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansRemoveAction.php b/tests/phpunit/unit/api/actions/beansRemoveAction.php index 466d4e95..39bff31c 100644 --- a/tests/phpunit/unit/api/actions/beansRemoveAction.php +++ b/tests/phpunit/unit/api/actions/beansRemoveAction.php @@ -1,6 +1,6 @@ null, 'callback' => null, 'priority' => null, 'args' => null, ); - foreach ( static::$test_actions as $beans_id => $action ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - $this->assertFalse( _beans_get_current_action( $beans_id ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Simulate that there is no "added" action. + Monkey\Functions\expect( '_beans_get_current_action' ) + ->once() + ->with( $beans_id ) + ->andReturn( false ); - // Remove the action. Test that an empty action is returned. - $this->assertSame( $empty_action, beans_remove_action( $beans_id ) ); + // Check that remove_action does not get called. + Monkey\Functions\expect( 'remove_action' )->never(); - // Check that the "empty" action is registered as "removed". - $this->assertSame( $empty_action, _beans_get_action( $beans_id, 'removed' ) ); + // Simulate storing the action as "removed". + Monkey\Functions\expect( '_beans_set_action' ) + ->once() + ->with( $beans_id, $expected, 'removed' ) + ->andReturn( $expected ); - // Check that the original action is not registered in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_remove_action() should store the "removed" action before the original action is "added". - * Once the original action is registered, then it should be removed. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_remove_action() { - - // Remove the actions. - foreach ( static::$test_actions as $beans_id => $action ) { - beans_remove_action( $beans_id ); - } - - // Load the post, which runs beans_add_action for each of our test actions. - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check that the action is registered as "added". - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - - // Check that the action is not registered in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + // Run the remove. + $this->assertSame( $expected, beans_remove_action( $beans_id ) ); } } @@ -80,23 +61,27 @@ public function test_should_store_and_then_remove_action() { * Test beans_remove_action() should remove the registered action. */ public function test_should_remove_registered_action() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check that the action is registered with Beans. - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - - // Check that the action is registered with WordPress. - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); - - // Remove it. - $this->assertSame( $action, beans_remove_action( $beans_id ) ); - - // Check that the action is registered as "removed". - $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); - // Check that the action is no longer registered with WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); + foreach ( static::$test_actions as $beans_id => $original_action ) { + // Simulate that the original action is "added". + Monkey\Functions\expect( '_beans_get_current_action' ) + ->once() + ->with( $beans_id ) + ->andReturn( $original_action ); + + // Expect that the original action gets removed. + Monkey\Functions\expect( 'remove_action' ) + ->once() + ->with( $original_action['hook'], $original_action['callback'], $original_action['priority'] ); + + // Simulate storing the action as "removed". + Monkey\Functions\expect( '_beans_set_action' ) + ->once() + ->with( $beans_id, $original_action, 'removed' ) + ->andReturn( $original_action ); + + // Run the remove. + $this->assertSame( $original_action, beans_remove_action( $beans_id ) ); } } } From 1341496055946adbcf6048ec1bfb3eccebada780 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 19:51:55 -0500 Subject: [PATCH 421/800] Simplified tests for beans_replace_action. --- .../unit/api/actions/beansResetAction.php | 426 ++++-------------- 1 file changed, 97 insertions(+), 329 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansResetAction.php b/tests/phpunit/unit/api/actions/beansResetAction.php index 60bae2bb..9dcea18c 100644 --- a/tests/phpunit/unit/api/actions/beansResetAction.php +++ b/tests/phpunit/unit/api/actions/beansResetAction.php @@ -1,6 +1,6 @@ $action ) { - $this->assertFalse( beans_reset_action( $beans_id ) ); - } - } - - /** - * Test beans_reset_action() should reset the original action after it was "removed". - */ - public function test_should_reset_after_remove() { - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Remove the action. - beans_remove_action( $beans_id ); - - // Check that the action was removed in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - - // Check that the action was "removed" in Beans. - $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); - - // Reset and then check in WordPress and Beans. - $this->reset_and_check( $beans_id, $action, true ); - } - } - - /** - * Test beans_reset_action() should reset the original action's hook after it was "modified". - */ - public function test_should_reset_after_modifying_the_hook() { - $modified_action = array( - 'hook' => 'foo', - ); - - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $modified_action['hook'] ) + Monkey\Functions\expect( '_beans_unset_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action ) { - // Check that the parameters remain unchanged in WordPress. - $this->assertSame( $action['callback'], $callback ); - $this->assertSame( $action['priority'], $priority ); - $this->assertSame( $action['args'], $args ); - } ); - - // Modify the action's hook. - beans_modify_action_hook( $beans_id, $modified_action['hook'] ); - - // Check that the action was modified in Beans. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Reset and then check in WordPress and Beans. - $this->reset_and_check( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's callback after it was "modified". - */ - public function test_should_reset_after_modifying_the_callback() { - $modified_action = array( - 'callback' => 'my_callback', - ); - - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $action['hook'] ) + ->with( $beans_id, 'modified' ) + ->andReturn() + ->andAlsoExpectIt() ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { - // Check that the callback was modified in WordPress. - $this->assertSame( $modified_action['callback'], $callback ); - // Check that the other parameters remain unchanged. - $this->assertSame( $action['priority'], $priority ); - $this->assertSame( $action['args'], $args ); - } ); + ->with( $beans_id, 'removed' ) + ->andReturn(); - // Modify the action's callback. - beans_modify_action_callback( $beans_id, $modified_action['callback'] ); - - // Check that the action was modified in Beans. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Reset and then check in WordPress and Beans. - $this->reset_and_check( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's priority after it was "modified". - */ - public function test_should_reset_after_modifying_the_priority() { - $modified_action = array( - 'priority' => 9999, - ); - - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $action['hook'] ) + // Simulate that there is no action registered. + Monkey\Functions\expect( '_beans_get_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { - // Check that the priority was modified in WordPress. - $this->assertSame( $modified_action['priority'], $priority ); - // Check that the other parameters remain unchanged. - $this->assertSame( $action['callback'], $callback ); - $this->assertSame( $action['args'], $args ); - } ); - - // Modify the action's priority. - beans_modify_action_priority( $beans_id, $modified_action['priority'] ); + ->with( $beans_id, 'added' ) + ->andReturn( false ); - // Check that the action was modified in Beans. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + // Check that it does bail out and not call these functions. + Monkey\Functions\expect( '_beans_get_current_action' )->never(); + Monkey\Functions\expect( 'remove_action' )->never(); + Monkey\Functions\expect( 'add_action' )->never(); - // Reset and then check in WordPress and Beans. - $this->reset_and_check( $beans_id, $action ); + $this->assertFalse( beans_reset_action( $beans_id ) ); } } /** - * Test beans_reset_action() should reset the original action's args after it was "modified". + * Test beans_reset_action() should reset the original action after it was "removed". */ - public function test_should_reset_after_modifying_the_args() { - $modified_action = array( - 'args' => 14, - ); + public function test_should_reset_after_remove() { + $this->assertEmpty( '' ); - $this->go_to_post( true ); + return; + global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $action['hook'] ) - ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { - // Check that the args was modified in WordPress. - $this->assertSame( $modified_action['args'], $args ); - // Check that the other parameters remain unchanged. - $this->assertSame( $action['callback'], $callback ); - $this->assertSame( $action['priority'], $priority ); - } ); - - // Modify the action's args. - beans_modify_action_arguments( $beans_id, $modified_action['args'] ); - - // Check that the action was modified in Beans. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Reset and then check in WordPress and Beans. - $this->reset_and_check( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's callback and args after they were "modified". - */ - public function test_should_reset_after_modifying_callback_and_args() { - $modified_action = array( - 'callback' => 'my_callback', - 'args' => 14, - ); - - $this->go_to_post( true ); + $_beans_registered_actions['added'][ $beans_id ] = $action; + $_beans_registered_actions['removed'][ $beans_id ] = $action; - foreach ( static::$test_actions as $beans_id => $action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $action['hook'] ) + Monkey\Functions\expect( '_beans_unset_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { - // Check that the callback and args were modified in WordPress. - $this->assertSame( $modified_action['callback'], $callback ); - $this->assertSame( $modified_action['args'], $args ); - // Check that the priority remains unchanged. - $this->assertSame( $action['priority'], $priority ); + ->with( $beans_id, 'modified' ) + ->andReturn() + ->andAlsoExpectIt() + ->once() + ->with( $beans_id, 'removed' ) + ->andReturnUsing( function( $id ) { + global $_beans_registered_actions; + unset( $_beans_registered_actions['removed'][ $id ] ); } ); - // Modify the action's callback and args. - beans_modify_action( $beans_id, null, $modified_action['callback'], null, $modified_action['args'] ); - - // Check that the action was modified in Beans. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Reset and then check in WordPress and Beans. - $this->reset_and_check( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's priority and args after they were "modified". - */ - public function test_should_reset_after_modifying_priority_and_args() { - $modified_action = array( - 'priority' => 79, - 'args' => 14, - ); - - $this->go_to_post( true ); + // Simulate that the original action is registered. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'added' ) + ->andReturn( $action ); + Monkey\Functions\expect( '_beans_get_current_action' ) + ->once() + ->with( $beans_id ) + ->andReturn( $action ); - foreach ( static::$test_actions as $beans_id => $action ) { - // Set up the WordPress simulator before we modify the action. + // Expect the add_action. Monkey\Actions\expectAdded( $action['hook'] ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { - // Check that the priority and args were modified in WordPress. - $this->assertSame( $modified_action['priority'], $priority ); - $this->assertSame( $modified_action['args'], $args ); - // Check that the callback remains unchanged. - $this->assertSame( $action['callback'], $callback ); - } ); + ->with( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); - // Modify the action's priority and args. - beans_modify_action( $beans_id, null, null, $modified_action['priority'], $modified_action['args'] ); + // Reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); - // Check that the action was modified in Beans. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); + // Check that the "removed" action container is reset. + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['removed'] ); - // Reset and then check in WordPress and Beans. - $this->reset_and_check( $beans_id, $action ); + // Check that the original action is registered in WordPress. + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) ); } } /** - * Test beans_reset_action() should reset the original action's callback and priority after they were "modified". + * Test beans_reset_action() should reset the original action after modifying it. */ - public function test_should_reset_after_modifying_callback_and_priority() { + public function test_should_reset_after_modifying_the_action() { + Monkey\Functions\when( '_beans_unset_action' ); + $modified_action = array( - 'callback' => 'foo', - 'priority' => 39, + 'callback' => 'my_new_callback', + 'priority' => 47, ); - $this->go_to_post( true ); - foreach ( static::$test_actions as $beans_id => $action ) { - // Set up the WordPress simulator before we modify the action. - Monkey\Actions\expectAdded( $action['hook'] ) + // Simulate modifying the action. + add_action( $action['hook'], $modified_action['callback'], $modified_action['priority'], $action['args'] ); + + // Simulate that the original action is registered. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'added' ) + ->andReturn( $action ); + Monkey\Functions\expect( '_beans_get_current_action' ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { - // Check that the callback and priority were modified in WordPress. - $this->assertSame( $modified_action['callback'], $callback ); - $this->assertSame( $modified_action['priority'], $priority ); - // Check that the args remains unchanged. - $this->assertSame( $action['args'], $args ); + ->with( $beans_id ) + ->andReturnUsing( function() use ( $action, $modified_action ) { + return array_merge( $action, $modified_action ); } ); - // Modify the action's callback and priority. - beans_modify_action( $beans_id, null, $modified_action['callback'], $modified_action['priority'] ); - - // Check that the action was modified in Beans. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Reset and then check in WordPress and Beans. - $this->reset_and_check( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's callback, priority, and args after they were - * "modified". - */ - public function test_should_reset_after_modifying_all_but_hook() { - $modified_action = array( - 'callback' => 'foo', - 'priority' => 39, - 'args' => 24, - ); - - $this->go_to_post( true ); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Set up the WordPress simulator before we modify the action. + // Expect the add_action. Monkey\Actions\expectAdded( $action['hook'] ) ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $action, $modified_action ) { - // Check that all of the parameters were modified in WordPress. - $this->assertSame( $modified_action['callback'], $callback ); - $this->assertSame( $modified_action['priority'], $priority ); - $this->assertSame( $modified_action['args'], $args ); - } ); + ->with( $action['callback'], $action['priority'], $action['args'] ); - // Modify the action. - beans_modify_action( $beans_id, null, $modified_action['callback'], $modified_action['priority'], $modified_action['args'] ); + // Reset the action. + $this->assertSame( $action, beans_reset_action( $beans_id ) ); - // Check that the action was modified in Beans. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Reset and then check in WordPress and Beans. - $this->reset_and_check( $beans_id, $action ); + // Check that the action is restored in WordPress. + $this->assertTrue( has_action( $action['hook'], $action['callback'] ) ); + $this->assertFalse( has_action( $action['hook'], $modified_action['callback'] ) ); } } /** - * Test beans_reset_action() should not reset after replacing the action's hook. + * Test beans_reset_action() should not reset after replacing the action. * - * Why? "Replace" overwrites and is not resettable. + * Why? "Replace" overwrites and is not resettable, meaning it stores in the "added" to overwrite it. */ - public function test_should_not_reset_after_replacing_hook() { - $hook = 'foo'; - - $this->go_to_post(); + public function test_should_not_reset_after_replacing_action() { + Monkey\Functions\when( '_beans_unset_action' ); foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); - - // Run the replace. - beans_replace_action_hook( $beans_id, $hook ); - - // Let's try to reset the action. - $this->assertSame( $hook, beans_reset_action( $beans_id )['hook'] ); - - // Check that the action was not reset. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertTrue( has_action( $hook, $action['callback'] ) !== false ); - } - } - - /** - * Test beans_reset_action() should not reset after replacing the action's callback. - * - * Why? "Replace" overwrites and is not resettable. - */ - public function test_should_not_reset_after_replacing_callback() { - $callback = 'foo_cb'; + $replaced_action = array_merge( $action, array( 'hook' => 'replaced_hook' ) ); - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); + // Simulate that the replaced action is registered. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'added' ) + ->andReturn( $replaced_action ); + Monkey\Functions\expect( '_beans_get_current_action' ) + ->once() + ->with( $beans_id ) + ->andReturn( $replaced_action ); - // Run the replace. - beans_replace_action_callback( $beans_id, $callback ); + // Expect the add_action. + Monkey\Actions\expectAdded( $replaced_action['hook'] ) + ->once() + ->with( $action['callback'], $action['priority'], $action['args'] ); - // Let's try to reset the action. - $this->assertSame( $callback, beans_reset_action( $beans_id )['callback'] ); + // Reset the action. + $this->assertSame( $replaced_action, beans_reset_action( $beans_id ) ); - // Check that the action was not reset. + // Check in WordPress. + $this->assertTrue( has_action( $replaced_action['hook'], $replaced_action['callback'] ) ); $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertTrue( has_action( $action['hook'], $callback ) !== false ); } } - - /** - * Reset the action. - * - * 1. Set up the WordPress simulator before we reset the action. - * 2. Then reset the action. - * 3. Check that the action was reset in WordPress. - * 4. Check that the action was reset in Beans. - * - * @since 1.5.0 - * - * @param string $beans_id Beans' action ID. - * @param array $original_action Action's original configuration. - * @param bool $after_remove Set to true when resetting after a remove. - * - * @return void - * @throws Monkey\Expectation\Exception\NotAllowedMethod Throws when callback is invalid. - */ - protected function reset_and_check( $beans_id, $original_action, $after_remove = false ) { - Monkey\Actions\expectAdded( $original_action['hook'] ) - ->once() - ->whenHappen( function( $callback, $priority, $args ) use ( $original_action ) { - $this->assertSame( $original_action['args'], $args ); - $this->assertSame( $original_action['callback'], $callback ); - $this->assertSame( $original_action['priority'], $priority ); - } ); - - $this->assertSame( $original_action, beans_reset_action( $beans_id ) ); - - if ( $after_remove ) { - $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); - } else { - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - } - - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); - } } From 660789d77081a9ef2562575019f67dfbd5fb00bc Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 19:53:26 -0500 Subject: [PATCH 422/800] Removed beansAddAnonymousAction unit test. Why? It is an integration test and not unit test. --- .../api/actions/beansAddAnonymousAction.php | 63 ------------------- 1 file changed, 63 deletions(-) delete mode 100644 tests/phpunit/unit/api/actions/beansAddAnonymousAction.php diff --git a/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php b/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php deleted file mode 100644 index e2f63e54..00000000 --- a/tests/phpunit/unit/api/actions/beansAddAnonymousAction.php +++ /dev/null @@ -1,63 +0,0 @@ -assertTrue( has_action( 'do_foo' ) ); - } - - /** - * Test _beans_add_anonymous_action() should call callback on the given hook. - */ - public function test_should_call_callback() { - $object = _beans_add_anonymous_action( 'beans_test_do_foo', array( 'foo_test_callback', array( 'foo' ) ) ); - - Functions\when( 'foo_test_callback' )->justReturn( 'foo' ); - Actions\expectDone( 'beans_test_do_foo' ) - ->once() - ->whenHappen( function() use ( $object ) { - ob_start(); - $object->callback(); - $this->assertEquals( 'foo', ob_get_clean() ); - } ); - - do_action( 'beans_test_do_foo' ); - } -} From adcbae606edd6540bea02add6650d1cab86b2599 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:03:14 -0500 Subject: [PATCH 423/800] Improved beans_get_action tests. 1. Mocked _beans_unique_action_id in unit test. 2. Added integration tests. --- .../api/actions/beansGetAction.php | 127 ++++++++++++++++++ .../unit/api/actions/beansGetAction.php | 10 ++ 2 files changed, 137 insertions(+) create mode 100644 tests/phpunit/integration/api/actions/beansGetAction.php diff --git a/tests/phpunit/integration/api/actions/beansGetAction.php b/tests/phpunit/integration/api/actions/beansGetAction.php new file mode 100644 index 00000000..91e42196 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansGetAction.php @@ -0,0 +1,127 @@ +assertEmpty( $_beans_registered_actions[ $status ] ); + $this->assertFalse( _beans_get_action( 'foo', $status ) ); + } + } + + /** + * Test _beans_get_action() should return false when the action is not registered. + */ + public function test_should_return_false_when_action_is_not_registered() { + + foreach ( static::$test_ids as $beans_id ) { + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); + } + } + + /** + * Test _beans_get_action() should return the "added" action. + */ + public function test_should_return_added_action() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['added'][ $beans_id ] = $action; + + // Test that we get the "added" action. + $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); + + // Make sure that it is not stored in the other registries. + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); + } + } + + /** + * Test _beans_get_action() should return the "modified" action. + */ + public function test_should_return_modified_action() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['modified'][ $beans_id ] = $action; + + // Test that we get the "modified" action. + $this->assertSame( $action, _beans_get_action( $beans_id, 'modified' ) ); + + // Make sure that it is not stored in the other registries. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); + } + } + + /** + * Test _beans_get_action() should return the "removed" action. + */ + public function test_should_return_removed_action() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['removed'][ $beans_id ] = $action; + + // Test that we get the "removed" action. + $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); + + // Make sure that it is not stored in the other registries. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); + } + } + + /** + * Test _beans_get_action() should return the "replaced" action. + */ + public function test_should_return_replaced_action() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['replaced'][ $beans_id ] = $action; + + // Test that we get the "replaced" action. + $this->assertSame( $action, _beans_get_action( $beans_id, 'replaced' ) ); + + // Make sure that it is not stored in the other registries. + $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); + $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); + } + } +} diff --git a/tests/phpunit/unit/api/actions/beansGetAction.php b/tests/phpunit/unit/api/actions/beansGetAction.php index 88977581..07b7ff7e 100644 --- a/tests/phpunit/unit/api/actions/beansGetAction.php +++ b/tests/phpunit/unit/api/actions/beansGetAction.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; +use Brain\Monkey; /** * Class Tests_BeansGetAction @@ -20,6 +21,15 @@ */ class Tests_BeansGetAction extends Actions_Test_Case { + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + Monkey\Functions\when( '_beans_unique_action_id' )->returnArg(); + } + /** * Test _beans_get_action() should return false when registry is empty. */ From 0dbecc8fc81a4cbe34dc5e4851db8e677caf80e3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:03:44 -0500 Subject: [PATCH 424/800] Added BEANS_API_PATH define to bootstrap. --- tests/phpunit/unit/bootstrap.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index 8f8ba81e..865d8de7 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -17,6 +17,7 @@ define( 'BEANS_TESTS_DIR', __DIR__ ); define( 'BEANS_THEME_DIR', dirname( dirname( dirname( __DIR__ ) ) ) . DIRECTORY_SEPARATOR ); define( 'BEANS_TESTS_LIB_DIR', BEANS_THEME_DIR . 'lib' . DIRECTORY_SEPARATOR ); +define( 'BEANS_API_PATH', BEANS_TESTS_LIB_DIR . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR ); // Let's define ABSPATH as it is in WordPress, i.e. relative to the filesystem's WordPress root path. if ( ! defined( 'ABSPATH' ) ) { From d90500a3045e3abcff2e94f41429f6e311a82a66 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:05:22 -0500 Subject: [PATCH 425/800] Added _beans_set_action integration tests. --- .../api/actions/beansSetAction.php | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 tests/phpunit/integration/api/actions/beansSetAction.php diff --git a/tests/phpunit/integration/api/actions/beansSetAction.php b/tests/phpunit/integration/api/actions/beansSetAction.php new file mode 100644 index 00000000..b8f6ef8c --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansSetAction.php @@ -0,0 +1,108 @@ + $action ) { + + // Test each status. + foreach ( $this->statuses as $status ) { + // Before we start, check that the action is not set. + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + + // Now do the tests. + $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); + $this->assertArrayHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); + } + } + } + + /** + * Test _beans_set_action() should not overwrite an existing registered action. + */ + public function test_should_not_overwrite_existing_registered_action() { + global $_beans_registered_actions; + + $new_action = array( + 'hook' => 'bar', + 'callback' => 'callback_bar', + 'priority' => 20, + 'args' => 2, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + + // Test each status. + foreach ( $this->statuses as $status ) { + // Register the original action. + $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); + + // Now test that it does not overwrite the previously registered action. + $this->assertSame( $action, _beans_set_action( $beans_id, $new_action, $status ) ); + $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); + } + } + } + + /** + * Test _beans_set_action() should overwrite the existing registered action when the "overwrite" + * argument is set to true. + */ + public function test_should_overwrite_existing_registered_action() { + global $_beans_registered_actions; + + $new_action = array( + 'hook' => 'bar', + 'callback' => 'callback_bar', + 'priority' => 20, + 'args' => 2, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + + // Test each status. + foreach ( $this->statuses as $status ) { + // Register the original action. + $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); + $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); + + // Now test that it does overwrite the previously registered action. + $this->assertSame( $new_action, _beans_set_action( $beans_id, $new_action, $status, true ) ); + $this->assertSame( $new_action, $_beans_registered_actions[ $status ][ $beans_id ] ); + } + } + } +} From 99bab4ac13342a7ff02aaea0a60eb6a7d29b5f8f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:16:16 -0500 Subject: [PATCH 426/800] Mocked function in _beans_set_action. --- .../unit/api/actions/beansSetAction.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/actions/beansSetAction.php b/tests/phpunit/unit/api/actions/beansSetAction.php index 590aa5eb..ed496a77 100644 --- a/tests/phpunit/unit/api/actions/beansSetAction.php +++ b/tests/phpunit/unit/api/actions/beansSetAction.php @@ -1,6 +1,6 @@ assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, $status ) + ->andReturn( false ); // Return false as the action is not stored. + // Now do the tests. $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); $this->assertArrayHasKey( $beans_id, $_beans_registered_actions[ $status ] ); @@ -70,6 +76,12 @@ public function test_should_not_overwrite_existing_registered_action() { // Register the original action. $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); + // Simulate getting the original action from the container. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, $status ) + ->andReturn( $action ); + // Now test that it does not overwrite the previously registered action. $this->assertSame( $action, _beans_set_action( $beans_id, $new_action, $status ) ); $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); @@ -96,9 +108,16 @@ public function test_should_overwrite_existing_registered_action() { // Test each status. foreach ( $this->statuses as $status ) { // Register the original action. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, $status ) + ->andReturn( false ); $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); + // Check that _beans_get_action() does not get called. + Monkey\Functions\expect( '_beans_get_action' )->never(); + // Now test that it does overwrite the previously registered action. $this->assertSame( $new_action, _beans_set_action( $beans_id, $new_action, $status, true ) ); $this->assertSame( $new_action, $_beans_registered_actions[ $status ][ $beans_id ] ); From f78291c34f1886c62bc94bb78571445104ac786d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:17:23 -0500 Subject: [PATCH 427/800] Added _beans_unset_action integration tests. --- .../api/actions/beansUnsetAction.php | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 tests/phpunit/integration/api/actions/beansUnsetAction.php diff --git a/tests/phpunit/integration/api/actions/beansUnsetAction.php b/tests/phpunit/integration/api/actions/beansUnsetAction.php new file mode 100644 index 00000000..ff60ea13 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansUnsetAction.php @@ -0,0 +1,91 @@ + $action ) { + + // Test each status. + foreach ( $this->statuses as $status ) { + $this->assertFalse( _beans_unset_action( $beans_id, $status ) ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + } + } + } + + /** + * Test _beans_unset_action() should unset the registered action. + */ + public function test_should_unset_registered_action() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { + + // Test each status. + foreach ( $this->statuses as $status ) { + // Register the action first. + _beans_set_action( $beans_id, $action, $status ); + $this->assertArrayHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + + // Test that it unsets the action. + $this->assertTrue( _beans_unset_action( $beans_id, $status ) ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + } + } + } + + /** + * Test _beans_unset_action() should return false when the status is invalid. + */ + public function test_should_return_false_when_status_is_invalid() { + + foreach ( static::$test_actions as $beans_id => $action ) { + + $this->assertFalse( _beans_unset_action( $beans_id, 'invalid_status' ) ); + $this->assertFalse( _beans_unset_action( $beans_id, 'foo' ) ); + $this->assertFalse( _beans_unset_action( $beans_id, 'not_valid_either' ) ); + + // Now store the action in each status. + foreach ( $this->statuses as $status ) { + _beans_set_action( $beans_id, $action, $status ); + } + + // Run the tests again. + $this->assertFalse( _beans_unset_action( $beans_id, 'invalid_status' ) ); + $this->assertFalse( _beans_unset_action( $beans_id, 'foo' ) ); + $this->assertFalse( _beans_unset_action( $beans_id, 'not_valid_either' ) ); + } + } +} From f400545a3d7747b2486961118542016257740f91 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:20:59 -0500 Subject: [PATCH 428/800] Mocked function for _beans_unset_action. --- .../phpunit/unit/api/actions/beansUnsetAction.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/actions/beansUnsetAction.php b/tests/phpunit/unit/api/actions/beansUnsetAction.php index a824af78..6c1be885 100644 --- a/tests/phpunit/unit/api/actions/beansUnsetAction.php +++ b/tests/phpunit/unit/api/actions/beansUnsetAction.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-actions-test-case.php'; @@ -39,6 +40,11 @@ public function test_should_return_false_when_not_registered() { // Test each status. foreach ( $this->statuses as $status ) { + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, $status ) + ->andReturn( false ); + $this->assertFalse( _beans_unset_action( $beans_id, $status ) ); $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); } @@ -59,6 +65,12 @@ public function test_should_unset_registered_action() { _beans_set_action( $beans_id, $action, $status ); $this->assertArrayHasKey( $beans_id, $_beans_registered_actions[ $status ] ); + // Simulate getting the registered action. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, $status ) + ->andReturn( $action ); + // Test that it unsets the action. $this->assertTrue( _beans_unset_action( $beans_id, $status ) ); $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); @@ -70,9 +82,9 @@ public function test_should_unset_registered_action() { * Test _beans_unset_action() should return false when the status is invalid. */ public function test_should_return_false_when_status_is_invalid() { + Monkey\Functions\when( '_beans_get_action' )->justReturn( false ); foreach ( static::$test_actions as $beans_id => $action ) { - $this->assertFalse( _beans_unset_action( $beans_id, 'invalid_status' ) ); $this->assertFalse( _beans_unset_action( $beans_id, 'foo' ) ); $this->assertFalse( _beans_unset_action( $beans_id, 'not_valid_either' ) ); From 7b7158f7c745443c16586d347e13aa185d875a20 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:21:54 -0500 Subject: [PATCH 429/800] Added _beans_merge_action integration tests. --- .../api/actions/beansMergeAction.php | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/phpunit/integration/api/actions/beansMergeAction.php diff --git a/tests/phpunit/integration/api/actions/beansMergeAction.php b/tests/phpunit/integration/api/actions/beansMergeAction.php new file mode 100644 index 00000000..8bebfd50 --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansMergeAction.php @@ -0,0 +1,68 @@ + 29, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + $merged_action = array_merge( $action, $modified_action ); + + // Test each status. + foreach ( $this->statuses as $status ) { + $_beans_registered_actions[ $status ][ $beans_id ] = $action; + $this->assertSame( $merged_action, _beans_merge_action( $beans_id, $modified_action, $status ) ); + } + } + } + + /** + * Test _beans_merge_action() should store a unregistered action. + */ + public function test_should_store_new_action() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { + + // Test each status. + foreach ( $this->statuses as $status ) { + $this->assertSame( $action, _beans_merge_action( $beans_id, $action, $status ) ); + $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); + } + } + } +} From e08d433670e4d122c9f356a6e38e49f80327a006 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:26:16 -0500 Subject: [PATCH 430/800] Mocked functions in _beans_merge_action. --- .../unit/api/actions/beansMergeAction.php | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansMergeAction.php b/tests/phpunit/unit/api/actions/beansMergeAction.php index f0e93e27..f6333d18 100644 --- a/tests/phpunit/unit/api/actions/beansMergeAction.php +++ b/tests/phpunit/unit/api/actions/beansMergeAction.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Actions; use Beans\Framework\Tests\Unit\API\Actions\Includes\Actions_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-actions-test-case.php'; @@ -33,8 +34,6 @@ class Tests_BeansMergeAction extends Actions_Test_Case { * Test _beans_set_action() should merge the new action's configuration with the registered one and then return it. */ public function test_should_merge_and_return() { - global $_beans_registered_actions; - $modified_action = array( 'priority' => 29, ); @@ -44,7 +43,18 @@ public function test_should_merge_and_return() { // Test each status. foreach ( $this->statuses as $status ) { - $_beans_registered_actions[ $status ][ $beans_id ] = $action; + // Simulate getting the original action. + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, $status ) + ->andReturn( $action ); + + // Simulate storing the merged action. + Monkey\Functions\expect( '_beans_set_action' ) + ->once() + ->with( $beans_id, $merged_action, $status, true ) + ->andReturn( $merged_action ); + $this->assertSame( $merged_action, _beans_merge_action( $beans_id, $modified_action, $status ) ); } } @@ -54,14 +64,23 @@ public function test_should_merge_and_return() { * Test _beans_merge_action() should store a unregistered action. */ public function test_should_store_new_action() { - global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { // Test each status. foreach ( $this->statuses as $status ) { + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, $status ) + ->andReturn( false ); // Simulate that no action is currently stored. + + // Simulate storing the merged action. + Monkey\Functions\expect( '_beans_set_action' ) + ->once() + ->with( $beans_id, $action, $status, true ) + ->andReturn( $action ); + $this->assertSame( $action, _beans_merge_action( $beans_id, $action, $status ) ); - $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); } } } From 4933c9e3e55f62d6f11da9f2ab67e488274bedad Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:27:20 -0500 Subject: [PATCH 431/800] Copied _beans_get_current_action from unit to integration. --- .../api/actions/beansGetCurrentAction.php | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 tests/phpunit/integration/api/actions/beansGetCurrentAction.php diff --git a/tests/phpunit/integration/api/actions/beansGetCurrentAction.php b/tests/phpunit/integration/api/actions/beansGetCurrentAction.php new file mode 100644 index 00000000..b93f25fa --- /dev/null +++ b/tests/phpunit/integration/api/actions/beansGetCurrentAction.php @@ -0,0 +1,96 @@ + $action ) { + // Store the action in the registry. + $_beans_registered_actions['removed'][ $beans_id ] = $action; + + // Test that it returns false. + $this->assertFalse( _beans_get_current_action( $beans_id ) ); + } + } + + /** + * Test _beans_get_current_action() should return the "added" action. + */ + public function test_should_return_added_action() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['added'][ $beans_id ] = $action; + + // Test that we get the "added" action. + $this->assertSame( $action, _beans_get_current_action( $beans_id ) ); + } + } + + /** + * Test _beans_get_current_action() should return false when there's a "modified" action but no "added" action. + */ + public function test_should_return_false_when_modified_but_no_added() { + global $_beans_registered_actions; + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['modified'][ $beans_id ] = $action; + + // Run the tests. + $this->assertFalse( _beans_get_current_action( $beans_id ) ); + $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['added'] ); + $this->assertSame( $action, $_beans_registered_actions['modified'][ $beans_id ] ); + } + } + + /** + * Test _beans_get_current_action() should return the merged "added" and "modified" action. + */ + public function test_should_return_merged_added_and_modified() { + global $_beans_registered_actions; + + $modified_action = array( + 'callback' => 'callback', + 'priority' => 27, + 'args' => 14, + ); + + foreach ( static::$test_actions as $beans_id => $action ) { + // Store the action in the registry. + $_beans_registered_actions['added'][ $beans_id ] = $action; + $_beans_registered_actions['modified'][ $beans_id ] = $modified_action; + + // Test that it merges the action. + $this->assertSame( + array_merge( $action, $modified_action ), + _beans_get_current_action( $beans_id ) + ); + } + } +} From eb3383f8c34109cd0b330e5fc01ca26135653391 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:37:05 -0500 Subject: [PATCH 432/800] Mocked functions in _beans_get_current_action. --- .../api/actions/beansGetCurrentAction.php | 66 ++++++++++++++----- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php index 48c88a25..d1bfc6c1 100644 --- a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php @@ -1,6 +1,6 @@ $action ) { - // Store the action in the registry. - $_beans_registered_actions['removed'][ $beans_id ] = $action; + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'removed' ) + ->andReturn( true ) + ->andAlsoExpectIt() + ->with( $beans_id, 'added' )->never() + ->andAlsoExpectIt() + ->with( $beans_id, 'modified' )->never(); // Test that it returns false. $this->assertFalse( _beans_get_current_action( $beans_id ) ); @@ -41,11 +47,21 @@ public function test_should_return_false_when_removed_status() { * Test _beans_get_current_action() should return the "added" action. */ public function test_should_return_added_action() { - global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['added'][ $beans_id ] = $action; + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'removed' ) + ->andReturn( false ) + ->andAlsoExpectIt() + // Simulate getting the "added" action from the container. + ->once() + ->with( $beans_id, 'added' ) + ->andReturn( $action ) + ->andAlsoExpectIt() + ->once() + ->with( $beans_id, 'modified' ) + ->andReturn( false ); // Test that we get the "added" action. $this->assertSame( $action, _beans_get_current_action( $beans_id ) ); @@ -56,16 +72,23 @@ public function test_should_return_added_action() { * Test _beans_get_current_action() should return false when there's a "modified" action but no "added" action. */ public function test_should_return_false_when_modified_but_no_added() { - global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['modified'][ $beans_id ] = $action; + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'removed' ) + ->andReturn( false ) + ->andAlsoExpectIt() + // Simulate that an action has not been stored in the "added" container. + ->once() + ->with( $beans_id, 'added' ) + ->andReturn( false ) + ->andAlsoExpectIt() + // This one should not get called. + ->with( $beans_id, 'modified' )->never(); // Run the tests. $this->assertFalse( _beans_get_current_action( $beans_id ) ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['added'] ); - $this->assertSame( $action, $_beans_registered_actions['modified'][ $beans_id ] ); } } @@ -73,8 +96,6 @@ public function test_should_return_false_when_modified_but_no_added() { * Test _beans_get_current_action() should return the merged "added" and "modified" action. */ public function test_should_return_merged_added_and_modified() { - global $_beans_registered_actions; - $modified_action = array( 'callback' => 'callback', 'priority' => 27, @@ -82,9 +103,20 @@ public function test_should_return_merged_added_and_modified() { ); foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['added'][ $beans_id ] = $action; - $_beans_registered_actions['modified'][ $beans_id ] = $modified_action; + Monkey\Functions\expect( '_beans_get_action' ) + ->once() + ->with( $beans_id, 'removed' ) + ->andReturn( false ) + ->andAlsoExpectIt() + // Simulate getting the "added" action from the container. + ->once() + ->with( $beans_id, 'added' ) + ->andReturn( $action ) + ->andAlsoExpectIt() + // Simulate getting the "modified" action from the container. + ->once() + ->with( $beans_id, 'modified' ) + ->andReturn( $modified_action ); // Test that it merges the action. $this->assertSame( From 6213f7b74ec1fd32f4a280d68e65c05697ed0f8c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 23 Mar 2018 20:43:48 -0500 Subject: [PATCH 433/800] Fixed beans_reset_action unit test. --- .../unit/api/actions/beansResetAction.php | 35 ++----------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansResetAction.php b/tests/phpunit/unit/api/actions/beansResetAction.php index 9dcea18c..7d78b76d 100644 --- a/tests/phpunit/unit/api/actions/beansResetAction.php +++ b/tests/phpunit/unit/api/actions/beansResetAction.php @@ -27,17 +27,9 @@ class Tests_BeansResetAction extends Actions_Test_Case { * Test beans_reset_action() should return false when the action is not registered. */ public function test_should_return_false_when_no_action_is_registered() { + Monkey\Functions\when( '_beans_unset_action' ); foreach ( static::$test_actions as $beans_id => $action ) { - Monkey\Functions\expect( '_beans_unset_action' ) - ->once() - ->with( $beans_id, 'modified' ) - ->andReturn() - ->andAlsoExpectIt() - ->once() - ->with( $beans_id, 'removed' ) - ->andReturn(); - // Simulate that there is no action registered. Monkey\Functions\expect( '_beans_get_action' ) ->once() @@ -57,27 +49,9 @@ public function test_should_return_false_when_no_action_is_registered() { * Test beans_reset_action() should reset the original action after it was "removed". */ public function test_should_reset_after_remove() { - $this->assertEmpty( '' ); - - return; - global $_beans_registered_actions; + Monkey\Functions\when( '_beans_unset_action' ); foreach ( static::$test_actions as $beans_id => $action ) { - $_beans_registered_actions['added'][ $beans_id ] = $action; - $_beans_registered_actions['removed'][ $beans_id ] = $action; - - Monkey\Functions\expect( '_beans_unset_action' ) - ->once() - ->with( $beans_id, 'modified' ) - ->andReturn() - ->andAlsoExpectIt() - ->once() - ->with( $beans_id, 'removed' ) - ->andReturnUsing( function( $id ) { - global $_beans_registered_actions; - unset( $_beans_registered_actions['removed'][ $id ] ); - } ); - // Simulate that the original action is registered. Monkey\Functions\expect( '_beans_get_action' ) ->once() @@ -91,14 +65,11 @@ public function test_should_reset_after_remove() { // Expect the add_action. Monkey\Actions\expectAdded( $action['hook'] ) ->once() - ->with( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + ->with( $action['callback'], $action['priority'], $action['args'] ); // Reset the action. $this->assertSame( $action, beans_reset_action( $beans_id ) ); - // Check that the "removed" action container is reset. - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['removed'] ); - // Check that the original action is registered in WordPress. $this->assertTrue( has_action( $action['hook'], $action['callback'] ) ); } From 208a017e3df214a5bcd6d4d737c65ae2e4e5051a Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 24 Mar 2018 14:45:31 -0400 Subject: [PATCH 434/800] Changed missed variable and added translating function --- lib/api/compiler/class-options.php | 2 +- lib/api/fields/functions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/compiler/class-options.php b/lib/api/compiler/class-options.php index a4ed507f..cdf75ae6 100644 --- a/lib/api/compiler/class-options.php +++ b/lib/api/compiler/class-options.php @@ -77,7 +77,7 @@ public function register() { array( 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', - 'label' => 'Choose the level of compilation.', + 'label' => __( 'Choose the level of compilation.', 'tm-beans' ), 'default' => 'aggressive', 'options' => array( 'aggressive' => __( 'Aggressive', 'tm-beans' ), diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 2cb4442d..1e23e5d3 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -130,7 +130,7 @@ function beans_field( array $field ) { 'class' => 'bs-field bs-' . $single_field['type'], ), $single_field ); - if ( 'group' === $field['type'] ) { + if ( $group_field_type ) { /** * Fires the "beans_field_group_label" event to render this field's label. * From fa3e36cee83144dbd750edfac002ad48f8344685 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 27 Mar 2018 11:39:24 -0500 Subject: [PATCH 435/800] Added unit tests. --- .../beans-anonymous-action/__construct.php | 59 ++++++++++++++ .../beans-anonymous-action/callback.php | 76 +++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php create mode 100644 tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php new file mode 100644 index 00000000..637890f7 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php @@ -0,0 +1,59 @@ +assertSame( 'foo_test_callback', $anonymous_action->callback[0] ); + $this->assertSame( array( 'foo', 'bar', 'baz' ), $anonymous_action->callback[1] ); + } + + /** + * Test __construct() should add the action's hook. + */ + public function test_should_add_action_hook() { + $anonymous_action = new _Beans_Anonymous_Actions( 'beans_test_do_foo', array( + 'foo_test_callback', + array( 'foo' ), + ), 50, 3 ); + + $this->assertTrue( has_action( 'beans_test_do_foo', array( $anonymous_action, 'callback' ) ) ); + } +} diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php new file mode 100644 index 00000000..5e4d63d9 --- /dev/null +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php @@ -0,0 +1,76 @@ +once() + ->with( 'foo', 'bar' ) + ->andReturnFirstArg(); + + ob_start(); + $anonymous_action->callback(); + ob_get_clean(); + + // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. + $this->assertTrue( true ); + } + + /** + * Test callback() should echo the returned content. + */ + public function test_should_echo_returned_content() { + $anonymous_action = new _Beans_Anonymous_Actions( 'beans_test_do_foo', array( + 'foo_test_callback', + array( 'Cool Beans!', 'It worked!' ), + ) ); + + Monkey\Functions\when( 'foo_test_callback' )->alias( function( $arg1, $arg2 ) { + return "{$arg1} {$arg2}"; + } ); + + ob_start(); + $anonymous_action->callback(); + $this->assertEquals( 'Cool Beans! It worked!', ob_get_clean() ); + } +} From 9236785fe5a89b6355c89f48a4db7aa9b8c1f686 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 27 Mar 2018 11:44:07 -0500 Subject: [PATCH 436/800] Renamed class to singular noun. The class represents "one" anonymous action. --- lib/api/actions/class-beans-anonymous-action.php | 2 +- lib/api/actions/functions.php | 4 ++-- .../actions/beans-anonymous-action/__construct.php | 12 ++++++------ .../api/actions/beans-anonymous-action/callback.php | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/api/actions/class-beans-anonymous-action.php b/lib/api/actions/class-beans-anonymous-action.php index 43be47ea..fa161959 100644 --- a/lib/api/actions/class-beans-anonymous-action.php +++ b/lib/api/actions/class-beans-anonymous-action.php @@ -16,7 +16,7 @@ * * @package Beans\Framework\API\Actions */ -final class _Beans_Anonymous_Actions { +final class _Beans_Anonymous_Action { /** * The callback to register to the given $hook. diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index a50f6281..a79508be 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -648,12 +648,12 @@ function _beans_build_action_array( $hook = null, $callback = null, $priority = * in the order in which they were added to the action. * @param int $number_args Optional. The number of arguments the function accepts. Default 1. * - * @return _Beans_Anonymous_Actions + * @return _Beans_Anonymous_Action */ function _beans_add_anonymous_action( $hook, array $callback, $priority = 10, $number_args = 1 ) { require_once BEANS_API_PATH . 'actions/class-beans-anonymous-action.php'; - return new _Beans_Anonymous_Actions( $hook, $callback, $priority, $number_args ); + return new _Beans_Anonymous_Action( $hook, $callback, $priority, $number_args ); } /** diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php index 637890f7..c6b8b52b 100644 --- a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php @@ -1,6 +1,6 @@ Date: Tue, 27 Mar 2018 11:49:40 -0500 Subject: [PATCH 437/800] Improved the PHPCS ignore "why" explanation. --- lib/api/actions/class-beans-anonymous-action.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/actions/class-beans-anonymous-action.php b/lib/api/actions/class-beans-anonymous-action.php index fa161959..25255e9b 100644 --- a/lib/api/actions/class-beans-anonymous-action.php +++ b/lib/api/actions/class-beans-anonymous-action.php @@ -51,6 +51,6 @@ public function __construct( $hook, array $callback, $priority = 10, $number_arg * @return void */ public function callback() { - echo call_user_func_array( $this->callback[0], $this->callback[1] ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- The callback should escape the output. + echo call_user_func_array( $this->callback[0], $this->callback[1] ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- The callback handles escaping its output, as Beans does not know what HTML or content will be passed back to it. } } From 054b76324f00090417cb591073c5caf0d0eb68b0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 27 Mar 2018 18:23:45 -0500 Subject: [PATCH 438/800] Fixed documentation. --- tests/phpunit/integration/api/html/beansWrapInnerMarkup.php | 3 +-- tests/phpunit/integration/api/html/beansWrapMarkup.php | 3 +-- .../unit/api/actions/beans-anonymous-action/__construct.php | 2 +- .../unit/api/actions/beans-anonymous-action/callback.php | 2 +- .../unit/api/html/fixtures/class-anonymous-action-stub.php | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php b/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php index fbcd8b8f..0855fa39 100644 --- a/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php +++ b/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php @@ -10,7 +10,6 @@ namespace Beans\Framework\Tests\Integration\API\HTML; use Beans\Framework\Tests\Integration\API\HTML\Includes\HTML_Test_Case; -use Brain\Monkey; require_once __DIR__ . '/includes/class-html-test-case.php'; @@ -31,7 +30,7 @@ class Tests_BeansWrapInnerMarkup extends HTML_Test_Case { * @param string $hook To given hook's event name. * @param int $priority The priority number for the callback. * - * @return \_Beans_Anonymous_Actions + * @return \_Beans_Anonymous_Action */ protected function get_instance_from_wp( $hook, $priority ) { global $wp_filter; diff --git a/tests/phpunit/integration/api/html/beansWrapMarkup.php b/tests/phpunit/integration/api/html/beansWrapMarkup.php index a179f450..9bfd019e 100644 --- a/tests/phpunit/integration/api/html/beansWrapMarkup.php +++ b/tests/phpunit/integration/api/html/beansWrapMarkup.php @@ -10,7 +10,6 @@ namespace Beans\Framework\Tests\Integration\API\HTML; use Beans\Framework\Tests\Integration\API\HTML\Includes\HTML_Test_Case; -use Brain\Monkey; require_once __DIR__ . '/includes/class-html-test-case.php'; @@ -31,7 +30,7 @@ class Tests_BeansWrapMarkup extends HTML_Test_Case { * @param string $hook To given hook's event name. * @param int $priority The priority number for the callback. * - * @return \_Beans_Anonymous_Actions + * @return \_Beans_Anonymous_Action */ protected function get_instance_from_wp( $hook, $priority ) { global $wp_filter; diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php index c6b8b52b..e3a39456 100644 --- a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php @@ -1,6 +1,6 @@ Date: Wed, 28 Mar 2018 10:23:58 -0500 Subject: [PATCH 439/800] Changes test case "expect" to "when". --- .../beans-compiler/addContentMediaQuery.php | 14 ++++++++++++-- .../compiler/includes/class-compiler-test-case.php | 9 ++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php index 656e91d9..c015f2a3 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php @@ -11,7 +11,7 @@ use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; -use Brain\Monkey\Functions; +use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -24,6 +24,16 @@ */ class Tests_Beans_Compiler_Add_Content_Media_Query extends Compiler_Test_Case { + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( $this->compiled_dir ); + Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url ); + } + /** * Test add_content_media_query() should return original content when current fragment is callable. */ @@ -98,7 +108,7 @@ public function test_should_wrap_content_in_media_query() { '(min-width: 768px)', ); - Functions\stubs( [ + Monkey\Functions\stubs( [ 'wp_parse_args' => function( $query_args ) { parse_str( $query_args, $args ); return $args; diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 907412f7..9d992935 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -72,7 +72,7 @@ public static function setUpBeforeClass() { } /** - * Set up the test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); @@ -81,7 +81,7 @@ protected function setUp() { $this->compiled_dir = vfsStream::url( 'compiled' ); $this->compiled_url = 'http:://beans.local/compiled/'; - Functions\expect( 'wp_upload_dir' )->andReturn( array( + Functions\when( 'wp_upload_dir' )->justReturn( array( 'path' => '', 'url' => '', 'subdir' => '', @@ -89,9 +89,8 @@ protected function setUp() { 'baseurl' => $this->compiled_url, 'error' => false, ) ); - - Functions\expect( 'is_admin' )->andReturn( $this->is_admin ); - Functions\expect( 'site_url' )->andReturn( 'http:://beans.local' ); + Functions\when( 'is_admin' )->justReturn( $this->is_admin ); + Functions\when( 'site_url' )->justReturn( 'http:://beans.local' ); $this->load_original_functions( array( 'api/utilities/functions.php', From 65f89a00ebf2e342dc95c7d575447b99f023ad9a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 10:34:48 -0500 Subject: [PATCH 440/800] Mocked dependent functions for add_content_media_query(). --- .../beans-compiler/addContentMediaQuery.php | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php index c015f2a3..6714fc23 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php @@ -38,6 +38,9 @@ protected function setUp() { * Test add_content_media_query() should return original content when current fragment is callable. */ public function test_should_return_content_when_fragment_is_callable() { + Monkey\Functions\expect( 'wp_parse_args' )->never(); + Monkey\Functions\expect( 'beans_get' )->never(); + $compiler = new _Beans_Compiler( array() ); $css = <<never(); + Monkey\Functions\expect( 'beans_get' )->never(); + $compiler = new _Beans_Compiler( array() ); $css = <<never(); + Monkey\Functions\expect( 'beans_get' )->never(); + $compiler = new _Beans_Compiler( array() ); $css = << function( $query_args ) { - parse_str( $query_args, $args ); - return $args; - }, - ] ); - foreach ( $media_queries as $media_query ) { $this->set_current_fragment( $compiler, 'http://foo.com/base.css?beans_compiler_media_query=' . $media_query ); + + Monkey\Functions\expect( 'wp_parse_args' ) + ->once() + ->with( 'beans_compiler_media_query=' . $media_query ) + ->andReturnUsing( function( $query_args ) { + parse_str( $query_args, $args ); + + return $args; + } ); + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'beans_compiler_media_query', array( 'beans_compiler_media_query' => $media_query ) ) + ->andReturn( $media_query ); + $this->assertSame( "@media {$media_query} {\n{$css}\n}\n", $compiler->add_content_media_query( $css ) From ae2c0403f01bda16b66347b7a339610aeaaca3dd Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 12:59:37 -0500 Subject: [PATCH 441/800] Added set reflection. Refactored set_current_fragment. --- .../includes/class-compiler-test-case.php | 15 +++++----- tests/phpunit/unit/class-test-case.php | 28 ++++++++++++++++--- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 9d992935..a337ef2c 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -174,13 +174,11 @@ protected function add_virtual_directory( $dir_name, $root_dir = 'compiled/beans * @param \_Beans_Compiler $compiler The Compiler instance. * @param mixed $fragment The given value to set. * - * @return void + * @return \ReflectionProperty|string + * @throws \ReflectionException Throws an exception if property does not exist. */ protected function set_current_fragment( $compiler, $fragment ) { - $current_fragment = ( new \ReflectionClass( $compiler ) )->getProperty( 'current_fragment' ); - $current_fragment->setAccessible( true ); - $current_fragment->setValue( $compiler, $fragment ); - $current_fragment->setAccessible( false ); + return $this->set_reflective_property( $fragment, 'current_fragment', $compiler ); } /** @@ -227,9 +225,9 @@ protected function mock_filesystem_for_fragments( $compiler, $times_called = 1 ) foreach ( $compiler->config['fragments'] as $fragment ) { $mock->shouldReceive( 'get_contents' ) - ->times( $times_called ) - ->with( $fragment ) - ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid in this edge case. + ->times( $times_called ) + ->with( $fragment ) + ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid in this edge case. } $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case as we are mocking the filesystem. @@ -263,6 +261,7 @@ protected function get_compiled_jquery() { var clickHandler=function(event){event.preventDefault();} $(document).ready(function(){init();});})(jQuery); EOB; + return str_replace( '/$', '$', $compiled_content ); } diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 18f12088..7aaa64ae 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -160,17 +160,37 @@ protected function get_reflective_method( $method_name, $class_name ) { * * @since 1.5.0 * - * @param string $property Property name for which to gain access. - * @param string $class_name Name of the target class. + * @param string $property Property name for which to gain access. + * @param string|mixed $class Class name or instance. * * @return \ReflectionProperty|string * @throws \ReflectionException Throws an exception if property does not exist. */ - protected function get_reflective_property( $property, $class_name ) { - $class = new \ReflectionClass( $class_name ); + protected function get_reflective_property( $property, $class ) { + $class = new \ReflectionClass( $class ); $property = $class->getProperty( $property ); $property->setAccessible( true ); return $property; } + + /** + * Set the value of a property or private property. + * + * @since 1.5.0 + * + * @param mixed $value The value to set for the property. + * @param string $property Property name for which to gain access. + * @param mixed $instance Instance of the target object. + * + * @return \ReflectionProperty|string + * @throws \ReflectionException Throws an exception if property does not exist. + */ + protected function set_reflective_property( $value, $property, $instance ) { + $property = $this->get_reflective_property( $property, $instance ); + $property->setValue( $instance, $value ); + $property->setAccessible( false ); + + return $property; + } } From 757687aa36097b2a37c934f5a916743b55120d74 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 19:04:41 -0500 Subject: [PATCH 442/800] Mocked dependency for cache_file(). --- .../api/compiler/beans-compiler/cacheFile.php | 168 +++++++++--------- .../includes/class-compiler-test-case.php | 9 +- 2 files changed, 91 insertions(+), 86 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php index 30f3ddb2..8e156da3 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php @@ -11,6 +11,8 @@ use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; +use Brain\Monkey; +use Mockery; use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -25,9 +27,19 @@ class Tests_Beans_Compiler_Cache_File extends Compiler_Test_Case { /** - * Test cache_file() should not create the file. + * Prepares the test environment before each test. */ - public function test_should_not_create_the_file() { + protected function setUp() { + parent::setUp(); + + Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); + Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); + } + + /** + * Test cache_file() should not create the file when the filename is empty. + */ + public function test_should_not_create_the_file_when_filename_empty() { $compiler = new _Beans_Compiler( array( 'id' => 'test-script', 'type' => 'script', @@ -37,18 +49,11 @@ public function test_should_not_create_the_file() { 'minify_js' => true, ) ); - // Set up the tests. - $this->mock_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler ); - // Run the tests. $this->assertFalse( $compiler->cache_file() ); - $this->assertFileNotExists( $compiler->get_filename() ); + + $this->set_reflective_property( null, 'filename', $compiler ); + $this->assertFalse( $compiler->cache_file() ); } /** @@ -64,19 +69,23 @@ public function test_should_create_compiled_jquery_file() { 'minify_js' => true, ) ); - // Set up the tests. - $this->mock_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler, true ); + // Mock the compiler's properties. + $compiled_content = $this->get_compiled_jquery(); + $filename = '099c7b1-68d31c8.js'; + $cached_file = vfsStream::url( 'compiled/beans/compiler/test-jquery/' . $filename ); + $this->set_reflective_property( $compiled_content, 'compiled_content', $compiler ); + $this->set_reflective_property( $filename, 'filename', $compiler ); + + // Just checking that the filename is what we expect. + $this->assertSame( $cached_file, $compiler->get_filename() ); + + // Mock the filesystem. + $this->mock_creating_file( 'test-jquery', $filename, $cached_file, $compiled_content ); // Run the tests. + $this->assertFileNotExists( $cached_file ); $this->assertTrue( $compiler->cache_file() ); - $this->assertFileExists( $compiler->get_filename() ); - $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_file_contents( $compiler ) ); + $this->assertFileExists( $cached_file ); } /** @@ -91,19 +100,20 @@ public function test_should_create_compiled_javascript_file() { 'minify_js' => true, ) ); - // Set up the tests. - $this->mock_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler, true ); + // Mock the compiler's properties. + $compiled_content = $this->get_compiled_jquery(); + $filename = '9a71ddb-b8d5d01.js'; + $cached_file = vfsStream::url( 'compiled/beans/compiler/test-js/' . $filename ); + $this->set_reflective_property( $compiled_content, 'compiled_content', $compiler ); + $this->set_reflective_property( $filename, 'filename', $compiler ); + + // Mock the filesystem. + $this->mock_creating_file( 'test-js', $filename, $cached_file, $compiled_content ); // Run the tests. + $this->assertFileNotExists( $cached_file ); $this->assertTrue( $compiler->cache_file() ); - $this->assertFileExists( $compiler->get_filename() ); - $this->assertSame( $this->get_compiled_js(), $this->get_cached_file_contents( $compiler ) ); + $this->assertFileExists( $cached_file ); } /** @@ -117,19 +127,20 @@ public function test_should_create_compiled_css_file() { 'fragments' => array( vfsStream::url( 'compiled/fixtures/style.css' ) ), ) ); - // Set up the tests. - $this->mock_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler, true ); + // Mock the compiler's properties. + $compiled_content = $this->get_compiled_css(); + $filename = '83b8fbe-3ff95a6.css'; + $cached_file = vfsStream::url( 'compiled/beans/compiler/test-css/' . $filename ); + $this->set_reflective_property( $compiled_content, 'compiled_content', $compiler ); + $this->set_reflective_property( $filename, 'filename', $compiler ); + + // Mock the filesystem. + $this->mock_creating_file( 'test-css', $filename, $cached_file, $compiled_content ); // Run the tests. + $this->assertFileNotExists( $cached_file ); $this->assertTrue( $compiler->cache_file() ); - $this->assertFileExists( $compiler->get_filename() ); - $this->assertSame( $this->get_compiled_css(), $this->get_cached_file_contents( $compiler ) ); + $this->assertFileExists( $cached_file ); } /** @@ -137,7 +148,7 @@ public function test_should_create_compiled_css_file() { */ public function test_should_create_compiled_less_file() { $compiler = new _Beans_Compiler( array( - 'id' => 'test-css', + 'id' => 'test-less', 'type' => 'style', 'format' => 'less', 'fragments' => array( @@ -146,19 +157,23 @@ public function test_should_create_compiled_less_file() { ), ) ); - // Set up the tests. - $this->mock_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler, true ); + // Mock the compiler's properties. + $compiled_content = $this->get_compiled_less(); + $filename = '033690d-9814877.css'; + $cached_file = vfsStream::url( 'compiled/beans/compiler/test-less/' . $filename ); + $this->set_reflective_property( $compiled_content, 'compiled_content', $compiler ); + $this->set_reflective_property( $filename, 'filename', $compiler ); + + // Just checking that the filename is what we expect. + $this->assertSame( $cached_file, $compiler->get_filename() ); + + // Mock the filesystem. + $this->mock_creating_file( 'test-less', $filename, $cached_file, $compiled_content ); // Run the tests. + $this->assertFileNotExists( $cached_file ); $this->assertTrue( $compiler->cache_file() ); - $this->assertFileExists( $compiler->get_filename() ); - $this->assertSame( $this->get_compiled_less(), $this->get_cached_file_contents( $compiler ) ); + $this->assertFileExists( $cached_file ); } /** @@ -166,38 +181,27 @@ public function test_should_create_compiled_less_file() { * * @since 1.5.0 * - * @param _Beans_Compiler $compiler Instance of the compiler. - * @param bool $should_create Optional. When true, mock creating the file. Default is false. + * @param string $folder_name Name of the folder to create, which is the configuration's ID. + * @param string $filename File's name. + * @param string $cached_file Cached file's name. + * @param string $compiled_content The compiled content. * * @return void */ - private function mock_creating_file( $compiler, $should_create = false ) { - $GLOBALS['wp_filesystem']->shouldReceive( 'put_contents' ) + private function mock_creating_file( $folder_name, $filename, $cached_file, $compiled_content ) { + $mock = Mockery::mock( 'WP_Filesystem_Direct' ); + $mock->shouldReceive( 'put_contents' ) ->once() - ->andReturn( $should_create ); - - if ( ! $should_create ) { - return; - } - - vfsStream::newFile( $compiler->filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $compiler->config['id'] ) ) - ->setContent( $compiler->compiled_content ); - } - - /** - * Get the file's content. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the compiler. - * - * @return string - */ - private function get_cached_file_contents( $compiler ) { - return $this->mock_filesystem - ->getChild( 'beans/compiler/' . $compiler->config['id'] ) - ->getChild( $compiler->filename ) - ->getcontent(); + ->with( $cached_file, $compiled_content, FS_CHMOD_FILE ) + ->andReturnUsing( function( $cached_filename, $content ) use ( $folder_name, $filename ) { + // Simulate creating the cached file. + $this->add_virtual_directory( $folder_name ); + vfsStream::newFile( $filename ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $folder_name ) ) + ->setContent( $content ); + + return true; + } ); + $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case as we are mocking the filesystem. } } diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index a337ef2c..9cc7c2bf 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -224,10 +224,11 @@ protected function mock_filesystem_for_fragments( $compiler, $times_called = 1 ) $mock = Mockery::mock( 'WP_Filesystem_Direct' ); foreach ( $compiler->config['fragments'] as $fragment ) { - $mock->shouldReceive( 'get_contents' ) - ->times( $times_called ) - ->with( $fragment ) - ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid in this edge case. + $mock + ->shouldReceive( 'get_contents' ) + ->times( $times_called ) + ->with( $fragment ) + ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid in this edge case. } $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case as we are mocking the filesystem. From 27aec8d8b19adde685be3156a8925b6041fc501a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 19:18:46 -0500 Subject: [PATCH 443/800] Mocked dependencies for cache_file_exists. --- .../api/compiler/beans-compiler/cacheFile.php | 9 +--- .../beans-compiler/cacheFileExist.php | 45 +++++++++---------- .../includes/class-compiler-test-case.php | 20 +++++++++ 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php index 8e156da3..a51d5947 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php @@ -76,9 +76,6 @@ public function test_should_create_compiled_jquery_file() { $this->set_reflective_property( $compiled_content, 'compiled_content', $compiler ); $this->set_reflective_property( $filename, 'filename', $compiler ); - // Just checking that the filename is what we expect. - $this->assertSame( $cached_file, $compiler->get_filename() ); - // Mock the filesystem. $this->mock_creating_file( 'test-jquery', $filename, $cached_file, $compiled_content ); @@ -194,11 +191,7 @@ private function mock_creating_file( $folder_name, $filename, $cached_file, $com ->once() ->with( $cached_file, $compiled_content, FS_CHMOD_FILE ) ->andReturnUsing( function( $cached_filename, $content ) use ( $folder_name, $filename ) { - // Simulate creating the cached file. - $this->add_virtual_directory( $folder_name ); - vfsStream::newFile( $filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $folder_name ) ) - ->setContent( $content ); + $this->create_virtual_file( $folder_name, $filename, $content ); return true; } ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php index 0d068e70..60f12ed7 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; +use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -23,6 +24,16 @@ */ class Tests_Beans_Compiler_CacheFileExist extends Compiler_Test_Case { + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); + Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); + } + /** * Test cache_file_exist() should return false when the filename has not been generated. */ @@ -34,9 +45,6 @@ public function test_should_return_false_when_filename_not_generated() { 'fragments' => array( $fragment ), ) ); - // Check that the filename does not exist. - $this->assertArrayNotHasKey( 'filename', $compiler->config ); - // Run cache_file_exist(). $this->assertFalse( $compiler->cache_file_exist() ); } @@ -52,17 +60,12 @@ public function test_should_return_false_when_file_does_not_exist() { 'fragments' => array( $fragment ), ) ); - // Set up the mocks. - $this->mock_dev_mode( true ); - $this->add_virtual_directory( 'test-script' ); + // Mock the compiler's property. + $filename = '9a71ddb-b8d5d01.js'; + $this->set_reflective_property( $filename, 'filename', $compiler ); - // Generate the filename. - $compiler->set_filename(); - - // Check that the cached file does not exist in the virtual filesystem. - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $compiler->filename ) ); - - // Run cache_file_exist(). + // Run the tests. + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $filename ) ); $this->assertFalse( $compiler->cache_file_exist() ); } @@ -77,19 +80,15 @@ public function test_should_return_true_when_file_exists() { 'fragments' => array( $fragment ), ) ); - // Set up the mocks. - $this->mock_dev_mode( true ); - $this->add_virtual_directory( 'test-script' ); + // Mock the compiler's property. + $filename = '9a71ddb-b8d5d01.js'; + $this->set_reflective_property( $filename, 'filename', $compiler ); // Add the cached file to the virtual filesystem. - $compiler->set_filename(); - vfsStream::newFile( $compiler->filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/test-script' ) ); + $cached_file = $this->create_virtual_file( 'test-script', $filename, $this->get_compiled_js() ); - // Check that the filename exists. - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/test-script/' . $compiler->filename ) ); - - // Run cache_file_exist(). + // Run the tests. + $this->assertFileExists( $cached_file ); $this->assertTrue( $compiler->cache_file_exist() ); } } diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 9cc7c2bf..cbb45838 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -166,6 +166,26 @@ protected function add_virtual_directory( $dir_name, $root_dir = 'compiled/beans vfsStream::newDirectory( $dir_name )->at( $this->mock_filesystem->getChild( $root_dir ) ); } + /** + * Create a file in the virtual directory system. + * + * @since 1.0.0 + * + * @param string $folder_name Name of the folder to create, which is the configuration's ID. + * @param string $filename File's name. + * @param string $content The content to store in the file. + * + * @return string + */ + protected function create_virtual_file( $folder_name, $filename, $content ) { + $this->add_virtual_directory( $folder_name ); + vfsStream::newFile( $filename ) + ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $folder_name ) ) + ->setContent( $content ); + + return vfsStream::url( 'compiled/beans/compiler/' . $folder_name . '/' . $filename ); + } + /** * Set the protected property "current_fragment". * From c871f30ac87c7419293e1b7c717942461fc307e2 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 20:16:49 -0500 Subject: [PATCH 444/800] Mocked dependencies for combine_fragments(). --- lib/api/compiler/class-beans-compiler.php | 2 +- .../beans-compiler/combineFragments.php | 35 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 420c9c24..0765fed8 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -384,7 +384,7 @@ public function combine_fragments() { $content .= $fragment_content; } - $this->compiled_content = $this->format_content( $content ); + $this->compiled_content = ! empty( $content ) ? $this->format_content( $content ) : ''; } /** diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php index a70a28ff..bbfc440a 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -11,6 +11,7 @@ use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; +use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -58,6 +59,9 @@ class Tests_Beans_Compiler_Combine_Fragments extends Compiler_Test_Case { protected function setUp() { parent::setUp(); + Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); + Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); + $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); $this->css = $fixtures->getChild( 'style.css' )->getContent(); $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) @@ -82,8 +86,19 @@ public function test_should_return_empty_string_when_no_fragments() { */ public function test_should_return_empty_string_when_fragment_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = new _Beans_Compiler( array() ); - $this->set_current_fragment( $compiler, $fragment ); + $compiler = new _Beans_Compiler( array( + 'id' => 'test-script', + 'type' => 'script', + 'fragments' => array( $fragment ), + 'dependencies' => array( 'javascript' ), + 'in_footer' => true, + 'minify_js' => true, + ) ); + + // Setup the mocks. + Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); + Monkey\Functions\when( 'wp_remote_get' )->justReturn(); + Monkey\Functions\when( 'is_wp_error' )->justReturn( true ); // Run the test. $compiler->combine_fragments(); @@ -105,6 +120,8 @@ public function test_should_compile_less_and_return_css() { ) ); // Set up the mocks. + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); $this->mock_filesystem_for_fragments( $compiler ); $this->mock_dev_mode( true ); @@ -136,6 +153,8 @@ public function test_should_return_minified_compiled_css() { ) ); // Set up the mocks. + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); $this->mock_filesystem_for_fragments( $compiler ); $this->mock_dev_mode( false ); @@ -160,6 +179,8 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { ) ); // Set up the mocks. + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); $this->mock_filesystem_for_fragments( $compiler ); $this->mock_dev_mode( false ); @@ -184,6 +205,8 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { ) ); // Set up the mocks. + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); $this->mock_filesystem_for_fragments( $compiler ); $this->mock_dev_mode( true ); @@ -211,6 +234,8 @@ public function test_should_return_minified_jquery() { $this->mock_dev_mode( false ); // Run the test. + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); $compiler->combine_fragments(); $this->assertSame( $this->get_compiled_jquery(), $compiler->compiled_content ); } @@ -230,6 +255,8 @@ public function test_should_return_original_js_when_minify_js_disabled() { ) ); // Set up the mocks. + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); $this->mock_filesystem_for_fragments( $compiler ); $this->mock_dev_mode( false ); @@ -253,6 +280,8 @@ public function test_should_always_return_original_js_when_in_dev_mode() { ) ); // Set up the mocks. + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); $this->mock_filesystem_for_fragments( $compiler ); $this->mock_dev_mode( true ); @@ -275,6 +304,8 @@ public function test_should_return_minified_javascript() { ) ); // Set up the mocks. + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); $this->mock_filesystem_for_fragments( $compiler ); $this->mock_dev_mode( false ); From cdb60147045ae5d2d3fd5cf447f95cb831f3b9d1 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 20:48:36 -0500 Subject: [PATCH 445/800] Mocked dependencies for format_content(). --- .../compiler/beans-compiler/formatContent.php | 85 ++++++++++++------- 1 file changed, 55 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php index 8be96ae8..7f52d229 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -11,7 +11,7 @@ use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; -use Brain\Monkey\Functions; +use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -67,6 +67,8 @@ public function test_should_return_original_content_when_type_not_style_or_scrip 'type' => 'foo', ) ); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); + // Run the tests. $this->assertSame( $this->less, $compiler->format_content( $this->less ) ); $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); @@ -83,10 +85,7 @@ public function test_should_return_compiled_css() { 'format' => 'less', ) ); - // Turn on development mode. - $this->mock_dev_mode( true ); - - $expected_css = <<once()->andReturn( true ); + $mock = \Mockery::mock( 'Beans_Lessc' ); + $mock->shouldReceive( 'compile' )->andReturn( $compiled_css ); + // Run the tests. - $this->assertSame( $expected_css, $compiler->format_content( $this->less ) ); + $this->assertSame( $compiled_css, $compiler->format_content( $this->less ) ); } /** @@ -108,14 +112,25 @@ public function test_should_return_minified_compiled_css() { 'format' => 'less', ) ); - // Turn off development mode. - $this->mock_dev_mode( false ); + $compiled_css = <<once()->andReturn( false ); + $mock = \Mockery::mock( 'Beans_Lessc' ); + $mock->shouldReceive( 'compile' )->andReturn( $compiled_css ); // Run the test. - $this->assertContains( - 'body{background-color:#fff;color:#000;font-size:18px;', - $compiler->format_content( $this->less ) - ); + $expected_css = <<assertSame( $expected_css, $compiler->format_content( $this->less ) ); } /** @@ -129,8 +144,9 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { 'minify_js' => false, ) ); - // Turn off development mode. - $this->mock_dev_mode( false ); + // Setup the mocks. + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); + \Mockery::mock( 'JSMin' )->shouldNotReceive( 'min' ); // Run the test. $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); @@ -147,8 +163,9 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { 'minify_js' => true, ) ); - // Turn on development mode. - $this->mock_dev_mode( true ); + // Setup the mocks. + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); + \Mockery::mock( 'JSMin' )->shouldNotReceive( 'min' ); // Run the test. $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); @@ -165,16 +182,20 @@ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_mini 'minify_js' => true, ) ); - // Turn off development mode. - $this->mock_dev_mode( false ); - - $expected = <<once()->andReturn( false ); + $mock = \Mockery::mock( 'JSMin' ); + $mock->shouldReceive( 'min' )->andReturn( $compiled_jquery ); + // Run the test. - $this->assertSame( str_replace( '/$', '$', $expected ), $compiler->format_content( $this->jquery ) ); + $this->assertSame( $compiled_jquery, $compiler->format_content( $this->jquery ) ); } /** @@ -188,8 +209,9 @@ public function test_should_return_original_js_when_minify_js_disabled() { 'minify_js' => false, ) ); - // Turn off development mode. - $this->mock_dev_mode( false ); + // Setup the mocks. + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); + \Mockery::mock( 'JSMin' )->shouldNotReceive( 'min' ); // Run the test. $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); @@ -206,8 +228,9 @@ public function test_should_always_return_original_js_when_in_dev_mode() { 'minify_js' => true, ) ); - // Turn on development mode. - $this->mock_dev_mode( true ); + // Setup the mocks. + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); + \Mockery::mock( 'JSMin' )->shouldNotReceive( 'min' ); // Run the test. $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); @@ -224,14 +247,16 @@ public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_j 'minify_js' => true, ) ); - // Turn off development mode. - $this->mock_dev_mode( false ); - - $expected = <<once()->andReturn( false ); + $mock = \Mockery::mock( 'JSMin' ); + $mock->shouldReceive( 'min' )->andReturn( $compiled_js ); + // Run the test. - $this->assertSame( $expected, $compiler->format_content( $this->js ) ); + $this->assertSame( $compiled_js, $compiler->format_content( $this->js ) ); } } From a8944a684ef446225b4d8a95100c74706e43086a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 21:04:40 -0500 Subject: [PATCH 446/800] Mocked dependencies for get_internal_content(). --- .../beans-compiler/getInternalContent.php | 39 +++++++++++++------ .../includes/class-compiler-test-case.php | 3 +- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php index 38ed4e27..a4d4e54b 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php @@ -11,6 +11,7 @@ use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; +use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -24,6 +25,17 @@ */ class Tests_Beans_Compiler_Get_Internal_Content extends Compiler_Test_Case { + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); + Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); + Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); + } + /** * Test get_internal_content() should return false when fragment is empty. */ @@ -38,12 +50,8 @@ public function test_should_return_false_when_fragment_is_empty() { * Test get_internal_content() should return false when the file does not exist. */ public function test_should_return_false_when_file_does_not_exist() { - // Set up the compiler. - $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = new _Beans_Compiler( array( - 'fragments' => array( $fragment ), - ) ); - $this->set_current_fragment( $compiler, $fragment ); + $compiler = new _Beans_Compiler( array() ); + $this->set_reflective_property( vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js', 'filename', $compiler ); // Run the test. $this->assertfalse( $compiler->get_internal_content() ); @@ -53,19 +61,26 @@ public function test_should_return_false_when_file_does_not_exist() { * Test get_internal_content() should return a fragment's contents. */ public function test_should_return_fragment_contents() { - // Set up the compiler. $fragment = vfsStream::url( 'compiled/fixtures/test.less' ); $compiler = new _Beans_Compiler( array( 'fragments' => array( $fragment ), ) ); - $this->set_current_fragment( $compiler, $fragment ); - // Set up the mocks. + // Setup the mocks. + $this->set_reflective_property( $fragment, 'current_fragment', $compiler ); $this->mock_filesystem_for_fragments( $compiler ); // Run the tests. - $contents = $compiler->get_internal_content(); - $this->assertContains( 'body {', $contents ); - $this->assertContains( 'color: @body-color;', $contents ); + $expected = <<assertSame( $expected, $compiler->get_internal_content() ); } } diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index cbb45838..f8ea8b95 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -244,8 +244,7 @@ protected function mock_filesystem_for_fragments( $compiler, $times_called = 1 ) $mock = Mockery::mock( 'WP_Filesystem_Direct' ); foreach ( $compiler->config['fragments'] as $fragment ) { - $mock - ->shouldReceive( 'get_contents' ) + $mock->shouldReceive( 'get_contents' ) ->times( $times_called ) ->with( $fragment ) ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid in this edge case. From 06d3066f743fb9d8ff6811c6f0acfda7badee251 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 21:08:27 -0500 Subject: [PATCH 447/800] Mocked dependencies for get_remote_content(). --- .../beans-compiler/getRemoteContent.php | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index 7c40121c..6a05df43 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -11,7 +11,8 @@ use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; -use Brain\Monkey\Functions; +use Brain\Monkey; +use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -24,6 +25,16 @@ */ class Tests_Beans_Compiler_Get_Remote_Content extends Compiler_Test_Case { + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); + Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); + } + /** * Test get_remote_content() should return false when the fragment is empty. */ @@ -50,8 +61,8 @@ public function test_should_return_empty_string_when_remote_does_not_exist_on_ht $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. - Functions\expect( 'wp_remote_get' )->once(); - Functions\expect( 'is_wp_error' )->once()->andReturn( true ); + Monkey\Functions\expect( 'wp_remote_get' )->once(); + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); // Run the test. $this->assertSame( '', $compiler->get_remote_content() ); @@ -67,8 +78,8 @@ public function test_should_return_empty_string_when_remote_does_not_exist_on_ht $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. - Functions\expect( 'wp_remote_get' )->twice(); - Functions\expect( 'is_wp_error' )->twice()->andReturnValues( array( false, true ) ); + Monkey\Functions\expect( 'wp_remote_get' )->twice(); + Monkey\Functions\expect( 'is_wp_error' )->twice()->andReturnValues( array( false, true ) ); // Run the test. $this->assertSame( '', $compiler->get_remote_content() ); @@ -84,8 +95,8 @@ public function test_should_retry_and_return_false_when_remote_file_does_not_exi $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->twice()->andReturn( false ); - Functions\expect( 'wp_remote_get' ) + Monkey\Functions\expect( 'is_wp_error' )->twice()->andReturn( false ); + Monkey\Functions\expect( 'wp_remote_get' ) ->with( $fragment ) ->once() ->ordered() @@ -123,13 +134,13 @@ public function test_should_return_content_when_relative_url() { ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->once()->andReturn( false ); - Functions\expect( 'wp_remote_get' ) + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Monkey\Functions\expect( 'wp_remote_get' ) // Check that it did add http: to the relative URL. ->with( 'http:' . $fragment ) ->once() ->andReturn( $request ); - Functions\expect( 'wp_remote_retrieve_body' ) + Monkey\Functions\expect( 'wp_remote_retrieve_body' ) ->with( $request ) ->once() ->andReturn( $this->get_expected_content() ); @@ -159,13 +170,13 @@ public function test_should_return_content_when_http() { ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->once()->andReturn( false ); - Functions\expect( 'wp_remote_get' ) + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Monkey\Functions\expect( 'wp_remote_get' ) // Check that it did add http: to the relative URL. ->with( $fragment ) ->once() ->andReturn( $request ); - Functions\expect( 'wp_remote_retrieve_body' ) + Monkey\Functions\expect( 'wp_remote_retrieve_body' ) ->with( $request ) ->once() ->andReturn( $this->get_expected_content() ); @@ -195,13 +206,13 @@ public function test_should_return_content_when_https() { ); // Set up the mocks. - Functions\expect( 'is_wp_error' )->once()->andReturn( false ); - Functions\expect( 'wp_remote_get' ) + Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( false ); + Monkey\Functions\expect( 'wp_remote_get' ) // Check that it did add http: to the relative URL. ->with( $fragment ) ->once() ->andReturn( $request ); - Functions\expect( 'wp_remote_retrieve_body' ) + Monkey\Functions\expect( 'wp_remote_retrieve_body' ) ->with( $request ) ->once() ->andReturn( $this->get_expected_content() ); From 095f665567617ada7536ba7d49ca69390cbf4dd6 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 21:17:58 -0500 Subject: [PATCH 448/800] Improved set_filename unit tests. --- .../compiler/beans-compiler/setFilename.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php index d445a6de..bcae8062 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; +use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -23,6 +24,16 @@ */ class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); + Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); + } + /** * Test set_filename() should return the hash created with the modification time from each of the fragments. */ @@ -40,11 +51,9 @@ public function test_should_return_hash_created_with_fragments_filemtime() { ); $compiler = new \_Beans_Compiler( $config ); - // Set up the mocks. - $this->mock_dev_mode( true ); $this->add_virtual_directory( 'test-script' ); - // Set the filename. Test. + // Run the tests. $compiler->set_filename(); $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); $this->assertSame( $expected, $compiler->filename ); @@ -70,16 +79,9 @@ public function test_should_exclude_external_fragments() { ); $compiler = new \_Beans_Compiler( $config ); - // Set up the mocks. - $this->mock_dev_mode( true ); $this->add_virtual_directory( 'test-script' ); - // Test that we are in dev mode & the directory does exist. - $this->assertTrue( _beans_is_compiler_dev_mode() ); - $this->directoryExists( vfsStream::url( 'compiled/beans/compiler/test-script' ) ); - $this->assertTrue( is_dir( $compiler->dir ) ); - - // Set the filename. Test. + // Run the tests. $compiler->set_filename(); $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); $this->assertSame( $expected, $compiler->filename ); @@ -102,8 +104,6 @@ public function test_should_remove_old_file() { ); $compiler = new \_Beans_Compiler( $config ); - // Set up the mocks. - $this->mock_dev_mode( true ); $this->add_virtual_directory( $config['id'] ); /** From 3429580dad055c8218ca14f119f4eb83837b42d5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 21:24:35 -0500 Subject: [PATCH 449/800] Mocked dependenices for set_fragments(). --- .../compiler/beans-compiler/setFragments.php | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php index dab86912..ebaa6bd3 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php @@ -24,6 +24,16 @@ */ class Tests_Beans_Compiler_Set_Fragments extends Compiler_Test_Case { + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); + Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); + } + /** * Test set_fragments() should return unchanged fragments, meaning no fragments were added or removed. */ @@ -40,10 +50,16 @@ public function test_should_return_unchanged_fragments() { $compiler = new \_Beans_Compiler( $config ); + // Setup the mock. + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'test', array() ) + ->andReturn(); + // Check before we start. $this->assertSame( $config['fragments'], $compiler->config['fragments'] ); - // Set the fragments. Test. + // Run the test. $compiler->set_fragments(); $this->assertSame( $config['fragments'], $compiler->config['fragments'] ); } @@ -71,10 +87,16 @@ public function test_should_return_fragments_merged_with_global() { ), ); + // Setup the mock. + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'test', $_beans_compiler_added_fragments['less'] ) + ->andReturn( $_beans_compiler_added_fragments['less']['test'] ); + // Check before we start. $this->assertSame( $config['fragments'], $compiler->config['fragments'] ); - // Set the fragments. Test. + // Run the test. $expected = array_merge( $config['fragments'], $_beans_compiler_added_fragments['less']['test'] ); $compiler->set_fragments(); $this->assertSame( $expected, $compiler->config['fragments'] ); @@ -96,13 +118,17 @@ public function test_should_fire_event() { $compiler = new \_Beans_Compiler( $config ); - // Set up the expectation before firing the event. + // Setup the mock. + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'test', array() ) + ->andReturn(); Monkey\Filters\expectApplied( 'beans_compiler_fragments_test' ) ->once() ->with( $config['fragments'] ) ->andReturn( $compiler->config['fragments'] ); - // Set the fragments. Test. + // Run the test. $compiler->set_fragments(); $this->assertSame( $config['fragments'], $compiler->config['fragments'] ); } From eeb22ff37b4bb5c7e42db54586419bed3ef623d4 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 28 Mar 2018 21:35:16 -0500 Subject: [PATCH 450/800] Refactored creating compiler to keep DRY. --- .../beans-compiler/addContentMediaQuery.php | 19 +++----------- .../api/compiler/beans-compiler/cacheFile.php | 22 ++++------------ .../beans-compiler/cacheFileExist.php | 17 +++--------- .../beans-compiler/combineFragments.php | 24 +++++++---------- .../api/compiler/beans-compiler/fileystem.php | 6 ++--- .../compiler/beans-compiler/formatContent.php | 19 +++++++------- .../unit/api/compiler/beans-compiler/get.php | 10 +++---- .../compiler/beans-compiler/getExtension.php | 12 ++++----- .../beans-compiler/getFunctionContent.php | 10 +++---- .../beans-compiler/getInternalContent.php | 9 +++---- .../beans-compiler/getRemoteContent.php | 26 +++++-------------- .../compiler/beans-compiler/replaceCssUrl.php | 25 +++++++++--------- .../compiler/beans-compiler/runCompiler.php | 13 +++++----- .../compiler/beans-compiler/setFilename.php | 17 +++--------- .../compiler/beans-compiler/setFragments.php | 16 +++--------- .../includes/class-compiler-test-case.php | 16 ++++++++++++ 16 files changed, 100 insertions(+), 161 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php index 6714fc23..3e40cd00 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php @@ -9,7 +9,6 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; -use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; use Brain\Monkey; @@ -24,16 +23,6 @@ */ class Tests_Beans_Compiler_Add_Content_Media_Query extends Compiler_Test_Case { - /** - * Prepares the test environment before each test. - */ - protected function setUp() { - parent::setUp(); - - Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( $this->compiled_dir ); - Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url ); - } - /** * Test add_content_media_query() should return original content when current fragment is callable. */ @@ -41,7 +30,7 @@ public function test_should_return_content_when_fragment_is_callable() { Monkey\Functions\expect( 'wp_parse_args' )->never(); Monkey\Functions\expect( 'beans_get' )->never(); - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler(); $css = <<never(); Monkey\Functions\expect( 'beans_get' )->never(); - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler(); $css = <<never(); Monkey\Functions\expect( 'beans_get' )->never(); - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); $css = <<create_compiler( array() ); $css = <<justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); - Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); - } - /** * Test cache_file() should not create the file when the filename is empty. */ public function test_should_not_create_the_file_when_filename_empty() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test-script', 'type' => 'script', 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), @@ -60,7 +48,7 @@ public function test_should_not_create_the_file_when_filename_empty() { * Test cache_file() should create the compiled jQuery file. */ public function test_should_create_compiled_jquery_file() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test-jquery', 'type' => 'script', 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), @@ -89,7 +77,7 @@ public function test_should_create_compiled_jquery_file() { * Test cache_file() should create the compiled JavaScript file. */ public function test_should_create_compiled_javascript_file() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test-js', 'type' => 'script', 'fragments' => array( vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ), @@ -117,7 +105,7 @@ public function test_should_create_compiled_javascript_file() { * Test cache_file() should create the compiled CSS file. */ public function test_should_create_compiled_css_file() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test-css', 'type' => 'style', 'format' => 'css', @@ -144,7 +132,7 @@ public function test_should_create_compiled_css_file() { * Test cache_file() should create the compiled LESS file. */ public function test_should_create_compiled_less_file() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test-less', 'type' => 'style', 'format' => 'less', diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php index 60f12ed7..73f6d306 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php @@ -10,7 +10,6 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; -use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -24,22 +23,12 @@ */ class Tests_Beans_Compiler_CacheFileExist extends Compiler_Test_Case { - /** - * Prepares the test environment before each test. - */ - protected function setUp() { - parent::setUp(); - - Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); - Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); - } - /** * Test cache_file_exist() should return false when the filename has not been generated. */ public function test_should_return_false_when_filename_not_generated() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $compiler = new \_Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'fragments' => array( $fragment ), @@ -54,7 +43,7 @@ public function test_should_return_false_when_filename_not_generated() { */ public function test_should_return_false_when_file_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $compiler = new \_Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test-script', 'type' => 'script', 'fragments' => array( $fragment ), @@ -74,7 +63,7 @@ public function test_should_return_false_when_file_does_not_exist() { */ public function test_should_return_true_when_file_exists() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $compiler = new \_Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test-script', 'type' => 'script', 'fragments' => array( $fragment ), diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php index bbfc440a..5c579d14 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -9,7 +9,6 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; -use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; use Brain\Monkey; use org\bovigo\vfs\vfsStream; @@ -59,9 +58,6 @@ class Tests_Beans_Compiler_Combine_Fragments extends Compiler_Test_Case { protected function setUp() { parent::setUp(); - Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); - Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); - $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); $this->css = $fixtures->getChild( 'style.css' )->getContent(); $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) @@ -74,7 +70,7 @@ protected function setUp() { * Test combine_fragments() should return an empty string when there are no fragments to combine. */ public function test_should_return_empty_string_when_no_fragments() { - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); // Run the test. $compiler->combine_fragments(); @@ -86,7 +82,7 @@ public function test_should_return_empty_string_when_no_fragments() { */ public function test_should_return_empty_string_when_fragment_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test-script', 'type' => 'script', 'fragments' => array( $fragment ), @@ -109,7 +105,7 @@ public function test_should_return_empty_string_when_fragment_does_not_exist() { * Test combine_fragments() should compile the LESS fragments and return the compiled CSS. */ public function test_should_compile_less_and_return_css() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'style', 'format' => 'less', @@ -142,7 +138,7 @@ public function test_should_compile_less_and_return_css() { * Test combine_fragments() should return minified, compiled CSS from the Less combined fragments. */ public function test_should_return_minified_compiled_css() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'style', 'format' => 'less', @@ -168,7 +164,7 @@ public function test_should_return_minified_compiled_css() { * but "minify_js" is disabled. */ public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => false, @@ -194,7 +190,7 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, @@ -219,7 +215,7 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * Test combine_fragments() should return minified jQuery. */ public function test_should_return_minified_jquery() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, @@ -245,7 +241,7 @@ public function test_should_return_minified_jquery() { * but "minify_js" is disabled. */ public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => false, @@ -270,7 +266,7 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, @@ -294,7 +290,7 @@ public function test_should_always_return_original_js_when_in_dev_mode() { * Test combine_fragments() should return minified JavaScript. */ public function test_should_return_minified_javascript() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php index f67d2723..24b0d219 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php @@ -10,7 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; -use Brain\Monkey\Functions; +use Brain\Monkey; use Mockery; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -32,10 +32,10 @@ public function test_should_return_true_when_wp_filesystem_is_init() { Mockery::mock( 'WP_Filesystem_Direct' ); $GLOBALS['wp_filesystem'] = new \WP_Filesystem_Direct(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case as we are mocking the filesystem. - Functions\when( 'WP_Filesystem' )->justReturn( true ); + Monkey\Functions\when( 'WP_Filesystem' )->justReturn( true ); // Test that the WP Filesystem is not loaded yet. - $compiler = new \_Beans_Compiler( array() ); + $compiler = $this->create_compiler(); $this->assertTrue( $compiler->filesystem() ); unset( $GLOBALS['wp_filesystem'] ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php index 7f52d229..7fd7d5ab 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -9,7 +9,6 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; -use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; use Brain\Monkey; @@ -63,7 +62,7 @@ protected function setUp() { * a style or script (per the configuration). */ public function test_should_return_original_content_when_type_not_style_or_script() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'type' => 'foo', ) ); @@ -79,7 +78,7 @@ public function test_should_return_original_content_when_type_not_style_or_scrip * Test format_content() should return compiled CSS (not minified) from the Less combined fragments. */ public function test_should_return_compiled_css() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'style', 'format' => 'less', @@ -106,7 +105,7 @@ public function test_should_return_compiled_css() { * Test format_content() should return minified, compiled CSS from the Less combined fragments. */ public function test_should_return_minified_compiled_css() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'style', 'format' => 'less', @@ -138,7 +137,7 @@ public function test_should_return_minified_compiled_css() { * but "minify_js" is disabled. */ public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => false, @@ -157,7 +156,7 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, @@ -176,7 +175,7 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, @@ -203,7 +202,7 @@ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_mini * but "minify_js" is disabled. */ public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => false, @@ -222,7 +221,7 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, @@ -241,7 +240,7 @@ public function test_should_always_return_original_js_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'script', 'minify_js' => true, diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/get.php b/tests/phpunit/unit/api/compiler/beans-compiler/get.php index 4f8a75d7..b7385269 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/get.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/get.php @@ -33,7 +33,7 @@ public function test_should_fix_configuration_dependency_key() { 'depedencies' => array( 'jquery' ), ); - $compiler = new \_Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Run the tests. $this->assertArrayNotHasKey( 'depedencies', $compiler->config ); @@ -45,7 +45,7 @@ public function test_should_fix_configuration_dependency_key() { * Test should return the configuration. */ public function test_should_return_configuration() { - $compiler = new \_Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test', 'type' => 'style', 'format' => 'less', @@ -64,7 +64,7 @@ public function test_should_return_configuration() { $compiler->config ); - $compiler = new \_Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'id' => 'test_scripts', 'type' => 'script', 'dependencies' => array( 'jquery' ), @@ -96,7 +96,7 @@ public function test_should_return_absolute_path_to_compiled_files_dir() { 'format' => 'less', ); - $compiler = new \_Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Run the test. $this->assertSame( vfsStream::url( 'compiled/beans/compiler/test' ), $compiler->dir ); @@ -111,7 +111,7 @@ public function test_should_return_url_to_compiled_files_dir() { 'type' => 'script', ); - $compiler = new \_Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Run the test. $this->assertSame( $this->compiled_url . 'beans/compiler/test_scripts', $compiler->url ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php index 428ce3fa..3b442fb5 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php @@ -26,7 +26,7 @@ class Tests_Beans_Compiler_Get_Extension extends Compiler_Test_Case { * Test get_extension() should return "css" when the type is "style". */ public function test_should_return_css_when_style() { - $compiler = new \_Beans_Compiler( array( 'type' => 'style' ) ); + $compiler = $this->create_compiler( array( 'type' => 'style' ) ); $this->assertSame( 'css', $compiler->get_extension() ); } @@ -35,7 +35,7 @@ public function test_should_return_css_when_style() { * Test get_extension() should return "js" when the type is "script". */ public function test_should_return_js_when_script() { - $compiler = new \_Beans_Compiler( array( 'type' => 'script' ) ); + $compiler = $this->create_compiler( array( 'type' => 'script' ) ); $this->assertSame( 'js', $compiler->get_extension() ); } @@ -44,16 +44,16 @@ public function test_should_return_js_when_script() { * Test get_extension() should return null when the type is invalid. */ public function test_should_return_null_when_invalid_type() { - $compiler = new \_Beans_Compiler( array( 'type' => 'invalid' ) ); + $compiler = $this->create_compiler( array( 'type' => 'invalid' ) ); $this->assertNull( $compiler->get_extension() ); - $compiler = new \_Beans_Compiler( array( 'type' => null ) ); + $compiler = $this->create_compiler( array( 'type' => null ) ); $this->assertNull( $compiler->get_extension() ); - $compiler = new \_Beans_Compiler( array( 'type' => false ) ); + $compiler = $this->create_compiler( array( 'type' => false ) ); $this->assertNull( $compiler->get_extension() ); - $compiler = new \_Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); $this->assertNull( $compiler->get_extension() ); } } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php index 5b90fa93..ac9109b0 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php @@ -10,7 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; -use Brain\Monkey\Functions; +use Brain\Monkey; use Mockery; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -28,7 +28,7 @@ class Tests_Beans_Compiler_Get_Function_Content extends Compiler_Test_Case { * Test get_function_content() should return false when the given fragment is not callable. */ public function test_should_return_false_when_fragment_not_callable() { - $compiler = new \_Beans_Compiler( array() ); + $compiler = $this->create_compiler(); // Run the tests. $this->assertfalse( $compiler->get_function_content() ); @@ -45,10 +45,10 @@ public function test_should_return_false_when_fragment_not_callable() { */ public function test_should_return_content_from_function() { $fragment = 'beans_test_get_function_content_callback'; - $compiler = new \_Beans_Compiler( array() ); + $compiler = $this->create_compiler(); // Set up the function mocks. - Functions\expect( $fragment )->once()->andReturn( 'Beans rocks' ); + Monkey\Functions\expect( $fragment )->once()->andReturn( 'Beans rocks' ); $this->set_current_fragment( $compiler, $fragment ); // Run the test. @@ -59,7 +59,7 @@ public function test_should_return_content_from_function() { * Test get_function_content() should return content from an object's method. */ public function test_should_return_content_from_method() { - $compiler = new \_Beans_Compiler( array() ); + $compiler = $this->create_compiler(); // Set up the mock. $mock = Mockery::mock( 'Get_Function_Content_Mock' ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php index a4d4e54b..8ecb9c3e 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php @@ -9,7 +9,6 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; -use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; use Brain\Monkey; use org\bovigo\vfs\vfsStream; @@ -32,15 +31,13 @@ protected function setUp() { parent::setUp(); Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); - Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); - Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); } /** * Test get_internal_content() should return false when fragment is empty. */ public function test_should_return_false_when_fragment_is_empty() { - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler(); // Run the test. $this->assertfalse( $compiler->get_internal_content() ); @@ -50,7 +47,7 @@ public function test_should_return_false_when_fragment_is_empty() { * Test get_internal_content() should return false when the file does not exist. */ public function test_should_return_false_when_file_does_not_exist() { - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler(); $this->set_reflective_property( vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js', 'filename', $compiler ); // Run the test. @@ -62,7 +59,7 @@ public function test_should_return_false_when_file_does_not_exist() { */ public function test_should_return_fragment_contents() { $fragment = vfsStream::url( 'compiled/fixtures/test.less' ); - $compiler = new _Beans_Compiler( array( + $compiler = $this->create_compiler( array( 'fragments' => array( $fragment ), ) ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index 6a05df43..3dba1c10 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -9,10 +9,8 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; -use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; use Brain\Monkey; -use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -25,21 +23,11 @@ */ class Tests_Beans_Compiler_Get_Remote_Content extends Compiler_Test_Case { - /** - * Prepares the test environment before each test. - */ - protected function setUp() { - parent::setUp(); - - Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); - Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); - } - /** * Test get_remote_content() should return false when the fragment is empty. */ public function test_should_return_false_when_fragment_is_empty() { - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); // Run the tests. $this->assertfalse( $compiler->get_remote_content() ); @@ -57,7 +45,7 @@ public function test_should_return_false_when_fragment_is_empty() { public function test_should_return_empty_string_when_remote_does_not_exist_on_http() { // Set up the compiler. $fragment = 'http://beans.local/invalid-file.js'; - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. @@ -74,7 +62,7 @@ public function test_should_return_empty_string_when_remote_does_not_exist_on_ht public function test_should_return_empty_string_when_remote_does_not_exist_on_https() { // Set up the compiler. $fragment = 'http://beans.local/invalid-file.js'; - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. @@ -91,7 +79,7 @@ public function test_should_return_empty_string_when_remote_does_not_exist_on_ht public function test_should_retry_and_return_false_when_remote_file_does_not_exist() { // Set up the compiler. $fragment = 'http://beans.local/invalid-file.js'; - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. @@ -124,7 +112,7 @@ public function test_should_retry_and_return_false_when_remote_file_does_not_exi public function test_should_return_content_when_relative_url() { // Set up the compiler. $fragment = '//fonts.googleapis.com/css?family=Lato'; - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); $this->set_current_fragment( $compiler, $fragment ); $request = array( 'body' => $this->get_expected_content(), @@ -160,7 +148,7 @@ public function test_should_return_content_when_relative_url() { public function test_should_return_content_when_http() { // Set up the compiler. $fragment = 'http://fonts.googleapis.com/css?family=Lato'; - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); $this->set_current_fragment( $compiler, $fragment ); $request = array( 'body' => $this->get_expected_content(), @@ -196,7 +184,7 @@ public function test_should_return_content_when_http() { public function test_should_return_content_when_https() { // Set up the compiler. $fragment = 'https://fonts.googleapis.com/css?family=Lato'; - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler( array() ); $this->set_current_fragment( $compiler, $fragment ); $request = array( 'body' => $this->get_expected_content(), diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php index 57523f48..01849d71 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php @@ -9,9 +9,8 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; -use _Beans_Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; -use Brain\Monkey\Functions; +use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -28,7 +27,7 @@ class Tests_Beans_Compiler_Replace_Css_Url extends Compiler_Test_Case { * Test replace_css_url() should return original content when there is no url source in the CSS. */ public function test_should_return_original_content_when_no_url() { - $compiler = new _Beans_Compiler( array() ); + $compiler = $this->create_compiler(); $css = <<create_compiler(); $css = <<create_compiler(); // Set up the mocks. $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); - Functions\expect( 'is_main_site' )->andReturn( true ); - Functions\expect( 'site_url' )->andReturn( 'http://foo.com/' ); + Monkey\Functions\expect( 'is_main_site' )->andReturn( true ); + Monkey\Functions\expect( 'site_url' )->andReturn( 'http://foo.com/' ); $css = <<create_compiler(); // Set up the mocks. $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); - Functions\expect( 'is_main_site' )->andReturn( true ); - Functions\expect( 'site_url' )->andReturn( 'http://foo.com/' ); + Monkey\Functions\expect( 'is_main_site' )->andReturn( true ); + Monkey\Functions\expect( 'site_url' )->andReturn( 'http://foo.com/' ); // Test with no spaces, single quotes, or double quotes. $css = <<create_compiler(); // Set up the mocks. $this->set_current_fragment( $compiler, 'http://example.com/assets/less/partials/hero.less' ); - Functions\expect( 'is_main_site' )->andReturn( true ); - Functions\expect( 'site_url' )->andReturn( 'http://example.com/' ); + Monkey\Functions\expect( 'is_main_site' )->andReturn( true ); + Monkey\Functions\expect( 'site_url' )->andReturn( 'http://example.com/' ); // Test with no spaces, single quotes, or double quotes. $css = << true, 'version' => '1.5.0', ); - $compiler = new _Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Store the cached file into the virtual filesystem. $this->add_virtual_directory( $config['id'] ); @@ -131,7 +130,7 @@ public function test_should_recompile_when_fragments_change() { 'minify_js' => true, 'version' => null, ); - $compiler = new _Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); /** * Set up the original "compiled" file. This is the file that should get removed during this @@ -203,7 +202,7 @@ public function test_should_compile_save_and_enqueue_jquery() { 'minify_js' => true, 'version' => null, ); - $compiler = new _Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Set up the mocks. $this->add_virtual_directory( $config['id'] ); @@ -235,7 +234,7 @@ public function test_should_compile_save_and_enqueue_js() { 'minify_js' => true, 'version' => null, ); - $compiler = new _Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Set up the mocks. $this->add_virtual_directory( $config['id'] ); @@ -266,7 +265,7 @@ public function test_should_compile_save_and_enqueue_css() { 'minify_js' => false, 'version' => '1.5.0', ); - $compiler = new _Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Set up the mocks. $this->add_virtual_directory( $config['id'] ); @@ -299,7 +298,7 @@ public function test_should_compile_save_and_enqueue_less() { 'minify_js' => false, 'version' => '1.5.0', ); - $compiler = new _Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Set up the mocks. $this->add_virtual_directory( $config['id'] ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php index bcae8062..93940e0f 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php @@ -10,7 +10,6 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; -use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -24,16 +23,6 @@ */ class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { - /** - * Prepares the test environment before each test. - */ - protected function setUp() { - parent::setUp(); - - Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); - Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); - } - /** * Test set_filename() should return the hash created with the modification time from each of the fragments. */ @@ -49,7 +38,7 @@ public function test_should_return_hash_created_with_fragments_filemtime() { 'minify_js' => true, 'version' => null, ); - $compiler = new \_Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); $this->add_virtual_directory( 'test-script' ); @@ -77,7 +66,7 @@ public function test_should_exclude_external_fragments() { 'minify_js' => true, 'version' => null, ); - $compiler = new \_Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); $this->add_virtual_directory( 'test-script' ); @@ -102,7 +91,7 @@ public function test_should_remove_old_file() { 'minify_js' => true, 'version' => null, ); - $compiler = new \_Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); $this->add_virtual_directory( $config['id'] ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php index ebaa6bd3..079b6537 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php @@ -24,16 +24,6 @@ */ class Tests_Beans_Compiler_Set_Fragments extends Compiler_Test_Case { - /** - * Prepares the test environment before each test. - */ - protected function setUp() { - parent::setUp(); - - Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); - Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); - } - /** * Test set_fragments() should return unchanged fragments, meaning no fragments were added or removed. */ @@ -48,7 +38,7 @@ public function test_should_return_unchanged_fragments() { ), ); - $compiler = new \_Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Setup the mock. Monkey\Functions\expect( 'beans_get' ) @@ -78,7 +68,7 @@ public function test_should_return_fragments_merged_with_global() { ), ); - $compiler = new \_Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); global $_beans_compiler_added_fragments; $_beans_compiler_added_fragments['less'] = array( 'test' => array( @@ -116,7 +106,7 @@ public function test_should_fire_event() { ), ); - $compiler = new \_Beans_Compiler( $config ); + $compiler = $this->create_compiler( $config ); // Setup the mock. Monkey\Functions\expect( 'beans_get' ) diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index f8ea8b95..862b84e6 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -186,6 +186,22 @@ protected function create_virtual_file( $folder_name, $filename, $content ) { return vfsStream::url( 'compiled/beans/compiler/' . $folder_name . '/' . $filename ); } + /** + * Create the compiler. + * + * @since 1.0.0 + * + * @param array $config Compiler's configuration parameters. + * + * @return \_Beans_Compiler + */ + protected function create_compiler( array $config = array() ) { + Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); + Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); + + return new \_Beans_Compiler( $config ); + } + /** * Set the protected property "current_fragment". * From 678b2cfd51059c79f02da10643ac743535272c01 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 29 Mar 2018 12:28:21 -0500 Subject: [PATCH 451/800] Improved run_compiler unit tests. 1. Refactored for readability and DRY. 2. Made sure dependencies are mocked. --- .../compiler/beans-compiler/runCompiler.php | 191 ++++++++++-------- .../includes/class-compiler-test-case.php | 7 +- 2 files changed, 116 insertions(+), 82 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index 00e33706..e83b29f0 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -10,7 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Compiler; use Beans\Framework\Tests\Unit\API\Compiler\Includes\Compiler_Test_Case; -use Brain\Monkey\Functions; +use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -53,19 +53,11 @@ class Tests_Beans_Compiler_Run_Compiler extends Compiler_Test_Case { protected $js; /** - * Set up the test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); - // Set up the global fragments container. - global $_beans_compiler_added_fragments; - $_beans_compiler_added_fragments = array( - 'css' => array(), - 'less' => array(), - 'js' => array(), - ); - $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); $this->css = $fixtures->getChild( 'style.css' )->getContent(); $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) @@ -93,22 +85,36 @@ public function test_should_enqueue_existing_cached_file_when_no_modifications() $compiler = $this->create_compiler( $config ); // Store the cached file into the virtual filesystem. - $this->add_virtual_directory( $config['id'] ); - $original_filename = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); - $original_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $original_filename ); - vfsStream::newFile( $original_filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) - ->setContent( $this->get_compiled_jquery() ); - $this->assertFileExists( $original_file ); + $filename = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); + $cached_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $filename ); + $this->create_virtual_file( $config['id'], $filename, $this->get_compiled_jquery() ); - // Set up the mocks. - $this->set_up_mocks( $compiler, $config, $original_file ); + // Prepare the mocks. + global $_beans_compiler_added_fragments; + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( $config['id'], $_beans_compiler_added_fragments[ $config['format'] ] ) + ->andReturn( $_beans_compiler_added_fragments[ $config['format'] ] ); + Monkey\Functions\expect( 'is_ssl' )->once()->andReturn( false ); + Monkey\Functions\expect( 'wp_enqueue_script' ) + ->once() + ->with( + $config['id'], + str_replace( 'vfs://compiled/', $this->compiled_url, $cached_file ), + $config['dependencies'], + $config['version'], + $config['in_footer'] + ) + ->andReturnNull(); + + // Check that the file is cached before we start the compiler. + $this->assertFileExists( $cached_file ); // Run the compiler. $compiler->run_compiler(); // Check that the "compiled" filename did not change. - $this->assertSame( $original_file, $compiler->get_filename() ); + $this->assertSame( $cached_file, $compiler->get_filename() ); // Check that the file still exists. $this->assertFileExists( $compiler->get_filename() ); @@ -133,54 +139,57 @@ public function test_should_recompile_when_fragments_change() { $compiler = $this->create_compiler( $config ); /** - * Set up the original "compiled" file. This is the file that should get removed during this - * test. We add the file into the virtual filesystem. + * Step 1: Store the "original" cached file into the virtual filesystem. + * This is the file that should get removed during this test. */ - $this->add_virtual_directory( $config['id'] ); $original_filemtime = filemtime( $fragment ); $original_filename = $this->get_filename( $compiler, $config, $original_filemtime ); - $original_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $original_filename ); - vfsStream::newFile( $original_filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) - ->setContent( $this->get_compiled_jquery() ); - $original_hashes = explode( '-', pathinfo( $original_filename, PATHINFO_FILENAME ) ); - $this->assertFileExists( $original_file ); + $this->create_virtual_file( $config['id'], $original_filename, $this->get_compiled_jquery() ); + + $original_cached_file = vfsStream::url( 'compiled/beans/compiler/test-script/' . $original_filename ); + $original_hashes = explode( '-', pathinfo( $original_filename, PATHINFO_FILENAME ) ); /** - * Next step is to modify the fragment, which will change its modification time. Let's add an opening - * comment to the fragment's content and then set up the modified file for our tests. + * Step 2: Modify the fragment. + * Modifying the fragment will change its modification time, which should trigger recompiling and storing + * a new cached file. */ - $compiled_content = $this->get_compiled_jquery() . "console.log('Beans rocks!');"; $this->mock_filesystem->getChild( 'fixtures' ) ->getChild( 'jquery.test.js' ) ->write( $this->jquery . "\n console.log( 'Beans rocks!' ); \n" ); + $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); + $modified_filemtime = filemtime( $fragment ); $modified_filename = $this->get_filename( $compiler, $config, $modified_filemtime ); + $modified_file = vfsStream::url( 'compiled/beans/compiler/test-script/' . $modified_filename ); $modified_hashes = explode( '-', pathinfo( $modified_filename, PATHINFO_FILENAME ) ); - $modified_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $modified_filename ); - $this->assertFileNotExists( $modified_file ); /** - * We've now completed the setup process. Let's test that the original fragment has changed by - * testing that it is not equal to the modification time, filename, and hashes. + * Step 4: Test the starting conditions. + * + * 1. Check that the original file is cached. + * 2. Check that the new "modified" file is not yet cached (as that happens when we run the compiler). + * 3. Compare the "original" file to the new "modified" file to ensure they are different. */ - $this->assertNotEquals( $modified_filemtime, $original_filemtime ); + $this->assertFileExists( $original_cached_file ); + $this->assertFileNotExists( $modified_file ); + $this->assertNotEquals( $original_filemtime, $modified_filemtime ); $this->assertNotEquals( $modified_filename, $original_filename ); $this->assertSame( $modified_hashes[0], $original_hashes[0] ); $this->assertNotEquals( $modified_hashes[1], $original_hashes[1] ); - // Set up the mocks. - $this->set_up_mocks( $compiler, $config, $modified_file, $compiled_content ); + // Step 4: Prepare the mocks. + $this->prepare_mocks( $compiler, $config, $modified_file, $this->get_compiled_jquery() . "console.log('Beans rocks!');" ); - // Run the compiler. + // Step 5: Run the compiler and then the tests. $compiler->run_compiler(); // Check that the "compiled" filename is different. - $this->assertNotEquals( $compiler->get_filename(), $original_file ); + $this->assertNotEquals( $compiler->get_filename(), $original_cached_file ); $this->assertSame( $modified_file, $compiler->get_filename() ); // Check that the original cached file was removed. - $this->assertFileNotExists( $original_file ); + $this->assertFileNotExists( $original_cached_file ); // Check that a new file was cached. $this->assertFileExists( $modified_file ); @@ -204,18 +213,15 @@ public function test_should_compile_save_and_enqueue_jquery() { ); $compiler = $this->create_compiler( $config ); - // Set up the mocks. - $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( - 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) - ); + // Prepare the mocks. + $expected_cache_filename = $this->get_cache_filename( $compiler, $config, $fragment ); + $this->prepare_mocks( $compiler, $config, $expected_cache_filename, $this->get_compiled_jquery() ); - $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_jquery() ); - - // Run the compiler. Test. + // Run the tests. + $this->assertFileNotExists( $expected_cache_filename ); $compiler->run_compiler(); $this->assertFileExists( $compiler->get_filename() ); - $this->assertSame( $expected_file, $compiler->get_filename() ); + $this->assertSame( $expected_cache_filename, $compiler->get_filename() ); $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_file_contents( $compiler ) ); } @@ -236,17 +242,15 @@ public function test_should_compile_save_and_enqueue_js() { ); $compiler = $this->create_compiler( $config ); - // Set up the mocks. - $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( - 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) - ); - $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_js() ); + // Prepare the mocks. + $expected_cache_filename = $this->get_cache_filename( $compiler, $config, $fragment ); + $this->prepare_mocks( $compiler, $config, $expected_cache_filename, $this->get_compiled_js() ); - // Run the compiler. Test. + // Run the tests. + $this->assertFileNotExists( $expected_cache_filename ); $compiler->run_compiler(); $this->assertFileExists( $compiler->get_filename() ); - $this->assertSame( $expected_file, $compiler->get_filename() ); + $this->assertSame( $expected_cache_filename, $compiler->get_filename() ); $this->assertSame( $this->get_compiled_js(), $this->get_cached_file_contents( $compiler ) ); } @@ -267,17 +271,15 @@ public function test_should_compile_save_and_enqueue_css() { ); $compiler = $this->create_compiler( $config ); - // Set up the mocks. - $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( - 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) - ); - $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_css() ); + // Prepare the mocks. + $expected_cache_filename = $this->get_cache_filename( $compiler, $config, $fragment ); + $this->prepare_mocks( $compiler, $config, $expected_cache_filename, $this->get_compiled_css() ); - // Run the compiler. Test. + // Run the tests. + $this->assertFileNotExists( $expected_cache_filename ); $compiler->run_compiler(); $this->assertFileExists( $compiler->get_filename() ); - $this->assertSame( $expected_file, $compiler->get_filename() ); + $this->assertSame( $expected_cache_filename, $compiler->get_filename() ); $this->assertSame( $this->get_compiled_css(), $this->get_cached_file_contents( $compiler ) ); } @@ -300,22 +302,42 @@ public function test_should_compile_save_and_enqueue_less() { ); $compiler = $this->create_compiler( $config ); - // Set up the mocks. - $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( - 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config ) - ); - $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_less() ); + // Prepare the mocks. + $expected_cache_filename = $this->get_cache_filename( $compiler, $config ); + $this->prepare_mocks( $compiler, $config, $expected_cache_filename, $this->get_compiled_less() ); - // Run the compiler. Test. + // Run the tests. + $this->assertFileNotExists( $expected_cache_filename ); $compiler->run_compiler(); $this->assertFileExists( $compiler->get_filename() ); - $this->assertSame( $expected_file, $compiler->get_filename() ); + $this->assertSame( $expected_cache_filename, $compiler->get_filename() ); $this->assertSame( $this->get_compiled_less(), $this->get_cached_file_contents( $compiler ) ); } /** - * Set up the mocks for this test. + * Builds and returns the filename for the expected "cache" file. + * + * @since 1.0.0 + * + * @param \_Beans_Compiler $compiler Instance of the compiler. + * @param array $config Compiler's configuration parameters. + * @param string $fragment The fragment. + * + * @return string + */ + protected function get_cache_filename( \_Beans_Compiler $compiler, array $config, $fragment = '' ) { + $this->add_virtual_directory( $config['id'] ); + + return vfsStream::url( + sprintf( 'compiled/beans/compiler/%s/%s', + $config['id'], + $this->get_filename( $compiler, $config, $fragment ? filemtime( $fragment ) : null ) + ) + ); + } + + /** + * Prepare the mocks for this test. * * @since 1.5.0 * @@ -327,12 +349,19 @@ public function test_should_compile_save_and_enqueue_less() { * * @return void */ - private function set_up_mocks( $compiler, $config, $file, $content = '', $in_dev_mode = false ) { - $this->mock_dev_mode( $in_dev_mode ); - Functions\when( 'is_ssl' )->justReturn( false ); + private function prepare_mocks( $compiler, $config, $file, $content = '', $in_dev_mode = false ) { + global $_beans_compiler_added_fragments; + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( $config['id'], $_beans_compiler_added_fragments[ $config['format'] ] ) + ->andReturn( $_beans_compiler_added_fragments[ $config['format'] ] ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( $in_dev_mode ); + Monkey\Functions\when( 'is_ssl' )->justReturn( false ); + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); if ( 'script' === $config['type'] ) { - Functions\expect( 'wp_enqueue_script' ) + Monkey\Functions\expect( 'wp_enqueue_script' ) ->once() ->with( $config['id'], @@ -345,7 +374,7 @@ private function set_up_mocks( $compiler, $config, $file, $content = '', $in_dev } if ( 'style' === $config['type'] ) { - Functions\expect( 'wp_enqueue_style' ) + Monkey\Functions\expect( 'wp_enqueue_style' ) ->once() ->with( $config['id'], diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 862b84e6..c5819c07 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -183,7 +183,12 @@ protected function create_virtual_file( $folder_name, $filename, $content ) { ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $folder_name ) ) ->setContent( $content ); - return vfsStream::url( 'compiled/beans/compiler/' . $folder_name . '/' . $filename ); + $cached_file = vfsStream::url( 'compiled/beans/compiler/' . $folder_name . '/' . $filename ); + + // vfs has a little quirk: We need to check the file to finish storing it in the system. This helps us to modify it later. + file_exists( $cached_file ); + + return $cached_file; } /** From 06ed49adf2ac85133d9230055c96ae96f71e9a44 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 30 Mar 2018 16:36:37 -0500 Subject: [PATCH 452/800] Fixed comment. --- tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index e83b29f0..5902dd06 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -165,7 +165,7 @@ public function test_should_recompile_when_fragments_change() { $modified_hashes = explode( '-', pathinfo( $modified_filename, PATHINFO_FILENAME ) ); /** - * Step 4: Test the starting conditions. + * Step 3: Test the starting conditions. * * 1. Check that the original file is cached. * 2. Check that the new "modified" file is not yet cached (as that happens when we run the compiler). From f8837fbd8c98888f40a4a8d8fd3e3d10a15c802e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 30 Mar 2018 16:46:04 -0500 Subject: [PATCH 453/800] Mocked _beans_is_compiler_dev_mode instead of the option. --- .../beans-compiler/combineFragments.php | 20 +++++++++---------- .../includes/class-compiler-test-case.php | 15 -------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php index 5c579d14..d54ad3f6 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -118,8 +118,8 @@ public function test_should_compile_less_and_return_css() { // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\expect( 'wp_remote_get' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); $this->mock_filesystem_for_fragments( $compiler ); - $this->mock_dev_mode( true ); // Run the test. $compiler->combine_fragments(); @@ -151,8 +151,8 @@ public function test_should_return_minified_compiled_css() { // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\expect( 'wp_remote_get' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); $this->mock_filesystem_for_fragments( $compiler ); - $this->mock_dev_mode( false ); // Run the test. $compiler->combine_fragments(); @@ -177,8 +177,8 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\expect( 'wp_remote_get' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); $this->mock_filesystem_for_fragments( $compiler ); - $this->mock_dev_mode( false ); // Run the test. $compiler->combine_fragments(); @@ -203,8 +203,8 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\expect( 'wp_remote_get' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); $this->mock_filesystem_for_fragments( $compiler ); - $this->mock_dev_mode( true ); // Run the test. $compiler->combine_fragments(); @@ -226,12 +226,12 @@ public function test_should_return_minified_jquery() { ) ); // Set up the mocks. + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'wp_remote_get' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); $this->mock_filesystem_for_fragments( $compiler ); - $this->mock_dev_mode( false ); // Run the test. - Monkey\Functions\expect( 'beans_url_to_path' )->never(); - Monkey\Functions\expect( 'wp_remote_get' )->never(); $compiler->combine_fragments(); $this->assertSame( $this->get_compiled_jquery(), $compiler->compiled_content ); } @@ -253,8 +253,8 @@ public function test_should_return_original_js_when_minify_js_disabled() { // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\expect( 'wp_remote_get' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); $this->mock_filesystem_for_fragments( $compiler ); - $this->mock_dev_mode( false ); // Run the test. $compiler->combine_fragments(); @@ -278,8 +278,8 @@ public function test_should_always_return_original_js_when_in_dev_mode() { // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\expect( 'wp_remote_get' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); $this->mock_filesystem_for_fragments( $compiler ); - $this->mock_dev_mode( true ); // Run the test. $compiler->combine_fragments(); @@ -302,8 +302,8 @@ public function test_should_return_minified_javascript() { // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\expect( 'wp_remote_get' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); $this->mock_filesystem_for_fragments( $compiler ); - $this->mock_dev_mode( false ); // Run the test. $compiler->combine_fragments(); diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index c5819c07..bbf24327 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -274,21 +274,6 @@ protected function mock_filesystem_for_fragments( $compiler, $times_called = 1 ) $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case as we are mocking the filesystem. } - /** - * Mock the site's development mode. - * - * @since 1.5.0 - * - * @param bool $is_enabled Optional. When true, development mode is enabled. Default is false. - * - * @return void - */ - protected function mock_dev_mode( $is_enabled = false ) { - Monkey\Functions\expect( 'get_option' ) - ->with( 'beans_dev_mode', false ) - ->andReturn( $is_enabled ); - } - /** * Get the compiled jQuery. * From 2e49bdea336e7f08404353fa33c259a99ddf1817 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 30 Mar 2018 20:25:57 -0400 Subject: [PATCH 454/800] Added integration tests for beansRegisterWPCustomizeOptions --- .../wp-customize/class-beans-wp-customize.php | 4 +- lib/api/wp-customize/functions.php | 4 +- .../beansRegisterWPCustomizeOptions.php | 87 +++++++++++++++++ .../api/wp-customize/fixtures/test-fields.php | 85 +++++++++++++++++ .../includes/class-wp-customize-test-case.php | 95 +++++++++++++++++++ 5 files changed, 271 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php create mode 100644 tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php create mode 100644 tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php diff --git a/lib/api/wp-customize/class-beans-wp-customize.php b/lib/api/wp-customize/class-beans-wp-customize.php index c2c49d13..2b475e8b 100644 --- a/lib/api/wp-customize/class-beans-wp-customize.php +++ b/lib/api/wp-customize/class-beans-wp-customize.php @@ -117,7 +117,7 @@ private function add_section( WP_Customize_Manager $wp_customize ) { * * @return void */ - private function add_setting( WP_Customize_Manager $wp_customize, $field ) { + private function add_setting( WP_Customize_Manager $wp_customize, array $field ) { $defaults = array( 'db_type' => 'theme_mod', 'capability' => 'edit_theme_options', @@ -149,7 +149,7 @@ private function add_setting( WP_Customize_Manager $wp_customize, $field ) { * * @return void */ - private function add_control( WP_Customize_Manager $wp_customize, $field ) { + private function add_control( WP_Customize_Manager $wp_customize, array $field ) { require_once 'class-beans-wp-customize-control.php'; $class = '_Beans_WP_Customize_Control'; diff --git a/lib/api/wp-customize/functions.php b/lib/api/wp-customize/functions.php index a24ebcf8..cd2d180e 100644 --- a/lib/api/wp-customize/functions.php +++ b/lib/api/wp-customize/functions.php @@ -46,7 +46,7 @@ * text to the section. Default false. * } * - * @return bool True on success, false on failure. + * @return bool|null False on failure. */ function beans_register_wp_customize_options( array $fields, $section, $args = array() ) { @@ -63,7 +63,7 @@ function beans_register_wp_customize_options( array $fields, $section, $args = a // Stop here if the current page isn't concerned. if ( ! is_customize_preview() ) { - return; + return false; } // Stop here if the field can't be registered. diff --git a/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php b/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php new file mode 100644 index 00000000..1af8af20 --- /dev/null +++ b/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php @@ -0,0 +1,87 @@ +wp_customize = new WP_Customize_Manager(); + $wp_customize = $this->wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. + } + + /** + * Cleans up the test environment after each test. + */ + public function tearDown() { + parent::tearDown(); + global $wp_customize; + $wp_customize = null; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. + } + + /** + * Test beans_register_wp_customize_options() should return false when not in the WP Customizer . + */ + public function test_should_return_null_when_no_customizer() { + $test_data = static::$test_data['single_fields']; + + $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); + $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); + $this->assertFalse( beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ) ); + } + + /** + * Test beans_register_wp_customize_options() should return false when there are no options. + */ + public function test_should_return_false_when_no_options() { + $this->wp_customize->start_previewing_theme(); + + $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); + $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); + } + + /** + * Test beans_register_wp_customize_options() should register the fields. + */ + public function test_should_register_fields() { + $this->wp_customize->start_previewing_theme(); + + $test_data = static::$test_data['single_fields']; + + $this->assertNull( beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ) ); + + // Check what was registered. + $registered = $this->get_reflective_property_value( 'registered' ); + $this->assertArrayHasKey( $test_data['section'], $registered['wp_customize'] ); + + foreach ( $test_data['fields'] as $index => $field ) { + $expected = $this->merge_field_with_default( $field ); + $this->assertSame( $expected, $registered['wp_customize']['tm-beans-customizer'][ $index ] ); + } + } +} diff --git a/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php b/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php new file mode 100644 index 00000000..74011308 --- /dev/null +++ b/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php @@ -0,0 +1,85 @@ + array( + 'fields' => array( + array( + 'id' => 'beans_customizer_layout', + 'label' => 'Layout', + 'type' => 'radio', + 'default' => 'default_fallback', + 'options' => array( + 'default_fallback' => 'Use Default Layout', + 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', + 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', + 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', + ), + ), + array( + 'id' => 'beans_customizer_checkbox', + 'label' => false, + 'checkbox_label' => 'Enable the checkbox test', + 'type' => 'checkbox', + 'default' => false, + ), + array( + 'id' => 'beans_customizer_text', + 'type' => 'text', + 'default' => 'Testing the text field.', + ), + ), + 'context' => 'beans-test', + 'section' => 'tm-beans-customizer', + 'args' => array( + 'title' => 'Beans Customizer Section', + 'priority' => 250, + 'description' => 'Customizer Beans Section', + ), + ), + + // Group of fields. + 'group' => array( + 'fields' => array( + array( + 'id' => 'beans_group_test', + 'label' => 'Group of fields', + 'description' => 'This is a group of fields.', + 'type' => 'group', + 'fields' => array( + array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ), + array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), + 'options' => array( + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ), + ), + array( + 'id' => 'beans_checkbox_test', + 'label' => false, + 'checkbox_label' => 'Enable the checkbox test', + 'type' => 'checkbox', + 'default' => false, + ), + ), + ), + ), + 'context' => 'group_tests', + 'section' => 'tm-beans-customizer', + ), +); diff --git a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php new file mode 100644 index 00000000..acb4c5ac --- /dev/null +++ b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php @@ -0,0 +1,95 @@ +get_reflective_property( $property, '_Beans_Fields' ); + return $reflective->getValue( new \_Beans_Fields() ); + } + + /** + * Merge the given field with the default structure. + * + * @since 1.5.0 + * + * @param array $field The given field to merge. + * @param bool $set_value Optional. When true, sets the "value" to the "default". + * + * @return array + */ + protected function merge_field_with_default( array $field, $set_value = true ) { + $field = array_merge( array( + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => 'wp_customize', + 'attributes' => array( + 'data-customize-setting-link' => $field['id'], + ), + 'db_group' => false, + ), $field ); + $field['name'] = $field['id']; + + if ( 'group' === $field['type'] ) { + + foreach ( $field['fields'] as $index => $_field ) { + $field['fields'][ $index ] = $this->merge_field_with_default( $_field, $set_value ); + } + } elseif ( $set_value ) { + $field['value'] = $field['default']; + } + + return $field; + } +} From 5372a0a802ead7842a2d93c94e0fa7a2d8be9e5a Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 30 Mar 2018 20:32:41 -0400 Subject: [PATCH 455/800] Fixed typo and sequence in tearDown() methods. --- tests/phpunit/integration/api/fields/beansField.php | 4 ++-- .../integration/api/fields/types/beansFieldActivation.php | 4 ++-- .../integration/api/fields/types/beansFieldCheckbox.php | 4 ++-- .../integration/api/fields/types/beansFieldDescription.php | 4 ++-- .../phpunit/integration/api/fields/types/beansFieldImage.php | 4 ++-- .../phpunit/integration/api/fields/types/beansFieldLabel.php | 4 ++-- .../phpunit/integration/api/fields/types/beansFieldRadio.php | 4 ++-- .../phpunit/integration/api/fields/types/beansFieldSelect.php | 4 ++-- .../phpunit/integration/api/fields/types/beansFieldSlider.php | 4 ++-- tests/phpunit/integration/api/fields/types/beansFieldText.php | 4 ++-- .../integration/api/fields/types/beansFieldTextarea.php | 4 ++-- tests/phpunit/unit/api/fields/types/beansFieldActivation.php | 4 ++-- tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php | 4 ++-- tests/phpunit/unit/api/fields/types/beansFieldImage.php | 4 ++-- tests/phpunit/unit/api/fields/types/beansFieldRadio.php | 4 ++-- tests/phpunit/unit/api/fields/types/beansFieldSelect.php | 4 ++-- tests/phpunit/unit/api/fields/types/beansFieldSlider.php | 4 ++-- tests/phpunit/unit/api/fields/types/beansFieldText.php | 4 ++-- tests/phpunit/unit/api/fields/types/beansFieldTextarea.php | 4 ++-- 19 files changed, 38 insertions(+), 38 deletions(-) diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index fb26c15a..46fc1647 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -46,10 +46,10 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_group_label', 'beans_field_label' ); beans_remove_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php index 7569be31..7e5c1fca 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_activation', 'beans_field_activation' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php index 24a6ab0e..93bc7591 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php index a3c23906..6549bc32 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php @@ -36,10 +36,10 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_label', 'beans_field_label' ); beans_remove_action( 'beans_field_description', 'beans_field_description' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index 8edc49be..2331fc4c 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -36,10 +36,10 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_enqueue_scripts_image', 'beans_field_enqueue_scripts_image' ); beans_remove_action( 'beans_field_image_assets', 'beans_field_image_assets' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php index a0035ea8..cfde535e 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php @@ -36,10 +36,10 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_label', 'beans_field_label' ); beans_remove_action( 'beans_field_description', 'beans_field_description' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php index 8be8f499..303afbfc 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_radio', 'beans_field_radio' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php index 27911715..eb7ee1f6 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_select', 'beans_field_select' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php index 3a80eb44..8fb7bace 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php @@ -36,10 +36,10 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_slider', 'beans_field_slider' ); beans_remove_action( 'beans_field_enqueue_scripts_slider', 'beans_field_enqueue_scripts_slider' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php index 44d46159..8b4c60a2 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldText.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldText.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_text', 'beans_field_text' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php index 4556d165..59216637 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_textarea', 'beans_field_textarea' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php index 695ac421..9edba0f5 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_activation', 'beans_field_activation' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php index 9833c854..9970da17 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 70b7e34f..56739582 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -37,10 +37,10 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_enqueue_scripts_image', 'beans_field_enqueue_scripts_image' ); beans_remove_action( 'beans_field_image_assets', 'beans_field_image_assets' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php index 2e2353c0..58e49db7 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_radio', 'beans_field_radio' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index 578b9ff1..044189f0 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_select', 'beans_field_select' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php index 596d1d6a..67f23324 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php @@ -36,10 +36,10 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_slider', 'beans_field_slider' ); beans_remove_action( 'beans_field_enqueue_scripts_slider', 'beans_field_enqueue_scripts_slider' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index f09262f4..7e56cf58 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_text', 'beans_field_text' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index c9ab4f98..95522bfd 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -36,9 +36,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::setUp(); - beans_remove_action( 'beans_field_textarea', 'beans_field_textarea' ); + + parent::tearDown(); } /** From 2b82904d550c4f85dc9838a0918b7a7d052e7816 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 31 Mar 2018 11:30:36 -0400 Subject: [PATCH 456/800] Added first pass of unit tests for beansRegisterWPCustomizeOptions --- lib/api/wp-customize/functions.php | 2 +- .../includes/class-wp-customize-test-case.php | 4 +- .../beansRegisterWPCustomizeOptions.php | 78 ++++++++ .../api/wp-customize/fixtures/test-fields.php | 85 ++++++++ .../includes/class-wp-customize-test-case.php | 181 ++++++++++++++++++ 5 files changed, 347 insertions(+), 3 deletions(-) create mode 100644 tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php create mode 100644 tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php create mode 100644 tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php diff --git a/lib/api/wp-customize/functions.php b/lib/api/wp-customize/functions.php index cd2d180e..d6a6bc29 100644 --- a/lib/api/wp-customize/functions.php +++ b/lib/api/wp-customize/functions.php @@ -46,7 +46,7 @@ * text to the section. Default false. * } * - * @return bool|null False on failure. + * @return bool False on failure. */ function beans_register_wp_customize_options( array $fields, $section, $args = array() ) { diff --git a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php index acb4c5ac..fcb1b3cd 100644 --- a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php @@ -1,6 +1,6 @@ alias( function( $fields ) { + return $fields; + }); + + } + + /** + * Test beans_register_wp_customize_options() should return false when not in the WP Customizer . + */ + public function test_should_return_null_when_no_customizer() { + Monkey\Functions\when( 'is_customize_preview' )->justReturn( false ); + + $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); + $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); + } + + /** + * Test beans_register_wp_customize_options() should return false when there are no options. + */ + public function test_should_return_false_when_no_options() { + Monkey\Functions\when( 'is_customize_preview' )->justReturn( true ); + Monkey\Functions\when( 'beans_register_fields' )->justReturn( false ); + + $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); + $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); + } + + /** + * Test beans_register_wp_customize_options() should register the fields. + */ + public function test_should_register_fields() { + $test_data = static::$test_data['single_fields']; + + $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); + global $wp_customize; + $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. + $mocked_wp_customize->shouldReceive( 'get_section' )->andReturn( true ); + + Monkey\Functions\when( 'is_customize_preview' )->justReturn( true ); + Monkey\Functions\when( 'beans_get_fields' )->justReturn( array() ); + Monkey\Functions\when( 'beans_add_attribute' )->justReturn( array() ); + Monkey\Functions\when( 'beans_register_fields' )->justReturn( true ); + + $this->assertNull( beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ) ); + } +} diff --git a/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php new file mode 100644 index 00000000..74011308 --- /dev/null +++ b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php @@ -0,0 +1,85 @@ + array( + 'fields' => array( + array( + 'id' => 'beans_customizer_layout', + 'label' => 'Layout', + 'type' => 'radio', + 'default' => 'default_fallback', + 'options' => array( + 'default_fallback' => 'Use Default Layout', + 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', + 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', + 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', + ), + ), + array( + 'id' => 'beans_customizer_checkbox', + 'label' => false, + 'checkbox_label' => 'Enable the checkbox test', + 'type' => 'checkbox', + 'default' => false, + ), + array( + 'id' => 'beans_customizer_text', + 'type' => 'text', + 'default' => 'Testing the text field.', + ), + ), + 'context' => 'beans-test', + 'section' => 'tm-beans-customizer', + 'args' => array( + 'title' => 'Beans Customizer Section', + 'priority' => 250, + 'description' => 'Customizer Beans Section', + ), + ), + + // Group of fields. + 'group' => array( + 'fields' => array( + array( + 'id' => 'beans_group_test', + 'label' => 'Group of fields', + 'description' => 'This is a group of fields.', + 'type' => 'group', + 'fields' => array( + array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ), + array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), + 'options' => array( + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ), + ), + array( + 'id' => 'beans_checkbox_test', + 'label' => false, + 'checkbox_label' => 'Enable the checkbox test', + 'type' => 'checkbox', + 'default' => false, + ), + ), + ), + ), + 'context' => 'group_tests', + 'section' => 'tm-beans-customizer', + ), +); diff --git a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php new file mode 100644 index 00000000..fa765d1c --- /dev/null +++ b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php @@ -0,0 +1,181 @@ +load_original_functions( array( + 'api/wp-customize/functions.php', + 'api/wp-customize/class-beans-wp-customize.php', + 'api/wp-customize/class-beans-wp-customize-control.php', + 'api/fields/class-beans-fields.php', + 'api/utilities/functions.php', + ) ); + +// $this->setup_function_mocks(); + $this->setup_common_wp_stubs(); + } + + /** + * Cleans up the test environment after each test. + */ + public function tearDown() { + parent::tearDown(); + + // Reset the "registered" container. + $registered = $this->get_reflective_property( 'registered' ); + $registered->setValue( new \_Beans_Fields(), array( + 'option' => array(), + 'post_meta' => array(), + 'term_meta' => array(), + 'wp_customize' => array(), + ) ); + + // Reset the other static properties. + foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { + $property = $this->get_reflective_property( $property_name ); + $property->setValue( new \_Beans_Fields(), array() ); + } + + } + + /** + * Get reflective access to the private method. + * + * @since 1.5.0 + * + * @param string $method_name Method name for which to gain access. + * @param string $class_name Optional. Name of the target class. + * + * @return \ReflectionMethod + * @throws \ReflectionException Throws an exception if method does not exist. + */ + protected function get_reflective_method( $method_name, $class_name = '_Beans_Fields' ) { + return parent::get_reflective_method( $method_name, $class_name ); + } + + /** + * Get reflective access to the private property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * @param string $class_name Optional. Name of the target class. + * + * @return \ReflectionProperty|string + * @throws \ReflectionException Throws an exception if property does not exist. + */ + protected function get_reflective_property( $property, $class_name = '_Beans_Fields' ) { + return parent::get_reflective_property( $property, $class_name ); + } + + /** + * Get the value of the private or protected property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * + * @return mixed + * @throws \ReflectionException Throws an exception if property does not exist. + */ + protected function get_reflective_property_value( $property ) { + $reflective = $this->get_reflective_property( $property ); + + return $reflective->getValue( new \_Beans_Fields() ); + } + + /** + * Merge the given field with the default structure. + * + * @since 1.5.0 + * + * @param array $field The given field to merge. + * @param bool $set_value Optional. When true, sets the "value" to the "default". + * + * @return array + */ + protected function merge_field_with_default( array $field, $set_value = true ) { + $merged_field = array_merge( array( + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => 'wp_customize', + 'attributes' => array( + 'data-customize-setting-link' => $field['id'], + ), + 'db_group' => false, + ), $field ); + $merged_field['name'] = $field['id']; + + if ( $set_value ) { + $merged_field['value'] = $field['default']; + } + + return $merged_field; + } + + /** + * Set up function mocks. + */ + protected function setup_function_mocks() { + + Monkey\Functions\when( 'beans_get' )->alias( function( $needle, $haystack = false, $default = null ) { + $haystack = (array) $haystack; + + return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : $default; + } ); + + Monkey\Functions\when( 'beans_esc_attributes' )->alias( function( $attributes ) { + $string = ''; + + foreach ( (array) $attributes as $attribute => $value ) { + + if ( null === $value ) { + continue; + } + + $string .= $attribute . '="' . $value . '" '; + } + + return trim( $string ); + } ); + } +} From 369a599c112ae10580a72d495ce29abeb9a28d2a Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 3 Apr 2018 16:39:01 -0400 Subject: [PATCH 457/800] Fixed formatting. --- .../beansRegisterWPCustomizeOptions.php | 1 - .../includes/class-wp-customize-test-case.php | 31 ++----------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php b/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php index d79a5b2d..d9496871 100644 --- a/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php +++ b/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php @@ -33,7 +33,6 @@ public function setUp() { Monkey\Functions\when( '_beans_pre_standardize_fields' )->alias( function( $fields ) { return $fields; }); - } /** diff --git a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php index fa765d1c..2ae076d0 100644 --- a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php @@ -49,7 +49,6 @@ public function setUp() { 'api/utilities/functions.php', ) ); -// $this->setup_function_mocks(); $this->setup_common_wp_stubs(); } @@ -73,9 +72,9 @@ public function tearDown() { $property = $this->get_reflective_property( $property_name ); $property->setValue( new \_Beans_Fields(), array() ); } - } + // phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found -- It's actually needed. /** * Get reflective access to the private method. * @@ -105,6 +104,7 @@ protected function get_reflective_method( $method_name, $class_name = '_Beans_Fi protected function get_reflective_property( $property, $class_name = '_Beans_Fields' ) { return parent::get_reflective_property( $property, $class_name ); } + // phpcs:enable Generic.CodeAnalysis.UselessOverridingMethod.Found /** * Get the value of the private or protected property. @@ -151,31 +151,4 @@ protected function merge_field_with_default( array $field, $set_value = true ) { return $merged_field; } - - /** - * Set up function mocks. - */ - protected function setup_function_mocks() { - - Monkey\Functions\when( 'beans_get' )->alias( function( $needle, $haystack = false, $default = null ) { - $haystack = (array) $haystack; - - return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : $default; - } ); - - Monkey\Functions\when( 'beans_esc_attributes' )->alias( function( $attributes ) { - $string = ''; - - foreach ( (array) $attributes as $attribute => $value ) { - - if ( null === $value ) { - continue; - } - - $string .= $attribute . '="' . $value . '" '; - } - - return trim( $string ); - } ); - } } From f4e363d771c5e57083843ef9f04736227c0ffa82 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 3 Apr 2018 22:06:23 -0400 Subject: [PATCH 458/800] Added resets to Unit test case, removed teadDown methods. --- .../integration/api/fields/beansField.php | 10 ---- .../includes/class-fields-test-case.php | 4 +- .../api/fields/types/beansFieldActivation.php | 9 ---- .../api/fields/types/beansFieldCheckbox.php | 9 ---- .../fields/types/beansFieldDescription.php | 10 ---- .../api/fields/types/beansFieldImage.php | 10 ---- .../api/fields/types/beansFieldLabel.php | 10 ---- .../api/fields/types/beansFieldRadio.php | 9 ---- .../api/fields/types/beansFieldSelect.php | 9 ---- .../api/fields/types/beansFieldSlider.php | 10 ---- .../api/fields/types/beansFieldText.php | 9 ---- .../api/fields/types/beansFieldTextarea.php | 9 ---- tests/phpunit/integration/class-test-case.php | 6 +-- .../includes/class-fields-test-case.php | 3 +- .../api/fields/types/beansFieldActivation.php | 9 ---- .../api/fields/types/beansFieldCheckbox.php | 9 ---- .../unit/api/fields/types/beansFieldImage.php | 10 ---- .../unit/api/fields/types/beansFieldRadio.php | 9 ---- .../api/fields/types/beansFieldSelect.php | 9 ---- .../api/fields/types/beansFieldSlider.php | 10 ---- .../unit/api/fields/types/beansFieldText.php | 9 ---- .../api/fields/types/beansFieldTextarea.php | 9 ---- tests/phpunit/unit/class-test-case.php | 51 +++++++++++++++++++ 23 files changed, 58 insertions(+), 184 deletions(-) diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 46fc1647..8d41f318 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -42,16 +42,6 @@ public function setUp() { beans_add_smart_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_group_label', 'beans_field_label' ); - beans_remove_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); - - parent::tearDown(); - } - /** * Test beans_field() should render the checkbox field. */ diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index f3bff11a..1cedabe8 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -51,11 +51,11 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::tearDown(); - remove_action( 'beans_field_group_label', 'beans_field_label' ); remove_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); remove_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php index 7e5c1fca..2c0460aa 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/activation.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_activation', 'beans_field_activation' ); - - parent::tearDown(); - } - /** * Test beans_field_activation() should render the activation field. */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php index 93bc7591..b3c21784 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/checkbox.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); - - parent::tearDown(); - } - /** * Test beans_field_checkbox() should render the checkbox with the label when given. */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php index 6549bc32..a675df3e 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php @@ -32,16 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/field.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_label', 'beans_field_label' ); - beans_remove_action( 'beans_field_description', 'beans_field_description' ); - - parent::tearDown(); - } - /** * Test beans_field_description() should not render the field's description when none is given. */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index 2331fc4c..d5e62b79 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -32,16 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/image.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_enqueue_scripts_image', 'beans_field_enqueue_scripts_image' ); - beans_remove_action( 'beans_field_image_assets', 'beans_field_image_assets' ); - - parent::tearDown(); - } - /** * Test beans_field_image() should render a single image field. */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php index cfde535e..c5aacc17 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php @@ -32,16 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/field.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_label', 'beans_field_label' ); - beans_remove_action( 'beans_field_description', 'beans_field_description' ); - - parent::tearDown(); - } - /** * Test beans_field_label() should not render the field's label when none is given. */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php index 303afbfc..f992c365 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/radio.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_radio', 'beans_field_radio' ); - - parent::tearDown(); - } - /** * Test beans_field_radio() should render the radio field with image options. */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php index eb7ee1f6..16b24bab 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/select.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_select', 'beans_field_select' ); - - parent::tearDown(); - } - /** * Test beans_field_select() should render the select field. */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php index 8fb7bace..cc958716 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php @@ -32,16 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/slider.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_slider', 'beans_field_slider' ); - beans_remove_action( 'beans_field_enqueue_scripts_slider', 'beans_field_enqueue_scripts_slider' ); - - parent::tearDown(); - } - /** * Test beans_field_slider() should render the slider field. */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php index 8b4c60a2..7eafba5f 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldText.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldText.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/text.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_text', 'beans_field_text' ); - - parent::tearDown(); - } - /** * Test beans_field_text() should render the text field. */ diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php index 59216637..edf99144 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/textarea.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_textarea', 'beans_field_textarea' ); - - parent::tearDown(); - } - /** * Test beans_field_textarea() should render the textarea field. */ diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index c0e0969e..bd0e1461 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -44,11 +44,11 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - Monkey\tearDown(); - parent::tearDown(); - $this->reset_fields_container(); $this->reset_actions_container(); + + Monkey\tearDown(); + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index a02ab2c5..1603033d 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -57,7 +57,6 @@ public function setUp() { * Cleans up the test environment after each test. */ protected function tearDown() { - parent::tearDown(); // Reset the "registered" container. $registered = $this->get_reflective_property( 'registered' ); @@ -73,6 +72,8 @@ protected function tearDown() { $property = $this->get_reflective_property( $property_name ); $property->setValue( new \_Beans_Fields(), array() ); } + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php index 9edba0f5..470d46f3 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/activation.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_activation', 'beans_field_activation' ); - - parent::tearDown(); - } - /** * Test beans_field_activation() should render the activation field. */ diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php index 9970da17..50594d46 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/checkbox.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); - - parent::tearDown(); - } - /** * Test beans_field_checkbox() should render the checkbox with the label when given. */ diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 56739582..8a4b6ef3 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -33,16 +33,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/image.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_enqueue_scripts_image', 'beans_field_enqueue_scripts_image' ); - beans_remove_action( 'beans_field_image_assets', 'beans_field_image_assets' ); - - parent::tearDown(); - } - /** * Test beans_field_image() should render a single image field. */ diff --git a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php index 58e49db7..66f82fc2 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/radio.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_radio', 'beans_field_radio' ); - - parent::tearDown(); - } - /** * Test beans_field_radio() should render the radio field with image options. */ diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index 044189f0..96498880 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/select.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_select', 'beans_field_select' ); - - parent::tearDown(); - } - /** * Test beans_field_checkbox() should render the select field. */ diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php index 67f23324..bfb8223f 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php @@ -32,16 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/slider.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_slider', 'beans_field_slider' ); - beans_remove_action( 'beans_field_enqueue_scripts_slider', 'beans_field_enqueue_scripts_slider' ); - - parent::tearDown(); - } - /** * Test beans_field_slider() should render the slider field. */ diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index 7e56cf58..1cc367b2 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/text.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_text', 'beans_field_text' ); - - parent::tearDown(); - } - /** * Test beans_field_text() should render the text field. */ diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index 95522bfd..ea625391 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -32,15 +32,6 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/fields/types/textarea.php'; } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - beans_remove_action( 'beans_field_textarea', 'beans_field_textarea' ); - - parent::tearDown(); - } - /** * Test beans_field_textarea() should render the textarea field. */ diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 7aaa64ae..34256c5f 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -27,6 +27,13 @@ abstract class Test_Case extends TestCase { */ protected $just_return_path = false; + /** + * Reset flag. + * + * @var bool + */ + protected $was_reset = false; + /** * Prepares the test environment before each test. */ @@ -79,12 +86,21 @@ protected function setup_common_wp_stubs() { foreach ( array( 'esc_attr_e', 'esc_html_e', '_e' ) as $wp_function ) { Monkey\Functions\when( $wp_function )->echoArg(); } + + if ( ! $this->was_reset ) { + $this->reset_actions_container(); + $this->reset_fields_container(); + $this->was_reset = true; + } } /** * Cleans up the test environment after each test. */ protected function tearDown() { + $this->reset_actions_container(); + $this->reset_fields_container(); + Monkey\tearDown(); parent::tearDown(); } @@ -136,6 +152,41 @@ protected function format_the_html( $html ) { return str_replace( '>', ">\n", $html ); } + /** + * Reset the Actions API container. + */ + protected function reset_actions_container() { + global $_beans_registered_actions; + $_beans_registered_actions = array( + 'added' => array(), + 'modified' => array(), + 'removed' => array(), + 'replaced' => array(), + ); + } + + /** + * Reset the Fields API container, i.e. static memories. + */ + protected function reset_fields_container() { + if ( ! class_exists( '_Beans_Fields' ) ) { + return; + } + // Reset the "registered" container. + $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); + $registered->setValue( new \_Beans_Fields(), array( + 'option' => array(), + 'post_meta' => array(), + 'term_meta' => array(), + 'wp_customize' => array(), + ) ); + // Reset the other static properties. + foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { + $property = $this->get_reflective_property( $property_name, '_Beans_Fields' ); + $property->setValue( new \_Beans_Fields(), array() ); + } + } + /** * Get reflective access to the private method. * From 1e0bd0ac52b4c05fafaabdee036eba5e4013716e Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 4 Apr 2018 08:45:33 -0400 Subject: [PATCH 459/800] Fix #202 --- lib/api/post-meta/functions-admin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/api/post-meta/functions-admin.php b/lib/api/post-meta/functions-admin.php index adc17769..98e8027c 100644 --- a/lib/api/post-meta/functions-admin.php +++ b/lib/api/post-meta/functions-admin.php @@ -103,6 +103,10 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = * @return bool */ function _beans_is_post_meta_conditions( $conditions ) { + // If user has designated boolean true, it's always true. Nothing more to do here. + if ( true === $conditions ) { + return true; + } // Check if it is a new post and treat it as such. if ( false !== stripos( $_SERVER['REQUEST_URI'], 'post-new.php' ) ) { @@ -136,7 +140,6 @@ function _beans_is_post_meta_conditions( $conditions ) { } $statements = array( - true === $conditions, in_array( $current_post_type, (array) $conditions, true ), // Check post type. isset( $post_id ) && in_array( $post_id, (array) $conditions, true ), // Check post id. isset( $post_id ) && in_array( get_post_meta( $post_id, '_wp_page_template', true ), (array) $conditions, true ), // Check page template. From 4ac0fd3f22674130f0ac7af89167617572de5d16 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 4 Apr 2018 09:11:42 -0400 Subject: [PATCH 460/800] Fix spaces vs tabs error in codesniff --- lib/api/post-meta/functions-admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/post-meta/functions-admin.php b/lib/api/post-meta/functions-admin.php index 98e8027c..9d9e8958 100644 --- a/lib/api/post-meta/functions-admin.php +++ b/lib/api/post-meta/functions-admin.php @@ -103,10 +103,10 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = * @return bool */ function _beans_is_post_meta_conditions( $conditions ) { - // If user has designated boolean true, it's always true. Nothing more to do here. - if ( true === $conditions ) { - return true; - } + // If user has designated boolean true, it's always true. Nothing more to do here. + if ( true === $conditions ) { + return true; + } // Check if it is a new post and treat it as such. if ( false !== stripos( $_SERVER['REQUEST_URI'], 'post-new.php' ) ) { From bb0c4e91edf1dd2df4585a563ac812940ced89b0 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 4 Apr 2018 13:42:02 -0400 Subject: [PATCH 461/800] Removed tearDown() from fields-test-case. --- .../includes/class-fields-test-case.php | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 1603033d..17eaed2f 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -53,29 +53,6 @@ public function setUp() { $this->setup_common_wp_stubs(); } - /** - * Cleans up the test environment after each test. - */ - protected function tearDown() { - - // Reset the "registered" container. - $registered = $this->get_reflective_property( 'registered' ); - $registered->setValue( new \_Beans_Fields(), array( - 'option' => array(), - 'post_meta' => array(), - 'term_meta' => array(), - 'wp_customize' => array(), - ) ); - - // Reset the other static properties. - foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { - $property = $this->get_reflective_property( $property_name ); - $property->setValue( new \_Beans_Fields(), array() ); - } - - parent::tearDown(); - } - /** * Get reflective access to the private method. * From 41177f3c704146567118a3ba76b5344d874a2ecd Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 4 Apr 2018 14:52:17 -0400 Subject: [PATCH 462/800] Removed tearDown() from Unit wp-customize-test-case. --- .../includes/class-wp-customize-test-case.php | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php index 2ae076d0..82ce143a 100644 --- a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php @@ -46,34 +46,11 @@ public function setUp() { 'api/wp-customize/class-beans-wp-customize.php', 'api/wp-customize/class-beans-wp-customize-control.php', 'api/fields/class-beans-fields.php', - 'api/utilities/functions.php', ) ); $this->setup_common_wp_stubs(); } - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - parent::tearDown(); - - // Reset the "registered" container. - $registered = $this->get_reflective_property( 'registered' ); - $registered->setValue( new \_Beans_Fields(), array( - 'option' => array(), - 'post_meta' => array(), - 'term_meta' => array(), - 'wp_customize' => array(), - ) ); - - // Reset the other static properties. - foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { - $property = $this->get_reflective_property( $property_name ); - $property->setValue( new \_Beans_Fields(), array() ); - } - } - // phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found -- It's actually needed. /** * Get reflective access to the private method. From 3e59eb0afa8a8fb9310b88897b4a84c84740c735 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 4 Apr 2018 15:23:42 -0400 Subject: [PATCH 463/800] Made Unit setUp() methods' visibility consistent. --- .../phpunit/unit/api/fields/includes/class-fields-test-case.php | 2 +- tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php | 2 +- tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php | 2 +- tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php | 2 +- .../unit/api/fields/types/_beansStandardizeRadioImage.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldActivation.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldImage.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldRadio.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldSelect.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldSlider.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldText.php | 2 +- tests/phpunit/unit/api/fields/types/beansFieldTextarea.php | 2 +- .../unit/api/options/includes/class-options-test-case.php | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 17eaed2f..91ac7519 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -40,7 +40,7 @@ public static function setUpBeforeClass() { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); $this->load_original_functions( array( diff --git a/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php b/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php index 0fb44b1a..3014a147 100644 --- a/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php +++ b/tests/phpunit/unit/api/fields/types/_BeansGetImageAlt.php @@ -26,7 +26,7 @@ class Tests_BeansGetImageAlt extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php b/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php index 4d3e0158..f03c6672 100644 --- a/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php +++ b/tests/phpunit/unit/api/fields/types/_BeansGetImageUrl.php @@ -26,7 +26,7 @@ class Tests_BeansGetImageUrl extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php index c15c9aa5..ec4f167f 100644 --- a/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/_beansIsRadioImage.php @@ -25,7 +25,7 @@ class Tests_BeansIsRadioImage extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php b/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php index 641ba206..7b50e8ff 100644 --- a/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/_beansStandardizeRadioImage.php @@ -25,7 +25,7 @@ class Tests_BeansStandardizeRadioImage extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php index 470d46f3..d18133a7 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php @@ -25,7 +25,7 @@ class Tests_BeansFieldActivation extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php index 50594d46..91f95d3f 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php @@ -25,7 +25,7 @@ class Tests_BeansFieldCheckbox extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 8a4b6ef3..1f6ff1d6 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -26,7 +26,7 @@ class Tests_BeansFieldImage extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php index 66f82fc2..e4571edd 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php @@ -25,7 +25,7 @@ class Tests_BeansFieldRadio extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index 96498880..002c0e1a 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -25,7 +25,7 @@ class Tests_BeansFieldSelect extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php index bfb8223f..592a9ced 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php @@ -25,7 +25,7 @@ class Tests_BeansFieldSlider extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index 1cc367b2..1b099045 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -25,7 +25,7 @@ class Tests_BeansFieldText extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index ea625391..855d4fea 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -25,7 +25,7 @@ class Tests_BeansFieldTextarea extends Fields_Test_Case { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); // Load the field type. diff --git a/tests/phpunit/unit/api/options/includes/class-options-test-case.php b/tests/phpunit/unit/api/options/includes/class-options-test-case.php index cad9e9bf..93df1e2b 100644 --- a/tests/phpunit/unit/api/options/includes/class-options-test-case.php +++ b/tests/phpunit/unit/api/options/includes/class-options-test-case.php @@ -38,7 +38,7 @@ public static function setUpBeforeClass() { /** * Prepares the test environment before each test. */ - public function setUp() { + protected function setUp() { parent::setUp(); $this->load_original_functions( array( From 1ae53809259679454e1c9e877933d6591919d6c3 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 4 Apr 2018 15:42:11 -0400 Subject: [PATCH 464/800] Add new line above comment per coding standard --- lib/api/post-meta/functions-admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api/post-meta/functions-admin.php b/lib/api/post-meta/functions-admin.php index 9d9e8958..65784155 100644 --- a/lib/api/post-meta/functions-admin.php +++ b/lib/api/post-meta/functions-admin.php @@ -103,6 +103,7 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = * @return bool */ function _beans_is_post_meta_conditions( $conditions ) { + // If user has designated boolean true, it's always true. Nothing more to do here. if ( true === $conditions ) { return true; From 36815d369eebc552ab46de5431efa4996d18e7d5 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 4 Apr 2018 16:47:21 -0400 Subject: [PATCH 465/800] Standardized sequence in tearDown() methods. --- .../api/actions/includes/class-actions-test-case.php | 3 ++- .../api/actions/includes/class-replace-action-test-case.php | 3 ++- .../api/compiler/includes/class-compiler-test-case.php | 4 ++-- .../api/filters/includes/class-filters-test-case.php | 3 ++- tests/phpunit/integration/api/layout/beansGetLayoutClass.php | 3 ++- .../api/options/includes/class-options-test-case.php | 3 ++- .../unit/api/actions/includes/class-actions-test-case.php | 4 ++-- .../unit/api/compiler/includes/class-compiler-test-case.php | 5 +++-- .../unit/api/filters/includes/class-filters-test-case.php | 3 ++- .../unit/api/options/includes/class-options-test-case.php | 4 ++-- 10 files changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index ff19c20c..6eae4167 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -76,7 +76,6 @@ public static function tearDownAfterClass() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::tearDown(); if ( false === $this->reset_beans_registry ) { return; @@ -89,6 +88,8 @@ public function tearDown() { 'removed' => array(), 'replaced' => array(), ); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php index a8c9cd8f..8f50d55a 100644 --- a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php @@ -34,7 +34,6 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::tearDown(); // Reset and restore. foreach ( static::$test_actions as $beans_id => $action ) { @@ -46,6 +45,8 @@ public function tearDown() { // Restore the original action. beans_add_smart_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index 62b98452..10bc021a 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -72,10 +72,10 @@ public function setUp() { * Tear down the test fixture. */ public function tearDown() { + unset( $GLOBALS['wp_filesystem'] ); + Mockery::close(); parent::tearDown(); - - unset( $GLOBALS['wp_filesystem'] ); } /** diff --git a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php index 89089e63..f921be1d 100644 --- a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php @@ -48,7 +48,6 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::tearDown(); foreach ( static::$test_filters as $beans_id => $filter ) { @@ -58,6 +57,8 @@ public function tearDown() { remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); } + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php index 528811e1..ff877735 100644 --- a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php @@ -40,10 +40,11 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::tearDown(); // Reset the Beans' sidebars. beans_do_register_widget_areas(); + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/api/options/includes/class-options-test-case.php b/tests/phpunit/integration/api/options/includes/class-options-test-case.php index 7715dfd4..de6e0566 100644 --- a/tests/phpunit/integration/api/options/includes/class-options-test-case.php +++ b/tests/phpunit/integration/api/options/includes/class-options-test-case.php @@ -49,13 +49,14 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - parent::tearDown(); // Let's clean up after the test. $this->clean_up_global_scope(); global $wp_meta_boxes; $wp_meta_boxes = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index 19fb6762..3f4884d7 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -89,8 +89,6 @@ protected function setUp() { * Cleans up the test environment after each test. */ protected function tearDown() { - parent::tearDown(); - global $_beans_registered_actions; $_beans_registered_actions = array( 'added' => array(), @@ -100,6 +98,8 @@ protected function tearDown() { ); $this->remove_test_actions(); + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index bbf24327..52f7ae1d 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -101,8 +101,6 @@ protected function setUp() { * Tear down the test fixture. */ protected function tearDown() { - Mockery::close(); - parent::tearDown(); // Reset the global fragments container. global $_beans_compiler_added_fragments; @@ -113,6 +111,9 @@ protected function tearDown() { ); unset( $GLOBALS['wp_filesystem'] ); + + Mockery::close(); + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php index c89e9ef5..d204e17e 100644 --- a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php @@ -52,7 +52,6 @@ protected function setUp() { * Reset the test fixture. */ protected function tearDown() { - parent::tearDown(); foreach ( static::$test_filters as $beans_id => $filter ) { @@ -62,6 +61,8 @@ protected function tearDown() { remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); } + + parent::tearDown(); } /** diff --git a/tests/phpunit/unit/api/options/includes/class-options-test-case.php b/tests/phpunit/unit/api/options/includes/class-options-test-case.php index 93df1e2b..30c1a3e1 100644 --- a/tests/phpunit/unit/api/options/includes/class-options-test-case.php +++ b/tests/phpunit/unit/api/options/includes/class-options-test-case.php @@ -56,10 +56,10 @@ protected function setUp() { * Cleans up the test environment after each test. */ protected function tearDown() { - parent::tearDown(); - global $wp_meta_boxes; $wp_meta_boxes = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. + + parent::tearDown(); } /** From b65fec7ccb6b264430d6b23b47c84b8822856e7b Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Wed, 4 Apr 2018 19:01:17 -0400 Subject: [PATCH 466/800] Removed tearDown() from Unit actions_test_case. --- .../includes/class-actions-test-case.php | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index 3f4884d7..d748685c 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -85,23 +85,6 @@ protected function setUp() { } ); } - /** - * Cleans up the test environment after each test. - */ - protected function tearDown() { - global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); - - $this->remove_test_actions(); - - parent::tearDown(); - } - /** * Simulate going to the post and loading in the template and fragments. * @@ -133,15 +116,4 @@ protected function go_to_post( $expect_added = false ) { } } } - - /** - * Remove the test actions. - */ - protected function remove_test_actions() { - - foreach ( static::$test_actions as $beans_id => $action ) { - _beans_unset_action( $beans_id, 'added' ); - remove_action( $action['hook'], $action['callback'], $action['priority'] ); - } - } } From c86dc85d565c336f0de3af86ec2123da060755de Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 5 Apr 2018 11:35:21 -0500 Subject: [PATCH 467/800] Renamed integration test class to comply with wpcs. --- .../api/compiler/beans-compiler/addContentMediaQuery.php | 4 ++-- .../integration/api/compiler/beans-compiler/cacheFile.php | 4 ++-- .../api/compiler/beans-compiler/combineFragments.php | 4 ++-- .../integration/api/compiler/beans-compiler/fileystem.php | 4 ++-- .../integration/api/compiler/beans-compiler/formatContent.php | 4 ++-- .../api/compiler/beans-compiler/getInternalContent.php | 4 ++-- .../api/compiler/beans-compiler/getRemoteContent.php | 4 ++-- .../integration/api/compiler/beans-compiler/replaceCssUrl.php | 4 ++-- .../integration/api/compiler/beans-compiler/runCompiler.php | 4 ++-- .../integration/api/compiler/beans-compiler/setFilename.php | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php index 741753b4..52d99023 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Add_Content_Media_Query + * Class Tests_BeansCompiler_AddContentMediaQuery * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Add_Content_Media_Query extends Compiler_Test_Case { +class Tests_BeansCompiler_AddContentMediaQuery extends Compiler_Test_Case { /** * Test add_content_media_query() should return original content when current fragment is callable. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php index ba15fd89..0efe5073 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php @@ -17,13 +17,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Cache_File + * Class Tests_BeansCompiler_CacheFile * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Cache_File extends Compiler_Test_Case { +class Tests_BeansCompiler_CacheFile extends Compiler_Test_Case { /** * Test cache_file() should not create the file. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php index 3eef3eaa..a42b4c1e 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Combine_Fragments + * Class Tests_BeansCompiler_CombineFragments * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Combine_Fragments extends Compiler_Test_Case { +class Tests_BeansCompiler_CombineFragments extends Compiler_Test_Case { /** * The CSS content. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php index d900a5e9..954d691d 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Filesystem + * Class Tests_BeansCompiler_Filesystem * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Filesystem extends Compiler_Test_Case { +class Tests_BeansCompiler_Filesystem extends Compiler_Test_Case { /** * Test filesystem() should render a report and die when no filesystem is selected. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php index 4c19bf5e..e902c905 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -14,13 +14,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Format_Content + * Class Tests_BeansCompiler_FormatContent * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Format_Content extends Compiler_Test_Case { +class Tests_BeansCompiler_FormatContent extends Compiler_Test_Case { /** * The Less content. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php index 895570f2..a3adb384 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Get_Internal_Content + * Class Tests_BeansCompiler_GetInternalContent * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Get_Internal_Content extends Compiler_Test_Case { +class Tests_BeansCompiler_GetInternalContent extends Compiler_Test_Case { /** * Test get_internal_content() should return false when fragment is empty. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php index 58e81b5d..55bc1561 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Get_Remote_Content + * Class Tests_BeansCompiler_GetRemoteContent * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Get_Remote_Content extends Compiler_Test_Case { +class Tests_BeansCompiler_GetRemoteContent extends Compiler_Test_Case { /** * Test get_remote_content() should return false when fragment is empty. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php index 3d8c1e37..44ff15de 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Replace_Css_Url + * Class Tests_BeansCompiler_ReplaceCssUrl * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Replace_Css_Url extends Compiler_Test_Case { +class Tests_BeansCompiler_ReplaceCssUrl extends Compiler_Test_Case { /** * Test replace_css_url() should return original content when there is no url source in the CSS. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php index acc358a8..9b9b2cc4 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Run_Compiler + * Class Tests_BeansCompiler_RunCompiler * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Run_Compiler extends Compiler_Test_Case { +class Tests_BeansCompiler_RunCompiler extends Compiler_Test_Case { /** * The CSS content. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php index da8db3fd..17aab9fc 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Set_Filename + * Class Tests_BeansCompiler_SetFilename * * @package Beans\Framework\Tests\Integration\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { +class Tests_BeansCompiler_SetFilename extends Compiler_Test_Case { /** * Test set_filename() should return the hash created with the modification time from each of the fragments. From d82eb897c437c0e5cab597cd8a35bdfedbab314e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 5 Apr 2018 11:42:12 -0500 Subject: [PATCH 468/800] Renamed unit test classes to comply with WPCS. --- .../unit/api/compiler/beans-compiler/addContentMediaQuery.php | 4 ++-- tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php | 4 ++-- .../unit/api/compiler/beans-compiler/cacheFileExist.php | 4 ++-- .../unit/api/compiler/beans-compiler/combineFragments.php | 4 ++-- tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php | 4 ++-- .../unit/api/compiler/beans-compiler/formatContent.php | 4 ++-- tests/phpunit/unit/api/compiler/beans-compiler/get.php | 4 ++-- .../phpunit/unit/api/compiler/beans-compiler/getExtension.php | 4 ++-- .../unit/api/compiler/beans-compiler/getFunctionContent.php | 4 ++-- .../unit/api/compiler/beans-compiler/getInternalContent.php | 4 ++-- .../unit/api/compiler/beans-compiler/getRemoteContent.php | 4 ++-- .../unit/api/compiler/beans-compiler/replaceCssUrl.php | 4 ++-- .../phpunit/unit/api/compiler/beans-compiler/runCompiler.php | 4 ++-- .../phpunit/unit/api/compiler/beans-compiler/setFilename.php | 4 ++-- .../phpunit/unit/api/compiler/beans-compiler/setFragments.php | 4 ++-- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php index 3e40cd00..c9c19984 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Add_Content_Media_Query + * Class Tests_BeansCompiler_AddContentMediaQuery * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Add_Content_Media_Query extends Compiler_Test_Case { +class Tests_BeansCompiler_AddContentMediaQuery extends Compiler_Test_Case { /** * Test add_content_media_query() should return original content when current fragment is callable. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php index 1d1b985c..44d545bc 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Cache_File + * Class Tests_BeansCompiler_CacheFile * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Cache_File extends Compiler_Test_Case { +class Tests_BeansCompiler_CacheFile extends Compiler_Test_Case { /** * Test cache_file() should not create the file when the filename is empty. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php index 73f6d306..1adb00d3 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_CacheFileExist + * Class Tests_BeansCompiler_CacheFileExist * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_CacheFileExist extends Compiler_Test_Case { +class Tests_BeansCompiler_CacheFileExist extends Compiler_Test_Case { /** * Test cache_file_exist() should return false when the filename has not been generated. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php index d54ad3f6..9e9c787e 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Combine_Fragments + * Class Tests_BeansCompiler_CombineFragments * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Combine_Fragments extends Compiler_Test_Case { +class Tests_BeansCompiler_CombineFragments extends Compiler_Test_Case { /** * The CSS content. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php index 24b0d219..7b819aaf 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Filesystem + * Class Tests_BeansCompiler_Filesystem * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Filesystem extends Compiler_Test_Case { +class Tests_BeansCompiler_Filesystem extends Compiler_Test_Case { /** * Test filesystem() should return true when the WP Filesystem is initialized to WP_Filesystem_Direct. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php index 7fd7d5ab..9e20dd3b 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Format_Content + * Class Tests_BeansCompiler_FormatContent * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Format_Content extends Compiler_Test_Case { +class Tests_BeansCompiler_FormatContent extends Compiler_Test_Case { /** * The Less content. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/get.php b/tests/phpunit/unit/api/compiler/beans-compiler/get.php index b7385269..6790cc24 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/get.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/get.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Get + * Class Tests_BeansCompiler_Get * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Get extends Compiler_Test_Case { +class Tests_BeansCompiler_Get extends Compiler_Test_Case { /** * Test should fix the configuration's dependency key. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php index 3b442fb5..14afad62 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php @@ -14,13 +14,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Get_Extension + * Class Tests_BeansCompiler_GetExtension * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Get_Extension extends Compiler_Test_Case { +class Tests_BeansCompiler_GetExtension extends Compiler_Test_Case { /** * Test get_extension() should return "css" when the type is "style". diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php index ac9109b0..36741d89 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Get_Function_Content + * Class Tests_BeansCompiler_GetFunctionContent * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Get_Function_Content extends Compiler_Test_Case { +class Tests_BeansCompiler_GetFunctionContent extends Compiler_Test_Case { /** * Test get_function_content() should return false when the given fragment is not callable. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php index 8ecb9c3e..0bec84ee 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Get_Internal_Content + * Class Tests_BeansCompiler_GetInternalContent * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Get_Internal_Content extends Compiler_Test_Case { +class Tests_BeansCompiler_GetInternalContent extends Compiler_Test_Case { /** * Prepares the test environment before each test. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index 3dba1c10..861145c6 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Get_Remote_Content + * Class Tests_BeansCompiler_GetRemoteContent * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Get_Remote_Content extends Compiler_Test_Case { +class Tests_BeansCompiler_GetRemoteContent extends Compiler_Test_Case { /** * Test get_remote_content() should return false when the fragment is empty. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php index 01849d71..42a99f05 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Replace_Css_Url + * Class Tests_BeansCompiler_ReplaceCssUrl * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Replace_Css_Url extends Compiler_Test_Case { +class Tests_BeansCompiler_ReplaceCssUrl extends Compiler_Test_Case { /** * Test replace_css_url() should return original content when there is no url source in the CSS. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index 5902dd06..b777af61 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Run_Compiler + * Class Tests_BeansCompiler_RunCompiler * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Run_Compiler extends Compiler_Test_Case { +class Tests_BeansCompiler_RunCompiler extends Compiler_Test_Case { /** * The CSS content. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php index 93940e0f..09e375dd 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php @@ -15,13 +15,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Set_Filename + * Class Tests_BeansCompiler_SetFilename * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Set_Filename extends Compiler_Test_Case { +class Tests_BeansCompiler_SetFilename extends Compiler_Test_Case { /** * Test set_filename() should return the hash created with the modification time from each of the fragments. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php index 079b6537..8a137526 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php @@ -16,13 +16,13 @@ require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; /** - * Class Tests_Beans_Compiler_Set_Fragments + * Class Tests_BeansCompiler_SetFragments * * @package Beans\Framework\Tests\Unit\API\Compiler * @group api * @group api-compiler */ -class Tests_Beans_Compiler_Set_Fragments extends Compiler_Test_Case { +class Tests_BeansCompiler_SetFragments extends Compiler_Test_Case { /** * Test set_fragments() should return unchanged fragments, meaning no fragments were added or removed. From ef784772b83430ffdcf7091458810e4dc6949811 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Sat, 7 Apr 2018 12:22:49 -0400 Subject: [PATCH 469/800] Fixes broken link to contributor wiki in readme.md (#207) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe7aba0f..980c6b17 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,6 @@ Beans community is growing rapidly and a lot of people are asking how they can c * Build extensions * Contribute to Beans core -If you are a Beans superstar and you want to contribute to Beans core, please see the [Beans Contributor's Wiki](wiki). +If you are a Beans superstar and you want to contribute to Beans core, please see the [Beans Contributor's Wiki](https://github.com/Getbeans/Beans/wiki). Thanks for making Beans such a great theme which is loved and used by truly passionate people. From ad0b60efdf110b1adb7fba73005ac3b92cce2536 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 14 Apr 2018 22:35:13 -0400 Subject: [PATCH 470/800] Added changes after feedback --- .../class-beans-wp-customize-control.php | 73 +++--- .../wp-customize/class-beans-wp-customize.php | 52 ++++- lib/api/wp-customize/functions.php | 4 +- .../beans-wp-customize.php/add.php | 30 +++ .../beansRegisterWPCustomizeOptions.php | 5 +- .../includes/class-wp-customize-test-case.php | 21 +- .../beans-wp-customize.php/add.php | 210 ++++++++++++++++++ .../beansRegisterWPCustomizeOptions.php | 72 +++++- .../api/wp-customize/fixtures/test-fields.php | 65 +++--- .../includes/class-wp-customize-test-case.php | 6 +- 10 files changed, 443 insertions(+), 95 deletions(-) create mode 100644 tests/phpunit/integration/api/wp-customize/beans-wp-customize.php/add.php create mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add.php diff --git a/lib/api/wp-customize/class-beans-wp-customize-control.php b/lib/api/wp-customize/class-beans-wp-customize-control.php index b788e598..13bcb2b7 100644 --- a/lib/api/wp-customize/class-beans-wp-customize-control.php +++ b/lib/api/wp-customize/class-beans-wp-customize-control.php @@ -7,45 +7,46 @@ * @since 1.5.0 */ -if ( class_exists( 'WP_Customize_Control' ) ) : +if ( ! class_exists( 'WP_Customize_Control' ) ) { + return; +} + +/** + * Render Beans fields content for WP Customize. + * + * @since 1.0.0 + * + * @ignore + * @access private + * + * @package Beans\Framework\API\WP_Customize + */ +class _Beans_WP_Customize_Control extends WP_Customize_Control { + /** - * Render Beans fields content for WP Customize. - * - * @since 1.0.0 - * - * @ignore - * @access private + * Field data. * - * @package Beans\Framework\API\WP_Customize + * @var string */ - class _Beans_WP_Customize_Control extends WP_Customize_Control { + private $beans_field; - /** - * Field data. - * - * @var string - */ - private $beans_field; - - /** - * Constructor. - */ - public function __construct() { - $args = func_get_args(); - call_user_func_array( array( 'parent', '__construct' ), $args ); - $this->beans_field = end( $args ); - } - - /** - * Field content. - * - * @since 1.0.0 - * - * @return void - */ - public function render_content() { - beans_field( $this->beans_field ); - } + /** + * Constructor. + */ + public function __construct() { + $args = func_get_args(); + call_user_func_array( array( 'parent', '__construct' ), $args ); + $this->beans_field = end( $args ); } -endif; + /** + * Field content. + * + * @since 1.0.0 + * + * @return void + */ + public function render_content() { + beans_field( $this->beans_field ); + } +} diff --git a/lib/api/wp-customize/class-beans-wp-customize.php b/lib/api/wp-customize/class-beans-wp-customize.php index 2b475e8b..53ff8c23 100644 --- a/lib/api/wp-customize/class-beans-wp-customize.php +++ b/lib/api/wp-customize/class-beans-wp-customize.php @@ -19,7 +19,7 @@ final class _Beans_WP_Customize { /** - * Metabox arguments + * Metabox arguments. * * @var array */ @@ -36,9 +36,9 @@ final class _Beans_WP_Customize { * Constructor. * * @param string $section Field section. - * @param array $args Meta box arguments. + * @param array $args Metabox arguments. */ - public function __construct( $section, $args ) { + public function __construct( $section, array $args ) { $defaults = array( 'title' => __( 'Undefined', 'tm-beans' ), 'priority' => 30, @@ -68,18 +68,34 @@ private function add() { $fields = beans_get_fields( 'wp_customize', $this->section ); foreach ( $fields as $field ) { - - if ( 'group' === $field['type'] ) { - foreach ( $field['fields'] as $_field ) { - $this->add_setting( $wp_customize, $_field ); - } - } - + $this->add_group_setting( $wp_customize, $field ); $this->add_setting( $wp_customize, $field ); $this->add_control( $wp_customize, $field ); } } + /** + * Add Group setting. + * + * @since 1.5.0 + * @ignore + * + * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. + * @param array $field Metabox settings. + * + * @return void + */ + private function add_group_setting( WP_Customize_Manager $wp_customize, array $field ) { + + if ( 'group' !== $field['type'] ) { + return; + } + + foreach ( $field['fields'] as $_field ) { + $this->add_setting( $wp_customize, $_field ); + } + } + /** * Add Section. * @@ -113,7 +129,13 @@ private function add_section( WP_Customize_Manager $wp_customize ) { * @ignore * * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. - * @param array $field Meta box settings. + * @param array $field { + * Array of Metabox settings. + * + * @type string $db_type Optional. Defines how the setting will be saved. Defaults to 'theme_mod'. + * @type string $capability Optional. Defines the user's permission level needed to see the setting. Defaults to 'edit_theme_options'. + * @type string $transport Optional. Defines how the live preview is updated. Defaults to 'refresh'. + * } * * @return void */ @@ -145,7 +167,13 @@ private function add_setting( WP_Customize_Manager $wp_customize, array $field ) * @ignore * * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. - * @param array $field Meta box settings. + * @param array $field { + * Metabox settings. + * + * @type string $type Field type or WP_Customize control class. + * @type string $name Name of the control. + * @type string $label Label of the control. + * } * * @return void */ diff --git a/lib/api/wp-customize/functions.php b/lib/api/wp-customize/functions.php index d6a6bc29..173c497f 100644 --- a/lib/api/wp-customize/functions.php +++ b/lib/api/wp-customize/functions.php @@ -46,7 +46,7 @@ * text to the section. Default false. * } * - * @return bool False on failure. + * @return _Beans_WP_Customize|bool False on failure. */ function beans_register_wp_customize_options( array $fields, $section, $args = array() ) { @@ -74,5 +74,5 @@ function beans_register_wp_customize_options( array $fields, $section, $args = a // Load the class only if this function is called to prevent unnecessary memory usage. require_once BEANS_API_PATH . 'wp-customize/class-beans-wp-customize.php'; - new _Beans_WP_Customize( $section, $args ); + return new _Beans_WP_Customize( $section, $args ); } diff --git a/tests/phpunit/integration/api/wp-customize/beans-wp-customize.php/add.php b/tests/phpunit/integration/api/wp-customize/beans-wp-customize.php/add.php new file mode 100644 index 00000000..8bd5346c --- /dev/null +++ b/tests/phpunit/integration/api/wp-customize/beans-wp-customize.php/add.php @@ -0,0 +1,30 @@ +assertNull( beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ) ); + beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ); // Check what was registered. $registered = $this->get_reflective_property_value( 'registered' ); diff --git a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php index fcb1b3cd..bbdf6e01 100644 --- a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php @@ -43,6 +43,23 @@ public function setUp() { require_once BEANS_THEME_DIR . '/lib/api/wp-customize/class-beans-wp-customize.php'; } + /** + * Get reflective access to the private method. + * + * @since 1.5.0 + * + * @param string $method_name Method name for which to gain access. + * + * @return \ReflectionMethod + */ + protected function get_reflective_method( $method_name ) { + $class = new \ReflectionClass( '_Beans_WP_Customize' ); + $method = $class->getMethod( $method_name ); + $method->setAccessible( true ); + + return $method; + } + /** * Get the value of the private or protected property. * @@ -54,8 +71,8 @@ public function setUp() { * @throws \ReflectionException Throws an exception if property does not exist. */ protected function get_reflective_property_value( $property ) { - $reflective = $this->get_reflective_property( $property, '_Beans_Fields' ); - return $reflective->getValue( new \_Beans_Fields() ); + $reflective = $this->get_reflective_property( $property, '_Beans_WP_Customize' ); + return $reflective->getValue( new \_Beans_WP_Customize() ); } /** diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add.php new file mode 100644 index 00000000..40599e67 --- /dev/null +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add.php @@ -0,0 +1,210 @@ +shouldReceive( 'get_section' )->andReturn( true ); + + Monkey\Functions\expect( 'beans_get_fields' ) + ->with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ) + ->andAlsoExpectIt() + ->with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add = $this->get_reflective_method( 'add' ); + + $this->assertNull( $add->invoke( $customizer ) ); + } + + /** + * Test add_section(). + */ + public function test_add_section() { + $test_data = static::$test_data['single_fields']; + + $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); + global $wp_customize; + $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. + $mocked_wp_customize->shouldReceive( 'get_section' )->andReturn( true ); + + Monkey\Functions\expect( 'beans_get_fields' ) + ->with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_section = $this->get_reflective_method( 'add_section' ); + + $this->assertNull( $add_section->invoke( $customizer, $wp_customize ) ); + } + + /** + * Test add_setting() calls beans_get(). + */ + public function test_add_setting_calls_beans_get() { + $test_data = static::$test_data['single_fields']; + + $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); + global $wp_customize; + $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. + $mocked_wp_customize->shouldReceive( 'get_section', 'add_setting', 'add_section' )->andReturn( true ); + + Monkey\Functions\expect( 'beans_get_fields' ) + ->with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->andReturn( 'default' ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_setting = $this->get_reflective_method( 'add_setting' ); + + $this->assertNull( $add_setting->invoke( $customizer, $wp_customize, $test_data['fields'] ) ); + } + + /** + * Test add_group_setting() with no grouped fields. + */ + public function test_add_group_setting_without_grouped_field() { + $test_data = static::$test_data['single_fields']; + + $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); + global $wp_customize; + $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. + $mocked_wp_customize->shouldReceive( 'get_section', 'add_setting', 'add_section' )->andReturn( true ); + + Monkey\Functions\expect( 'beans_get_fields' ) + ->with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_group_setting = $this->get_reflective_method( 'add_group_setting' ); + + $this->assertNull( $add_group_setting->invoke( $customizer, $wp_customize, $test_data['fields'] ) ); + } + + /** + * Test add_group_setting()_with_group_fields(). + */ + public function test_add_group_setting_with_grouped_fields() { + $test_data = static::$test_data['group']; + + $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); + global $wp_customize; + $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. + $mocked_wp_customize->shouldReceive( 'get_section', 'add_setting', 'add_section' )->andReturn( true ); + + Monkey\Functions\expect( 'beans_get_fields' ) + ->with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_get' ) + ->times( 3 ) + ->andReturn( 'default' ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_group_setting = $this->get_reflective_method( 'add_group_setting' ); + + $this->assertNull( $add_group_setting->invoke( $customizer, $wp_customize, $test_data['fields'] ) ); + } + + + /** + * Test add_control(). + */ + public function test_add_control() { + $test_data = static::$test_data['single_fields']; + + $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); + global $wp_customize; + $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. + $mocked_wp_customize->shouldReceive( 'get_section', 'add_setting', 'add_section', 'add_control' )->andReturn( true ); + + $mocked_beans_customize_control = Mockery::mock( '_Beans_WP_Customize_Control' ); + + Monkey\Functions\expect( 'beans_get_fields' ) + ->with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_control = $this->get_reflective_method( 'add_control' ); + + $this->assertNull( $add_control->invoke( $customizer, $wp_customize, $test_data['fields'] ) ); + } +} diff --git a/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php b/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php index d9496871..7bfa976f 100644 --- a/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php +++ b/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php @@ -30,16 +30,25 @@ class Tests_BeansRegisterWPCustomizeOptions extends WP_Customize_Test_Case { public function setUp() { parent::setUp(); - Monkey\Functions\when( '_beans_pre_standardize_fields' )->alias( function( $fields ) { - return $fields; - }); + Monkey\Functions\when( '_beans_pre_standardize_fields' )->returnArg(); } /** * Test beans_register_wp_customize_options() should return false when not in the WP Customizer . */ public function test_should_return_null_when_no_customizer() { - Monkey\Functions\when( 'is_customize_preview' )->justReturn( false ); + Monkey\Functions\expect( 'is_customize_preview' ) + ->withNoArgs() + ->once() + ->ordered() + ->andReturn( false ) + ->andAlsoExpectIt() + ->withNoArgs() + ->once() + ->ordered() + ->andReturn( false ); + + Monkey\Functions\expect( 'beans_register_fields' )->never(); $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); @@ -49,8 +58,27 @@ public function test_should_return_null_when_no_customizer() { * Test beans_register_wp_customize_options() should return false when there are no options. */ public function test_should_return_false_when_no_options() { - Monkey\Functions\when( 'is_customize_preview' )->justReturn( true ); - Monkey\Functions\when( 'beans_register_fields' )->justReturn( false ); + Monkey\Functions\expect( 'is_customize_preview' ) + ->withNoArgs() + ->once() + ->ordered() + ->andReturn( true ) + ->andAlsoExpectIt() + ->withNoArgs() + ->once() + ->ordered() + ->andReturn( true ); + + Monkey\Functions\expect( 'beans_register_fields' ) + ->with( array(), 'wp_customize', '' ) + ->once() + ->ordered() + ->andReturn( false ) + ->andAlsoExpectIt() + ->with( array(), 'wp_customize', 'post_meta' ) + ->once() + ->ordered() + ->andReturn( false ); $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); @@ -67,11 +95,33 @@ public function test_should_register_fields() { $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. $mocked_wp_customize->shouldReceive( 'get_section' )->andReturn( true ); - Monkey\Functions\when( 'is_customize_preview' )->justReturn( true ); - Monkey\Functions\when( 'beans_get_fields' )->justReturn( array() ); - Monkey\Functions\when( 'beans_add_attribute' )->justReturn( array() ); - Monkey\Functions\when( 'beans_register_fields' )->justReturn( true ); + Monkey\Functions\expect( 'is_customize_preview' ) + ->withNoArgs() + ->once() + ->ordered() + ->andReturn( true ); + + Monkey\Functions\expect( 'beans_get_fields' ) + ->with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_register_fields' ) + ->with( $test_data['fields'], 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( true ); + + beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ); - $this->assertNull( beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ) ); + // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. + $this->assertTrue( true ); } } diff --git a/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php index 74011308..34baf416 100644 --- a/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php +++ b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php @@ -11,8 +11,12 @@ // Single fields. 'single_fields' => array( 'fields' => array( + 'name' => 'beans-test', + 'type' => 'radio', + 'label' => 'Layout', array( 'id' => 'beans_customizer_layout', + 'name' => 'beans-test', 'label' => 'Layout', 'type' => 'radio', 'default' => 'default_fallback', @@ -25,6 +29,7 @@ ), array( 'id' => 'beans_customizer_checkbox', + 'name' => 'beans-test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', @@ -32,6 +37,7 @@ ), array( 'id' => 'beans_customizer_text', + 'name' => 'beans-test', 'type' => 'text', 'default' => 'Testing the text field.', ), @@ -48,38 +54,43 @@ // Group of fields. 'group' => array( 'fields' => array( - array( - 'id' => 'beans_group_test', - 'label' => 'Group of fields', - 'description' => 'This is a group of fields.', - 'type' => 'group', - 'fields' => array( - array( - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ), - array( - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ), - ), - array( - 'id' => 'beans_checkbox_test', - 'label' => false, - 'checkbox_label' => 'Enable the checkbox test', - 'type' => 'checkbox', - 'default' => false, + 'name' => 'beans-test', + 'type' => 'group', + 'fields' => array( + array( + 'id' => 'beans_compile_all_scripts', + 'name' => 'beans-test', + 'type' => 'activation', + 'default' => false, + ), + array( + 'id' => 'beans_compile_all_scripts_mode', + 'name' => 'beans-test', + 'type' => 'select', + 'default' => 'aggressive', + 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), + 'options' => array( + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', ), ), + array( + 'id' => 'beans_checkbox_test', + 'name' => 'beans-test', + 'label' => false, + 'checkbox_label' => 'Enable the checkbox test', + 'type' => 'checkbox', + 'default' => false, + ), ), ), 'context' => 'group_tests', 'section' => 'tm-beans-customizer', + 'name' => 'beans-test', + 'args' => array( + 'title' => 'Beans Customizer Section', + 'priority' => 250, + 'description' => 'Customizer Beans Section', + ), ), ); diff --git a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php index 82ce143a..f943b764 100644 --- a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php @@ -63,7 +63,7 @@ public function setUp() { * @return \ReflectionMethod * @throws \ReflectionException Throws an exception if method does not exist. */ - protected function get_reflective_method( $method_name, $class_name = '_Beans_Fields' ) { + protected function get_reflective_method( $method_name, $class_name = '_Beans_WP_Customize' ) { return parent::get_reflective_method( $method_name, $class_name ); } @@ -78,7 +78,7 @@ protected function get_reflective_method( $method_name, $class_name = '_Beans_Fi * @return \ReflectionProperty|string * @throws \ReflectionException Throws an exception if property does not exist. */ - protected function get_reflective_property( $property, $class_name = '_Beans_Fields' ) { + protected function get_reflective_property( $property, $class_name = '_Beans_WP_Customize' ) { return parent::get_reflective_property( $property, $class_name ); } // phpcs:enable Generic.CodeAnalysis.UselessOverridingMethod.Found @@ -96,7 +96,7 @@ protected function get_reflective_property( $property, $class_name = '_Beans_Fie protected function get_reflective_property_value( $property ) { $reflective = $this->get_reflective_property( $property ); - return $reflective->getValue( new \_Beans_Fields() ); + return $reflective->getValue( new \_Beans_WP_Customize() ); } /** From f0c12b33bcfa6e0f403a0a565b439c486f5c54c9 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Thu, 26 Apr 2018 13:50:35 -0400 Subject: [PATCH 471/800] Added reflective tests --- .../wp-customize/class-beans-wp-customize.php | 40 ++-- .../api/fields/beansRegisterFields.php | 2 +- .../includes/class-fields-test-case.php | 15 -- .../beans-wp-customize.php/add.php | 57 +++++- .../beansRegisterWPCustomizeOptions.php | 71 ++++--- .../api/wp-customize/fixtures/test-fields.php | 11 +- .../includes/class-wp-customize-test-case.php | 52 +++-- tests/phpunit/integration/class-test-case.php | 16 ++ .../beans-wp-customize.php/add.php | 179 ++---------------- .../beans-wp-customize.php/add_control.php | 54 ++++++ .../add_group_setting.php | 81 ++++++++ .../beans-wp-customize.php/add_section.php | 52 +++++ .../beans-wp-customize.php/add_setting.php | 56 ++++++ .../beansRegisterWPCustomizeOptions.php | 8 +- .../api/wp-customize/fixtures/test-fields.php | 2 +- .../includes/class-wp-customize-test-case.php | 65 ++----- 16 files changed, 431 insertions(+), 330 deletions(-) create mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_control.php create mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_group_setting.php create mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_section.php create mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_setting.php diff --git a/lib/api/wp-customize/class-beans-wp-customize.php b/lib/api/wp-customize/class-beans-wp-customize.php index 53ff8c23..2fa9a15d 100644 --- a/lib/api/wp-customize/class-beans-wp-customize.php +++ b/lib/api/wp-customize/class-beans-wp-customize.php @@ -75,51 +75,51 @@ private function add() { } /** - * Add Group setting. + * Add Section. * - * @since 1.5.0 + * @since 1.0.0 * @ignore * * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. - * @param array $field Metabox settings. * * @return void */ - private function add_group_setting( WP_Customize_Manager $wp_customize, array $field ) { + private function add_section( WP_Customize_Manager $wp_customize ) { - if ( 'group' !== $field['type'] ) { + if ( $wp_customize->get_section( $this->section ) ) { return; } - foreach ( $field['fields'] as $_field ) { - $this->add_setting( $wp_customize, $_field ); - } + $wp_customize->add_section( + $this->section, + array( + 'title' => $this->args['title'], + 'priority' => $this->args['priority'], + 'description' => $this->args['description'], + ) + ); } /** - * Add Section. + * Add Group setting. * - * @since 1.0.0 + * @since 1.5.0 * @ignore * * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. + * @param array $field Metabox settings. * * @return void */ - private function add_section( WP_Customize_Manager $wp_customize ) { + private function add_group_setting( WP_Customize_Manager $wp_customize, array $field ) { - if ( $wp_customize->get_section( $this->section ) ) { + if ( 'group' !== $field['type'] ) { return; } - $wp_customize->add_section( - $this->section, - array( - 'title' => $this->args['title'], - 'priority' => $this->args['priority'], - 'description' => $this->args['description'], - ) - ); + foreach ( $field['fields'] as $_field ) { + $this->add_setting( $wp_customize, $_field ); + } } /** diff --git a/tests/phpunit/integration/api/fields/beansRegisterFields.php b/tests/phpunit/integration/api/fields/beansRegisterFields.php index 32a9b40e..2f06f8a1 100644 --- a/tests/phpunit/integration/api/fields/beansRegisterFields.php +++ b/tests/phpunit/integration/api/fields/beansRegisterFields.php @@ -39,7 +39,7 @@ public function test_should_register_fields() { $this->assertTrue( beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ) ); // Check what was registered. - $registered = $this->get_reflective_property_value( 'registered' ); + $registered = $this->get_reflective_property_value( 'registered', '_Beans_Fields' ); $this->assertArrayHasKey( 'beans_tests', $registered ); $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index 1cedabe8..6320d249 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -58,21 +58,6 @@ public function tearDown() { parent::tearDown(); } - /** - * Get the value of the private or protected property. - * - * @since 1.5.0 - * - * @param string $property Property name for which to gain access. - * - * @return mixed - * @throws \ReflectionException Throws an exception if property does not exist. - */ - protected function get_reflective_property_value( $property ) { - $reflective = $this->get_reflective_property( $property, '_Beans_Fields' ); - return $reflective->getValue( new \_Beans_Fields() ); - } - /** * Merge the given field with the default structure. * diff --git a/tests/phpunit/integration/api/wp-customize/beans-wp-customize.php/add.php b/tests/phpunit/integration/api/wp-customize/beans-wp-customize.php/add.php index 8bd5346c..dcef3634 100644 --- a/tests/phpunit/integration/api/wp-customize/beans-wp-customize.php/add.php +++ b/tests/phpunit/integration/api/wp-customize/beans-wp-customize.php/add.php @@ -2,29 +2,66 @@ /** * Tests for add() method of _Beans_WP_Customize. * - * @package Beans\Framework\Tests\Integration\API\WP-Customize + * @package Beans\Framework\Tests\Integration\API\WP_Customize * * @since 1.5.0 */ -namespace Beans\Framework\Tests\Integration\API\WPCustomize; +namespace Beans\Framework\Tests\Integration\API\WP_Customize; -use Beans\Framework\Tests\Integration\API\WPCustomize\Includes\WP_Customize_Test_Case; +use Beans\Framework\Tests\Integration\API\WP_Customize\Includes\WP_Customize_Test_Case; use _Beans_WP_Customize; -use WP_Customize_Manager; - -require_once __DIR__ . '/includes/class-wp-customize-test-case.php'; -require_once dirname( dirname( dirname( getcwd() ) ) ) . '/wp-includes/class-wp-customize-manager.php'; +require_once dirname( __DIR__ ) . '/includes/class-wp-customize-test-case.php'; /** - * Class Tests_Beans_Options_Actions + * Class Tests_BeansWPCustomize_Add * - * @package Beans\Framework\Tests\Integration\API\Options + * @package Beans\Framework\Tests\Integration\API\WP_Customize * @group api * @group api-wp-customize */ -class Tests_Beans_WP_Customize_Add extends WP_Customize_Test_Case { +class Tests_BeansWPCustomize_Add extends WP_Customize_Test_Case { + + /** + * Test add() should add section, settings and controls to the WP Customizer. + */ + public function test_should_add_section_settings_and_controls_to_wp_customizer() { + $test_data = static::$test_data['single_fields']; + + beans_register_fields( $test_data['fields'], 'wp_customize', $test_data['section'] ); + + $customizer = new _Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add = $this->get_reflective_method( 'add', '_Beans_WP_Customize' ); + + $this->assertNull( $add->invoke( $customizer ) ); + + $this->assertNotEmpty( $this->wp_customize->get_section( 'tm-beans-test-customizer' ) ); + $this->assertNotEmpty( $this->wp_customize->get_control( 'beans_customizer_layout' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_customizer_layout' ) ); + $this->assertNotEmpty( $this->wp_customize->get_control( 'beans_customizer_checkbox' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_customizer_checkbox' ) ); + $this->assertNotEmpty( $this->wp_customize->get_control( 'beans_customizer_text' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_customizer_text' ) ); + } + + /** + * Test add() should add section and settings of grouped fields to the WP Customizer. + */ + public function test_should_add_section_and_settings_of_grouped_fields_to_wp_customizer() { + $test_data = static::$test_data['group']; + + beans_register_fields( $test_data['fields'], 'wp_customize', $test_data['section'] ); + + $customizer = new _Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add = $this->get_reflective_method( 'add', '_Beans_WP_Customize' ); + $this->assertNull( $add->invoke( $customizer ) ); + $this->assertEmpty( $this->wp_customize->get_section( 'tm-beans-test-customizer' ) ); + $this->assertNotEmpty( $this->wp_customize->get_section( 'tm-beans-group-test-customizer' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_compile_all_scripts' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_compile_all_scripts_mode' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_checkbox_test' ) ); + } } diff --git a/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php b/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php index 5d7736f8..631c2252 100644 --- a/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php +++ b/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php @@ -2,49 +2,26 @@ /** * Tests for beans_register_wp_customize_options() * - * @package Beans\Framework\Tests\Integration\API\WPCustomize + * @package Beans\Framework\Tests\Integration\API\WP_Customize * * @since 1.5.0 */ -namespace Beans\Framework\Tests\Integration\API\WPCustomize; +namespace Beans\Framework\Tests\Integration\API\WP_Customize; -use Beans\Framework\Tests\Integration\API\WPCustomize\Includes\WP_Customize_Test_Case; -use WP_Customize_Manager; +use Beans\Framework\Tests\Integration\API\WP_Customize\Includes\WP_Customize_Test_Case; require_once __DIR__ . '/includes/class-wp-customize-test-case.php'; -require_once dirname( dirname( dirname( getcwd() ) ) ) . '/wp-includes/class-wp-customize-manager.php'; /** * Class Tests_BeansRegisterWPCustomizeOptions * - * @package Beans\Framework\Tests\Integration\API\WPCustomize + * @package Beans\Framework\Tests\Integration\API\WP_Customize * @group api * @group api-wp-customize */ class Tests_BeansRegisterWPCustomizeOptions extends WP_Customize_Test_Case { - /** - * Prepares the test environment before each test. - */ - public function setUp() { - parent::setUp(); - - global $wp_customize; - $this->wp_customize = new WP_Customize_Manager(); - $wp_customize = $this->wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. - } - - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - global $wp_customize; - $wp_customize = null; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. - - parent::tearDown(); - } - /** * Test beans_register_wp_customize_options() should return false when not in the WP Customizer . */ @@ -77,12 +54,48 @@ public function test_should_register_fields() { beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ); // Check what was registered. - $registered = $this->get_reflective_property_value( 'registered' ); + $registered = $this->get_reflective_property_value( 'registered', '_Beans_Fields' ); $this->assertArrayHasKey( $test_data['section'], $registered['wp_customize'] ); foreach ( $test_data['fields'] as $index => $field ) { $expected = $this->merge_field_with_default( $field ); - $this->assertSame( $expected, $registered['wp_customize']['tm-beans-customizer'][ $index ] ); + $this->assertSame( $expected, $registered['wp_customize']['tm-beans-test-customizer'][ $index ] ); } } + + /** + * Test beans_register_wp_customize_options() should add section, settings and controls to the WP Customizer. + */ + public function test_should_add_section_settings_and_controls() { + $this->wp_customize->start_previewing_theme(); + + $test_data = static::$test_data['single_fields']; + + beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ); + + $this->assertNotEmpty( $this->wp_customize->get_section( 'tm-beans-test-customizer' ) ); + $this->assertNotEmpty( $this->wp_customize->get_control( 'beans_customizer_layout' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_customizer_layout' ) ); + $this->assertNotEmpty( $this->wp_customize->get_control( 'beans_customizer_checkbox' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_customizer_checkbox' ) ); + $this->assertNotEmpty( $this->wp_customize->get_control( 'beans_customizer_text' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_customizer_text' ) ); + } + + /** + * Test beans_register_wp_customize_options() should add section and settings for grouped fields to the WP Customizer. + */ + public function test_should_add_section_and_settings_for_grouped_fields() { + $this->wp_customize->start_previewing_theme(); + + $test_data = static::$test_data['group']; + + beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ); + + $this->assertEmpty( $this->wp_customize->get_section( 'tm-beans-test-customizer' ) ); + $this->assertNotEmpty( $this->wp_customize->get_section( 'tm-beans-group-test-customizer' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_compile_all_scripts' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_compile_all_scripts_mode' ) ); + $this->assertNotEmpty( $this->wp_customize->get_setting( 'beans_checkbox_test' ) ); + } } diff --git a/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php b/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php index 74011308..b3fd0490 100644 --- a/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php +++ b/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php @@ -2,7 +2,7 @@ /** * Test data for the WP Customize unit tests. * - * @package Beans\Framework\Tests\Integration\API\WP-Customize\Fixtures + * @package Beans\Framework\Tests\Integration\API\WP_Customize\Fixtures * * @since 1.5.0 */ @@ -37,7 +37,7 @@ ), ), 'context' => 'beans-test', - 'section' => 'tm-beans-customizer', + 'section' => 'tm-beans-test-customizer', 'args' => array( 'title' => 'Beans Customizer Section', 'priority' => 250, @@ -80,6 +80,11 @@ ), ), 'context' => 'group_tests', - 'section' => 'tm-beans-customizer', + 'section' => 'tm-beans-group-test-customizer', + 'args' => array( + 'title' => 'Beans Customizer Group Section', + 'priority' => 250, + 'description' => 'Customizer Beans Group Section', + ), ), ); diff --git a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php index bbdf6e01..2027823f 100644 --- a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php @@ -2,19 +2,22 @@ /** * Test Case for Beans' WP Customize API integration tests. * - * @package Beans\Framework\Tests\Integration\API\WPCustomize\Includes + * @package Beans\Framework\Tests\Integration\API\WP_Customize\Includes * * @since 1.5.0 */ -namespace Beans\Framework\Tests\Integration\API\WPCustomize\Includes; +namespace Beans\Framework\Tests\Integration\API\WP_Customize\Includes; use Beans\Framework\Tests\Integration\Test_Case; +use WP_Customize_Manager; + +require_once dirname( dirname( dirname( getcwd() ) ) ) . '/wp-includes/class-wp-customize-manager.php'; /** * Abstract Class WP_Customize_Test_Case * - * @package Beans\Framework\Tests\Integration\API\WPCustomize\Includes + * @package Beans\Framework\Tests\Integration\API\WP_Customize\Includes */ abstract class WP_Customize_Test_Case extends Test_Case { @@ -34,6 +37,13 @@ public static function setUpBeforeClass() { static::$test_data = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-fields.php'; } + /** + * WP Customizer Manager object. + * + * @var WP_Customize_Manager + */ + protected $wp_customize; + /** * Prepares the test environment before each test. */ @@ -41,38 +51,20 @@ public function setUp() { parent::setUp(); require_once BEANS_THEME_DIR . '/lib/api/wp-customize/class-beans-wp-customize.php'; - } - - /** - * Get reflective access to the private method. - * - * @since 1.5.0 - * - * @param string $method_name Method name for which to gain access. - * - * @return \ReflectionMethod - */ - protected function get_reflective_method( $method_name ) { - $class = new \ReflectionClass( '_Beans_WP_Customize' ); - $method = $class->getMethod( $method_name ); - $method->setAccessible( true ); - return $method; + global $wp_customize; + $this->wp_customize = new WP_Customize_Manager(); + $wp_customize = $this->wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. } /** - * Get the value of the private or protected property. - * - * @since 1.5.0 - * - * @param string $property Property name for which to gain access. - * - * @return mixed - * @throws \ReflectionException Throws an exception if property does not exist. + * Cleans up the test environment after each test. */ - protected function get_reflective_property_value( $property ) { - $reflective = $this->get_reflective_property( $property, '_Beans_WP_Customize' ); - return $reflective->getValue( new \_Beans_WP_Customize() ); + public function tearDown() { + global $wp_customize; + $wp_customize = null; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. + + parent::tearDown(); } /** diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index bd0e1461..91ba0972 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -173,4 +173,20 @@ protected function get_reflective_property( $property, $class_name ) { return $property; } + + /** + * Get the value of the private or protected property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * @param string $class_name Name of the target class. + * + * @return mixed + * @throws \ReflectionException Throws an exception if property does not exist. + */ + protected function get_reflective_property_value( $property, $class_name ) { + $reflective = $this->get_reflective_property( $property, $class_name ); + return $reflective->getValue( new $class_name() ); + } } diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add.php index 40599e67..d8296450 100644 --- a/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add.php +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add.php @@ -2,39 +2,35 @@ /** * Tests for add() method of _Beans_WP_Customize. * - * @package Beans\Framework\Tests\Unit\API\WP-Customize + * @package Beans\Framework\Tests\Unit\API\WP_Customize * * @since 1.5.0 */ -namespace Beans\Framework\Tests\Unit\API\WPCustomize; +namespace Beans\Framework\Tests\Unit\API\WP_Customize; -use Beans\Framework\Tests\Unit\API\WPCustomize\Includes\WP_Customize_Test_Case; +use Beans\Framework\Tests\Unit\API\WP_Customize\Includes\WP_Customize_Test_Case; +use _Beans_WP_Customize; use Brain\Monkey; use Mockery; require_once dirname( __DIR__ ) . '/includes/class-wp-customize-test-case.php'; /** - * Class Tests_Beans_Options_Actions + * Class Tests_BeansWPCustomize_Add * - * @package Beans\Framework\Tests\Unit\API\Options + * @package Beans\Framework\Tests\Unit\API\WP_Customize * @group api * @group api-wp-customize */ -class Tests_Beans_WP_Customize_Add extends WP_Customize_Test_Case { +class Tests_BeansWPCustomize_Add extends WP_Customize_Test_Case { /** - * Test add(). + * Test add() should call expected functions and WP_Customize_Control. */ - public function test_add_adds() { + public function test_add_should_call_wp_customize_control() { $test_data = static::$test_data['single_fields']; - $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); - global $wp_customize; - $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. - $mocked_wp_customize->shouldReceive( 'get_section' )->andReturn( true ); - Monkey\Functions\expect( 'beans_get_fields' ) ->with( 'wp_customize', $test_data['section'] ) ->once() @@ -51,160 +47,11 @@ public function test_add_adds() { ->once() ->andReturn( true ); - $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); - $add = $this->get_reflective_method( 'add' ); - - $this->assertNull( $add->invoke( $customizer ) ); - } - - /** - * Test add_section(). - */ - public function test_add_section() { - $test_data = static::$test_data['single_fields']; - - $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); - global $wp_customize; - $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. - $mocked_wp_customize->shouldReceive( 'get_section' )->andReturn( true ); - - Monkey\Functions\expect( 'beans_get_fields' ) - ->with( 'wp_customize', $test_data['section'] ) - ->once() - ->ordered() - ->andReturn( array() ); - - Monkey\Functions\expect( 'beans_add_attribute' ) - ->with( 'beans_field_label', 'class', 'customize-control-title' ) - ->once() - ->andReturn( true ); - - $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); - $add_section = $this->get_reflective_method( 'add_section' ); - - $this->assertNull( $add_section->invoke( $customizer, $wp_customize ) ); - } + $this->wp_customize_mock->shouldReceive( 'get_section' )->andReturn( true ); - /** - * Test add_setting() calls beans_get(). - */ - public function test_add_setting_calls_beans_get() { - $test_data = static::$test_data['single_fields']; + $customizer = new _Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add = $this->get_reflective_method( 'add', '_Beans_WP_Customize' ); - $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); - global $wp_customize; - $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. - $mocked_wp_customize->shouldReceive( 'get_section', 'add_setting', 'add_section' )->andReturn( true ); - - Monkey\Functions\expect( 'beans_get_fields' ) - ->with( 'wp_customize', $test_data['section'] ) - ->once() - ->ordered() - ->andReturn( array() ); - - Monkey\Functions\expect( 'beans_get' ) - ->once() - ->andReturn( 'default' ); - - Monkey\Functions\expect( 'beans_add_attribute' ) - ->with( 'beans_field_label', 'class', 'customize-control-title' ) - ->once() - ->andReturn( true ); - - $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); - $add_setting = $this->get_reflective_method( 'add_setting' ); - - $this->assertNull( $add_setting->invoke( $customizer, $wp_customize, $test_data['fields'] ) ); - } - - /** - * Test add_group_setting() with no grouped fields. - */ - public function test_add_group_setting_without_grouped_field() { - $test_data = static::$test_data['single_fields']; - - $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); - global $wp_customize; - $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. - $mocked_wp_customize->shouldReceive( 'get_section', 'add_setting', 'add_section' )->andReturn( true ); - - Monkey\Functions\expect( 'beans_get_fields' ) - ->with( 'wp_customize', $test_data['section'] ) - ->once() - ->ordered() - ->andReturn( array() ); - - Monkey\Functions\expect( 'beans_add_attribute' ) - ->with( 'beans_field_label', 'class', 'customize-control-title' ) - ->once() - ->andReturn( true ); - - $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); - $add_group_setting = $this->get_reflective_method( 'add_group_setting' ); - - $this->assertNull( $add_group_setting->invoke( $customizer, $wp_customize, $test_data['fields'] ) ); - } - - /** - * Test add_group_setting()_with_group_fields(). - */ - public function test_add_group_setting_with_grouped_fields() { - $test_data = static::$test_data['group']; - - $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); - global $wp_customize; - $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. - $mocked_wp_customize->shouldReceive( 'get_section', 'add_setting', 'add_section' )->andReturn( true ); - - Monkey\Functions\expect( 'beans_get_fields' ) - ->with( 'wp_customize', $test_data['section'] ) - ->once() - ->ordered() - ->andReturn( array() ); - - Monkey\Functions\expect( 'beans_get' ) - ->times( 3 ) - ->andReturn( 'default' ); - - Monkey\Functions\expect( 'beans_add_attribute' ) - ->with( 'beans_field_label', 'class', 'customize-control-title' ) - ->once() - ->andReturn( true ); - - $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); - $add_group_setting = $this->get_reflective_method( 'add_group_setting' ); - - $this->assertNull( $add_group_setting->invoke( $customizer, $wp_customize, $test_data['fields'] ) ); - } - - - /** - * Test add_control(). - */ - public function test_add_control() { - $test_data = static::$test_data['single_fields']; - - $mocked_wp_customize = Mockery::mock( 'WP_Customize_Manager' ); - global $wp_customize; - $wp_customize = $mocked_wp_customize; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. - $mocked_wp_customize->shouldReceive( 'get_section', 'add_setting', 'add_section', 'add_control' )->andReturn( true ); - - $mocked_beans_customize_control = Mockery::mock( '_Beans_WP_Customize_Control' ); - - Monkey\Functions\expect( 'beans_get_fields' ) - ->with( 'wp_customize', $test_data['section'] ) - ->once() - ->ordered() - ->andReturn( array() ); - - Monkey\Functions\expect( 'beans_add_attribute' ) - ->with( 'beans_field_label', 'class', 'customize-control-title' ) - ->once() - ->andReturn( true ); - - $customizer = new \_Beans_WP_Customize( $test_data['section'], $test_data['args'] ); - $add_control = $this->get_reflective_method( 'add_control' ); - - $this->assertNull( $add_control->invoke( $customizer, $wp_customize, $test_data['fields'] ) ); + $this->assertNull( $add->invoke( $customizer ) ); } } diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_control.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_control.php new file mode 100644 index 00000000..61ba4dbf --- /dev/null +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_control.php @@ -0,0 +1,54 @@ +with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + $this->wp_customize_mock->shouldReceive( 'get_section', 'add_setting', 'add_section', 'add_control' )->andReturn( true ); + + $mocked_beans_customize_control = Mockery::mock( '_Beans_WP_Customize_Control' ); + + $customizer = new _Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_control = $this->get_reflective_method( 'add_control', '_Beans_WP_Customize' ); + + $this->assertNull( $add_control->invoke( $customizer, $this->wp_customize_mock, $test_data['fields'] ) ); + } +} diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_group_setting.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_group_setting.php new file mode 100644 index 00000000..3d8b9202 --- /dev/null +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_group_setting.php @@ -0,0 +1,81 @@ +with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + Monkey\Functions\expect( 'beans_get' ) + ->times( 3 ) + ->andReturn( 'default' ); + + $this->wp_customize_mock->shouldReceive( 'get_section', 'add_setting', 'add_section' )->andReturn( true ); + + $customizer = new _Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_group_setting = $this->get_reflective_method( 'add_group_setting', '_Beans_WP_Customize' ); + + $this->assertNull( $add_group_setting->invoke( $customizer, $this->wp_customize_mock, $test_data['fields'] ) ); + } + + /** + * Test add_group_setting() should not call beans_get() when no grouped fields. + */ + public function test_add_group_setting_should_not_call_beans_get_when_no_grouped_fields() { + $test_data = static::$test_data['single_fields']; + + Monkey\Functions\expect( 'beans_get_fields' ) + ->with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + $this->wp_customize_mock->shouldReceive( 'get_section', 'add_setting', 'add_section' )->andReturn( true ); + + $customizer = new _Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_group_setting = $this->get_reflective_method( 'add_group_setting', '_Beans_WP_Customize' ); + + $this->assertNull( $add_group_setting->invoke( $customizer, $this->wp_customize_mock, $test_data['fields'] ) ); + } +} diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_section.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_section.php new file mode 100644 index 00000000..7fc0a94d --- /dev/null +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_section.php @@ -0,0 +1,52 @@ +with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + $this->wp_customize_mock->shouldReceive( 'get_section' )->andReturn( true ); + + $customizer = new _Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_section = $this->get_reflective_method( 'add_section', '_Beans_WP_Customize' ); + + $this->assertNull( $add_section->invoke( $customizer, $this->wp_customize_mock ) ); + } +} diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_setting.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_setting.php new file mode 100644 index 00000000..67cdb5ef --- /dev/null +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize.php/add_setting.php @@ -0,0 +1,56 @@ +with( 'wp_customize', $test_data['section'] ) + ->once() + ->ordered() + ->andReturn( array() ); + + Monkey\Functions\expect( 'beans_add_attribute' ) + ->with( 'beans_field_label', 'class', 'customize-control-title' ) + ->once() + ->andReturn( true ); + + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->andReturn( 'default' ); + + $this->wp_customize_mock->shouldReceive( 'get_section', 'add_setting', 'add_section' )->andReturn( true ); + + $customizer = new _Beans_WP_Customize( $test_data['section'], $test_data['args'] ); + $add_setting = $this->get_reflective_method( 'add_setting', '_Beans_WP_Customize' ); + + $this->assertNull( $add_setting->invoke( $customizer, $this->wp_customize_mock, $test_data['fields'] ) ); + } +} diff --git a/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php b/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php index 7bfa976f..dc3828dc 100644 --- a/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php +++ b/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php @@ -2,14 +2,14 @@ /** * Tests for beans_register_wp_customize_options() * - * @package Beans\Framework\Tests\Integration\API\WPCustomize + * @package Beans\Framework\Tests\Integration\API\WP_Customize * * @since 1.5.0 */ -namespace Beans\Framework\Tests\Unit\API\WPCustomize; +namespace Beans\Framework\Tests\Unit\API\WP_Customize; -use Beans\Framework\Tests\Unit\API\WPCustomize\Includes\WP_Customize_Test_Case; +use Beans\Framework\Tests\Unit\API\WP_Customize\Includes\WP_Customize_Test_Case; use Brain\Monkey; use Mockery; @@ -18,7 +18,7 @@ /** * Class Tests_BeansRegisterWPCustomizeOptions * - * @package Beans\Framework\Tests\Unit\API\WPCustomize + * @package Beans\Framework\Tests\Unit\API\WP_Customize * @group api * @group api-wp-customize */ diff --git a/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php index 34baf416..3766524f 100644 --- a/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php +++ b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php @@ -2,7 +2,7 @@ /** * Test data for the WP Customize unit tests. * - * @package Beans\Framework\Tests\Integration\API\WP-Customize\Fixtures + * @package Beans\Framework\Tests\Integration\API\WP_Customize\Fixtures * * @since 1.5.0 */ diff --git a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php index f943b764..f2940726 100644 --- a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php @@ -2,20 +2,21 @@ /** * Test Case for Beans' WP Customize API unit tests. * - * @package Beans\Framework\Tests\Unit\API\WPCustomize\Includes + * @package Beans\Framework\Tests\Unit\API\WP_Customize\Includes * * @since 1.5.0 */ -namespace Beans\Framework\Tests\Unit\API\WPCustomize\Includes; +namespace Beans\Framework\Tests\Unit\API\WP_Customize\Includes; use Beans\Framework\Tests\Unit\Test_Case; use Brain\Monkey; +use Mockery; /** * Abstract Class WP_Customize_Test_Case * - * @package Beans\Framework\Tests\Unit\API\WPCustomize\Includes + * @package Beans\Framework\Tests\Unit\API\WP_Customize\Includes */ abstract class WP_Customize_Test_Case extends Test_Case { @@ -35,6 +36,13 @@ public static function setUpBeforeClass() { static::$test_data = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-fields.php'; } + /** + * Mocked WP Customizer Manager object. + * + * @var WP_Customize_Manager + */ + protected $wp_customize_mock; + /** * Prepares the test environment before each test. */ @@ -45,58 +53,13 @@ public function setUp() { 'api/wp-customize/functions.php', 'api/wp-customize/class-beans-wp-customize.php', 'api/wp-customize/class-beans-wp-customize-control.php', - 'api/fields/class-beans-fields.php', ) ); $this->setup_common_wp_stubs(); - } - - // phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found -- It's actually needed. - /** - * Get reflective access to the private method. - * - * @since 1.5.0 - * - * @param string $method_name Method name for which to gain access. - * @param string $class_name Optional. Name of the target class. - * - * @return \ReflectionMethod - * @throws \ReflectionException Throws an exception if method does not exist. - */ - protected function get_reflective_method( $method_name, $class_name = '_Beans_WP_Customize' ) { - return parent::get_reflective_method( $method_name, $class_name ); - } - - /** - * Get reflective access to the private property. - * - * @since 1.5.0 - * - * @param string $property Property name for which to gain access. - * @param string $class_name Optional. Name of the target class. - * - * @return \ReflectionProperty|string - * @throws \ReflectionException Throws an exception if property does not exist. - */ - protected function get_reflective_property( $property, $class_name = '_Beans_WP_Customize' ) { - return parent::get_reflective_property( $property, $class_name ); - } - // phpcs:enable Generic.CodeAnalysis.UselessOverridingMethod.Found - - /** - * Get the value of the private or protected property. - * - * @since 1.5.0 - * - * @param string $property Property name for which to gain access. - * - * @return mixed - * @throws \ReflectionException Throws an exception if property does not exist. - */ - protected function get_reflective_property_value( $property ) { - $reflective = $this->get_reflective_property( $property ); - return $reflective->getValue( new \_Beans_WP_Customize() ); + $this->wp_customize_mock = Mockery::mock( 'WP_Customize_Manager' ); + global $wp_customize; + $wp_customize = $this->wp_customize_mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Limited to test function scope. } /** From cfc3bc940f51a956f1ed692370ba6805a654cb87 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Fri, 27 Apr 2018 16:25:55 -0400 Subject: [PATCH 472/800] Beans Post Meta API Tests (PR #208) * Adds unit and integration tests for Beans Post Meta API * Refactors all html into view files. * Refactors use of DOING_AUTOSAVE constant into `utilities/functions/beans_doing_autosave()` function. * Adds check/bailout in several instances for improved performance --- .../{class.php => class-beans-post-meta.php} | 77 ++++---- lib/api/post-meta/functions-admin.php | 63 +++---- lib/api/post-meta/views/nonce.php | 12 ++ lib/api/post-meta/views/script.php | 35 ++++ lib/api/utilities/functions.php | 13 ++ .../post-meta/beans-post-meta/construct.php | 47 +++++ .../post-meta/beans-post-meta/okToSave.php | 87 +++++++++ .../beans-post-meta/registerMetabox.php | 38 ++++ .../beans-post-meta/renderMetaboxContent.php | 46 +++++ .../post-meta/beans-post-meta/renderNonce.php | 41 +++++ .../api/post-meta/beans-post-meta/save.php | 55 ++++++ .../beans-post-meta/saveAttachment.php | 46 +++++ .../api/post-meta/beansGetPostMeta.php | 10 +- .../post-meta/beansIsPostMetaConditions.php | 166 ++++++++++++++++++ .../beansPostMetaPageTemplateReload.php | 71 ++++++++ .../api/post-meta/beansRegisterPostMeta.php | 78 ++++++++ .../api/post-meta/fixtures/test-fields.php | 39 ++++ .../class-beans-post-meta-test-case.php | 31 ++++ .../post-meta/beans-post-meta/okToSave.php | 72 ++++++++ .../beans-post-meta/registerMetabox.php | 57 ++++++ .../beans-post-meta/renderMetaboxContent.php | 56 ++++++ .../post-meta/beans-post-meta/renderNonce.php | 41 +++++ .../api/post-meta/beans-post-meta/save.php | 65 +++++++ .../beans-post-meta/saveAttachment.php | 58 ++++++ .../unit/api/post-meta/beansGetPostMeta.php | 18 +- .../post-meta/beansIsPostMetaConditions.php | 166 ++++++++++++++++++ .../beansPostMetaPageTemplateReload.php | 68 +++++++ .../api/post-meta/beansRegisterPostMeta.php | 94 ++++++++++ .../class-beans-post-meta-test-case.php | 38 ++++ 29 files changed, 1600 insertions(+), 88 deletions(-) rename lib/api/post-meta/{class.php => class-beans-post-meta.php} (65%) create mode 100644 lib/api/post-meta/views/nonce.php create mode 100644 lib/api/post-meta/views/script.php create mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php create mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php create mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php create mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php create mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php create mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/save.php create mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php create mode 100644 tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php create mode 100644 tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php create mode 100644 tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php create mode 100644 tests/phpunit/integration/api/post-meta/fixtures/test-fields.php create mode 100644 tests/phpunit/integration/api/post-meta/includes/class-beans-post-meta-test-case.php create mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/okToSave.php create mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/registerMetabox.php create mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php create mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/renderNonce.php create mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/save.php create mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php create mode 100644 tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php create mode 100644 tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php create mode 100644 tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php create mode 100644 tests/phpunit/unit/api/post-meta/includes/class-beans-post-meta-test-case.php diff --git a/lib/api/post-meta/class.php b/lib/api/post-meta/class-beans-post-meta.php similarity index 65% rename from lib/api/post-meta/class.php rename to lib/api/post-meta/class-beans-post-meta.php index 4ea214d6..f70fbab9 100644 --- a/lib/api/post-meta/class.php +++ b/lib/api/post-meta/class-beans-post-meta.php @@ -60,28 +60,28 @@ public function __construct( $section, $args ) { * @return void */ private function do_once() { - static $once = false; + static $did_once = false; - if ( ! $once ) { - add_action( 'edit_form_top', array( $this, 'nonce' ) ); - add_action( 'save_post', array( $this, 'save' ) ); - add_filter( 'attachment_fields_to_save', array( $this, 'save_attachment' ) ); - - $once = true; + if ( $did_once ) { + return; } + + add_action( 'edit_form_top', array( $this, 'render_nonce' ) ); + add_action( 'save_post', array( $this, 'save' ) ); + add_filter( 'attachment_fields_to_save', array( $this, 'save_attachment' ) ); + + $did_once = true; } /** - * Post meta nonce. + * Render post meta nonce. * * @since 1.0.0 * * @return void */ - public function nonce() { - ?> - - section, $this->args['title'], array( $this, 'metabox_content' ), $post_type, $this->args['context'], $this->args['priority'] ); + add_meta_box( + $this->section, + $this->args['title'], + array( $this, 'render_metabox_content' ), + $post_type, + $this->args['context'], + $this->args['priority'] + ); } /** - * Metabox content. + * Render metabox content. * * @since 1.0.0 * - * @param int $post Post ID. - * * @return void */ - public function metabox_content( $post ) { + public function render_metabox_content() { foreach ( beans_get_fields( 'post_meta', $this->section ) as $field ) { beans_field( $field ); @@ -124,17 +129,13 @@ public function metabox_content( $post ) { */ public function save( $post_id ) { - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { + if ( _beans_doing_autosave() ) { return false; } - if ( ! wp_verify_nonce( beans_post( 'beans_post_meta_nonce' ), 'beans_post_meta_nonce' ) ) { - return $post_id; - } - $fields = beans_post( 'beans_fields' ); - if ( ! $fields ) { + if ( ! $this->ok_to_save( $post_id, $fields ) ) { return $post_id; } @@ -148,23 +149,19 @@ public function save( $post_id ) { * * @since 1.0.0 * - * @param int $attachment Attachment ID. + * @param array $attachment Attachment data. * * @return mixed */ public function save_attachment( $attachment ) { - if ( ! wp_verify_nonce( beans_post( 'beans_post_meta_nonce' ), 'beans_post_meta_nonce' ) ) { - return $post_id; - } - - if ( ! current_user_can( 'edit_post', $attachment['ID'] ) ) { + if ( _beans_doing_autosave() ) { return $attachment; } $fields = beans_post( 'beans_fields' ); - if ( ! $fields ) { + if ( ! $this->ok_to_save( $attachment['ID'], $fields ) ) { return $attachment; } @@ -174,4 +171,24 @@ public function save_attachment( $attachment ) { return $attachment; } + + /** + * Check if all criteria are met to safely save post meta. + * + * @param int $id The Post Id. + * @param array $fields The array of fields to save. + * + * @return bool + */ + public function ok_to_save( $id, $fields ) { + if ( ! wp_verify_nonce( beans_post( 'beans_post_meta_nonce' ), 'beans_post_meta_nonce' ) ) { + return false; + } + + if ( ! current_user_can( 'edit_post', $id ) ) { + return false; + } + + return ! empty( $fields ); + } } diff --git a/lib/api/post-meta/functions-admin.php b/lib/api/post-meta/functions-admin.php index 65784155..111ecbfe 100644 --- a/lib/api/post-meta/functions-admin.php +++ b/lib/api/post-meta/functions-admin.php @@ -17,32 +17,33 @@ * @param array $fields { * Array of fields to register. * - * @type string $id A unique id used for the field. This id will also be used to save the value in + * @type string $id A unique id used for the field. This id will also be used to save the value in * the database. - * @type string $type The type of field to use. Please refer to the Beans core field types for more + * @type string $type The type of field to use. Please refer to the Beans core field types for more * information. Custom field types are accepted here. - * @type string $label The field label. Default false. - * @type string $description The field description. The description can be truncated using + * @type string $label The field label. Default false. + * @type string $description The field description. The description can be truncated using * as a delimiter. Default false. - * @type array $attributes An array of attributes to add to the field. The array key defines the + * @type array $attributes An array of attributes to add to the field. The array key defines the * attribute name and the array value defines the attribute value. Default array. - * @type mixed $default The default field value. Default false. - * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the + * @type mixed $default The default field value. Default false. + * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the * {@see beans_register_fields()} $fields arguments. - * @type bool $db_group Must only be used for 'group' field type. Defines whether the group of fields + * @type bool $db_group Must only be used for 'group' field type. Defines whether the group of fields * registered should be saved as a group in the database or as individual * entries. Default false. * } + * * @param string|array $conditions Array of 'post types id(s)', 'post id(s)' or 'page template slug(s)' for which the post meta should be registered. * 'page template slug(s)' must include '.php' file extention. Set to true to display everywhere. - * @param string $section A section id to define the group of fields. + * @param string $section A section id to define the group of fields. * @param array $args { * Optional. Array of arguments used to register the fields. * - * @type string $title The metabox Title. Default 'Undefined'. - * @type string $context Where on the page the metabox should be shown + * @type string $title The metabox Title. Default 'Undefined'. + * @type string $context Where on the page the metabox should be shown * ('normal', 'advanced', or 'side'). Default 'normal'. - * @type int $priority The priority within the context where the boxes should show + * @type int $priority The priority within the context where the boxes should show * ('high', 'core', 'default' or 'low'). Default 'high'. * } * @@ -51,6 +52,10 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = array() ) { global $_beans_post_meta_conditions; + if ( empty( $fields ) ) { + return false; + } + /** * Filter the post meta fields. * @@ -77,7 +82,7 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = // Stop here if the current page isn't concerned. if ( ! _beans_is_post_meta_conditions( $conditions ) || ! is_admin() ) { - return; + return false; } // Stop here if the field can't be registered. @@ -86,9 +91,11 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once BEANS_API_PATH . 'post-meta/class.php'; + require_once BEANS_API_PATH . 'post-meta/class-beans-post-meta.php'; new _Beans_Post_Meta( $section, $args ); + + return true; } /** @@ -98,7 +105,7 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = * @ignore * @access private * - * @param array $conditions Conditions to show a Post Meta box. + * @param array|bool $conditions Conditions to show a Post Meta box. * * @return bool */ @@ -173,31 +180,7 @@ function _beans_post_meta_page_template_reload() { return; } - ?> - - + diff --git a/lib/api/post-meta/views/script.php b/lib/api/post-meta/views/script.php new file mode 100644 index 00000000..e2a00fe4 --- /dev/null +++ b/lib/api/post-meta/views/script.php @@ -0,0 +1,35 @@ + + + diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index a9075d62..3ae2402d 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -532,3 +532,16 @@ function beans_esc_attributes( $attributes ) { function _beans_is_uri( $maybe_uri ) { return ( 1 === preg_match( '#^(http|https|\/\/|data)#', $maybe_uri ) ); } + +/** + * Checks if WP is doing an autosave. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @return bool + */ +function _beans_doing_autosave() { + return defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE; +} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php new file mode 100644 index 00000000..baafcbf1 --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php @@ -0,0 +1,47 @@ + 'Post Options' ) ); + + $this->assertEquals( 10, has_action( 'edit_form_top', array( $post_meta, 'render_nonce' ) ) ); + $this->assertEquals( 10, has_action( 'save_post', array( $post_meta, 'save' ) ) ); + $this->assertEquals( 10, has_filter( 'attachment_fields_to_save', array( $post_meta, 'save_attachment' ) ) ); + $this->assertEquals( 10, has_action( 'add_meta_boxes', array( $post_meta, 'register_metabox' ) ) ); + + // Subsequent instantiation sets 'add_meta_boxes' hook only. + $post_meta_2 = new _Beans_Post_Meta( 'tm-beans-custom-post-meta', array( 'title' => 'Custom Options' ) ); + + $this->assertFalse( has_action( 'edit_form_top', array( $post_meta_2, 'render_nonce' ) ) ); + $this->assertFalse( has_action( 'save_post', array( $post_meta_2, 'save' ) ) ); + $this->assertFalse( has_filter( 'attachment_fields_to_save', array( $post_meta_2, 'save_attachment' ) ) ); + $this->assertEquals( 10, has_action( 'add_meta_boxes', array( $post_meta_2, 'register_metabox' ) ) ); + } +} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php new file mode 100644 index 00000000..a8f1e154 --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php @@ -0,0 +1,87 @@ + 'Post Options' ) ); + $post_id = $this->factory()->post->create(); + + $this->assertFalse( $post_meta->ok_to_save( $post_id, array( array( 'id' => 'beans_test_slider' ) ) ) ); + } + + /** + * Test _Beans_Post_Meta::ok_to_save() should return false when user permissions are invalid. + */ + public function test_ok_to_save_should_return_false_when_user_cannot_edit() { + $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_id = $this->factory()->post->create(); + + // Run without permission to save. + $user_id = $this->factory()->user->create( array( 'role' => 'subscriber' ) ); + wp_set_current_user( $user_id ); + + // Set a nonce to return. + $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); + + $this->assertFalse( $post_meta->ok_to_save( $post_id, array( array( 'id' => 'beans_test_slider' ) ) ) ); + } + + /** + * Test _Beans_Post_Meta::ok_to_save() should return false when post meta has no fields. + */ + public function test_ok_to_save_should_return_false_when_fields_empty() { + $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_id = $this->factory()->post->create(); + + // Run with permission to save. + $user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) ); + wp_set_current_user( $user_id ); + + // Set a nonce to return. + $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); + + $this->assertFalse( $post_meta->ok_to_save( $post_id, array() ) ); + } + + /** + * Test _Beans_Post_Meta::ok_to_save() should return true when all conditions for saving are met. + */ + public function test_ok_to_save_should_return_true_when_all_conditions_met() { + $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_id = $this->factory()->post->create(); + + // Run with permission to save. + $user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) ); + wp_set_current_user( $user_id ); + + // Set a nonce to return. + $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); + + $this->assertTrue( $post_meta->ok_to_save( $post_id, array( array( 'id' => 'beans_test_slider' ) ) ) ); + } +} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php new file mode 100644 index 00000000..02ce7371 --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php @@ -0,0 +1,38 @@ + 'Post Options' ) ); + $post_meta->register_metabox( 'post' ); + + $this->assertArrayHasKey( 'tm-beans', $wp_meta_boxes['post']['normal']['high'] ); + } +} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php new file mode 100644 index 00000000..6ae9aa70 --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php @@ -0,0 +1,46 @@ + 'Post Options' ) ); + + beans_register_fields( $test_data['fields'], 'post_meta', $test_data['section'] ); + + $post_id = $this->factory()->post->create(); + + ob_start(); + $post_meta->render_metabox_content( $post_id ); + $output = ob_get_clean(); + + $this->assertContains( 'bs-radio', $output ); + $this->assertContains( 'bs-checkbox', $output ); + $this->assertContains( 'bs-text', $output ); + } +} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php new file mode 100644 index 00000000..245062c3 --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php @@ -0,0 +1,41 @@ + 'Post Options' ) ); + + $expected_html_output = ''; + + ob_start(); + $post_meta->render_nonce(); + $actual_output = ob_get_clean(); + + $this->assertStringMatchesFormat( $expected_html_output, $actual_output ); + } +} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php new file mode 100644 index 00000000..84ce42d1 --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php @@ -0,0 +1,55 @@ + 'Post Options' ) ); + $post_id = $this->factory()->post->create(); + + $this->assertEquals( $post_id, $post_meta->save( $post_id ) ); + } + + /** + * Test _Beans_Post_Meta::save() should run update_post_meta() and return null when ok_to_save() is true. + */ + public function test_save_should_run_update_post_meta_and_return_null_when_ok_to_save() { + $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_id = $this->factory()->post->create(); + + // Run with permission to save. + $user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) ); + wp_set_current_user( $user_id ); + + // Give beans_post() a field to find and set a nonce to return. + $_POST['beans_fields'] = array( 'beans_post_test_field' => 'beans_post_test_field_value' ); + $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); + + $this->assertnull( $post_meta->save( $post_id ) ); + $this->assertEquals( 'beans_post_test_field_value', get_post_meta( $post_id, 'beans_post_test_field', true ) ); + } +} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php new file mode 100644 index 00000000..5c85608b --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php @@ -0,0 +1,46 @@ + 'Post Options' ) ); + $attachment_id = $this->factory()->attachment->create(); + $attachment_data = get_post( $attachment_id, ARRAY_A ); + + // Run with permission to save. + $user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) ); + wp_set_current_user( $user_id ); + + // Give beans_post() a field to find and set a nonce to return. + $_POST['beans_fields'] = array( 'beans_post_test_field' => 'beans_post_test_field_value' ); + $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); + + $this->assertSame( $attachment_data, $post_meta->save_attachment( $attachment_data ) ); + $this->assertEquals( 'beans_post_test_field_value', get_post_meta( $attachment_id, 'beans_post_test_field', true ) ); + } +} diff --git a/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php b/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php index fd1a8dc0..866fa2b2 100644 --- a/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php +++ b/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php @@ -9,16 +9,18 @@ namespace Beans\Framework\Tests\Integration\API\Post_Meta; -use WP_UnitTestCase; +use Beans\Framework\Tests\Integration\API\Post_Meta\Includes\Beans_Post_Meta_Test_Case; + +require_once dirname( __FILE__ ) . '/includes/class-beans-post-meta-test-case.php'; /** * Class Tests_BeansGetPostMeta * * @package Beans\Framework\Tests\Integration\API\Post_Meta - * @group integration-tests * @group api + * @group api-post-meta */ -class Tests_BeansGetPostMeta extends WP_UnitTestCase { +class Tests_BeansGetPostMeta extends Beans_Post_Meta_Test_Case { /** * Test beans_get_post_meta() should return the default when the post_id cannot be resolved. @@ -54,7 +56,7 @@ public function test_should_get_post_id_when_none_is_provided() { } /** - * Test beans_get_post_meta() should return the post's meta value. + * Test beans_get_post_meta() should return the post's meta value when all conditions are met. */ public function test_should_return_post_meta_value() { $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); diff --git a/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php b/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php new file mode 100644 index 00000000..3c2c6dec --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php @@ -0,0 +1,166 @@ +assertTrue( _beans_is_post_meta_conditions( true ) ); + } + + /** + * Tests is_post_meta_conditions should return true when is a new post and $conditions include 'post'. + */ + public function test_returns_true_when_new_post_and_conditions_include_post() { + set_current_screen( 'post' ); + $_SERVER['REQUEST_URI'] = 'post-new.php'; + + $this->assertTrue( _beans_is_post_meta_conditions( array( 'post' ) ) ); + + // Clean up server globals. + $_SERVER['REQUEST_URI'] = ''; + } + + /** + * Tests is_post_meta_conditions should return false when is a new post and $conditions don't include 'post'. + */ + public function test_returns_false_when_new_post_and_conditions_dont_include_post() { + set_current_screen( 'post' ); + $_SERVER['REQUEST_URI'] = 'post-new.php'; + + $this->assertFalse( _beans_is_post_meta_conditions( array( 'page' ) ) ); + + // Clean up server globals. + $_SERVER['REQUEST_URI'] = ''; + } + + /** + * Tests is_post_meta_conditions should return false when post_id can't be found. + */ + public function test_returns_false_when_post_id_not_found() { + set_current_screen( 'edit' ); + + $this->assertFalse( _beans_is_post_meta_conditions( array( 'post' ) ) ); + } + + /** + * Tests is_post_meta_conditions should return true when $conditions match post type. + */ + public function test_returns_true_when_conditions_match_post_type() { + $post_id = $this->factory()->post->create( array( 'post_type' => 'cpt' ) ); + set_current_screen( 'cpt' ); + + // Setup for when post_id is in GET. + $_GET['post'] = $post_id; + + $this->assertTrue( _beans_is_post_meta_conditions( array( 'cpt' ) ) ); + + // Clear Global GET. + $_GET['post'] = null; + + // Set up for when post_id is in POST. + $_POST['post_ID'] = $post_id; + + $this->assertTrue( _beans_is_post_meta_conditions( array( 'cpt' ) ) ); + + // Clear Global POST. + $_POST['post_ID'] = null; + } + + /** + * Tests is_post_meta_conditions should return true when conditions match post ID. + */ + public function test_returns_true_when_conditions_match_post_id() { + $post_id = $this->factory()->post->create(); + set_current_screen( 'edit' ); + + // Setup for when post_id is in GET. + $_GET['post'] = $post_id; + + $this->assertTrue( _beans_is_post_meta_conditions( array( $post_id ) ) ); + + // Clear Global GET. + $_GET['post'] = null; + + // Set up for when post_id is in POST. + $_POST['post_ID'] = $post_id; + + $this->assertTrue( _beans_is_post_meta_conditions( array( $post_id ) ) ); + + // Clear Global POST. + $_POST['post_ID'] = null; + } + + /** + * Tests is_post_meta_conditions should return true when conditions match a page template name. + */ + public function test_returns_true_when_conditions_match_page_template_name() { + $page_id = $this->factory()->post->create( array( 'post_type' => 'page' ) ); + set_current_screen( 'edit' ); + add_post_meta( $page_id, '_wp_page_template', 'page-template-name' ); + + // Setup for when post_id is in GET. + $_GET['post'] = $page_id; + + $this->assertTrue( _beans_is_post_meta_conditions( array( 'page-template-name' ) ) ); + + // Clear Global GET. + $_GET['post'] = null; + + // Set up for when post_id is in POST. + $_POST['post_ID'] = $page_id; + + $this->assertTrue( _beans_is_post_meta_conditions( array( 'page-template-name' ) ) ); + + // Clear Global POST. + $_POST['post_ID'] = null; + } + + /** + * Tests is_post_meta_conditions should return false when no conditions match. + */ + public function test_returns_false_when_no_conditions_match() { + + $page_id = $this->factory()->post->create( array( 'post_type' => 'page' ) ); + set_current_screen( 'edit' ); + add_post_meta( $page_id, '_wp_page_template', 'page-template-name' ); + + // Setup for when post_id is in GET. + $_GET['post'] = $page_id; + + $this->assertFalse( _beans_is_post_meta_conditions( array( 'some-other-conditions' ) ) ); + + // Clear Global GET. + $_GET['post'] = null; + + // Set up for when post_id is in POST. + $_POST['post_ID'] = $page_id; + + $this->assertFalse( _beans_is_post_meta_conditions( array( 'some-other-conditions' ) ) ); + + // Clear Global POST. + $_POST['post_ID'] = null; + } +} diff --git a/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php b/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php new file mode 100644 index 00000000..8092dda9 --- /dev/null +++ b/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php @@ -0,0 +1,71 @@ +assertSame( '', $output ); + } + + /** + * Test beans_post_meta_page_template_reload should do nothing when post meta not assigned to page templates. + */ + public function test_does_nothing_when_post_meta_not_assigned_to_page_templates() { + global $_beans_post_meta_conditions, $pagenow; + + $_beans_post_meta_conditions = array(); + $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. + + ob_start(); + _beans_post_meta_page_template_reload(); + $output = ob_get_clean(); + + $this->assertSame( '', $output ); + } + + /** + * Test beans_post_meta_page_template_reload should output script html when post meta is assigned to page templates. + */ + public function test_does_nothing_when_post_meta_assigned_to_page_templates() { + global $_beans_post_meta_conditions, $pagenow; + + $_beans_post_meta_conditions = array( 'page-template-name.php' ); + $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. + + ob_start(); + _beans_post_meta_page_template_reload(); + $output = ob_get_clean(); + + $this->assertContains( '\n", $localized ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Needs review. } } - -new _Beans_Page_Compiler(); diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 413fac53..2c2f41e4 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -301,6 +301,23 @@ function beans_add_compiler_options_to_settings() { return $instance; } +add_action( 'beans_loaded_api_component_compiler', 'beans_add_page_assets_compiler' ); +/** + * Add the page assets' compiler. + * + * @since 1.5.0 + * + * @return _Beans_Compiler_Options|void + */ +function beans_add_page_assets_compiler() { + + if ( ! class_exists( '_Beans_Page_Compiler' ) ) { + return; + } + + return new _Beans_Page_Compiler(); +} + /** * Check if development mode is enabled. * From 2cda1c61beab4b0340a0b3f79ecf49867e0d4232 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 11 May 2018 18:38:36 -0500 Subject: [PATCH 554/800] Moved the hooks into an init() method. Hooks should be part of the object's initialization instead of automatically running them during instantiation process. --- lib/api/compiler/class-beans-page-compiler.php | 8 ++++++-- lib/api/compiler/functions.php | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index a3a508e4..7027564f 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -26,9 +26,13 @@ final class _Beans_Page_Compiler { private $dequeued_scripts = array(); /** - * Constructor. + * Initialize the hooks. + * + * @since 1.5.0 + * + * @return void */ - public function __construct() { + public function init() { add_action( 'wp_enqueue_scripts', array( $this, 'compile_page_styles' ), 9999 ); add_action( 'wp_enqueue_scripts', array( $this, 'compile_page_scripts' ), 9999 ); } diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 2c2f41e4..5b9d6f98 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -307,7 +307,7 @@ function beans_add_compiler_options_to_settings() { * * @since 1.5.0 * - * @return _Beans_Compiler_Options|void + * @return _Beans_Page_Compiler|void */ function beans_add_page_assets_compiler() { @@ -315,7 +315,10 @@ function beans_add_page_assets_compiler() { return; } - return new _Beans_Page_Compiler(); + $instance = new _Beans_Page_Compiler(); + $instance->init(); + + return $instance; } /** From c7a127fe0de645515404c7af5b033221bd3edf72 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 11 May 2018 19:31:53 -0500 Subject: [PATCH 555/800] Added unit tests for compile_page_styles(). --- .../compiler/class-beans-page-compiler.php | 26 +- .../beans-page-compiler/compilePageStyles.php | 443 ++++++++++++++++++ .../class-page-compiler-test-case.php | 32 ++ 3 files changed, 495 insertions(+), 6 deletions(-) create mode 100644 tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php create mode 100644 tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 7027564f..d63b9f0c 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -46,15 +46,30 @@ public function init() { */ public function compile_page_styles() { - if ( ! beans_get_component_support( 'wp_styles_compiler' ) || ! get_option( 'beans_compile_all_styles', false ) || _beans_is_compiler_dev_mode() ) { + if ( $this->do_not_compile_styles() ) { return; } $styles = $this->compile_enqueued( 'style' ); - if ( $styles ) { - beans_compile_css_fragments( 'beans', $styles, array( 'version' => null ) ); + if ( empty( $styles ) ) { + return; } + + beans_compile_css_fragments( 'beans', $styles, array( 'version' => null ) ); + } + + /** + * Checks if the page's styles should not be compiled. + * + * @since 1.5.0 + * + * @return bool + */ + private function do_not_compile_styles() { + return ! beans_get_component_support( 'wp_styles_compiler' ) || + ! get_option( 'beans_compile_all_styles', false ) || + _beans_is_compiler_dev_mode(); } /** @@ -83,17 +98,16 @@ public function compile_page_scripts() { /** * Compile all wp enqueued assets. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * - * @param string $type Type of asset, e.g. style or script. + * @param string $type Type of asset, e.g. style or script. * @param string $dependencies Optional. Dependencies of the asset. Default is false. * * @return array */ private function compile_enqueued( $type, $dependencies = false ) { - $assets = beans_get( "wp_{$type}s", $GLOBALS ); if ( ! $assets ) { diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php new file mode 100644 index 00000000..6fccfcee --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php @@ -0,0 +1,443 @@ +once() + ->with( 'wp_styles_compiler' ) + ->andReturn( false ); + Monkey\Functions\expect( 'get_option' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the "compile all styles" option is not + * set. + */ + public function test_should_not_compile_when_option_is_not_set() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\expect( 'get_option' ) + ->once() + ->with( 'beans_compile_all_styles', false ) + ->andReturn( false ); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when in dev mode. + */ + public function test_should_not_compile_when_in_dev_mode() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when there are not styles. + */ + public function test_should_not_compile_when_there_are_not_styles() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_action' )->never(); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Check that beans_get() only gets called once. + Monkey\Functions\expect( 'beans_get' )->once()->andReturn( null ); + + // Check that this function does not get called. + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when assets are admin bar only. + */ + public function test_should_not_compile_when_assets_are_admin_bar_only() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_action' )->never(); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'open-sans', 'dashicons' ] ); + + // Check that beans_get() only gets called once. + Monkey\Functions\expect( 'beans_get' )->once()->andReturn( $assets ); + + // Check that beans_compile_css_fragments() does not get called. + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the style is not registered. + */ + public function test_should_not_compile_when_style_is_not_registered() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_action' )->never(); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'uikit', 'child-style' ] ); + $assets->registered['uikit'] = null; + $assets->registered['child-style'] = null; + + // Set up the order of how beans_get() will be called. + Monkey\Functions\expect( 'beans_get' ) + ->ordered() + ->once() + ->with( 'wp_styles', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'child-style', $assets->registered ) + ->andReturn( $assets->registered['child-style'] ); + + // Check that beans_compile_css_fragments() does not get called. + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the style has no src. + */ + public function test_should_not_compile_when_style_has_no_src() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_action' )->never(); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'uikit', 'child-style' ] ); + $assets->registered['uikit']->src = ''; + $assets->registered['child-style']->src = ''; + + // Set up the order of how beans_get() will be called. + Monkey\Functions\expect( 'beans_get' ) + ->ordered() + ->once() + ->with( 'wp_styles', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'child-style', $assets->registered ) + ->andReturn( $assets->registered['child-style'] ); + + // Check that beans_compile_css_fragments() does not get called. + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should compile when the style has src but no dependencies. + */ + public function test_should_compile_when_style_has_src_but_no_deps() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_action' )->never(); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'uikit', 'child-style' ] ); + + // Set up the order of how beans_get() will be called. + Monkey\Functions\expect( 'beans_get' ) + ->ordered() + ->once() + ->with( 'wp_styles', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'child-style', $assets->registered ) + ->andReturn( $assets->registered['child-style'] ); + + // Mock how beans_compile_css_fragments() will be called. + Monkey\Functions\expect( 'beans_compile_css_fragments' ) + ->once() + ->with( + 'beans', + [ + 'uikit' => $assets->registered['uikit']->src, + 'child-style' => $assets->registered['child-style']->src, + ], + [ 'version' => null ] + ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + + // Check the asset's done state. + $this->assertSame( [ 'uikit', 'child-style' ], $assets->done ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should add the query arg to the compiled style's src. + */ + public function test_should_add_query_arg_to_compiled_style_src() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_action' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'child-style' ] ); + $assets->registered['child-style']->args = 'screen'; + $original_src = $assets->registered['child-style']->src; + $new_src = $original_src . '?beans_compiler_media_query=screen'; + + // Set up the order of how beans_get() will be called. + Monkey\Functions\expect( 'beans_get' ) + ->ordered() + ->once() + ->with( 'wp_styles', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'child-style', $assets->registered ) + ->andReturn( $assets->registered['child-style'] ); + + // Check that add_query_arg() is called. + Monkey\Functions\expect( 'add_query_arg' ) + ->once() + ->with( [ 'beans_compiler_media_query' => 'screen' ], $original_src ) + ->andReturn( $new_src ); + + // Check that the new source is compiled. + Monkey\Functions\expect( 'beans_compile_css_fragments' ) + ->once() + ->with( 'beans', [ 'child-style' => $new_src ], [ 'version' => null ] ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + + // Check the asset states when done. + $this->assertSame( $new_src, $assets->registered['child-style']->src ); + $this->assertSame( [ 'child-style' ], $assets->done ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should compile styles and dependencies. + */ + public function test_should_compile_style_and_deps() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_action' )->never(); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ + 'admin-bar', + 'debug-bar', + 'uikit', + 'child-style', + 'debug-bar-actions-filters', + ] ); + + // Set up the order of how beans_get() will be called. + Monkey\Functions\expect( 'beans_get' ) + ->ordered() + ->once() + ->with( 'wp_styles', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'debug-bar', $assets->registered ) + ->andReturn( $assets->registered['debug-bar'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'child-style', $assets->registered ) + ->andReturn( $assets->registered['child-style'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'debug-bar-actions-filters', $assets->registered ) + ->andReturn( $assets->registered['debug-bar-actions-filters'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'wp_styles', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'debug-bar', $assets->registered ) + ->andReturn( $assets->registered['debug-bar'] ); + + // Mock how beans_compile_css_fragments() will be called. + Monkey\Functions\expect( 'beans_compile_css_fragments' ) + ->once() + ->with( + 'beans', + [ + 'debug-bar' => $assets->registered['debug-bar']->src, + 'uikit' => $assets->registered['uikit']->src, + 'child-style' => $assets->registered['child-style']->src, + 'debug-bar-actions-filters' => $assets->registered['debug-bar-actions-filters']->src, + ], + [ 'version' => null ] + ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + + // Check the asset's done state. + $this->assertSame( [ 'debug-bar', 'uikit', 'child-style', 'debug-bar', 'debug-bar-actions-filters' ], $assets->done ); + } + + /** + * Get the mocked assets. + * + * @since 1.5.0 + * + * @param array $queue Array of assets to build. + * + * @return \Mockery\MockInterface + */ + protected function get_mock_assets( array $queue ) { + $wp_styles_mock = \Mockery::mock( 'WP_Styles' ); + $wp_styles_mock->queue = $queue; + $registered = []; + + if ( in_array( 'debug-bar', $queue, true ) ) { + $registered['debug-bar'] = $this->get_deps_mock( [ + 'handle' => 'debug-bar', + 'src' => 'http://beansdev.test/wp-content/plugins/debug-bar/css/debug-bar.dev.css', + 'ver' => '20170515', + ] ); + } + + if ( in_array( 'uikit', $queue, true ) ) { + $registered['uikit'] = $this->get_deps_mock( [ + 'handle' => 'uikit', + 'src' => 'http://beansdev.test/wp-content/uploads/beans/compiler/uikit/ac2cc0a-f36bb75.css', + ] ); + } + + if ( in_array( 'child-style', $queue, true ) ) { + $registered['child-style'] = $this->get_deps_mock( [ + 'handle' => 'child-style', + 'src' => 'http://beansdev.test/wp-content/themes/tm-beans-child/style.css', + ] ); + } + + if ( in_array( 'debug-bar-actions-filters', $queue, true ) ) { + $registered['debug-bar-actions-filters'] = $this->get_deps_mock( [ + 'handle' => 'debug-bar-actions-filters', + 'src' => 'http://beansdev.test/wp-content/plugins/debug-bar-actions-and-filters-addon/css/debug-bar-actions-filters.css', + 'deps' => [ 'debug-bar' ], + 'ver' => '1.5.1all', + ] ); + } + + $wp_styles_mock->registered = $registered; + + return $wp_styles_mock; + } + + /** + * Get the deps mock. + * + * @since 1.5.0 + * + * @param array $config Configuration parameters to set the properties. + * + * @return Mockery\MockInterface + */ + protected function get_deps_mock( array $config ) { + $mock = \Mockery::mock( '_WP_Dependency' ); + $mock->handle = $config['handle']; + $mock->src = $config['src']; + $mock->deps = isset( $config['deps'] ) ? $config['deps'] : []; + $mock->ver = isset( $config['ver'] ) ? $config['ver'] : false; + $mock->args = isset( $config['args'] ) ? $config['args'] : 'all'; + $mock->extra = isset( $config['extra'] ) ? $config['extra'] : []; + + return $mock; + } +} diff --git a/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php new file mode 100644 index 00000000..6ed5c83a --- /dev/null +++ b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php @@ -0,0 +1,32 @@ +load_original_functions( array( + 'api/compiler/class-beans-page-compiler.php', + 'api/options/functions.php', + ) ); + } +} From e233f0a64fe32ea92f29b391fd2e506ab982e210 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 13:09:52 -0500 Subject: [PATCH 556/800] Checked if the src is set before stored in fragments. Added a check to ensure the asset's src is set (not empty). If no, we do not add it to the fragments to be compiled. Why? We need the src in order to compile it. --- lib/api/compiler/class-beans-page-compiler.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index d63b9f0c..bcd9d105 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -159,7 +159,9 @@ private function compile_enqueued( $type, $dependencies = false ) { $this->dequeued_scripts[ $id ] = $args->src; } - $fragments[ $id ] = $args->src; + if ( ! empty( $args->src ) ) { + $fragments[ $id ] = $args->src; + } } return $fragments; From 459726832bc95cd98684d980557ad9ececcd297f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 13:12:45 -0500 Subject: [PATCH 557/800] Renamed variables to before tell us what they represent. `$args` is not descriptive. Plus, it's confusing. Why? It actually is the registered asset, i.e. the style or script that was registered with WordPress the enqueue process. Therefore, it's been renamed to `$asset`. `$id` is not descriptive either. To correlate it to WordPress, it's been renamed to `$handle`. --- .../compiler/class-beans-page-compiler.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index bcd9d105..f9e1705c 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -124,25 +124,25 @@ private function compile_enqueued( $type, $dependencies = false ) { $fragments = array(); - foreach ( $dependencies as $id ) { + foreach ( $dependencies as $handle ) { // Don't compile admin bar assets. - if ( in_array( $id, array( 'admin-bar', 'open-sans', 'dashicons' ), true ) ) { + if ( in_array( $handle, array( 'admin-bar', 'open-sans', 'dashicons' ), true ) ) { continue; } - $args = beans_get( $id, $assets->registered ); + $asset = beans_get( $handle, $assets->registered ); - if ( ! $args ) { + if ( ! $asset ) { continue; } - if ( $args->deps ) { + if ( $asset->deps ) { - foreach ( $this->compile_enqueued( $type, $args->deps ) as $dep_id => $dep_src ) { + foreach ( $this->compile_enqueued( $type, $asset->deps ) as $dep_handle => $dep_src ) { if ( ! empty( $dep_src ) ) { - $fragments[ $dep_id ] = $dep_src; + $fragments[ $dep_handle ] = $dep_src; } } } @@ -150,17 +150,17 @@ private function compile_enqueued( $type, $dependencies = false ) { if ( 'style' === $type ) { // Add compiler media query if set. - if ( 'all' !== $args->args ) { - $args->src = add_query_arg( array( 'beans_compiler_media_query' => $args->args ), $args->src ); + if ( 'all' !== $asset->args ) { + $asset->src = add_query_arg( array( 'beans_compiler_media_query' => $asset->args ), $asset->src ); } - $assets->done[] = $id; + $assets->done[] = $handle; } elseif ( 'script' === $type ) { - $this->dequeued_scripts[ $id ] = $args->src; + $this->dequeued_scripts[ $handle ] = $asset->src; } - if ( ! empty( $args->src ) ) { - $fragments[ $id ] = $args->src; + if ( ! empty( $asset->src ) ) { + $fragments[ $handle ] = $asset->src; } } From ecaf839e9c8804aab4606eb3c09891a272c1a128 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 13:36:18 -0500 Subject: [PATCH 558/800] Abstracted getting the asset dependencies' sources. Abstracted the inner loop for getting the asset dependencies' sources to a separate private method. Why? To reduce complexity in the compile_enqueued() method. There's just too much going on in that method. Note, the collected asset sources is passed by reference. Why? We do this to reduce memory when passing around an array. It allows the new method to add additional assets to the collection without having to merge those sources back in when returning. --- .../compiler/class-beans-page-compiler.php | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index f9e1705c..f37fdaf3 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -67,9 +67,7 @@ public function compile_page_styles() { * @return bool */ private function do_not_compile_styles() { - return ! beans_get_component_support( 'wp_styles_compiler' ) || - ! get_option( 'beans_compile_all_styles', false ) || - _beans_is_compiler_dev_mode(); + return ! beans_get_component_support( 'wp_styles_compiler' ) || ! get_option( 'beans_compile_all_styles', false ) || _beans_is_compiler_dev_mode(); } /** @@ -102,8 +100,8 @@ public function compile_page_scripts() { * @ignore * @access private * - * @param string $type Type of asset, e.g. style or script. - * @param string $dependencies Optional. Dependencies of the asset. Default is false. + * @param string $type Type of asset, e.g. style or script. + * @param string|array $dependencies Optional. The asset's dependency(ies). Default is false. * * @return array */ @@ -137,15 +135,7 @@ private function compile_enqueued( $type, $dependencies = false ) { continue; } - if ( $asset->deps ) { - - foreach ( $this->compile_enqueued( $type, $asset->deps ) as $dep_handle => $dep_src ) { - - if ( ! empty( $dep_src ) ) { - $fragments[ $dep_handle ] = $dep_src; - } - } - } + $this->get_deps_to_be_compiled( $type, $asset, $fragments ); if ( 'style' === $type ) { @@ -167,6 +157,33 @@ private function compile_enqueued( $type, $dependencies = false ) { return $fragments; } + /** + * Get the asset's dependencies to be compiled. + * + * @since 1.5.0 + * + * @param string $type Type of asset. + * @param _WP_Dependency $asset Instance of the asset. + * @param array $srcs Array of compiled asset srcs to be compiled. Passed by reference. + * + * @return void + */ + private function get_deps_to_be_compiled( $type, $asset, array &$srcs ) { + + if ( empty( $asset->deps ) ) { + return; + } + + foreach ( $this->compile_enqueued( $type, $asset->deps, true ) as $dep_handle => $dep_src ) { + + if ( empty( $dep_src ) ) { + continue; + } + + $srcs[ $dep_handle ] = $dep_src; + } + } + /** * Dequeue scripts which have been compiled, grab localized * data and add it inline. From f55205a155f22751359c52b4a53e02232c32c7a2 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 14:22:34 -0500 Subject: [PATCH 559/800] Moved get_deps_mock() to test case. --- .../beans-page-compiler/compilePageStyles.php | 23 +------------------ .../class-page-compiler-test-case.php | 22 ++++++++++++++++++ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php index 6fccfcee..b00d0324 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php @@ -380,7 +380,7 @@ public function test_should_compile_style_and_deps() { * @return \Mockery\MockInterface */ protected function get_mock_assets( array $queue ) { - $wp_styles_mock = \Mockery::mock( 'WP_Styles' ); + $wp_styles_mock = Mockery::mock( 'WP_Styles' ); $wp_styles_mock->queue = $queue; $registered = []; @@ -419,25 +419,4 @@ protected function get_mock_assets( array $queue ) { return $wp_styles_mock; } - - /** - * Get the deps mock. - * - * @since 1.5.0 - * - * @param array $config Configuration parameters to set the properties. - * - * @return Mockery\MockInterface - */ - protected function get_deps_mock( array $config ) { - $mock = \Mockery::mock( '_WP_Dependency' ); - $mock->handle = $config['handle']; - $mock->src = $config['src']; - $mock->deps = isset( $config['deps'] ) ? $config['deps'] : []; - $mock->ver = isset( $config['ver'] ) ? $config['ver'] : false; - $mock->args = isset( $config['args'] ) ? $config['args'] : 'all'; - $mock->extra = isset( $config['extra'] ) ? $config['extra'] : []; - - return $mock; - } } diff --git a/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php index 6ed5c83a..8d2a20bf 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Unit\API\Compiler\Includes; use Beans\Framework\Tests\Unit\Test_Case; +use Mockery; /** * Abstract Class Page_Compiler_Test_Case @@ -29,4 +30,25 @@ protected function setUp() { 'api/options/functions.php', ) ); } + + /** + * Get the deps mock. + * + * @since 1.5.0 + * + * @param array $config Configuration parameters to set the properties. + * + * @return Mockery\MockInterface + */ + protected function get_deps_mock( array $config ) { + $mock = Mockery::mock( '_WP_Dependency' ); + $mock->handle = $config['handle']; + $mock->src = $config['src']; + $mock->deps = isset( $config['deps'] ) ? $config['deps'] : []; + $mock->ver = isset( $config['ver'] ) ? $config['ver'] : false; + $mock->args = isset( $config['args'] ) ? $config['args'] : 'all'; + $mock->extra = isset( $config['extra'] ) ? $config['extra'] : []; + + return $mock; + } } From 63cd06263f834102cd115b87447ffb700f425c4a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 15:22:30 -0500 Subject: [PATCH 560/800] Added unit tests for compile_page_scripts(). --- .../compiler/class-beans-page-compiler.php | 27 +- .../compilePageScripts.php | 413 ++++++++++++++++++ 2 files changed, 433 insertions(+), 7 deletions(-) create mode 100644 tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index f37fdaf3..d46109aa 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -79,18 +79,31 @@ private function do_not_compile_styles() { */ public function compile_page_scripts() { - if ( ! beans_get_component_support( 'wp_scripts_compiler' ) || ! get_option( 'beans_compile_all_scripts', false ) || _beans_is_compiler_dev_mode() ) { + if ( $this->do_not_compile_scripts() ) { return; } $scripts = $this->compile_enqueued( 'script' ); - if ( $scripts ) { - beans_compile_js_fragments( 'beans', $scripts, array( - 'in_footer' => ( 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ) ) ? true : false, - 'version' => null, - ) ); + if ( empty( $scripts ) ) { + return; } + + beans_compile_js_fragments( 'beans', $scripts, array( + 'in_footer' => 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ), + 'version' => null, + ) ); + } + + /** + * Checks if the page's scripts should not be compiled. + * + * @since 1.5.0 + * + * @return bool + */ + private function do_not_compile_scripts() { + return ! beans_get_component_support( 'wp_scripts_compiler' ) || ! get_option( 'beans_compile_all_scripts', false ) || _beans_is_compiler_dev_mode(); } /** @@ -149,7 +162,7 @@ private function compile_enqueued( $type, $dependencies = false ) { $this->dequeued_scripts[ $handle ] = $asset->src; } - if ( ! empty( $asset->src ) ) { + if ( $asset->src ) { $fragments[ $handle ] = $asset->src; } } diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php new file mode 100644 index 00000000..8cbf88b6 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php @@ -0,0 +1,413 @@ +once() + ->with( 'wp_scripts_compiler' ) + ->andReturn( false ); + Monkey\Functions\expect( 'get_option' )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when the "compile all scripts" option is not + * set. + */ + public function test_should_not_compile_when_option_is_not_set() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\expect( 'get_option' ) + ->once() + ->with( 'beans_compile_all_scripts', false ) + ->andReturn( false ); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when in dev mode. + */ + public function test_should_not_compile_when_in_dev_mode() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when there are not scripts. + */ + public function test_should_not_compile_when_there_are_not_scripts() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_action' )->never(); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Check that beans_get() only gets called once. + Monkey\Functions\expect( 'beans_get' )->once()->andReturn( null ); + + // Check that this function does not get called. + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when assets are admin bar only. + */ + public function test_should_not_compile_when_assets_are_admin_bar_only() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'open-sans', 'dashicons' ] ); + + // Check that beans_get() only gets called once. + Monkey\Functions\expect( 'beans_get' )->once()->andReturn( $assets ); + + // Check that beans_compile_js_fragments() does not get called. + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when the script is not registered. + */ + public function test_should_not_compile_when_style_is_not_registered() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'uikit' ] ); + $assets->registered['uikit'] = null; + + // Set up the order of how beans_get() will be called. + Monkey\Functions\expect( 'beans_get' ) + ->ordered() + ->once() + ->with( 'wp_scripts', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ); + + // Check that beans_compile_js_fragments() does not get called. + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when the script has no src. + */ + public function test_should_not_compile_when_script_has_no_src() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\when( 'get_option' )->justReturn( true ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'uikit' ] ); + $assets->registered['uikit']->src = ''; + $assets->registered['uikit']->deps = []; + + // Set up the order of how beans_get() will be called. + Monkey\Functions\expect( 'beans_get' ) + ->ordered() + ->once() + ->with( 'wp_scripts', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ); + + // Check that beans_compile_js_fragments() does not get called. + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should compile when the script has src but no dependencies. + */ + public function test_should_compile_when_script_has_src_but_no_deps() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\expect( 'get_option' ) + ->ordered() + ->once() + ->with( 'beans_compile_all_scripts', false ) + ->andReturn( true ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'beans_compile_all_scripts_mode', 'aggressive' ) + ->andReturn( 'aggressive' ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'uikit', 'debug-bar' ] ); + $assets->registered['uikit']->deps = []; + $assets->registered['debug-bar']->deps = []; + + // Set up the order of how beans_get() will be called. + Monkey\Functions\expect( 'beans_get' ) + ->ordered() + ->once() + ->with( 'wp_scripts', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'debug-bar', $assets->registered ) + ->andReturn( $assets->registered['debug-bar'] ); + + // Mock how beans_compile_js_fragments() will be called. + Monkey\Functions\expect( 'beans_compile_js_fragments' ) + ->once() + ->with( + 'beans', + [ + 'uikit' => $assets->registered['uikit']->src, + 'debug-bar' => $assets->registered['debug-bar']->src, + ], + [ + 'in_footer' => true, + 'version' => null, + ] + ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should compile scripts and dependencies. + */ + public function test_should_compile_scripts_and_deps() { + Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); + Monkey\Functions\expect( 'get_option' ) + ->ordered() + ->once() + ->with( 'beans_compile_all_scripts', false ) + ->andReturn( true ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'beans_compile_all_scripts_mode', 'aggressive' ) + ->andReturn( 'aggressive' ); + Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Initialize the mocked assets. + $assets = $this->get_mock_assets( [ 'admin-bar', 'debug-bar', 'uikit' ] ); + + // Set up the order of how beans_get() will be called. + Monkey\Functions\expect( 'beans_get' ) + ->ordered() + ->once() + ->with( 'wp_scripts', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + // Handle debug-bar and its dependencies. + ->ordered() + ->once() + ->with( 'debug-bar', $assets->registered ) + ->andReturn( $assets->registered['debug-bar'] ) + ->andAlsoExpectIt() + // Recursive stack for dependencies. + ->ordered() + ->once() + ->with( 'wp_scripts', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'jquery', $assets->registered ) + ->andReturn( $assets->registered['jquery'] ) + ->andAlsoExpectIt() + // Recursive stack for jquery's dependencies. + ->ordered() + ->once() + ->with( 'wp_scripts', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'jquery-core', $assets->registered ) + ->andReturn( $assets->registered['jquery-core'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'jquery-migrate', $assets->registered ) + ->andReturn( $assets->registered['jquery-migrate'] ) + ->andAlsoExpectIt() + // Handle uikit and its dependencies. + ->ordered() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ) + ->andAlsoExpectIt() + // Recursive stack for dependencies. + ->ordered() + ->once() + ->with( 'wp_scripts', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'jquery', $assets->registered ) + ->andReturn( $assets->registered['jquery'] ) + ->andAlsoExpectIt() + // Recursive stack for jquery's dependencies. + ->ordered() + ->once() + ->with( 'wp_scripts', $GLOBALS ) + ->andReturn( $assets ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'jquery-core', $assets->registered ) + ->andReturn( $assets->registered['jquery-core'] ) + ->andAlsoExpectIt() + ->ordered() + ->once() + ->with( 'jquery-migrate', $assets->registered ) + ->andReturn( $assets->registered['jquery-migrate'] ); + + // Mock how beans_compile_js_fragments() will be called. + Monkey\Functions\expect( 'beans_compile_js_fragments' ) + ->once() + ->with( + 'beans', + [ + 'jquery-core' => $assets->registered['jquery-core']->src, + 'jquery-migrate' => $assets->registered['jquery-migrate']->src, + 'debug-bar' => $assets->registered['debug-bar']->src, + 'uikit' => $assets->registered['uikit']->src, + ], + [ + 'in_footer' => true, + 'version' => null, + ] + ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Get the mocked assets. + * + * @since 1.5.0 + * + * @param array $queue Array of assets to build. + * + * @return \Mockery\MockInterface + */ + protected function get_mock_assets( array $queue ) { + $wp_scripts_mock = Mockery::mock( 'WP_Scripts' ); + $wp_scripts_mock->queue = $queue; + $registered = [ + 'jquery' => $this->get_deps_mock( [ + 'handle' => 'jquery', + 'src' => false, + 'deps' => [ 'jquery-core', 'jquery-migrate' ], + 'ver' => '1.12.4', + ] ), + 'jquery-core' => $this->get_deps_mock( [ + 'handle' => 'jquery-core', + 'src' => '/wp-includes/js/jquery/jquery.js', + 'ver' => '1.12.4', + ] ), + 'jquery-migrate' => $this->get_deps_mock( [ + 'handle' => 'jquery-migrate', + 'src' => '/wp-includes/js/jquery/jquery-migrate.js', + 'ver' => '1.4.1', + ] ), + ]; + + if ( in_array( 'debug-bar', $queue, true ) ) { + $registered['debug-bar'] = $this->get_deps_mock( [ + 'handle' => 'debug-bar', + 'src' => '/wp-content/plugins/debug-bar/js/debug-bar.dev.js', + 'deps' => [ 'jquery' ], + 'ver' => '20170515', + 'extra' => [ 'group' => 1 ], + ] ); + } + + if ( in_array( 'uikit', $queue, true ) ) { + $registered['uikit'] = $this->get_deps_mock( [ + 'handle' => 'uikit', + 'src' => 'wp-content/uploads/beans/compiler/uikit/3b2a958-921f3e0.js', + 'deps' => [ 'jquery' ], + ] ); + } + + $wp_scripts_mock->registered = $registered; + + return $wp_scripts_mock; + } +} From 83c828b3fa8d885bb01330514fbf6da5425e9871 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 15:25:23 -0500 Subject: [PATCH 561/800] Optimized by moving the add_action to dequence_scripts. Due to the recursive calling for script dependencies, the add_action was being called 1 + # of dependencies. That's inefficient. By moving it up into the `compile_page_scripts()` method, we register the `dequence_scripts` only once. This change optimizes for processing speed while also improving the readability of the code. --- lib/api/compiler/class-beans-page-compiler.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index d46109aa..68457356 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -89,6 +89,8 @@ public function compile_page_scripts() { return; } + add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 ); + beans_compile_js_fragments( 'beans', $scripts, array( 'in_footer' => 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ), 'version' => null, @@ -125,10 +127,6 @@ private function compile_enqueued( $type, $dependencies = false ) { return array(); } - if ( 'script' === $type ) { - add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 ); - } - if ( ! $dependencies ) { $dependencies = $assets->queue; } From ec68cb6c0e14e261c7bf868df528d703369f15c7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 15:28:48 -0500 Subject: [PATCH 562/800] Removed the add_action mock as it's no longer needed. --- .../api/compiler/beans-page-compiler/compilePageStyles.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php index b00d0324..5cb4fbd7 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php @@ -81,7 +81,6 @@ public function test_should_not_compile_when_there_are_not_styles() { Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); Monkey\Functions\when( 'get_option' )->justReturn( true ); Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( 'add_action' )->never(); Monkey\Functions\expect( 'add_query_arg' )->never(); // Check that beans_get() only gets called once. @@ -101,7 +100,6 @@ public function test_should_not_compile_when_assets_are_admin_bar_only() { Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); Monkey\Functions\when( 'get_option' )->justReturn( true ); Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( 'add_action' )->never(); Monkey\Functions\expect( 'add_query_arg' )->never(); // Initialize the mocked assets. @@ -124,7 +122,6 @@ public function test_should_not_compile_when_style_is_not_registered() { Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); Monkey\Functions\when( 'get_option' )->justReturn( true ); Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( 'add_action' )->never(); Monkey\Functions\expect( 'add_query_arg' )->never(); // Initialize the mocked assets. @@ -163,7 +160,6 @@ public function test_should_not_compile_when_style_has_no_src() { Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); Monkey\Functions\when( 'get_option' )->justReturn( true ); Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( 'add_action' )->never(); Monkey\Functions\expect( 'add_query_arg' )->never(); // Initialize the mocked assets. @@ -202,7 +198,6 @@ public function test_should_compile_when_style_has_src_but_no_deps() { Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); Monkey\Functions\when( 'get_option' )->justReturn( true ); Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( 'add_action' )->never(); Monkey\Functions\expect( 'add_query_arg' )->never(); // Initialize the mocked assets. @@ -252,7 +247,6 @@ public function test_should_add_query_arg_to_compiled_style_src() { Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); Monkey\Functions\when( 'get_option' )->justReturn( true ); Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( 'add_action' )->never(); // Initialize the mocked assets. $assets = $this->get_mock_assets( [ 'admin-bar', 'child-style' ] ); @@ -299,7 +293,6 @@ public function test_should_compile_style_and_deps() { Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); Monkey\Functions\when( 'get_option' )->justReturn( true ); Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( 'add_action' )->never(); Monkey\Functions\expect( 'add_query_arg' )->never(); // Initialize the mocked assets. From e9da58acfcba4ceb3d7796eaa51ac1d4bff9d229 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 15:29:31 -0500 Subject: [PATCH 563/800] Fixed CompilePageStyles class name. --- .../unit/api/compiler/beans-page-compiler/compilePageStyles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php index 5cb4fbd7..80341b0a 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php @@ -23,7 +23,7 @@ * @group api * @group api-compiler */ -class Tests_BeansPageCompiler_CompileStyles extends Page_Compiler_Test_Case { +class Tests_BeansPageCompiler_CompilePageStyles extends Page_Compiler_Test_Case { /** * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the styles compiler is not supported. From 48515137c2075e94d5e127eabb32f3e9d7c1250b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 15:44:28 -0500 Subject: [PATCH 564/800] Optimized by setting dequeued_scripts property before compiling. The previous design was: 1. Redundant, as the fragments array being built has the same data in it. 2. Slower, as each asset's handle and src had to stored in it on each iteration. By moving it up after we get all the scripts sources, this change optimizes. It also makes the code more readable as there is less of it. --- lib/api/compiler/class-beans-page-compiler.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 68457356..629380df 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -89,6 +89,7 @@ public function compile_page_scripts() { return; } + $this->dequeued_scripts = $scripts; add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 ); beans_compile_js_fragments( 'beans', $scripts, array( @@ -156,8 +157,6 @@ private function compile_enqueued( $type, $dependencies = false ) { } $assets->done[] = $handle; - } elseif ( 'script' === $type ) { - $this->dequeued_scripts[ $handle ] = $asset->src; } if ( $asset->src ) { From ae4b406be89be86c620df53d1948b48b344da298 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 15:59:05 -0500 Subject: [PATCH 565/800] Optimized by moving the handles to skip to a property. The previous design created the array on every single iteration for both scripts and styles. That's expensive and unnecessary. By moving the "skip" configuration to a property, this class is a bit faster and uses less memory. --- lib/api/compiler/class-beans-page-compiler.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 629380df..fcd6d398 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -25,6 +25,13 @@ final class _Beans_Page_Compiler { */ private $dequeued_scripts = array(); + /** + * Skip these asset handles when compiling. + * + * @var array + */ + private $skip_asset_handles = array( 'admin-bar', 'open-sans', 'dashicons' ); + /** * Initialize the hooks. * @@ -137,7 +144,7 @@ private function compile_enqueued( $type, $dependencies = false ) { foreach ( $dependencies as $handle ) { // Don't compile admin bar assets. - if ( in_array( $handle, array( 'admin-bar', 'open-sans', 'dashicons' ), true ) ) { + if ( in_array( $handle, $this->skip_asset_handles, true ) ) { continue; } From a45eced67def4f34b31d6ad596fa212d292b8fdb Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 16:07:52 -0500 Subject: [PATCH 566/800] Made the "skip" conditional more readable. The inline comment existed to explain the intent of the conditional, i.e. to determine if the asset's handle should not be compiled. This change moves that conditional to a private method. Using the name of the method, we can quickly understand what the check is doing and why. This change makes the code more readable. --- .../compiler/class-beans-page-compiler.php | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index fcd6d398..227528bd 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -26,11 +26,11 @@ final class _Beans_Page_Compiler { private $dequeued_scripts = array(); /** - * Skip these asset handles when compiling. + * An array of assets to not compile. * * @var array */ - private $skip_asset_handles = array( 'admin-bar', 'open-sans', 'dashicons' ); + private $handles_not_to_compile = array( 'admin-bar', 'open-sans', 'dashicons' ); /** * Initialize the hooks. @@ -143,8 +143,7 @@ private function compile_enqueued( $type, $dependencies = false ) { foreach ( $dependencies as $handle ) { - // Don't compile admin bar assets. - if ( in_array( $handle, $this->skip_asset_handles, true ) ) { + if ( $this->do_not_compile_asset( $handle ) ) { continue; } @@ -174,6 +173,19 @@ private function compile_enqueued( $type, $dependencies = false ) { return $fragments; } + /** + * Checks the given asset's handle to determine if it should not be compiled. + * + * @since 1.5.0 + * + * @param string $handle The asset handle to check. + * + * @return bool + */ + private function do_not_compile_asset( $handle ) { + return in_array( $handle, $this->handles_not_to_compile, true ); + } + /** * Get the asset's dependencies to be compiled. * From 77d9aafd338a1e088be24ae10f8ee8878ea02b0b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 16:10:21 -0500 Subject: [PATCH 567/800] Changed the $dependencies parameter default to empty string. Why? To set the data type to either string or array to match what we expect to receive. --- lib/api/compiler/class-beans-page-compiler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 227528bd..8cb61943 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -124,11 +124,11 @@ private function do_not_compile_scripts() { * @access private * * @param string $type Type of asset, e.g. style or script. - * @param string|array $dependencies Optional. The asset's dependency(ies). Default is false. + * @param string|array $dependencies Optional. The asset's dependency(ies). Default is an empty string. * * @return array */ - private function compile_enqueued( $type, $dependencies = false ) { + private function compile_enqueued( $type, $dependencies = '' ) { $assets = beans_get( "wp_{$type}s", $GLOBALS ); if ( ! $assets ) { From ae4a0a9a8e119a11686ec2021dccdcb3a00144e2 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 16:17:20 -0500 Subject: [PATCH 568/800] Skipped logic when the src is empty. --- lib/api/compiler/class-beans-page-compiler.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 8cb61943..f54cce77 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -155,6 +155,10 @@ private function compile_enqueued( $type, $dependencies = '' ) { $this->get_deps_to_be_compiled( $type, $asset, $fragments ); + if ( empty( $asset->src ) ) { + continue; + } + if ( 'style' === $type ) { // Add compiler media query if set. @@ -165,9 +169,7 @@ private function compile_enqueued( $type, $dependencies = '' ) { $assets->done[] = $handle; } - if ( $asset->src ) { - $fragments[ $handle ] = $asset->src; - } + $fragments[ $handle ] = $asset->src; } return $fragments; From b72ada339bd1d5b94c4ec87d0402275d577521cd Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 16:31:16 -0500 Subject: [PATCH 569/800] Optimized to process asset dependencies once. The previous design iterated through all assets and each asset's dependencies. If more than one asset used the same dependency, that dependency was processed more than once. For example, let's say we have 5 scripts and each of the require 'jquery' as a dependency. jQuery requires 2 other dependencies: 'jquery-core' and 'jquery-migrate'. The compile_enqueued() processed these dependencies 5 times, once for each script that specified it as a dependency. Wow, that's a lot of PHP cycles and memory consumption. We only need to process a dependency once. This change keeps track of each handle that is processed. If a handle has already been processed, it skips over the processing code. The results: 1. The Page Compiler is faster. 2. It uses less memory. --- .../compiler/class-beans-page-compiler.php | 63 ++++++++++++++++--- .../compilePageScripts.php | 28 +-------- .../beans-page-compiler/compilePageStyles.php | 13 +--- 3 files changed, 59 insertions(+), 45 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index f54cce77..38f83d84 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -32,6 +32,13 @@ final class _Beans_Page_Compiler { */ private $handles_not_to_compile = array( 'admin-bar', 'open-sans', 'dashicons' ); + /** + * An array of the handles that have been processed. + * + * @var array + */ + private $processed_handles = array(); + /** * Initialize the hooks. * @@ -57,7 +64,8 @@ public function compile_page_styles() { return; } - $styles = $this->compile_enqueued( 'style' ); + $this->processed_handles = array(); + $styles = $this->compile_enqueued( 'style' ); if ( empty( $styles ) ) { return; @@ -90,7 +98,8 @@ public function compile_page_scripts() { return; } - $scripts = $this->compile_enqueued( 'script' ); + $this->processed_handles = array(); + $scripts = $this->compile_enqueued( 'script' ); if ( empty( $scripts ) ) { return; @@ -147,6 +156,10 @@ private function compile_enqueued( $type, $dependencies = '' ) { continue; } + if ( $this->did_handle( $handle ) ) { + continue; + } + $asset = beans_get( $handle, $assets->registered ); if ( ! $asset ) { @@ -160,11 +173,7 @@ private function compile_enqueued( $type, $dependencies = '' ) { } if ( 'style' === $type ) { - - // Add compiler media query if set. - if ( 'all' !== $asset->args ) { - $asset->src = add_query_arg( array( 'beans_compiler_media_query' => $asset->args ), $asset->src ); - } + $this->maybe_add_media_query_to_src( $asset ); $assets->done[] = $handle; } @@ -175,6 +184,46 @@ private function compile_enqueued( $type, $dependencies = '' ) { return $fragments; } + /** + * Checks if the handle has already been processed. If no, it stores the handle. + * + * Note: This check eliminates processing dependencies that are in more than one asset. For example, if more than + * one script requires 'jquery', then this check ensures we only process jquery's dependencies once. + * + * @since 1.5.0 + * + * @param string $handle The asset's handle. + * + * @return bool + */ + private function did_handle( $handle ) { + if ( in_array( $handle, $this->processed_handles ) ) { + return true; + } + + $this->processed_handles[] = $handle; + + return false; + } + + /** + * When the args are not set to "all," adds the media query to the asset's src. + * + * @since 1.5.0 + * + * @param _WP_Dependency $asset The given asset. + * + * @return void + */ + private function maybe_add_media_query_to_src( $asset ) { + // Add compiler media query if set. + if ( 'all' === $asset->args ) { + return; + } + + $asset->src = add_query_arg( array( 'beans_compiler_media_query' => $asset->args ), $asset->src ); + } + /** * Checks the given asset's handle to determine if it should not be compiled. * diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php index 8cbf88b6..c87bfe7a 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php @@ -307,33 +307,7 @@ public function test_should_compile_scripts_and_deps() { ->once() ->with( 'uikit', $assets->registered ) ->andReturn( $assets->registered['uikit'] ) - ->andAlsoExpectIt() - // Recursive stack for dependencies. - ->ordered() - ->once() - ->with( 'wp_scripts', $GLOBALS ) - ->andReturn( $assets ) - ->andAlsoExpectIt() - ->ordered() - ->once() - ->with( 'jquery', $assets->registered ) - ->andReturn( $assets->registered['jquery'] ) - ->andAlsoExpectIt() - // Recursive stack for jquery's dependencies. - ->ordered() - ->once() - ->with( 'wp_scripts', $GLOBALS ) - ->andReturn( $assets ) - ->andAlsoExpectIt() - ->ordered() - ->once() - ->with( 'jquery-core', $assets->registered ) - ->andReturn( $assets->registered['jquery-core'] ) - ->andAlsoExpectIt() - ->ordered() - ->once() - ->with( 'jquery-migrate', $assets->registered ) - ->andReturn( $assets->registered['jquery-migrate'] ); + ->andAlsoExpectIt(); // Mock how beans_compile_js_fragments() will be called. Monkey\Functions\expect( 'beans_compile_js_fragments' ) diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php index 80341b0a..a834e698 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php @@ -330,16 +330,7 @@ public function test_should_compile_style_and_deps() { ->once() ->with( 'debug-bar-actions-filters', $assets->registered ) ->andReturn( $assets->registered['debug-bar-actions-filters'] ) - ->andAlsoExpectIt() - ->ordered() - ->once() - ->with( 'wp_styles', $GLOBALS ) - ->andReturn( $assets ) - ->andAlsoExpectIt() - ->ordered() - ->once() - ->with( 'debug-bar', $assets->registered ) - ->andReturn( $assets->registered['debug-bar'] ); + ->andAlsoExpectIt(); // Mock how beans_compile_css_fragments() will be called. Monkey\Functions\expect( 'beans_compile_css_fragments' ) @@ -360,7 +351,7 @@ public function test_should_compile_style_and_deps() { $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); // Check the asset's done state. - $this->assertSame( [ 'debug-bar', 'uikit', 'child-style', 'debug-bar', 'debug-bar-actions-filters' ], $assets->done ); + $this->assertSame( [ 'debug-bar', 'uikit', 'child-style', 'debug-bar-actions-filters' ], $assets->done ); } /** From d943d198902c2a1cdeca1b5b53c165bf06aeb78c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 19:43:09 -0500 Subject: [PATCH 570/800] Added integration tests. --- .../compiler/class-beans-page-compiler.php | 5 + .../compilePageScripts.php | 209 +++++++++++++++ .../beans-page-compiler/compilePageStyles.php | 244 ++++++++++++++++++ .../includes/class-compiler-test-case.php | 8 + .../class-page-compiler-test-case.php | 31 +++ 5 files changed, 497 insertions(+) create mode 100644 tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php create mode 100644 tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php create mode 100644 tests/phpunit/integration/api/compiler/includes/class-page-compiler-test-case.php diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 38f83d84..e6fd31cf 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -67,6 +67,11 @@ public function compile_page_styles() { $this->processed_handles = array(); $styles = $this->compile_enqueued( 'style' ); + if ( isset( $GLOBALS['tonya'] ) ) { + var_dump( $styles ); + die(); + } + if ( empty( $styles ) ) { return; } diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php new file mode 100644 index 00000000..49a31149 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php @@ -0,0 +1,209 @@ +registered[ $handle ] ); + } + + $GLOBALS['wp_scripts']->done = []; + + parent::tearDown(); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when the scripts compiler is not supported. + */ + public function test_should_not_compile_when_scripts_compiler_not_supported() { + beans_remove_api_component_support( 'wp_scripts_compiler' ); + + Monkey\Functions\expect( 'get_option' )->with( 'beans_compile_all_scripts', false )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when the "compile all scripts" option is not + * set. + */ + public function test_should_not_compile_when_option_is_not_set() { + beans_add_api_component_support( 'wp_scripts_compiler' ); + delete_option( 'beans_compile_all_scripts' ); + + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when in dev mode. + */ + public function test_should_not_compile_when_in_dev_mode() { + beans_add_api_component_support( 'wp_scripts_compiler' ); + update_option( 'beans_compile_all_scripts', 1 ); + update_option( 'beans_dev_mode', 1 ); + + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when there are not scripts. + */ + public function test_should_not_compile_when_there_are_not_scripts() { + beans_add_api_component_support( 'wp_scripts_compiler' ); + update_option( 'beans_compile_all_scripts', 1 ); + delete_option( 'beans_dev_mode' ); + + Monkey\Functions\expect( 'add_query_arg' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the tests. + $this->assertEmpty( $GLOBALS['wp_scripts']->queue ); + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when assets are admin bar only. + */ + public function test_should_not_compile_when_assets_are_admin_bar_only() { + beans_add_api_component_support( 'wp_scripts_compiler' ); + update_option( 'beans_compile_all_scripts', 1 ); + delete_option( 'beans_dev_mode' ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Enqueue the admin bar's script. + wp_enqueue_script( 'admin-bar' ); + $this->assertArrayHasKey( 'admin-bar', $GLOBALS['wp_scripts']->registered ); + $this->assertContains( 'admin-bar', $GLOBALS['wp_scripts']->queue ); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when scripts are not registered. + */ + public function test_should_not_compile_when_scripts_not_registered() { + beans_add_api_component_support( 'wp_scripts_compiler' ); + update_option( 'beans_compile_all_scripts', 1 ); + delete_option( 'beans_dev_mode' ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Enqueue the admin bar's script. + wp_enqueue_script( 'admin-bar' ); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should compile when the script has src but no dependencies. + */ + public function test_should_compile_when_script_has_src_but_no_deps() { + beans_add_api_component_support( 'wp_scripts_compiler' ); + update_option( 'beans_compile_all_scripts', 1 ); + delete_option( 'beans_dev_mode' ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Enqueue the scripts. + wp_enqueue_script( 'admin-bar' ); + wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); + wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js' ); + + // Mock how beans_compile_js_fragments() will be called. + Monkey\Functions\expect( 'beans_compile_js_fragments' ) + ->once() + ->with( + 'beans', + [ + 'test-compiler-js' => '/foo/tests/compiler.js', + 'test-uikit-js' => '/foo/tests/uikit.js', + ], + [ + 'in_footer' => true, + 'version' => null, + ] + ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_scripts() should compile scripts and dependencies. + */ + public function test_should_compile_scripts_and_deps() { + beans_add_api_component_support( 'wp_scripts_compiler' ); + update_option( 'beans_compile_all_scripts', 1 ); + delete_option( 'beans_dev_mode' ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Enqueue the scripts. + wp_enqueue_script( 'admin-bar' ); + wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); + wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js', [ 'jquery' ] ); + + // Mock how beans_compile_js_fragments() will be called. + Monkey\Functions\expect( 'beans_compile_js_fragments' ) + ->once() + ->with( + 'beans', + [ + 'jquery-core' => $GLOBALS['wp_scripts']->registered['jquery-core']->src, + 'jquery-migrate' => $GLOBALS['wp_scripts']->registered['jquery-migrate']->src, + 'test-compiler-js' => '/foo/tests/compiler.js', + 'test-uikit-js' => '/foo/tests/uikit.js', + ], + [ + 'in_footer' => true, + 'version' => null, + ] + ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); + } +} diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php new file mode 100644 index 00000000..805dd8be --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php @@ -0,0 +1,244 @@ +registered[ $handle ] ); + } + + $GLOBALS['wp_styles']->done = []; + + parent::tearDown(); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the styles compiler is not supported. + */ + public function test_should_not_compile_when_styles_compiler_not_supported() { + beans_remove_api_component_support( 'wp_styles_compiler' ); + + Monkey\Functions\expect( 'get_option' )->with( 'beans_compile_all_styles', false )->never(); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the "compile all styles" option is not + * set. + */ + public function test_should_not_compile_when_option_is_not_set() { + beans_add_api_component_support( 'wp_styles_compiler' ); + delete_option( 'beans_compile_all_styles' ); + Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when in dev mode. + */ + public function test_should_not_compile_when_in_dev_mode() { + beans_add_api_component_support( 'wp_styles_compiler' ); + update_option( 'beans_compile_all_styles', 1 ); + update_option( 'beans_dev_mode', 1 ); + Monkey\Functions\expect( 'beans_get' )->never(); + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when there are not styles. + */ + public function test_should_not_compile_when_there_are_not_styles() { + beans_add_api_component_support( 'wp_styles_compiler' ); + update_option( 'beans_compile_all_styles', 1 ); + delete_option( 'beans_dev_mode' ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Run the tests. + $this->assertEmpty( $GLOBALS['wp_styles']->queue ); + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when assets are admin bar only. + */ + public function test_should_not_compile_when_assets_are_admin_bar_only() { + beans_add_api_component_support( 'wp_styles_compiler' ); + update_option( 'beans_compile_all_styles', 1 ); + delete_option( 'beans_dev_mode' ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Enqueue the styles and then check that they are registered. + wp_enqueue_style( 'admin-bar' ); + wp_enqueue_style( 'open-sans' ); + wp_enqueue_style( 'dashicons' ); + $this->assertArrayHasKey( 'admin-bar', $GLOBALS['wp_styles']->registered ); + $this->assertContains( 'admin-bar', $GLOBALS['wp_styles']->queue ); + $this->assertArrayHasKey( 'open-sans', $GLOBALS['wp_styles']->registered ); + $this->assertContains( 'open-sans', $GLOBALS['wp_styles']->queue ); + $this->assertArrayHasKey( 'dashicons', $GLOBALS['wp_styles']->registered ); + $this->assertContains( 'dashicons', $GLOBALS['wp_styles']->queue ); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the style is not registered. + */ + public function test_should_not_compile_when_style_is_not_registered() { + beans_add_api_component_support( 'wp_styles_compiler' ); + update_option( 'beans_compile_all_styles', 1 ); + delete_option( 'beans_dev_mode' ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); + + // Enqueue the style. + wp_enqueue_style( 'admin-bar' ); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should compile when the style has src but no dependencies. + */ + public function test_should_compile_when_style_has_src_but_no_deps() { + beans_add_api_component_support( 'wp_styles_compiler' ); + update_option( 'beans_compile_all_styles', 1 ); + delete_option( 'beans_dev_mode' ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Enqueue the styles. + wp_enqueue_style( 'admin-bar' ); + wp_enqueue_style( 'test-compiler-css', '/foo/tests/compiler.css' ); + wp_enqueue_style( 'test-uikit-css', '/foo/tests/uikit.css' ); + + // Mock how beans_compile_css_fragments() will be called. + Monkey\Functions\expect( 'beans_compile_css_fragments' ) + ->once() + ->with( + 'beans', + [ + 'test-compiler-css' => '/foo/tests/compiler.css', + 'test-uikit-css' => '/foo/tests/uikit.css', + ], + [ 'version' => null ] + ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + + // Check the asset's done state. + $this->assertSame( [ 'test-compiler-css', 'test-uikit-css' ], $GLOBALS['wp_styles']->done ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should add the query arg to the compiled style's src. + */ + public function test_should_add_query_arg_to_compiled_style_src() { + beans_add_api_component_support( 'wp_styles_compiler' ); + update_option( 'beans_compile_all_styles', 1 ); + + // Enqueue the styles. + wp_enqueue_style( 'admin-bar' ); + wp_enqueue_style( 'test-compiler-css', '/foo/tests/compiler.css', [], null, 'screen' ); + wp_enqueue_style( 'test-uikit-css', '/foo/tests/uikit.css', [], null, '(max-width: 640px)' ); + + // Mock how beans_compile_css_fragments() will be called. + Monkey\Functions\expect( 'beans_compile_css_fragments' ) + ->once() + ->with( + 'beans', + [ + 'test-compiler-css' => '/foo/tests/compiler.css?beans_compiler_media_query=screen', + 'test-uikit-css' => '/foo/tests/uikit.css?beans_compiler_media_query=(max-width: 640px)', + ], + [ 'version' => null ] + ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + + // Check the asset's done state. + $this->assertSame( [ 'test-compiler-css', 'test-uikit-css' ], $GLOBALS['wp_styles']->done ); + } + + /** + * Test _Beans_Page_Compiler::compile_page_styles() should compile styles and dependencies. + */ + public function test_should_compile_style_and_deps() { + beans_add_api_component_support( 'wp_styles_compiler' ); + update_option( 'beans_compile_all_styles', 1 ); + delete_option( 'beans_dev_mode' ); + Monkey\Functions\expect( 'add_query_arg' )->never(); + + // Enqueue the styles. + wp_enqueue_style( 'admin-bar' ); + wp_enqueue_style( 'test-compiler-css', '/foo/tests/compiler.css' ); + wp_enqueue_style( 'test-uikit-css', '/foo/tests/uikit.css', [ 'test-compiler-css' ] ); + + // Mock how beans_compile_css_fragments() will be called. + Monkey\Functions\expect( 'beans_compile_css_fragments' ) + ->once() + ->with( + 'beans', + [ + 'test-compiler-css' => '/foo/tests/compiler.css', + 'test-uikit-css' => '/foo/tests/uikit.css', + ], + [ 'version' => null ] + ) + ->andReturnNull(); + + // Run the tests. + $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); + + // Check the asset's done state. + $this->assertSame( [ 'test-compiler-css', 'test-uikit-css' ], $GLOBALS['wp_styles']->done ); + } +} diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index 69596266..8e2a08a3 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -67,6 +67,14 @@ public static function setUpBeforeClass() { * Tear down the test fixture. */ public function tearDown() { + wp_dequeue_script( 'test-jquery' ); + unset( $GLOBALS['wp_scripts']->registered['test-jquery'] ); + wp_dequeue_script( 'test-script' ); + unset( $GLOBALS['wp_scripts']->registered['test-script'] ); + wp_dequeue_script( 'test-js' ); + unset( $GLOBALS['wp_scripts']->registered['test-js'] ); + wp_dequeue_style( 'test-css' ); + unset( $GLOBALS['wp_styles']->registered['test-css'] ); unset( $GLOBALS['wp_filesystem'] ); parent::tearDown(); } diff --git a/tests/phpunit/integration/api/compiler/includes/class-page-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-page-compiler-test-case.php new file mode 100644 index 00000000..4ddaf102 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/includes/class-page-compiler-test-case.php @@ -0,0 +1,31 @@ + Date: Sat, 12 May 2018 20:17:45 -0500 Subject: [PATCH 571/800] Added tests for dequeue_scripts. --- .../beans-page-compiler/dequeueScripts.php | 130 +++++++++++ .../beans-page-compiler/dequeueScripts.php | 216 ++++++++++++++++++ 2 files changed, 346 insertions(+) create mode 100644 tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php create mode 100644 tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php new file mode 100644 index 00000000..9504886f --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php @@ -0,0 +1,130 @@ +registered[ $handle ] ); + } + + $GLOBALS['wp_scripts']->done = []; + + parent::tearDown(); + } + + /** + * Test _Beans_Page_Compiler::dequeue_scripts() should not dequeue scripts when there are no scripts. + */ + public function test_should_not_dequeue_scripts_when_no_scripts() { + $this->assertNull( ( new _Beans_Page_Compiler() )->dequeue_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::dequeue_scripts() should not dequeue when no scripts are registered. + */ + public function test_should_not_dequeue_when_no_scripts_registered() { + $compiler = new _Beans_Page_Compiler(); + $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); + $dequeued_scripts->setValue( $compiler, [ 'test-compiler-js', 'test-uikit-js' ] ); + + $this->assertNull( $compiler->dequeue_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::dequeue_scripts() should dequeue scripts. + */ + public function test_should_dequeue_scripts() { + $compiler = new _Beans_Page_Compiler(); + $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); + $dequeued_scripts->setValue( $compiler, [ + 'test-compiler-js' => '/foo/tests/compiler.js', + 'test-uikit-js' => '/foo/tests/uikit.js', + ] ); + + // Set up the scripts. + wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); + wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js' ); + + // Run the tests. + $this->assertNull( $compiler->dequeue_scripts() ); + $this->assertSame( [ 'test-compiler-js', 'test-uikit-js' ], $GLOBALS['wp_scripts']->done ); + } + + /** + * Test _Beans_Page_Compiler::dequeue_scripts() should not print the inline localization when no scripts have + * localized data. + */ + public function test_should_not_print_inline_when_no_scripts_have_localized_data() { + $compiler = new _Beans_Page_Compiler(); + $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); + $dequeued_scripts->setValue( $compiler, [ + 'test-compiler-js' => '/foo/tests/compiler.js', + 'test-uikit-js' => '/foo/tests/uikit.js', + ] ); + + // Set up the scripts. + wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); + wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js' ); + + // Run the test. + ob_start(); + $compiler->dequeue_scripts(); + $this->assertSame( '', ob_get_clean() ); + } + + /** + * Test _Beans_Page_Compiler::dequeue_scripts() should print the inline localization content. + */ + public function test_should_print_inline_localization_content() { + $compiler = new _Beans_Page_Compiler(); + $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); + $dequeued_scripts->setValue( $compiler, [ + 'test-compiler-js' => '/foo/tests/compiler.js', + 'test-uikit-js' => '/foo/tests/uikit.js', + ] ); + + // Set up the scripts. + wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); + wp_localize_script( 'test-compiler-js', 'testParams', 'hello-beans' ); + wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js' ); + + // Run the tests. + ob_start(); + $compiler->dequeue_scripts(); + $inline_script = ob_get_clean(); + + $expected = << + var testParams = "hello-beans"; + + +EOB; + + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $inline_script ) ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php new file mode 100644 index 00000000..4b819b15 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php @@ -0,0 +1,216 @@ +never(); + + // Run the test. + $this->assertNull( ( new _Beans_Page_Compiler() )->dequeue_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::dequeue_scripts() should not dequeue when no scripts are registered. + */ + public function test_should_not_dequeue_when_no_scripts_registered() { + $assets = $this->get_mock_assets( [ 'uikit' ] ); + $compiler = new _Beans_Page_Compiler(); + + // Set the scripts to be dequeued. + $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); + $dequeued_scripts->setValue( $compiler, [ 'uikit' => $assets->registered['uikit']->src ] ); + + // Set up the asset mocks. + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( null ); + + // Run the tests. + $this->assertNull( $compiler->dequeue_scripts() ); + } + + /** + * Test _Beans_Page_Compiler::dequeue_scripts() should dequeue scripts. + */ + public function test_should_dequeue_scripts() { + $assets = $this->get_mock_assets( [ 'debug-bar', 'uikit' ] ); + $compiler = new _Beans_Page_Compiler(); + + // Set the scripts to be dequeued. + $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); + $dequeued_scripts->setValue( $compiler, [ + 'debug-bar' => $assets->registered['debug-bar']->src, + 'uikit' => $assets->registered['uikit']->src, + ] ); + + // Set up the asset mocks. + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'debug-bar', $assets->registered ) + ->andReturn( $assets->registered['debug-bar'] ) + ->andAlsoExpectIt() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ); + + // Run the tests. + $this->assertNull( $compiler->dequeue_scripts() ); + + global $wp_scripts; + $this->assertSame( [ 'debug-bar', 'uikit' ], $wp_scripts->done ); + } + + /** + * Test _Beans_Page_Compiler::dequeue_scripts() should not print the inline localization when no scripts have + * localized data. + */ + public function test_should_not_print_inline_when_no_scripts_have_localized_data() { + $assets = $this->get_mock_assets( [ 'debug-bar', 'uikit' ] ); + $compiler = new _Beans_Page_Compiler(); + + // Set the scripts to be dequeued. + $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); + $dequeued_scripts->setValue( $compiler, [ + 'debug-bar' => $assets->registered['debug-bar']->src, + 'uikit' => $assets->registered['uikit']->src, + ] ); + + // Set up the asset mocks. + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'debug-bar', $assets->registered ) + ->andReturn( $assets->registered['debug-bar'] ) + ->andAlsoExpectIt() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ); + + // Run the tests. + ob_start(); + $compiler->dequeue_scripts(); + $this->assertSame( '', ob_get_clean() ); + } + + /** + * Test _Beans_Page_Compiler::dequeue_scripts() should print the inline localization content. + */ + public function test_should_print_inline_localization_content() { + $assets = $this->get_mock_assets( [ 'debug-bar', 'uikit' ], true ); + $compiler = new _Beans_Page_Compiler(); + + // Set the scripts to be dequeued. + $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); + $dequeued_scripts->setValue( $compiler, [ + 'debug-bar' => $assets->registered['debug-bar']->src, + 'uikit' => $assets->registered['uikit']->src, + ] ); + + // Set up the asset mocks. + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'debug-bar', $assets->registered ) + ->andReturn( $assets->registered['debug-bar'] ) + ->andAlsoExpectIt() + ->once() + ->with( 'uikit', $assets->registered ) + ->andReturn( $assets->registered['uikit'] ); + + // Run the tests. + ob_start(); + $compiler->dequeue_scripts(); + $inline_script = ob_get_clean(); + + $expected = << + var testParams = "hello-beans"; + +EOB; + + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $inline_script ) ); + } + + /** + * Get the mocked assets. + * + * @since 1.5.0 + * + * @param array $queue Array of assets to build. + * @param bool $with_extras When true, adds the extras for localization. Default is false. + * + * @return \Mockery\MockInterface + */ + protected function get_mock_assets( array $queue, $with_extras = false ) { + $wp_scripts_mock = Mockery::mock( 'WP_Scripts' ); + $wp_scripts_mock->queue = $queue; + $registered = [ + 'jquery' => $this->get_deps_mock( [ + 'handle' => 'jquery', + 'src' => false, + 'deps' => [ 'jquery-core', 'jquery-migrate' ], + 'ver' => '1.12.4', + ] ), + 'jquery-core' => $this->get_deps_mock( [ + 'handle' => 'jquery-core', + 'src' => '/wp-includes/js/jquery/jquery.js', + 'ver' => '1.12.4', + ] ), + 'jquery-migrate' => $this->get_deps_mock( [ + 'handle' => 'jquery-migrate', + 'src' => '/wp-includes/js/jquery/jquery-migrate.js', + 'ver' => '1.4.1', + ] ), + ]; + + if ( in_array( 'debug-bar', $queue, true ) ) { + $registered['debug-bar'] = $this->get_deps_mock( [ + 'handle' => 'debug-bar', + 'src' => '/wp-content/plugins/debug-bar/js/debug-bar.dev.js', + 'deps' => [ 'jquery' ], + 'ver' => '20170515', + 'extra' => $with_extras ? [ 'data' => 'var testParams = "hello-beans";' ] : [], + ] ); + } + + if ( in_array( 'uikit', $queue, true ) ) { + $registered['uikit'] = $this->get_deps_mock( [ + 'handle' => 'uikit', + 'src' => 'wp-content/uploads/beans/compiler/uikit/3b2a958-921f3e0.js', + 'deps' => [ 'jquery' ], + ] ); + } + + $wp_scripts_mock->registered = $registered; + + global $wp_scripts; + $wp_scripts = $wp_scripts_mock; + + return $wp_scripts_mock; + } +} From 5425bf778ea1f59b072248fc3ae6e764aa982f03 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 20:46:57 -0500 Subject: [PATCH 572/800] Renamed $id to $handle. It better represents what the value is, making it more readable. --- lib/api/compiler/class-beans-page-compiler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index e6fd31cf..6cd41bc6 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -287,9 +287,9 @@ public function dequeue_scripts() { $localized = ''; // Fetch the localized content and dequeue script. - foreach ( $this->dequeued_scripts as $id => $src ) { + foreach ( $this->dequeued_scripts as $handle => $src ) { - $args = beans_get( $id, $wp_scripts->registered ); + $args = beans_get( $handle, $wp_scripts->registered ); if ( ! $args ) { continue; @@ -299,7 +299,7 @@ public function dequeue_scripts() { $localized .= $args->extra['data'] . "\n"; } - $wp_scripts->done[] = $id; + $wp_scripts->done[] = $handle; } // Stop here if there isn't any content to add. From a3373a803869b94fed667f8cde2000a9c6a66f32 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 20:50:27 -0500 Subject: [PATCH 573/800] Renamed $args to $script. More readable. --- lib/api/compiler/class-beans-page-compiler.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 6cd41bc6..4246dce4 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -278,31 +278,29 @@ private function get_deps_to_be_compiled( $type, $asset, array &$srcs ) { * @return void */ public function dequeue_scripts() { - global $wp_scripts; if ( empty( $this->dequeued_scripts ) ) { return; } + global $wp_scripts; $localized = ''; // Fetch the localized content and dequeue script. foreach ( $this->dequeued_scripts as $handle => $src ) { + $script = beans_get( $handle, $wp_scripts->registered ); - $args = beans_get( $handle, $wp_scripts->registered ); - - if ( ! $args ) { + if ( ! $script ) { continue; } - if ( isset( $args->extra['data'] ) ) { - $localized .= $args->extra['data'] . "\n"; + if ( isset( $script->extra['data'] ) ) { + $localized .= $script->extra['data'] . "\n"; } $wp_scripts->done[] = $handle; } - // Stop here if there isn't any content to add. if ( empty( $localized ) ) { return; } From 76fdadb94afded28f614e0cca850a932e766f181 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 20:58:47 -0500 Subject: [PATCH 574/800] Moved the inline script to a view file. Separation of concerns. --- lib/api/compiler/class-beans-page-compiler.php | 2 +- lib/api/compiler/views/localized-content.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 lib/api/compiler/views/localized-content.php diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 4246dce4..41cc69e3 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -306,6 +306,6 @@ public function dequeue_scripts() { } // Add localized content since it was removed with dequeue scripts. - printf( "\n", $localized ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Needs review. + require dirname( __FILE__ ) . '/views/localized-content.php'; } } diff --git a/lib/api/compiler/views/localized-content.php b/lib/api/compiler/views/localized-content.php new file mode 100644 index 00000000..631272a4 --- /dev/null +++ b/lib/api/compiler/views/localized-content.php @@ -0,0 +1,15 @@ + + + From c84b03f6004eba0be46ab0a9b90b3d0c2f32094f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 12 May 2018 21:50:12 -0500 Subject: [PATCH 575/800] Fixed formatting. Improved documentation. --- lib/api/compiler/class-beans-page-compiler.php | 7 +------ .../api/compiler/beans-page-compiler/dequeueScripts.php | 4 ++-- .../compiler/includes/class-compiler-options-test-case.php | 2 +- .../compiler/includes/class-page-compiler-test-case.php | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 41cc69e3..74048f38 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -67,11 +67,6 @@ public function compile_page_styles() { $this->processed_handles = array(); $styles = $this->compile_enqueued( 'style' ); - if ( isset( $GLOBALS['tonya'] ) ) { - var_dump( $styles ); - die(); - } - if ( empty( $styles ) ) { return; } @@ -202,7 +197,7 @@ private function compile_enqueued( $type, $dependencies = '' ) { * @return bool */ private function did_handle( $handle ) { - if ( in_array( $handle, $this->processed_handles ) ) { + if ( in_array( $handle, $this->processed_handles, true ) ) { return true; } diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php index 4b819b15..b50f78d3 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php @@ -44,7 +44,7 @@ public function test_should_not_dequeue_when_no_scripts_registered() { // Set the scripts to be dequeued. $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ 'uikit' => $assets->registered['uikit']->src ] ); + $dequeued_scripts->setValue( $compiler, [ 'uikit' => $assets->registered['uikit']->src ] ); // Set up the asset mocks. Monkey\Functions\expect( 'beans_get' ) @@ -209,7 +209,7 @@ protected function get_mock_assets( array $queue, $with_extras = false ) { $wp_scripts_mock->registered = $registered; global $wp_scripts; - $wp_scripts = $wp_scripts_mock; + $wp_scripts = $wp_scripts_mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case to load mocks for tests. return $wp_scripts_mock; } diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php index b75d4d35..c48df6e8 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php @@ -1,6 +1,6 @@ Date: Sun, 13 May 2018 12:15:32 -0500 Subject: [PATCH 576/800] Renamed class to comply with WPCS. --- lib/api/components.php | 2 +- .../{class-options.php => class-beans-image-options.php} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename lib/api/image/{class-options.php => class-beans-image-options.php} (95%) diff --git a/lib/api/components.php b/lib/api/components.php index 6efcc6a2..e0f06331 100644 --- a/lib/api/components.php +++ b/lib/api/components.php @@ -61,7 +61,7 @@ function beans_load_api_components( $components ) { 'post-meta' => $root . 'post-meta/functions-admin.php', 'term-meta' => $root . 'term-meta/functions-admin.php', 'compiler' => $root . 'compiler/class-beans-compiler-options.php', - 'image' => $root . 'image/class-options.php', + 'image' => $root . 'image/class-beans-image-options.php', '_admin_menu' => $root . 'admin-menu.php', // Internal use. ); } else { diff --git a/lib/api/image/class-options.php b/lib/api/image/class-beans-image-options.php similarity index 95% rename from lib/api/image/class-options.php rename to lib/api/image/class-beans-image-options.php index 4f17c254..98b34533 100644 --- a/lib/api/image/class-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -1,6 +1,6 @@ Date: Sun, 13 May 2018 12:17:04 -0500 Subject: [PATCH 577/800] Refactored to instantiate through callback. The v1.4.x design is difficult to nearly impossible to test. Why? 1. We can't grab the instance of the object. 2. We can't reload the file for subsequent tests, i.e. as it would cause a fatal error for reloading the same class into memory. -------------------- How do we fix this? -------------------- First of all, we have to return the instance of the object. That solves 1st issue. For 2nd issue, we have a couple of choices: 1. Wrap the entire class in a `class_exists()` conditional to avoid a fatal error upon reloading the file. (This is less readable.) 2. Create the object outside of the class file. ----------------- Proposed solution ----------------- This commit uses the 2nd option. Instead of automatically instantiating upon file load, added a new callback, that is hooked into after the compiler components are loaded into memory. --- lib/api/image/class-beans-image-options.php | 13 +++++++------ lib/api/image/functions.php | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index 98b34533..01b75c46 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -24,7 +24,7 @@ final class _Beans_Image_Options { public function __construct() { // Load with priority 15 so that we can check if other Beans metaboxes exist. add_action( 'admin_init', array( $this, 'register' ), 15 ); - add_action( 'admin_init', array( $this, 'flush' ), -1 ); + add_action( 'admin_init', array( $this, 'flush' ), - 1 ); add_action( 'admin_notices', array( $this, 'admin_notice' ) ); add_action( 'beans_field_flush_edited_images', array( $this, 'option' ) ); } @@ -49,7 +49,8 @@ public function register() { beans_register_options( $fields, 'beans_settings', 'images_options', array( 'title' => __( 'Images options', 'tm-beans' ), - 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', // Check of other beans boxes. + 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', + // Check of other beans boxes. ) ); } @@ -83,7 +84,8 @@ public function admin_notice() { } ?> -

    +

    +
    - + Date: Sun, 13 May 2018 12:18:45 -0500 Subject: [PATCH 578/800] Moved the hooks into an init() method. Hooks should be part of the object's initialization instead of automatically running them during instantiation process. --- lib/api/image/class-beans-image-options.php | 8 ++++++-- lib/api/image/functions.php | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index 01b75c46..4328b821 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -19,9 +19,13 @@ final class _Beans_Image_Options { /** - * Constructor. + * Initialize the hooks. + * + * @since 1.5.0 + * + * @return void */ - public function __construct() { + public function init() { // Load with priority 15 so that we can check if other Beans metaboxes exist. add_action( 'admin_init', array( $this, 'register' ), 15 ); add_action( 'admin_init', array( $this, 'flush' ), - 1 ); diff --git a/lib/api/image/functions.php b/lib/api/image/functions.php index ac6d936a..f9b5506c 100644 --- a/lib/api/image/functions.php +++ b/lib/api/image/functions.php @@ -121,7 +121,7 @@ function beans_get_images_dir() { add_action( 'beans_loaded_api_component_image', 'beans_add_image_options_to_settings' ); /** - * Add the "impage options" to the Beans Settings page. + * Add the "image options" to the Beans Settings page. * * @since 1.5.0 * @@ -133,5 +133,8 @@ function beans_add_image_options_to_settings() { return; } - return new _Beans_Image_Options(); + $instance = new _Beans_Image_Options(); + $instance->init(); + + return $instance; } From 49995f5da15c3d3bb790256eae6dcfd27ea6e5c7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 13 May 2018 12:44:11 -0500 Subject: [PATCH 579/800] Reworked test cases to break up tasks. The other tasks in the Image API do not need everything that is defined in the original test case. This change splits it up to reduce complexity and ensure that each test has what it needs. --- .../image/includes/class-base-test-case.php | 84 +++++++++++++++++++ .../image/includes/class-image-test-case.php | 60 ++----------- .../includes/class-options-test-case.php | 32 +++++++ 3 files changed, 125 insertions(+), 51 deletions(-) create mode 100644 tests/phpunit/unit/api/image/includes/class-base-test-case.php create mode 100644 tests/phpunit/unit/api/image/includes/class-options-test-case.php diff --git a/tests/phpunit/unit/api/image/includes/class-base-test-case.php b/tests/phpunit/unit/api/image/includes/class-base-test-case.php new file mode 100644 index 00000000..4e99c05d --- /dev/null +++ b/tests/phpunit/unit/api/image/includes/class-base-test-case.php @@ -0,0 +1,84 @@ +set_up_virtual_filesystem(); + + $this->load_original_functions( array( + 'api/utilities/functions.php', + 'api/image/functions.php', + ) ); + + $this->setup_common_wp_stubs(); + } + + /** + * Set up the virtual filesystem. + */ + protected function set_up_virtual_filesystem() { + $this->mock_filesystem = vfsStream::setup( + 'uploads', + 0755, + $this->get_virtual_structure() + ); + $this->images_dir = vfsStream::url( 'uploads/beans/images' ); + $this->images_url = 'http://example.com/uploads/beans/images/'; + } + + /** + * Get the virtual filesystem's structure. + */ + protected function get_virtual_structure() { + return array( + 'beans' => array( + 'images' => array( + 'index.php' => '', + ), + ), + ); + } +} diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index 474c8a18..ad0a58c2 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -11,16 +11,17 @@ namespace Beans\Framework\Tests\Unit\API\Image\Includes; -use Beans\Framework\Tests\Unit\Test_Case; use Brain\Monkey; use org\bovigo\vfs\vfsStream; +require_once __DIR__ . '/class-base-test-case.php'; + /** * Abstract Class Image_Test_Case * * @package Beans\Framework\Tests\Unit\API\Image\Includes */ -abstract class Image_Test_Case extends Test_Case { +abstract class Image_Test_Case extends Base_Test_Case { /** * When true, return the given path when doing wp_normalize_path(). @@ -29,27 +30,6 @@ abstract class Image_Test_Case extends Test_Case { */ protected $just_return_path = true; - /** - * Path to the images' directory. - * - * @var string - */ - protected $images_dir; - - /** - * Path to the images directory's URL. - * - * @var string - */ - protected $images_url; - - /** - * Instance of vfsStreamDirectory to mock the filesystem. - * - * @var vfsStreamDirectory - */ - protected $mock_filesystem; - /** * Flag is in admin area (back-end). * @@ -92,38 +72,16 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( - 'api/image/functions.php', - 'api/image/class-beans-image-editor.php', - 'api/utilities/functions.php', - ) ); - - $this->set_up_virtual_filesystem(); - $this->setup_function_mocks(); - $this->images = array( + $this->load_original_functions( [ + 'api/image/class-beans-image-editor.php', + ] ); + + $this->images = [ $this->images_dir . '/image1.jpg' => static::$fixtures_dir . '/image1.jpg', $this->images_dir . '/image2.jpg' => static::$fixtures_dir . '/image2.jpg', - ); - } - - /** - * Set up the virtual filesystem. - */ - private function set_up_virtual_filesystem() { - $structure = array( - 'beans' => array( - 'images' => array( - 'index.php' => '', - ), - ), - ); - - // Set up the "beans" directory's virtual filesystem. - $this->mock_filesystem = vfsStream::setup( 'uploads', 0755, $structure ); - $this->images_dir = vfsStream::url( 'uploads/beans/images' ); - $this->images_url = 'http://example.com/uploads/beans/images/'; + ]; } /** diff --git a/tests/phpunit/unit/api/image/includes/class-options-test-case.php b/tests/phpunit/unit/api/image/includes/class-options-test-case.php new file mode 100644 index 00000000..2aae7273 --- /dev/null +++ b/tests/phpunit/unit/api/image/includes/class-options-test-case.php @@ -0,0 +1,32 @@ +load_original_functions( array( + 'api/image/class-beans-image-options.php', + 'api/options/functions.php', + ) ); + } +} From 87a785814d2feea18747f9ed234f2baf597d6b5b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 13 May 2018 14:39:59 -0500 Subject: [PATCH 580/800] Added tests suite. --- lib/api/image/class-beans-image-options.php | 8 +- .../image/beans-image-options/adminNotice.php | 59 ++++++++++ .../api/image/beans-image-options/flush.php | 58 ++++++++++ .../api/image/beans-image-options/option.php | 49 ++++++++ .../image/beans-image-options/register.php | 105 ++++++++++++++++++ .../image/includes/class-base-test-case.php | 100 +++++++++++++++++ .../image/includes/class-image-test-case.php | 53 +-------- .../includes/class-options-test-case.php | 48 ++++++++ .../image/beans-image-options/adminNotice.php | 61 ++++++++++ .../api/image/beans-image-options/flush.php | 74 ++++++++++++ .../api/image/beans-image-options/option.php | 51 +++++++++ .../image/beans-image-options/register.php | 100 +++++++++++++++++ 12 files changed, 711 insertions(+), 55 deletions(-) create mode 100644 tests/phpunit/integration/api/image/beans-image-options/adminNotice.php create mode 100644 tests/phpunit/integration/api/image/beans-image-options/flush.php create mode 100644 tests/phpunit/integration/api/image/beans-image-options/option.php create mode 100644 tests/phpunit/integration/api/image/beans-image-options/register.php create mode 100644 tests/phpunit/integration/api/image/includes/class-base-test-case.php create mode 100644 tests/phpunit/integration/api/image/includes/class-options-test-case.php create mode 100644 tests/phpunit/unit/api/image/beans-image-options/adminNotice.php create mode 100644 tests/phpunit/unit/api/image/beans-image-options/flush.php create mode 100644 tests/phpunit/unit/api/image/beans-image-options/option.php create mode 100644 tests/phpunit/unit/api/image/beans-image-options/register.php diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index 4328b821..4e93a4a6 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -38,7 +38,7 @@ public function init() { * * @since 1.0.0 * - * @return void + * @return bool */ public function register() { global $wp_meta_boxes; @@ -51,10 +51,9 @@ public function register() { ), ); - beans_register_options( $fields, 'beans_settings', 'images_options', array( + return beans_register_options( $fields, 'beans_settings', 'images_options', array( 'title' => __( 'Images options', 'tm-beans' ), 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', - // Check of other beans boxes. ) ); } @@ -109,8 +108,7 @@ public function option( $field ) { } ?> - + go_to_settings_page(); + $this->assertArrayNotHasKey( 'beans_flush_edited_images', $_POST ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- No need for nonce in this test. + + ob_start(); + ( new _Beans_Image_Options() )->admin_notice(); + $this->assertEmpty( ob_get_clean() ); + } + + /** + * Test _Beans_Image_Options::admin_notice() should render when flushing edited images cache. + */ + public function test_should_render_when_flushing_edited_images_cache() { + $this->go_to_settings_page(); + $_POST['beans_flush_edited_images'] = 1; + + ob_start(); + ( new _Beans_Image_Options() )->admin_notice(); + $actual = ob_get_clean(); + + $expected = << +

    Images flushed successfully!

    + +EOB; + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); + + // Clean up. + unset( $_POST['beans_flush_edited_images'] ); + } +} diff --git a/tests/phpunit/integration/api/image/beans-image-options/flush.php b/tests/phpunit/integration/api/image/beans-image-options/flush.php new file mode 100644 index 00000000..9c2a2ef5 --- /dev/null +++ b/tests/phpunit/integration/api/image/beans-image-options/flush.php @@ -0,0 +1,58 @@ +directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); + + $this->assertNull( ( new _Beans_Image_Options() )->flush() ); + + // Check that it still exists and was not removed. + $this->directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); + } + + /** + * Test _Beans_Image_Options::flush() should remove the cached directory. + */ + public function test_should_remove_cached_dir() { + // Check that the cached directory exists before we start. + $this->directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); + + $this->go_to_settings_page(); + $_POST['beans_flush_edited_images'] = 1; + + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. + Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); + + $this->assertNull( ( new _Beans_Image_Options() )->flush() ); + $this->assertDirectoryNotExists( vfsStream::url( 'uploads/beans/images/' ) ); + } +} diff --git a/tests/phpunit/integration/api/image/beans-image-options/option.php b/tests/phpunit/integration/api/image/beans-image-options/option.php new file mode 100644 index 00000000..20974f9b --- /dev/null +++ b/tests/phpunit/integration/api/image/beans-image-options/option.php @@ -0,0 +1,49 @@ +option( [ 'id' => 'foo' ] ); + $this->assertEmpty( ob_get_clean() ); + } + + /** + * Test _Beans_Image_Options::option() should render when the field is for image options. + */ + public function test_should_render_when_field_is_image_options() { + ob_start(); + ( new _Beans_Image_Options() )->option( [ 'id' => 'beans_edited_images_directories' ] ); + $actual = ob_get_clean(); + + $expected = << +EOB; + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); + } +} diff --git a/tests/phpunit/integration/api/image/beans-image-options/register.php b/tests/phpunit/integration/api/image/beans-image-options/register.php new file mode 100644 index 00000000..fcd2ae81 --- /dev/null +++ b/tests/phpunit/integration/api/image/beans-image-options/register.php @@ -0,0 +1,105 @@ +fields = [ + [ + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + 'description' => 'Clear all edited images. New images will be created on page load.', + ], + ]; + + require_once BEANS_THEME_DIR . '/lib/api/options/functions.php'; + } + + /** + * Test _Beans_Image_Options::register() should register the options with column context when other metaboxes are + * registered. + */ + public function test_should_register_options_with_column_context_when_other_metaboxes_are_registered() { + $this->go_to_settings_page(); + + global $wp_meta_boxes; + $wp_meta_boxes = [ 'beans_settings' => [ 'foo' ] ]; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case to set up the test. + + $this->assertTrue( ( new _Beans_Image_Options() )->register() ); + + // Check that the right fields did get registered. + $registered_fields = beans_get_fields( 'option', 'images_options' ); + $this->assertCount( 1, $registered_fields ); + $this->assertArraySubset( [ + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + ], current( $registered_fields ) ); + + // Check that the metabox did get registered. + global $wp_meta_boxes; + $this->assertArrayHasKey( 'images_options', $wp_meta_boxes['beans_settings']['column']['default'] ); + $this->assertEquals( 'Images options', $wp_meta_boxes['beans_settings']['column']['default']['images_options']['title'] ); + + // Clean up. + unset( $wp_meta_boxes['beans_settings'] ); + } + + /** + * Test _Beans_Image_Options::register() should register the options with normal context when no metaboxes are + * registered. + */ + public function test_should_register_options_with_normal_context_when_no_metaboxes_are_registered() { + $this->go_to_settings_page(); + + $this->assertTrue( ( new _Beans_Image_Options() )->register() ); + + // Check that the right fields did get registered. + $registered_fields = beans_get_fields( 'option', 'images_options' ); + $this->assertCount( 1, $registered_fields ); + $this->assertArraySubset( [ + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + ], current( $registered_fields ) ); + + // Check that the metabox did get registered. + global $wp_meta_boxes; + $this->assertArrayHasKey( 'images_options', $wp_meta_boxes['beans_settings']['normal']['default'] ); + $this->assertEquals( 'Images options', $wp_meta_boxes['beans_settings']['normal']['default']['images_options']['title'] ); + + // Clean up. + unset( $wp_meta_boxes['beans_settings'] ); + } +} diff --git a/tests/phpunit/integration/api/image/includes/class-base-test-case.php b/tests/phpunit/integration/api/image/includes/class-base-test-case.php new file mode 100644 index 00000000..ba0f5908 --- /dev/null +++ b/tests/phpunit/integration/api/image/includes/class-base-test-case.php @@ -0,0 +1,100 @@ +set_up_virtual_filesystem(); + + // Set the Uploads directory to our virtual filesystem. + add_filter( 'upload_dir', function( array $uploads_dir ) { + $virtual_dir = vfsStream::url( 'uploads' ); + $uploads_dir['path'] = $virtual_dir . $uploads_dir['subdir']; + $uploads_dir['basedir'] = $virtual_dir; + + return $uploads_dir; + } ); + } + + /** + * Tear down the test fixture. + */ + public function tearDown() { + Mockery::close(); + parent::tearDown(); + } + + /** + * Set up the virtual filesystem. + */ + protected function set_up_virtual_filesystem() { + $this->mock_filesystem = vfsStream::setup( + 'uploads', + 0755, + $this->get_virtual_structure() + ); + $this->images_dir = vfsStream::url( 'uploads/beans/images' ); + } + + /** + * Get the virtual filesystem's structure. + */ + protected function get_virtual_structure() { + return array( + 'beans' => array( + 'images' => array( + 'index.php' => '', + ), + ), + ); + } + + /** + * Set Development Mode. + * + * @since 1.5.0 + * + * @param bool $is_enabled Optional. When true, turns on development mode. Default is false. + * + * @return void + */ + protected function set_dev_mode( $is_enabled = false ) { + update_option( 'beans_dev_mode', $is_enabled ); + } +} diff --git a/tests/phpunit/integration/api/image/includes/class-image-test-case.php b/tests/phpunit/integration/api/image/includes/class-image-test-case.php index 0ed81554..b7fc4aa4 100644 --- a/tests/phpunit/integration/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/integration/api/image/includes/class-image-test-case.php @@ -9,15 +9,16 @@ namespace Beans\Framework\Tests\Integration\API\Image\Includes; -use Beans\Framework\Tests\Integration\Test_Case; use org\bovigo\vfs\vfsStream; +require_once __DIR__ . '/class-base-test-case.php'; + /** * Abstract Class Image_Test_Case * * @package Beans\Framework\Tests\Integration\API\Image\Includes */ -abstract class Image_Test_Case extends Test_Case { +abstract class Image_Test_Case extends Base_Test_Case { /** * When true, return the given path when doing wp_normalize_path(). @@ -26,54 +27,6 @@ abstract class Image_Test_Case extends Test_Case { */ protected $just_return_path = true; - /** - * Path to the images' directory. - * - * @var string - */ - protected $images_dir; - - /** - * Instance of vfsStreamDirectory to mock the filesystem. - * - * @var vfsStreamDirectory - */ - protected $mock_filesystem; - - /** - * Set up the test fixture. - */ - public function setUp() { - parent::setUp(); - - $this->set_up_virtual_filesystem(); - $this->images_dir = vfsStream::url( 'uploads/beans/images' ); - - // Set the Uploads directory to our virtual filesystem. - add_filter( 'upload_dir', function( array $uploads_dir ) { - $virtual_dir = vfsStream::url( 'uploads' ); - $uploads_dir['path'] = $virtual_dir . $uploads_dir['subdir']; - $uploads_dir['basedir'] = $virtual_dir; - return $uploads_dir; - } ); - } - - /** - * Set up the virtual filesystem. - */ - private function set_up_virtual_filesystem() { - $structure = array( - 'beans' => array( - 'images' => array( - 'index.php' => '', - ), - ), - ); - - // Set up the "beans" directory's virtual filesystem. - $this->mock_filesystem = vfsStream::setup( 'uploads', 0755, $structure ); - } - /** * Initialize the virtual "edited" image. * diff --git a/tests/phpunit/integration/api/image/includes/class-options-test-case.php b/tests/phpunit/integration/api/image/includes/class-options-test-case.php new file mode 100644 index 00000000..30241315 --- /dev/null +++ b/tests/phpunit/integration/api/image/includes/class-options-test-case.php @@ -0,0 +1,48 @@ +assertTrue( is_admin() ); + } +} diff --git a/tests/phpunit/unit/api/image/beans-image-options/adminNotice.php b/tests/phpunit/unit/api/image/beans-image-options/adminNotice.php new file mode 100644 index 00000000..a1de96ab --- /dev/null +++ b/tests/phpunit/unit/api/image/beans-image-options/adminNotice.php @@ -0,0 +1,61 @@ +once() + ->with( 'beans_flush_edited_images' ) + ->andReturn( false ); + Monkey\Functions\expect( 'esc_html_e' )->never(); + + ob_start(); + ( new _Beans_Image_Options() )->admin_notice(); + $this->assertEmpty( ob_get_clean() ); + } + + /** + * Test _Beans_Image_Options::admin_notice() should render when flushing edited images cache. + */ + public function test_should_render_when_flushing_edited_images_cache() { + Monkey\Functions\expect( 'beans_post' ) + ->once() + ->with( 'beans_flush_edited_images' ) + ->andReturn( true ); + ob_start(); + ( new _Beans_Image_Options() )->admin_notice(); + $actual = ob_get_clean(); + + $expected = << +

    Images flushed successfully!

    + +EOB; + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); + } +} diff --git a/tests/phpunit/unit/api/image/beans-image-options/flush.php b/tests/phpunit/unit/api/image/beans-image-options/flush.php new file mode 100644 index 00000000..6dea33a9 --- /dev/null +++ b/tests/phpunit/unit/api/image/beans-image-options/flush.php @@ -0,0 +1,74 @@ +directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); + + Monkey\Functions\expect( 'beans_post' ) + ->once() + ->with( 'beans_flush_edited_images' ) + ->andReturnNull(); + Monkey\Functions\expect( 'beans_get_images_dir' )->never(); + Monkey\Functions\expect( 'beans_remove_dir' )->never(); + + $this->assertNull( ( new _Beans_Image_Options() )->flush() ); + + // Check that it still exists and was not removed. + $this->directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); + } + + /** + * Test _Beans_Image_Options::flush() should remove the cached directory. + */ + public function test_should_remove_cached_dir() { + // Check that the cached directory exists before we start. + $this->directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); + + Monkey\Functions\expect( 'beans_post' ) + ->once() + ->with( 'beans_flush_edited_images' ) + ->andReturnFirstArg(); + Monkey\Functions\expect( 'beans_get_images_dir' ) + ->once() + ->andReturn( vfsStream::url( 'uploads/beans/images/' ) ); + Monkey\Functions\expect( 'beans_remove_dir' ) + ->once() + ->with( vfsStream::url( 'uploads/beans/images/' ) ) + ->andReturnUsing( function() { + // Keep it simple. Remove by redefining. + vfsStream::setup( 'uploads', 0755, [ 'beans' => [] ] ); + } ); + + $this->assertNull( ( new _Beans_Image_Options() )->flush() ); + $this->assertDirectoryNotExists( vfsStream::url( 'uploads/beans/images/' ) ); + } +} diff --git a/tests/phpunit/unit/api/image/beans-image-options/option.php b/tests/phpunit/unit/api/image/beans-image-options/option.php new file mode 100644 index 00000000..8c6e5e3b --- /dev/null +++ b/tests/phpunit/unit/api/image/beans-image-options/option.php @@ -0,0 +1,51 @@ +never(); + + ob_start(); + ( new _Beans_Image_Options() )->option( [ 'id' => 'foo' ] ); + $this->assertEmpty( ob_get_clean() ); + } + + /** + * Test _Beans_Image_Options::option() should render when the field is for image options. + */ + public function test_should_render_when_field_is_image_options() { + ob_start(); + ( new _Beans_Image_Options() )->option( [ 'id' => 'beans_edited_images_directories' ] ); + $actual = ob_get_clean(); + + $expected = << +EOB; + $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); + } +} diff --git a/tests/phpunit/unit/api/image/beans-image-options/register.php b/tests/phpunit/unit/api/image/beans-image-options/register.php new file mode 100644 index 00000000..7ca82d1a --- /dev/null +++ b/tests/phpunit/unit/api/image/beans-image-options/register.php @@ -0,0 +1,100 @@ +fields = [ + [ + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + 'description' => 'Clear all edited images. New images will be created on page load.', + ], + ]; + } + + /** + * Test _Beans_Image_Options::register() should register the options with column context when other metaboxes are + * registered. + */ + public function test_should_register_options_with_column_context_when_other_metaboxes_are_registered() { + global $wp_meta_boxes; + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'beans_settings', $wp_meta_boxes ) + ->andReturn( [ 'foo' ] ); + Monkey\Functions\expect( 'beans_register_options' ) + ->once() + ->with( + $this->fields, + 'beans_settings', + 'images_options', + [ + 'title' => 'Images options', + 'context' => 'column', + ] + ) + ->andReturn( true ); + + $this->assertTrue( ( new _Beans_Image_Options() )->register() ); + } + + /** + * Test _Beans_Image_Options::register() should register the options with normal context when no metaboxes are + * registered. + */ + public function test_should_register_options_with_normal_context_when_no_metaboxes_are_registered() { + global $wp_meta_boxes; + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'beans_settings', $wp_meta_boxes ) + ->andReturn( [] ); + Monkey\Functions\expect( 'beans_register_options' ) + ->once() + ->with( + $this->fields, + 'beans_settings', + 'images_options', + [ + 'title' => 'Images options', + 'context' => 'normal', + ] + ) + ->andReturn( true ); + + $this->assertTrue( ( new _Beans_Image_Options() )->register() ); + } +} From 7beb9422ee2acf73df74f5ab9047dd9d3e80e1f7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 13 May 2018 14:43:49 -0500 Subject: [PATCH 581/800] Renamed methods. The new names describes the expected behavior that will occur when this method is called. It is more readable and quickly understandable. --- lib/api/image/class-beans-image-options.php | 14 +++++++------- .../{option.php => renderFlushButton.php} | 10 +++++----- .../{adminNotice.php => renderSuccessNotice.php} | 10 +++++----- .../{option.php => renderFlushButton.php} | 10 +++++----- .../{adminNotice.php => renderSuccessNotice.php} | 10 +++++----- 5 files changed, 27 insertions(+), 27 deletions(-) rename tests/phpunit/integration/api/image/beans-image-options/{option.php => renderFlushButton.php} (69%) rename tests/phpunit/integration/api/image/beans-image-options/{adminNotice.php => renderSuccessNotice.php} (77%) rename tests/phpunit/unit/api/image/beans-image-options/{option.php => renderFlushButton.php} (69%) rename tests/phpunit/unit/api/image/beans-image-options/{adminNotice.php => renderSuccessNotice.php} (76%) diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index 4e93a4a6..8adeeb59 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -29,8 +29,8 @@ public function init() { // Load with priority 15 so that we can check if other Beans metaboxes exist. add_action( 'admin_init', array( $this, 'register' ), 15 ); add_action( 'admin_init', array( $this, 'flush' ), - 1 ); - add_action( 'admin_notices', array( $this, 'admin_notice' ) ); - add_action( 'beans_field_flush_edited_images', array( $this, 'option' ) ); + add_action( 'admin_notices', array( $this, 'render_success_notice' ) ); + add_action( 'beans_field_flush_edited_images', array( $this, 'render_flush_button' ) ); } /** @@ -74,13 +74,13 @@ public function flush() { } /** - * Image editor notice notice. + * Renders the success admin notice. * * @since 1.0.0 * * @return void */ - public function admin_notice() { + public function render_success_notice() { if ( ! beans_post( 'beans_flush_edited_images' ) ) { return; @@ -93,15 +93,15 @@ public function admin_notice() { } /** - * Add a button to flush images. + * Render the flush button, which is used to flush the images' cache. * * @since 1.0.0 * - * @param array $field Metabox settings. + * @param array $field Registered options. * * @return void */ - public function option( $field ) { + public function render_flush_button( $field ) { if ( 'beans_edited_images_directories' !== $field['id'] ) { return; diff --git a/tests/phpunit/integration/api/image/beans-image-options/option.php b/tests/phpunit/integration/api/image/beans-image-options/renderFlushButton.php similarity index 69% rename from tests/phpunit/integration/api/image/beans-image-options/option.php rename to tests/phpunit/integration/api/image/beans-image-options/renderFlushButton.php index 20974f9b..d9293fe7 100644 --- a/tests/phpunit/integration/api/image/beans-image-options/option.php +++ b/tests/phpunit/integration/api/image/beans-image-options/renderFlushButton.php @@ -1,6 +1,6 @@ option( [ 'id' => 'foo' ] ); + ( new _Beans_Image_Options() )->render_flush_button( [ 'id' => 'foo' ] ); $this->assertEmpty( ob_get_clean() ); } /** - * Test _Beans_Image_Options::option() should render when the field is for image options. + * Test _Beans_Image_Options::render_flush_button() should render when the field is for image options. */ public function test_should_render_when_field_is_image_options() { ob_start(); - ( new _Beans_Image_Options() )->option( [ 'id' => 'beans_edited_images_directories' ] ); + ( new _Beans_Image_Options() )->render_flush_button( [ 'id' => 'beans_edited_images_directories' ] ); $actual = ob_get_clean(); $expected = <<go_to_settings_page(); $this->assertArrayNotHasKey( 'beans_flush_edited_images', $_POST ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- No need for nonce in this test. ob_start(); - ( new _Beans_Image_Options() )->admin_notice(); + ( new _Beans_Image_Options() )->render_success_notice(); $this->assertEmpty( ob_get_clean() ); } /** - * Test _Beans_Image_Options::admin_notice() should render when flushing edited images cache. + * Test _Beans_Image_Options::render_success_notice() should render when flushing edited images cache. */ public function test_should_render_when_flushing_edited_images_cache() { $this->go_to_settings_page(); $_POST['beans_flush_edited_images'] = 1; ob_start(); - ( new _Beans_Image_Options() )->admin_notice(); + ( new _Beans_Image_Options() )->render_success_notice(); $actual = ob_get_clean(); $expected = <<never(); ob_start(); - ( new _Beans_Image_Options() )->option( [ 'id' => 'foo' ] ); + ( new _Beans_Image_Options() )->render_flush_button( [ 'id' => 'foo' ] ); $this->assertEmpty( ob_get_clean() ); } /** - * Test _Beans_Image_Options::option() should render when the field is for image options. + * Test _Beans_Image_Options::render_flush_button() should render when the field is for image options. */ public function test_should_render_when_field_is_image_options() { ob_start(); - ( new _Beans_Image_Options() )->option( [ 'id' => 'beans_edited_images_directories' ] ); + ( new _Beans_Image_Options() )->render_flush_button( [ 'id' => 'beans_edited_images_directories' ] ); $actual = ob_get_clean(); $expected = <<never(); ob_start(); - ( new _Beans_Image_Options() )->admin_notice(); + ( new _Beans_Image_Options() )->render_success_notice(); $this->assertEmpty( ob_get_clean() ); } /** - * Test _Beans_Image_Options::admin_notice() should render when flushing edited images cache. + * Test _Beans_Image_Options::render_success_notice() should render when flushing edited images cache. */ public function test_should_render_when_flushing_edited_images_cache() { Monkey\Functions\expect( 'beans_post' ) @@ -48,7 +48,7 @@ public function test_should_render_when_flushing_edited_images_cache() { ->with( 'beans_flush_edited_images' ) ->andReturn( true ); ob_start(); - ( new _Beans_Image_Options() )->admin_notice(); + ( new _Beans_Image_Options() )->render_success_notice(); $actual = ob_get_clean(); $expected = << Date: Sun, 13 May 2018 14:54:37 -0500 Subject: [PATCH 582/800] Moved HTML to views for separation of concerns. --- lib/api/image/class-beans-image-options.php | 9 ++------- lib/api/image/views/flush-button.php | 12 ++++++++++++ lib/api/image/views/flushed-notice.php | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 lib/api/image/views/flush-button.php create mode 100644 lib/api/image/views/flushed-notice.php diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index 8adeeb59..1803a522 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -86,10 +86,7 @@ public function render_success_notice() { return; } - ?> -

    -
    - - - + diff --git a/lib/api/image/views/flushed-notice.php b/lib/api/image/views/flushed-notice.php new file mode 100644 index 00000000..995e3da7 --- /dev/null +++ b/lib/api/image/views/flushed-notice.php @@ -0,0 +1,14 @@ + +
    +

    +
    From b08c791b9581411082db2908b54d6519f47daf52 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 13 May 2018 15:15:49 -0500 Subject: [PATCH 583/800] Moved the fields configuration to a config file. Instead of hard-coding the fields configuration, this commit moves it into a configuration file. Why? 1. Better conveys intent. 2. Improves testing. 3. Replaces the array_merge with unset(), which is a little bit faster. --- lib/api/image/class-beans-image-options.php | 35 +++++++++++-------- lib/api/image/config/fields.php | 16 +++++++++ .../image/beans-image-options/register.php | 8 +---- 3 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 lib/api/image/config/fields.php diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index 1803a522..cfbc1513 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -4,15 +4,15 @@ * * @package Beans\Framework\Api\Image * - * @since 1.0.0 + * @since 1.0.0 */ /** * Beans Image Options Handler. * - * @since 1.0.0 + * @since 1.0.0 * @ignore - * @access private + * @access private * * @package Beans\Framework\API\Image */ @@ -34,7 +34,7 @@ public function init() { } /** - * Register options. + * Register the options. * * @since 1.0.0 * @@ -43,18 +43,25 @@ public function init() { public function register() { global $wp_meta_boxes; - $fields = array( - array( - 'id' => 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - 'description' => __( 'Clear all edited images. New images will be created on page load.', 'tm-beans' ), - ), + return beans_register_options( + $this->get_fields_to_register(), + 'beans_settings', + 'images_options', array( + 'title' => __( 'Images options', 'tm-beans' ), + 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', + ) ); + } - return beans_register_options( $fields, 'beans_settings', 'images_options', array( - 'title' => __( 'Images options', 'tm-beans' ), - 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', - ) ); + /** + * Get the fields to register. + * + * @since 1.5.0 + * + * @return array + */ + private function get_fields_to_register() { + return require dirname( __FILE__ ) . '/config/fields.php'; } /** diff --git a/lib/api/image/config/fields.php b/lib/api/image/config/fields.php new file mode 100644 index 00000000..b35aef71 --- /dev/null +++ b/lib/api/image/config/fields.php @@ -0,0 +1,16 @@ + array( + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + 'description' => __( 'Clear all edited images. New images will be created on page load.', 'tm-beans' ), + ), +); diff --git a/tests/phpunit/unit/api/image/beans-image-options/register.php b/tests/phpunit/unit/api/image/beans-image-options/register.php index 7ca82d1a..5ee00928 100644 --- a/tests/phpunit/unit/api/image/beans-image-options/register.php +++ b/tests/phpunit/unit/api/image/beans-image-options/register.php @@ -37,13 +37,7 @@ class Tests_BeansImageOptions_Register extends Options_Test_Case { protected function setUp() { parent::setUp(); - $this->fields = [ - [ - 'id' => 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - 'description' => 'Clear all edited images. New images will be created on page load.', - ], - ]; + $this->fields = require BEANS_THEME_DIR . '/lib/api/image/config/fields.php'; } /** From 53bb20442ddae11b6b9b82e1b80c0881cd9d40c3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 13 May 2018 15:26:10 -0500 Subject: [PATCH 584/800] Abstracted checking if any metaboxes are registered. The inline comment was necessary to explain what the check was doing and why. By abstracting to a method, the code is more readable and quickly understandable without the comment. --- lib/api/image/class-beans-image-options.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index cfbc1513..a60ede3e 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -41,14 +41,12 @@ public function init() { * @return bool */ public function register() { - global $wp_meta_boxes; - return beans_register_options( $this->get_fields_to_register(), 'beans_settings', 'images_options', array( 'title' => __( 'Images options', 'tm-beans' ), - 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', + 'context' => $this->has_metaboxes() ? 'column' : 'normal', ) ); } @@ -64,6 +62,20 @@ private function get_fields_to_register() { return require dirname( __FILE__ ) . '/config/fields.php'; } + /** + * Checks if there are metaboxes registered already. + * + * @since 1.5.0 + * + * @return bool + */ + private function has_metaboxes() { + global $wp_meta_boxes; + + $metaboxes = beans_get( 'beans_settings', $wp_meta_boxes ); + return ! empty( $metaboxes ); + } + /** * Flush images for all folders set. * From 4d41b025527f6db58080bb44fa5e1094e309348e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sun, 13 May 2018 15:50:22 -0500 Subject: [PATCH 585/800] Fixed failing Layout API integration tests. The integration tests were failing for being set to the backend, which caused is_admin() to be true. Fixed by: 1. Switching back to the front in the Test Case. 2. Using the Test Case in each of the Layout API's integration tests. --- .../api/image/includes/class-options-test-case.php | 9 +++++++++ .../integration/api/layout/beansGetDefaultLayout.php | 6 +++--- tests/phpunit/integration/api/layout/beansGetLayout.php | 6 +++--- .../integration/api/layout/beansGetLayoutClass.php | 6 +++--- tests/phpunit/integration/class-test-case.php | 9 +++++++++ 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/integration/api/image/includes/class-options-test-case.php b/tests/phpunit/integration/api/image/includes/class-options-test-case.php index 30241315..f05f9f8c 100644 --- a/tests/phpunit/integration/api/image/includes/class-options-test-case.php +++ b/tests/phpunit/integration/api/image/includes/class-options-test-case.php @@ -36,6 +36,15 @@ public static function setUpBeforeClass() { require_once BEANS_THEME_DIR . '/lib/api/image/class-beans-image-options.php'; } + /** + * Set up the test before we run the test setups. + */ + public static function setUpAfterClass() { + parent::setUpAfterClass(); + + set_current_screen( 'front' ); + } + /** * Go to the Settings Page. */ diff --git a/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php b/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php index cf6b4da0..6f1b44b2 100644 --- a/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php +++ b/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php @@ -9,16 +9,16 @@ namespace Beans\Framework\Tests\Integration\API\Layout; -use WP_UnitTestCase; +use Beans\Framework\Tests\Integration\Test_Case; /** * Class Tests_BeansGetDefaultLayout * * @package Beans\Framework\Tests\Integration\API\Layout - * @group integration-tests * @group api + * @group api-layout */ -class Tests_BeansGetDefaultLayout extends WP_UnitTestCase { +class Tests_BeansGetDefaultLayout extends Test_Case { /** * Prepares the test environment before each test. diff --git a/tests/phpunit/integration/api/layout/beansGetLayout.php b/tests/phpunit/integration/api/layout/beansGetLayout.php index ae918a24..f91a25d4 100644 --- a/tests/phpunit/integration/api/layout/beansGetLayout.php +++ b/tests/phpunit/integration/api/layout/beansGetLayout.php @@ -9,16 +9,16 @@ namespace Beans\Framework\Tests\Integration\API\Layout; -use WP_UnitTestCase; +use Beans\Framework\Tests\Integration\Test_Case; /** * Class Tests_BeansGetLayout * * @package Beans\Framework\Tests\Integration\API\Layout - * @group integration-tests * @group api + * @group api-layout */ -class Tests_BeansGetLayout extends WP_UnitTestCase { +class Tests_BeansGetLayout extends Test_Case { /** * Test beans_get_layout() should return the layout for a single post or page. diff --git a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php index ff877735..761ed419 100644 --- a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php @@ -9,16 +9,16 @@ namespace Beans\Framework\Tests\Integration\API\Layout; -use WP_UnitTestCase; +use Beans\Framework\Tests\Integration\Test_Case; /** * Class Tests_BeansGetLayoutClass * * @package Beans\Framework\Tests\Integration\API\Layout - * @group integration-tests * @group api + * @group api-layout */ -class Tests_BeansGetLayoutClass extends WP_UnitTestCase { +class Tests_BeansGetLayoutClass extends Test_Case { /** * Test post's ID. diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index bd0e1461..b9126b48 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -26,6 +26,15 @@ abstract class Test_Case extends WP_UnitTestCase { */ protected $was_reset = false; + /** + * Set up the test before we run the test setups. + */ + public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + + set_current_screen( 'front' ); + } + /** * Prepares the test environment before each test. */ From 4112649f36394c937ce22b61a41621c687817d1d Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 16 May 2018 08:40:30 -0400 Subject: [PATCH 586/800] Fix undef var in beans_widget_area_shortcodes() --- lib/api/widget/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 8739b2b2..4532fefd 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -218,7 +218,7 @@ function beans_widget_area_shortcodes( $content ) { $content = build_query( $content ); } - return beans_array_shortcodes( $string, $GLOBALS['_beans_widget_area'] ); + return beans_array_shortcodes( $content, $GLOBALS['_beans_widget_area'] ); } /** From 4a47f4e4a36e8dcb87554620e98054fc7738324e Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 16 May 2018 09:05:36 -0400 Subject: [PATCH 587/800] Fix beans_register_widget_areas() return type --- lib/api/widget/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 4532fefd..1a0fc0b1 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -48,7 +48,7 @@ function beans_register_widget_area( $args = array(), $widget_control = array() $id = beans_get( 'id', $args ); if ( ! $id ) { - return; + return ''; } /** From cc251f9929f867263beed990fc4a8ac7a34086dc Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 16 May 2018 09:06:03 -0400 Subject: [PATCH 588/800] Add Widget API test case classes --- .../includes/class-beans-widget-test-case.php | 30 ++++++++++++++++ .../includes/class-beans-widget-test-case.php | 35 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php create mode 100644 tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php diff --git a/tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php new file mode 100644 index 00000000..2c0c8dbf --- /dev/null +++ b/tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php @@ -0,0 +1,30 @@ +clean_up_global_scope(); + + parent::tearDown(); + } +} diff --git a/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php new file mode 100644 index 00000000..993ea333 --- /dev/null +++ b/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php @@ -0,0 +1,35 @@ +load_original_functions( array( + 'api/widget/functions.php', + 'api/utilities/functions.php', + ) ); + + $this->setup_common_wp_stubs(); + } + +} From cf81523466bb8f6b8404f122d825b76ef8663e67 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 16 May 2018 10:14:45 -0400 Subject: [PATCH 589/800] Fix register_widget_area doc: $id is not optional Leaving out the id causes early return without registration. --- lib/api/widget/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 1a0fc0b1..c52223f0 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -28,7 +28,7 @@ * @param array $args { * Optional. Arguments used by the widget area. * - * @type string $id Optional. The unique identifier by which the widget area will be called. + * @type string $id The unique identifier by which the widget area will be called. * @type string $name Optional. The name or title of the widget area displayed in the * admin dashboard. * @type string $description Optional. The widget area description. From 8026e595a95af34d9f1dc4702f1d372d2522044a Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 16 May 2018 10:15:06 -0400 Subject: [PATCH 590/800] Add beans_register_widget_area tests --- .../widget/beansRegisterWidgetArea.php | 44 +++++++++++ .../api/widget/beansRegisterWidgetArea.php | 76 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 tests/phpunit/integration/widget/beansRegisterWidgetArea.php create mode 100644 tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php diff --git a/tests/phpunit/integration/widget/beansRegisterWidgetArea.php b/tests/phpunit/integration/widget/beansRegisterWidgetArea.php new file mode 100644 index 00000000..3296d3eb --- /dev/null +++ b/tests/phpunit/integration/widget/beansRegisterWidgetArea.php @@ -0,0 +1,44 @@ +assertSame( '', beans_register_widget_area( [] ) ); + } + + /** + * Test beans_register_widget_area() should return the widget area id when the widget area is registered. + */ + public function test_should_return_widget_area_ID_when_widget_area_registered() { + $this->assertEquals( + 'new-widget-area', + beans_register_widget_area( array( + 'id' => 'new-widget-area', + 'beans_type' => 'grid', + ) ) ); + } + +} \ No newline at end of file diff --git a/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php new file mode 100644 index 00000000..2aea2fe4 --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php @@ -0,0 +1,76 @@ +once() + ->with( 'id', [] ) + ->andReturn( false ); + + $this->assertSame( '', beans_register_widget_area( array() ) ); + } + + /** + * Test beans_register_widget_area() should return the widget area id when the widget area is registered. + */ + public function test_should_return_widget_area_ID_when_widget_area_registered() { + Monkey\Functions\expect( 'beans_get' ) + ->once()->with( 'id', array( 'id' => 'new-widget-area', 'beans_type' => 'grid', ) ) + ->andReturn( 'new-widget-area' ); + + Monkey\Functions\expect( 'beans_apply_filters' ) + ->once() + ->with( 'beans_widgets_area_args[_new-widget-area]', $this->get_merged_args() ) + ->andReturn( $this->get_merged_args() ); + + Monkey\Functions\expect( 'register_sidebar' ) + ->once() + ->with( $this->get_merged_args() ) + ->andReturn( 'new-widget-area' ); + + $this->assertEquals( + 'new-widget-area', + beans_register_widget_area( array( + 'id' => 'new-widget-area', + 'beans_type' => 'grid', + ) ) ); + } + + /** + * Return the expected merged arguments array. + */ + protected function get_merged_args() { + return array( + 'beans_type' => 'grid', + 'beans_show_widget_title' => true, + 'beans_show_widget_badge' => false, + 'beans_widget_badge_content' => __( 'Hello', 'tm-beans' ), + 'id' => 'new-widget-area', + ); + } +} From 99fe31a503ce44e2868c5f45e498772a57153e8c Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 16 May 2018 14:21:33 -0400 Subject: [PATCH 591/800] Add tests for deregister, isActive and has methods --- .../widget/beansDeregisterWidgetArea.php | 42 +++++++++++++++++ .../integration/widget/beansHasWidgetArea.php | 38 +++++++++++++++ .../widget/beansIsActiveWidgetArea.php | 46 +++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 tests/phpunit/integration/widget/beansDeregisterWidgetArea.php create mode 100644 tests/phpunit/integration/widget/beansHasWidgetArea.php create mode 100644 tests/phpunit/integration/widget/beansIsActiveWidgetArea.php diff --git a/tests/phpunit/integration/widget/beansDeregisterWidgetArea.php b/tests/phpunit/integration/widget/beansDeregisterWidgetArea.php new file mode 100644 index 00000000..28d6dfea --- /dev/null +++ b/tests/phpunit/integration/widget/beansDeregisterWidgetArea.php @@ -0,0 +1,42 @@ + 'stack', + 'beans_show_widget_title' => true, + 'beans_show_widget_badge' => false, + 'beans_widget_badge_content' => __( 'Hello', 'tm-beans' ), + 'id' => 'unwanted-sidebar', + ); + + beans_deregister_widget_area( 'unwanted-sidebar' ); + + $this->assertArrayNotHasKey( 'unwanted-sidebar', $wp_registered_sidebars ); + } + + +} \ No newline at end of file diff --git a/tests/phpunit/integration/widget/beansHasWidgetArea.php b/tests/phpunit/integration/widget/beansHasWidgetArea.php new file mode 100644 index 00000000..3e3a7a67 --- /dev/null +++ b/tests/phpunit/integration/widget/beansHasWidgetArea.php @@ -0,0 +1,38 @@ +assertFalse( beans_has_widget_area( 'unregistered-area' ) ); + } + + /** + * Test beans_has_widget_area() should return true when widget area is registered. + */ + public function testShouldReturnTrueWhenWidgetAreaRegistered() { + $this->assertTrue( beans_has_widget_area( 'sidebar_primary' ) ); + } +} \ No newline at end of file diff --git a/tests/phpunit/integration/widget/beansIsActiveWidgetArea.php b/tests/phpunit/integration/widget/beansIsActiveWidgetArea.php new file mode 100644 index 00000000..ab8c46ef --- /dev/null +++ b/tests/phpunit/integration/widget/beansIsActiveWidgetArea.php @@ -0,0 +1,46 @@ +assertFalse( beans_is_active_widget_area( 'inactive-widget-area' ) ); + } + + /** + * Test beans_is_active_widget_area() should return true when widget area is active. + */ + public function testShouldReturnTrueWhenWidgetAreaIsActive() { + global $_wp_sidebars_widgets; + + // Clear global widget areas registry so we can start clean. + $_wp_sidebars_widgets = []; + + // Prime the WP database with an active sidebar. + update_option( 'sidebars_widgets', array( 'an-active-sidebar' => array( 'text-2' ) ) ); + + $this->assertTrue( beans_is_active_widget_area( 'an-active-sidebar' ) ); + } +} \ No newline at end of file From ee1a0b1eba5e00e9027dc517d0f255a165961941 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 16 May 2018 14:22:44 -0400 Subject: [PATCH 592/800] Refactor beans_has_widget_area() for performance Just return isset: removes if/true - else/false --- lib/api/widget/functions.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index c52223f0..c233d618 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -123,11 +123,7 @@ function beans_is_active_widget_area( $id ) { function beans_has_widget_area( $id ) { global $wp_registered_sidebars; - if ( isset( $wp_registered_sidebars[ $id ] ) ) { - return true; - } - - return false; + return isset( $wp_registered_sidebars[ $id ] ); } /** From 828356f238573820afb38247043d1a2cda16d2aa Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Thu, 17 May 2018 10:26:05 -0400 Subject: [PATCH 593/800] Deprecate beans_widget_area() Replace with beans_get_widget_area_contents() --- lib/api/init.php | 1 + lib/api/widget/deprecated.php | 24 ++++++++++++++++++++++++ lib/api/widget/functions.php | 8 ++++---- lib/templates/fragments/widget-area.php | 6 +++--- 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 lib/api/widget/deprecated.php diff --git a/lib/api/init.php b/lib/api/init.php index 8fef4a43..ac2d8236 100644 --- a/lib/api/init.php +++ b/lib/api/init.php @@ -36,6 +36,7 @@ require_once BEANS_API_PATH . 'utilities/polyfills.php'; require_once BEANS_API_PATH . 'utilities/functions.php'; require_once BEANS_API_PATH . 'utilities/deprecated.php'; +require_once BEANS_API_PATH . 'widget/deprecated.php'; require_once BEANS_API_PATH . 'components.php'; // Url. diff --git a/lib/api/widget/deprecated.php b/lib/api/widget/deprecated.php new file mode 100644 index 00000000..bc69a922 --- /dev/null +++ b/lib/api/widget/deprecated.php @@ -0,0 +1,24 @@ + Date: Thu, 17 May 2018 11:36:16 -0400 Subject: [PATCH 594/800] Add tests for beans_get_widget_area_output() --- .../widget/beansGetWidgetAreaOutput.php | 56 ++++++++++++++++++ .../api/widget/beansGetWidgetAreaOutput.php | 57 +++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php create mode 100644 tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php diff --git a/tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php new file mode 100644 index 00000000..a87ccd81 --- /dev/null +++ b/tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php @@ -0,0 +1,56 @@ +assertFalse( beans_get_widget_area_output( 'unregistered-widget-area' ) ); + } + + /** + * Test beans_get_widget_area_output() should return output when a widget area is registered. + */ + public function test_should_return_widget_output_when_widget_area_is_registered() { + $this->assertEquals( $this->get_expected_output(), beans_get_widget_area_output( 'sidebar_primary' ) ); + } + + /** + * Get the expected output (html) of the beans default primary sidebar. + */ + protected function get_expected_output() { + return <<

    Recent Comments

      Archives

        +
      +

      Categories

        +
      • No categories
      +
      +OUTPUT; + } +} diff --git a/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php new file mode 100644 index 00000000..51ee27dc --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php @@ -0,0 +1,57 @@ +once() + ->with( 'unregistered-widget-area' ) + ->andReturn( false ); + + $this->assertFalse( beans_get_widget_area_output( 'unregistered-widget-area' ) ); + } + + /** + * Test beans_get_widget_area_output() should return output when a widget area is registered. + */ + public function test_should_return_widget_output_when_widget_area_is_registered() { + Monkey\Functions\expect( 'beans_has_widget_area' ) + ->once() + ->with( 'primary_sidebar' ) + ->andReturn( true ); + + Monkey\Functions\expect( '_beans_reset_widget_area' ) + ->once() + ->andReturn(); + + $output = beans_get_widget_area_output( 'primary_sidebar' ); + + $this->assertEquals( 1, did_action( 'beans_widget_area_init' ) ); + $this->assertEquals( 1, did_action( 'beans_widget_area' ) ); + $this->assertEquals( 1, did_action( 'beans_widget_area_reset' ) ); + } +} From a4808fd2a6fbf864b38eeebce492b452d8b49714 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 17 May 2018 11:25:14 -0500 Subject: [PATCH 595/800] Improved documentation and naming. --- lib/api/compiler/class-beans-page-compiler.php | 8 ++++---- .../beans-page-compiler/compilePageScripts.php | 4 ++-- .../beans-page-compiler/compilePageStyles.php | 6 +++--- .../includes/class-page-compiler-test-case.php | 2 +- .../beans-page-compiler/compilePageScripts.php | 14 +++++++------- .../beans-page-compiler/compilePageStyles.php | 16 ++++++++-------- .../includes/class-page-compiler-test-case.php | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 74048f38..2ee3150b 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -26,7 +26,7 @@ final class _Beans_Page_Compiler { private $dequeued_scripts = array(); /** - * An array of assets to not compile. + * An array of assets not to compile. * * @var array */ @@ -52,7 +52,7 @@ public function init() { } /** - * Enqueue compiled wp styles. + * Enqueue the compiled WP styles. * * @since 1.0.0 * @@ -86,7 +86,7 @@ private function do_not_compile_styles() { } /** - * Enqueue compiled wp scripts. + * Enqueue the compiled WP scripts. * * @since 1.0.0 * @@ -126,7 +126,7 @@ private function do_not_compile_scripts() { } /** - * Compile all wp enqueued assets. + * Compile all of the enqueued assets, i.e. all assets that are registered with WordPress. * * @since 1.0.0 * @ignore diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php index 49a31149..8f4340d7 100644 --- a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php +++ b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php @@ -86,9 +86,9 @@ public function test_should_not_compile_when_in_dev_mode() { } /** - * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when there are not scripts. + * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when there are no scripts. */ - public function test_should_not_compile_when_there_are_not_scripts() { + public function test_should_not_compile_when_there_are_no_scripts() { beans_add_api_component_support( 'wp_scripts_compiler' ); update_option( 'beans_compile_all_scripts', 1 ); delete_option( 'beans_dev_mode' ); diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php index 805dd8be..ec38d1b1 100644 --- a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php +++ b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php @@ -86,9 +86,9 @@ public function test_should_not_compile_when_in_dev_mode() { } /** - * Test _Beans_Page_Compiler::compile_page_styles() should not compile when there are not styles. + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when there are no styles. */ - public function test_should_not_compile_when_there_are_not_styles() { + public function test_should_not_compile_when_there_are_no_styles() { beans_add_api_component_support( 'wp_styles_compiler' ); update_option( 'beans_compile_all_styles', 1 ); delete_option( 'beans_dev_mode' ); @@ -211,7 +211,7 @@ public function test_should_add_query_arg_to_compiled_style_src() { /** * Test _Beans_Page_Compiler::compile_page_styles() should compile styles and dependencies. */ - public function test_should_compile_style_and_deps() { + public function test_should_compile_styles_and_deps() { beans_add_api_component_support( 'wp_styles_compiler' ); update_option( 'beans_compile_all_styles', 1 ); delete_option( 'beans_dev_mode' ); diff --git a/tests/phpunit/integration/api/compiler/includes/class-page-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-page-compiler-test-case.php index 4ddaf102..5bf7fff7 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-page-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-page-compiler-test-case.php @@ -1,6 +1,6 @@ justReturn( true ); Monkey\Functions\when( 'get_option' )->justReturn( true ); Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); @@ -87,7 +87,7 @@ public function test_should_not_compile_when_there_are_not_scripts() { // Check that beans_get() only gets called once. Monkey\Functions\expect( 'beans_get' )->once()->andReturn( null ); - // Check that this function does not get called. + // Check that beans_compile_js_fragments() does not get called. Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); // Run the tests. @@ -129,7 +129,7 @@ public function test_should_not_compile_when_style_is_not_registered() { $assets = $this->get_mock_assets( [ 'admin-bar', 'uikit' ] ); $assets->registered['uikit'] = null; - // Set up the order of how beans_get() will be called. + // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) ->ordered() ->once() @@ -162,7 +162,7 @@ public function test_should_not_compile_when_script_has_no_src() { $assets->registered['uikit']->src = ''; $assets->registered['uikit']->deps = []; - // Set up the order of how beans_get() will be called. + // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) ->ordered() ->once() @@ -204,7 +204,7 @@ public function test_should_compile_when_script_has_src_but_no_deps() { $assets->registered['uikit']->deps = []; $assets->registered['debug-bar']->deps = []; - // Set up the order of how beans_get() will be called. + // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) ->ordered() ->once() @@ -262,7 +262,7 @@ public function test_should_compile_scripts_and_deps() { // Initialize the mocked assets. $assets = $this->get_mock_assets( [ 'admin-bar', 'debug-bar', 'uikit' ] ); - // Set up the order of how beans_get() will be called. + // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) ->ordered() ->once() diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php index a834e698..16c01eb9 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php @@ -75,9 +75,9 @@ public function test_should_not_compile_when_in_dev_mode() { } /** - * Test _Beans_Page_Compiler::compile_page_styles() should not compile when there are not styles. + * Test _Beans_Page_Compiler::compile_page_styles() should not compile when there are no styles. */ - public function test_should_not_compile_when_there_are_not_styles() { + public function test_should_not_compile_when_there_are_no_styles() { Monkey\Functions\when( 'beans_get_component_support' )->justReturn( true ); Monkey\Functions\when( 'get_option' )->justReturn( true ); Monkey\Functions\when( '_beans_is_compiler_dev_mode' )->justReturn( false ); @@ -86,7 +86,7 @@ public function test_should_not_compile_when_there_are_not_styles() { // Check that beans_get() only gets called once. Monkey\Functions\expect( 'beans_get' )->once()->andReturn( null ); - // Check that this function does not get called. + // Check that beans_compile_css_fragments() does not get called. Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); // Run the tests. @@ -129,7 +129,7 @@ public function test_should_not_compile_when_style_is_not_registered() { $assets->registered['uikit'] = null; $assets->registered['child-style'] = null; - // Set up the order of how beans_get() will be called. + // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) ->ordered() ->once() @@ -167,7 +167,7 @@ public function test_should_not_compile_when_style_has_no_src() { $assets->registered['uikit']->src = ''; $assets->registered['child-style']->src = ''; - // Set up the order of how beans_get() will be called. + // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) ->ordered() ->once() @@ -203,7 +203,7 @@ public function test_should_compile_when_style_has_src_but_no_deps() { // Initialize the mocked assets. $assets = $this->get_mock_assets( [ 'admin-bar', 'uikit', 'child-style' ] ); - // Set up the order of how beans_get() will be called. + // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) ->ordered() ->once() @@ -254,7 +254,7 @@ public function test_should_add_query_arg_to_compiled_style_src() { $original_src = $assets->registered['child-style']->src; $new_src = $original_src . '?beans_compiler_media_query=screen'; - // Set up the order of how beans_get() will be called. + // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) ->ordered() ->once() @@ -304,7 +304,7 @@ public function test_should_compile_style_and_deps() { 'debug-bar-actions-filters', ] ); - // Set up the order of how beans_get() will be called. + // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) ->ordered() ->once() diff --git a/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php index a1a0b1f5..4bf9f112 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php @@ -1,6 +1,6 @@ Date: Thu, 17 May 2018 12:06:34 -0500 Subject: [PATCH 596/800] Fixed documentation and test naming. --- lib/api/image/class-beans-image-options.php | 2 +- .../integration/api/image/beans-image-options/register.php | 3 +-- .../api/image/beans-image-options/renderFlushButton.php | 5 ++--- .../api/image/beans-image-options/renderSuccessNotice.php | 4 ++-- .../unit/api/image/beans-image-options/renderFlushButton.php | 4 ++-- .../api/image/beans-image-options/renderSuccessNotice.php | 4 ++-- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index a60ede3e..ca2e97b4 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -77,7 +77,7 @@ private function has_metaboxes() { } /** - * Flush images for all folders set. + * Flush images from the Beans cached folder. * * @since 1.0.0 * diff --git a/tests/phpunit/integration/api/image/beans-image-options/register.php b/tests/phpunit/integration/api/image/beans-image-options/register.php index fcd2ae81..323ea460 100644 --- a/tests/phpunit/integration/api/image/beans-image-options/register.php +++ b/tests/phpunit/integration/api/image/beans-image-options/register.php @@ -1,6 +1,6 @@ Date: Fri, 18 May 2018 14:47:45 -0500 Subject: [PATCH 597/800] Reset on tearDown only. --- tests/phpunit/integration/class-test-case.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index b9126b48..13d3b9a1 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -19,13 +19,6 @@ */ abstract class Test_Case extends WP_UnitTestCase { - /** - * Reset flag. - * - * @var bool - */ - protected $was_reset = false; - /** * Set up the test before we run the test setups. */ @@ -41,12 +34,6 @@ public static function setUpBeforeClass() { public function setUp() { parent::setUp(); Monkey\setUp(); - - if ( ! $this->was_reset ) { - $this->reset_fields_container(); - $this->reset_actions_container(); - $this->was_reset = true; - } } /** From 1b99f37a9cbbfce8b5db41c8c090e3c12929522e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 15:18:39 -0500 Subject: [PATCH 598/800] Moved the common test case functionality to a trait. With this change, we can now reuse the functionality in any test suite without duplication. --- tests/phpunit/integration/bootstrap.php | 1 + tests/phpunit/integration/class-test-case.php | 88 +------------ tests/phpunit/test-case-trait.php | 118 ++++++++++++++++++ tests/phpunit/unit/bootstrap.php | 1 + tests/phpunit/unit/class-test-case.php | 108 +--------------- 5 files changed, 126 insertions(+), 190 deletions(-) create mode 100644 tests/phpunit/test-case-trait.php diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index 0af6629f..561ad73c 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -73,4 +73,5 @@ function beans_get_wp_tests_dir() { require_once $beans_tests_dir . '/includes/bootstrap.php'; // Load the Integration Test Case. +require_once dirname( __DIR__ ) . '/test-case-trait.php'; require_once BEANS_TESTS_DIR . '/class-test-case.php'; diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index 13d3b9a1..54669601 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -9,6 +9,7 @@ namespace Beans\Framework\Tests\Integration; +use Beans\Framework\Tests\Test_Case_Trait; use Brain\Monkey; use WP_UnitTestCase; @@ -19,6 +20,8 @@ */ abstract class Test_Case extends WP_UnitTestCase { + use Test_Case_Trait; + /** * Set up the test before we run the test setups. */ @@ -47,53 +50,6 @@ public function tearDown() { parent::tearDown(); } - /** - * Load the original Beans' functions into memory before we start. - * - * Then in our tests, we monkey patch via Brain Monkey, which redefines the original function. - * At tear down, the original function is restored in Brain Monkey, by calling Patchwork\restoreAll(). - * - * @since 1.5.0 - * - * @param array $files Array of files to load into memory. - * - * @return void - */ - protected function load_original_functions( array $files ) { - - foreach ( $files as $file ) { - require_once BEANS_TESTS_LIB_DIR . $file; - } - } - - /** - * Format the HTML by stripping out the whitespace between the HTML tags and then putting each tag on a separate - * line. - * - * Why? We can then compare the actual vs. expected HTML patterns without worrying about tabs, new lines, and extra - * spaces. - * - * @since 1.5.0 - * - * @param string $html HTML to strip. - * - * @return string - */ - protected function format_the_html( $html ) { - $html = trim( $html ); - - // Strip whitespace between the tags. - $html = preg_replace( '/(\>)\s*(\<)/m', '$1$2', $html ); - - // Strip whitespace at the end of a tag. - $html = preg_replace( '/(\>)\s*/m', '$1$2', $html ); - - // Strip whitespace at the start of a tag. - $html = preg_replace( '/\s*(\<)/m', '$1$2', $html ); - - return str_replace( '>', ">\n", $html ); - } - /** * Reset the Actions API container. */ @@ -131,42 +87,4 @@ protected function reset_fields_container() { $property->setValue( new \_Beans_Fields(), array() ); } } - - /** - * Get reflective access to the private method. - * - * @since 1.5.0 - * - * @param string $method_name Method name for which to gain access. - * @param string $class_name Name of the target class. - * - * @return \ReflectionMethod - * @throws \ReflectionException Throws an exception if method does not exist. - */ - protected function get_reflective_method( $method_name, $class_name ) { - $class = new \ReflectionClass( $class_name ); - $method = $class->getMethod( $method_name ); - $method->setAccessible( true ); - - return $method; - } - - /** - * Get reflective access to the private property. - * - * @since 1.5.0 - * - * @param string $property Property name for which to gain access. - * @param string $class_name Name of the target class. - * - * @return \ReflectionProperty|string - * @throws \ReflectionException Throws an exception if property does not exist. - */ - protected function get_reflective_property( $property, $class_name ) { - $class = new \ReflectionClass( $class_name ); - $property = $class->getProperty( $property ); - $property->setAccessible( true ); - - return $property; - } } diff --git a/tests/phpunit/test-case-trait.php b/tests/phpunit/test-case-trait.php new file mode 100644 index 00000000..de957737 --- /dev/null +++ b/tests/phpunit/test-case-trait.php @@ -0,0 +1,118 @@ +)\s*(\<)/m', '$1$2', $html ); + + // Strip whitespace at the end of a tag. + $html = preg_replace( '/(\>)\s*/m', '$1$2', $html ); + + // Strip whitespace at the start of a tag. + $html = preg_replace( '/\s*(\<)/m', '$1$2', $html ); + + return str_replace( '>', ">\n", $html ); + } + + /** + * Get reflective access to the private method. + * + * @since 1.5.0 + * + * @param string $method_name Method name for which to gain access. + * @param string $class_name Name of the target class. + * + * @return \ReflectionMethod + * @throws \ReflectionException Throws an exception if method does not exist. + */ + protected function get_reflective_method( $method_name, $class_name ) { + $class = new \ReflectionClass( $class_name ); + $method = $class->getMethod( $method_name ); + $method->setAccessible( true ); + + return $method; + } + + /** + * Get reflective access to the private property. + * + * @since 1.5.0 + * + * @param string $property Property name for which to gain access. + * @param string|mixed $class Class name or instance. + * + * @return \ReflectionProperty|string + * @throws \ReflectionException Throws an exception if property does not exist. + */ + protected function get_reflective_property( $property, $class ) { + $class = new \ReflectionClass( $class ); + $property = $class->getProperty( $property ); + $property->setAccessible( true ); + + return $property; + } + + /** + * Set the value of a property or private property. + * + * @since 1.5.0 + * + * @param mixed $value The value to set for the property. + * @param string $property Property name for which to gain access. + * @param mixed $instance Instance of the target object. + * + * @return \ReflectionProperty|string + * @throws \ReflectionException Throws an exception if property does not exist. + */ + protected function set_reflective_property( $value, $property, $instance ) { + $property = $this->get_reflective_property( $property, $instance ); + $property->setValue( $instance, $value ); + $property->setAccessible( false ); + + return $property; + } +} diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index 865d8de7..14cbafe9 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -33,4 +33,5 @@ require_once $beans_autoload_path . 'autoload.php'; unset( $beans_autoload_path ); +require_once dirname( __DIR__ ) . '/test-case-trait.php'; require_once BEANS_TESTS_DIR . '/class-test-case.php'; diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 6e09718f..f10ef5b5 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -9,6 +9,7 @@ namespace Beans\Framework\Tests\Unit; +use Beans\Framework\Tests\Test_Case_Trait; use Brain\Monkey; use Brain\Monkey\Functions; use PHPUnit\Framework\TestCase; @@ -20,6 +21,8 @@ */ abstract class Test_Case extends TestCase { + use Test_Case_Trait; + /** * When true, return the given path when doing wp_normalize_path(). * @@ -105,53 +108,6 @@ protected function tearDown() { parent::tearDown(); } - /** - * Load the original Beans' functions into memory before we start. - * - * Then in our tests, we monkey patch via Brain Monkey, which redefines the original function. - * At tear down, the original function is restored in Brain Monkey, by calling Patchwork\restoreAll(). - * - * @since 1.5.0 - * - * @param array $files Array of files to load into memory. - * - * @return void - */ - protected function load_original_functions( array $files ) { - - foreach ( $files as $file ) { - require_once BEANS_TESTS_LIB_DIR . $file; - } - } - - /** - * Format the HTML by stripping out the whitespace between the HTML tags and then putting each tag on a separate - * line. - * - * Why? We can then compare the actual vs. expected HTML patterns without worrying about tabs, new lines, and extra - * spaces. - * - * @since 1.5.0 - * - * @param string $html HTML to strip. - * - * @return string - */ - protected function format_the_html( $html ) { - $html = trim( $html ); - - // Strip whitespace between the tags. - $html = preg_replace( '/(\>)\s*(\<)/m', '$1$2', $html ); - - // Strip whitespace at the end of a tag. - $html = preg_replace( '/(\>)\s*/m', '$1$2', $html ); - - // Strip whitespace at the start of a tag. - $html = preg_replace( '/\s*(\<)/m', '$1$2', $html ); - - return str_replace( '>', ">\n", $html ); - } - /** * Reset the Actions API container. */ @@ -189,62 +145,4 @@ protected function reset_fields_container() { $property->setValue( new \_Beans_Fields(), array() ); } } - - /** - * Get reflective access to the private method. - * - * @since 1.5.0 - * - * @param string $method_name Method name for which to gain access. - * @param string $class_name Name of the target class. - * - * @return \ReflectionMethod - * @throws \ReflectionException Throws an exception if method does not exist. - */ - protected function get_reflective_method( $method_name, $class_name ) { - $class = new \ReflectionClass( $class_name ); - $method = $class->getMethod( $method_name ); - $method->setAccessible( true ); - - return $method; - } - - /** - * Get reflective access to the private property. - * - * @since 1.5.0 - * - * @param string $property Property name for which to gain access. - * @param string|mixed $class Class name or instance. - * - * @return \ReflectionProperty|string - * @throws \ReflectionException Throws an exception if property does not exist. - */ - protected function get_reflective_property( $property, $class ) { - $class = new \ReflectionClass( $class ); - $property = $class->getProperty( $property ); - $property->setAccessible( true ); - - return $property; - } - - /** - * Set the value of a property or private property. - * - * @since 1.5.0 - * - * @param mixed $value The value to set for the property. - * @param string $property Property name for which to gain access. - * @param mixed $instance Instance of the target object. - * - * @return \ReflectionProperty|string - * @throws \ReflectionException Throws an exception if property does not exist. - */ - protected function set_reflective_property( $value, $property, $instance ) { - $property = $this->get_reflective_property( $property, $instance ); - $property->setValue( $instance, $value ); - $property->setAccessible( false ); - - return $property; - } } From f8d4a47397c8691c2300f36704dd792b41fd7ced Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 15:40:21 -0500 Subject: [PATCH 599/800] Added the initial Beans Resetter for the test suites. The Beans Resetter's job is to reset the framework back to its starting state. Why? Each test needs to start at a known, predictable, repeatable starting state. Why? To ensure that each test does not impact the other tests in the suites. This commit is the first step to building a Resetter for each test suite's Test Case. --- tests/phpunit/class-beans-resetter.php | 106 ++++++++++++++++++ tests/phpunit/functions.php | 39 +++++++ tests/phpunit/integration/bootstrap.php | 1 + tests/phpunit/integration/class-test-case.php | 42 +------ tests/phpunit/unit/bootstrap.php | 1 + tests/phpunit/unit/class-test-case.php | 55 +-------- 6 files changed, 151 insertions(+), 93 deletions(-) create mode 100644 tests/phpunit/class-beans-resetter.php create mode 100644 tests/phpunit/functions.php diff --git a/tests/phpunit/class-beans-resetter.php b/tests/phpunit/class-beans-resetter.php new file mode 100644 index 00000000..78d828c3 --- /dev/null +++ b/tests/phpunit/class-beans-resetter.php @@ -0,0 +1,106 @@ +reset_global_state(); + + // Reset APIs. + $this->reset_components(); + $this->reset_actions_api(); + $this->reset_compiler_api(); + $this->reset_fields_api(); + } + + /** + * Reset the global state. + */ + protected function reset_global_state() { + $_GET = []; + $_POST = []; + } + + /** + * Resets the Beans' API Components. + */ + protected function reset_components() { + + if ( ! function_exists( 'beans_get_component_support' ) ) { + return; + } + + global $_beans_api_components_support; + $_beans_api_components_support = []; + } + + /** + * Reset the Actions API. + */ + protected function reset_actions_api() { + global $_beans_registered_actions; + $_beans_registered_actions = [ + 'added' => [], + 'modified' => [], + 'removed' => [], + 'replaced' => [], + ]; + } + + /** + * Reset the Compiler API. + */ + protected function reset_compiler_api() { + global $_beans_compiler_added_fragments; + $_beans_compiler_added_fragments = [ + 'css' => [], + 'less' => [], + 'js' => [], + ]; + } + + /** + * Reset the Fields API. + */ + protected function reset_fields_api() { + + if ( ! class_exists( '_Beans_Fields' ) ) { + return; + } + + // Reset the "registered" container. + $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); + $registered->setValue( new _Beans_Fields(), [ + 'option' => [], + 'post_meta' => [], + 'term_meta' => [], + 'wp_customize' => [], + ] ); + + // Reset the other static properties. + foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { + $property = $this->get_reflective_property( $property_name, '_Beans_Fields' ); + $property->setValue( new _Beans_Fields(), [] ); + } + } +} diff --git a/tests/phpunit/functions.php b/tests/phpunit/functions.php new file mode 100644 index 00000000..0823552c --- /dev/null +++ b/tests/phpunit/functions.php @@ -0,0 +1,39 @@ +reset(); +} + +/** + * Gets the Bean's Resetter. + * + * @since 1.5.0 + * + * @return Beans_Resetter + */ +function get_beans_resetter() { + static $resetter; + + if ( is_null( $resetter ) ) { + require_once __DIR__ . '/class-beans-resetter.php'; + $resetter = new Beans_Resetter(); + } + + return $resetter; +} diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index 561ad73c..28927d58 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -73,5 +73,6 @@ function beans_get_wp_tests_dir() { require_once $beans_tests_dir . '/includes/bootstrap.php'; // Load the Integration Test Case. +require_once dirname( __DIR__ ) . '/functions.php'; require_once dirname( __DIR__ ) . '/test-case-trait.php'; require_once BEANS_TESTS_DIR . '/class-test-case.php'; diff --git a/tests/phpunit/integration/class-test-case.php b/tests/phpunit/integration/class-test-case.php index 54669601..bb83a7b8 100644 --- a/tests/phpunit/integration/class-test-case.php +++ b/tests/phpunit/integration/class-test-case.php @@ -9,6 +9,7 @@ namespace Beans\Framework\Tests\Integration; +use function Beans\Framework\Tests\reset_beans; use Beans\Framework\Tests\Test_Case_Trait; use Brain\Monkey; use WP_UnitTestCase; @@ -43,48 +44,9 @@ public function setUp() { * Cleans up the test environment after each test. */ public function tearDown() { - $this->reset_fields_container(); - $this->reset_actions_container(); + reset_beans(); Monkey\tearDown(); parent::tearDown(); } - - /** - * Reset the Actions API container. - */ - protected function reset_actions_container() { - global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); - } - - /** - * Reset the Fields API container, i.e. static memories. - */ - protected function reset_fields_container() { - - if ( ! class_exists( '_Beans_Fields' ) ) { - return; - } - - // Reset the "registered" container. - $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); - $registered->setValue( new \_Beans_Fields(), array( - 'option' => array(), - 'post_meta' => array(), - 'term_meta' => array(), - 'wp_customize' => array(), - ) ); - - // Reset the other static properties. - foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { - $property = $this->get_reflective_property( $property_name, '_Beans_Fields' ); - $property->setValue( new \_Beans_Fields(), array() ); - } - } } diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index 14cbafe9..33531e28 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -33,5 +33,6 @@ require_once $beans_autoload_path . 'autoload.php'; unset( $beans_autoload_path ); +require_once dirname( __DIR__ ) . '/functions.php'; require_once dirname( __DIR__ ) . '/test-case-trait.php'; require_once BEANS_TESTS_DIR . '/class-test-case.php'; diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index f10ef5b5..e2e5c343 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -9,6 +9,7 @@ namespace Beans\Framework\Tests\Unit; +use function Beans\Framework\Tests\reset_beans; use Beans\Framework\Tests\Test_Case_Trait; use Brain\Monkey; use Brain\Monkey\Functions; @@ -30,13 +31,6 @@ abstract class Test_Case extends TestCase { */ protected $just_return_path = false; - /** - * Reset flag. - * - * @var bool - */ - protected $was_reset = false; - /** * Prepares the test environment before each test. */ @@ -89,60 +83,15 @@ protected function setup_common_wp_stubs() { foreach ( array( 'esc_attr_e', 'esc_html_e', '_e' ) as $wp_function ) { Monkey\Functions\when( $wp_function )->echoArg(); } - - if ( ! $this->was_reset ) { - $this->reset_actions_container(); - $this->reset_fields_container(); - $this->was_reset = true; - } } /** * Cleans up the test environment after each test. */ protected function tearDown() { - $this->reset_actions_container(); - $this->reset_fields_container(); + reset_beans(); Monkey\tearDown(); parent::tearDown(); } - - /** - * Reset the Actions API container. - */ - protected function reset_actions_container() { - global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); - } - - /** - * Reset the Fields API container, i.e. static memories. - */ - protected function reset_fields_container() { - - if ( ! class_exists( '_Beans_Fields' ) ) { - return; - } - - // Reset the "registered" container. - $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); - $registered->setValue( new \_Beans_Fields(), array( - 'option' => array(), - 'post_meta' => array(), - 'term_meta' => array(), - 'wp_customize' => array(), - ) ); - - // Reset the other static properties. - foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { - $property = $this->get_reflective_property( $property_name, '_Beans_Fields' ); - $property->setValue( new \_Beans_Fields(), array() ); - } - } } From ddfed48f714c51713f74eb9bb2e42a90d3f4c54c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 16:07:45 -0500 Subject: [PATCH 600/800] Fixed Filters API tests @group. --- .../phpunit/integration/api/filters/beansAddAnonymousFilter.php | 2 +- tests/phpunit/integration/api/filters/beansAddFilter.php | 2 +- tests/phpunit/integration/api/filters/beansApplyFilters.php | 2 +- tests/phpunit/integration/api/filters/beansHasFilters.php | 2 +- tests/phpunit/unit/api/filters/beansAddFilter.php | 2 +- tests/phpunit/unit/api/filters/beansApplyFilters.php | 2 +- tests/phpunit/unit/api/filters/beansHasFilters.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php b/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php index 74cdda14..2a4ef7a3 100644 --- a/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php +++ b/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php @@ -15,8 +15,8 @@ * Class Tests_BeansAddAnonymousFilter * * @package Beans\Framework\Tests\Integration\API\Filters - * @group integration-tests * @group api + * @group api-filters */ class Tests_BeansAddAnonymousFilter extends WP_UnitTestCase { diff --git a/tests/phpunit/integration/api/filters/beansAddFilter.php b/tests/phpunit/integration/api/filters/beansAddFilter.php index 71ace5f8..9e046ffa 100644 --- a/tests/phpunit/integration/api/filters/beansAddFilter.php +++ b/tests/phpunit/integration/api/filters/beansAddFilter.php @@ -17,8 +17,8 @@ * Class Tests_BeansAddFilter * * @package Beans\Framework\Tests\Integration\API\Filters - * @group integration-tests * @group api + * @group api-filters */ class Tests_BeansAddFilter extends Filters_Test_Case { diff --git a/tests/phpunit/integration/api/filters/beansApplyFilters.php b/tests/phpunit/integration/api/filters/beansApplyFilters.php index 7c48474d..42497e0e 100644 --- a/tests/phpunit/integration/api/filters/beansApplyFilters.php +++ b/tests/phpunit/integration/api/filters/beansApplyFilters.php @@ -17,8 +17,8 @@ * Class Tests_BeansApplyFilters * * @package Beans\Framework\Tests\Integration\API\Filters - * @group integration-tests * @group api + * @group api-filters */ class Tests_BeansApplyFilters extends Filters_Test_Case { diff --git a/tests/phpunit/integration/api/filters/beansHasFilters.php b/tests/phpunit/integration/api/filters/beansHasFilters.php index 8c75f0b0..3dc1e98b 100644 --- a/tests/phpunit/integration/api/filters/beansHasFilters.php +++ b/tests/phpunit/integration/api/filters/beansHasFilters.php @@ -17,8 +17,8 @@ * Class Tests_BeansHasFilters * * @package Beans\Framework\Tests\Integration\API\Filters - * @group integration-tests * @group api + * @group api-filters */ class Tests_BeansHasFilters extends Filters_Test_Case { diff --git a/tests/phpunit/unit/api/filters/beansAddFilter.php b/tests/phpunit/unit/api/filters/beansAddFilter.php index 4cc56891..28d2a6d0 100644 --- a/tests/phpunit/unit/api/filters/beansAddFilter.php +++ b/tests/phpunit/unit/api/filters/beansAddFilter.php @@ -17,8 +17,8 @@ * Class Tests_BeansAddFilter * * @package Beans\Framework\Tests\Unit\API\Filters - * @group unit-tests * @group api + * @group api-filters */ class Tests_BeansAddFilter extends Filters_Test_Case { diff --git a/tests/phpunit/unit/api/filters/beansApplyFilters.php b/tests/phpunit/unit/api/filters/beansApplyFilters.php index b923908d..76cb3a19 100644 --- a/tests/phpunit/unit/api/filters/beansApplyFilters.php +++ b/tests/phpunit/unit/api/filters/beansApplyFilters.php @@ -18,8 +18,8 @@ * Class Tests_BeansApplyFilters * * @package Beans\Framework\Tests\Unit\API\Filters - * @group unit-tests * @group api + * @group api-filters */ class Tests_BeansApplyFilters extends Filters_Test_Case { diff --git a/tests/phpunit/unit/api/filters/beansHasFilters.php b/tests/phpunit/unit/api/filters/beansHasFilters.php index 7e3ace56..4d519e06 100644 --- a/tests/phpunit/unit/api/filters/beansHasFilters.php +++ b/tests/phpunit/unit/api/filters/beansHasFilters.php @@ -17,8 +17,8 @@ * Class Tests_BeansHasFilters * * @package Beans\Framework\Tests\Unit\API\Filters - * @group unit-tests * @group api + * @group api-filters */ class Tests_BeansHasFilters extends Filters_Test_Case { From 3e4af2dd3cde278fea81893068ff195c843db21a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 16:41:52 -0500 Subject: [PATCH 601/800] Fixed fields tests. --- tests/phpunit/integration/api/fields/beansField.php | 1 + .../integration/api/options/beans-options/renderMetabox.php | 3 +++ .../unit/api/fields/includes/class-fields-test-case.php | 3 +++ 3 files changed, 7 insertions(+) diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 8d41f318..838678d6 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -40,6 +40,7 @@ public function setUp() { beans_add_smart_action( 'beans_field_group_label', 'beans_field_label' ); beans_add_smart_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + beans_add_smart_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); } /** diff --git a/tests/phpunit/integration/api/options/beans-options/renderMetabox.php b/tests/phpunit/integration/api/options/beans-options/renderMetabox.php index 70ac0d8b..6015557e 100644 --- a/tests/phpunit/integration/api/options/beans-options/renderMetabox.php +++ b/tests/phpunit/integration/api/options/beans-options/renderMetabox.php @@ -48,6 +48,8 @@ public function test_should_render_registered_fields() { // Register the field and option. $option = end( static::$test_data ); beans_register_fields( $option['fields'], 'option', $option['section'] ); + beans_add_smart_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + beans_add_smart_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); beans_add_smart_action( 'beans_field_checkbox', 'beans_field_checkbox' ); $instance->register( $option['section'], $option['args'] ); @@ -67,6 +69,7 @@ public function test_should_render_registered_fields() { Enable development mode +
      This option should be enabled while your website is in development.
      EOB; $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 071b2ebe..c9a96e61 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -44,6 +44,7 @@ protected function setUp() { parent::setUp(); $this->load_original_functions( array( + 'api/actions/functions.php', 'api/fields/functions.php', 'api/fields/class-beans-fields.php', 'api/utilities/functions.php', @@ -123,5 +124,7 @@ protected function setup_function_mocks() { return trim( $string ); } ); + + Monkey\Functions\when( 'beans_add_smart_action' )->justReturn(); } } From acc6c6488e96ccb4f6a875434939bd3e1bcd70c1 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 16:48:51 -0500 Subject: [PATCH 602/800] Fixed Template API tests @group. --- .../integration/api/template/beansLoadDefaultTemplate.php | 2 +- .../phpunit/integration/api/template/beansLoadFragmentFile.php | 2 +- tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php | 2 +- tests/phpunit/unit/api/template/beansLoadFragmentFile.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php index b88716ab..95505dd5 100644 --- a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php @@ -15,8 +15,8 @@ * Class Tests_BeansLoadDefaultTemplate * * @package Beans\Framework\Tests\Integration\API\Template - * @group integration-tests * @group api + * @group api-template */ class Tests_BeansLoadDefaultTemplate extends WP_UnitTestCase { diff --git a/tests/phpunit/integration/api/template/beansLoadFragmentFile.php b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php index 040a39dd..cc8e8452 100644 --- a/tests/phpunit/integration/api/template/beansLoadFragmentFile.php +++ b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php @@ -16,8 +16,8 @@ * Class Tests_BeansLoadFragmentFile * * @package Beans\Framework\Tests\Integration\API\Template - * @group integration-tests * @group api + * @group api-template */ class Tests_BeansLoadFragmentFile extends WP_UnitTestCase { diff --git a/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php index 84afa161..36993dff 100644 --- a/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php @@ -18,8 +18,8 @@ * Class Tests_BeansLoadDefaultTemplate * * @package Beans\Framework\Tests\Unit\API\Template - * @group unit-tests * @group api + * @group api-template */ class Tests_BeansLoadDefaultTemplate extends Template_Test_Case { diff --git a/tests/phpunit/unit/api/template/beansLoadFragmentFile.php b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php index 6024d3e5..0639e0e0 100644 --- a/tests/phpunit/unit/api/template/beansLoadFragmentFile.php +++ b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php @@ -18,8 +18,8 @@ * Class Tests_BeansLoadFragmentFile * * @package Beans\Framework\Tests\Unit\API\Template - * @group unit-tests * @group api + * @group api-template */ class Tests_BeansLoadFragmentFile extends Template_Test_Case { From 387f51645a744382ffec03339726f72f7cd7f59e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 16:50:42 -0500 Subject: [PATCH 603/800] Fixed Utilities API tests @group. --- tests/phpunit/unit/api/utilities/beansGet.php | 2 +- tests/phpunit/unit/api/utilities/beansIsUrl.php | 2 +- tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php | 2 +- tests/phpunit/unit/api/utilities/beansPathToUrl.php | 2 +- tests/phpunit/unit/api/utilities/beansRemoveDir.php | 2 +- tests/phpunit/unit/api/utilities/beansRenderFunction.php | 2 +- tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php | 2 +- tests/phpunit/unit/api/utilities/beansSanitizePath.php | 2 +- tests/phpunit/unit/api/utilities/beansUrlToPath.php | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/unit/api/utilities/beansGet.php b/tests/phpunit/unit/api/utilities/beansGet.php index ab4327fe..f623d165 100644 --- a/tests/phpunit/unit/api/utilities/beansGet.php +++ b/tests/phpunit/unit/api/utilities/beansGet.php @@ -15,8 +15,8 @@ * Class Tests_BeansGet * * @package Beans\Framework\Tests\Unit\API\Utilities - * @group unit-tests * @group api + * @group api-utilities */ class Tests_BeansGet extends Test_Case { diff --git a/tests/phpunit/unit/api/utilities/beansIsUrl.php b/tests/phpunit/unit/api/utilities/beansIsUrl.php index 84b35eff..4ad679b9 100644 --- a/tests/phpunit/unit/api/utilities/beansIsUrl.php +++ b/tests/phpunit/unit/api/utilities/beansIsUrl.php @@ -15,8 +15,8 @@ * Class Tests_BeansIsUrl * * @package Beans\Framework\Tests\Unit\API\Utilities - * @group unit-tests * @group api + * @group api-utilities */ class Tests_BeansIsUrl extends Test_Case { diff --git a/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php index 137d3809..cdc67df0 100644 --- a/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php +++ b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php @@ -15,8 +15,8 @@ * Class Tests_BeansMultiArrayKeyExists * * @package Beans\Framework\Tests\Unit\API\Utilities - * @group unit-tests * @group api + * @group api-utilities */ class Tests_BeansMultiArrayKeyExists extends Test_Case { diff --git a/tests/phpunit/unit/api/utilities/beansPathToUrl.php b/tests/phpunit/unit/api/utilities/beansPathToUrl.php index 3b507ef8..394613ff 100644 --- a/tests/phpunit/unit/api/utilities/beansPathToUrl.php +++ b/tests/phpunit/unit/api/utilities/beansPathToUrl.php @@ -16,8 +16,8 @@ * Class Tests_BeansPathToUrl * * @package Beans\Framework\Tests\Unit\API\Utilities - * @group unit-tests * @group api + * @group api-utilities */ class Tests_BeansPathToUrl extends Test_Case { diff --git a/tests/phpunit/unit/api/utilities/beansRemoveDir.php b/tests/phpunit/unit/api/utilities/beansRemoveDir.php index 96560de4..7cf1f2fa 100644 --- a/tests/phpunit/unit/api/utilities/beansRemoveDir.php +++ b/tests/phpunit/unit/api/utilities/beansRemoveDir.php @@ -16,8 +16,8 @@ * Class Tests_BeansRemoveDir * * @package Beans\Framework\Tests\Unit\API\Utilities - * @group unit-tests * @group api + * @group api-utilities */ class Tests_BeansRemoveDir extends Test_Case { diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunction.php b/tests/phpunit/unit/api/utilities/beansRenderFunction.php index ba7edede..bde18d9d 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunction.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunction.php @@ -16,8 +16,8 @@ * Class Tests_BeansRenderFunction * * @package Beans\Framework\Tests\Unit\API\Utilities - * @group unit-tests * @group api + * @group api-utilities */ class Tests_BeansRenderFunction extends Test_Case { diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php index 9c728366..3457aec8 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php @@ -15,8 +15,8 @@ * Class Tests_BeansRenderFunctionArray * * @package Beans\Framework\Tests\API\Utilities - * @group unit-tests * @group api + * @group api-utilities */ class Tests_BeansRenderFunctionArray extends Test_Case { diff --git a/tests/phpunit/unit/api/utilities/beansSanitizePath.php b/tests/phpunit/unit/api/utilities/beansSanitizePath.php index caf2a509..c385e36d 100644 --- a/tests/phpunit/unit/api/utilities/beansSanitizePath.php +++ b/tests/phpunit/unit/api/utilities/beansSanitizePath.php @@ -15,8 +15,8 @@ * Class Tests_BeansSanitizePath * * @package Beans\Framework\Tests\Unit\API\Utilities - * @group unit-tests * @group api + * @group api-utilities */ class Tests_BeansSanitizePath extends Test_Case { diff --git a/tests/phpunit/unit/api/utilities/beansUrlToPath.php b/tests/phpunit/unit/api/utilities/beansUrlToPath.php index b4a7bcb9..73d6724a 100644 --- a/tests/phpunit/unit/api/utilities/beansUrlToPath.php +++ b/tests/phpunit/unit/api/utilities/beansUrlToPath.php @@ -16,8 +16,8 @@ * Class Tests_BeansUrlToPath * * @package Beans\Framework\Tests\Unit\API\Utilities - * @group unit-tests * @group api + * @group api-utilities */ class Tests_BeansUrlToPath extends Test_Case { From 933ac7722198db6ca2dc54772622ceda21c4c197 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 17:29:42 -0500 Subject: [PATCH 604/800] Fixed & standardized Term Meta integration rendering test. --- .../beans-term-meta/renderFields.php | 69 ++++++++++++++++++- .../fixtures/test-field-outout-html.php | 55 --------------- .../class-beans-term-meta-test-case.php | 3 +- .../beans-term-meta/renderFields.php | 16 +++++ .../class-beans-term-meta-test-case.php | 7 +- 5 files changed, 87 insertions(+), 63 deletions(-) delete mode 100644 tests/phpunit/integration/api/term-meta/fixtures/test-field-outout-html.php diff --git a/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php b/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php index a6b1fd00..54fff466 100644 --- a/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php +++ b/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php @@ -33,6 +33,8 @@ public function test_should_render_field_html() { beans_add_smart_action( 'beans_field_radio', 'beans_field_radio' ); beans_add_smart_action( 'beans_field_checkbox', 'beans_field_checkbox' ); beans_add_smart_action( 'beans_field_text', 'beans_field_text' ); + beans_add_smart_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); + beans_add_smart_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); // Set WP to Edit Category screen. set_current_screen( 'edit' ); @@ -45,11 +47,72 @@ public function test_should_render_field_html() { $term_meta = new _Beans_Term_Meta( 'tm-beans' ); ob_start(); $term_meta->render_fields(); - $output = trim( ob_get_clean() ); + $html = ob_get_clean(); // Check output is as expected. $beans_theme_url = BEANS_THEME_URL; - $expected_output = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-field-outout-html.php'; - $this->assertEquals( $expected_output, $output ); + $expected_html = << + + +
      +
      +
      +
      + Layout + + + + +
      +
      +
      +
      + + + + + + +
      +
      +
      + + + Enable the checkbox test +
      +
      +
      + + + + + +
      +
      +
      + +
      +
      +
      +

      Sample Text Field Description

      + + +FIELDSHTML; + $this->assertSame( $this->format_the_html( $expected_html ), $this->format_the_html( $html ) ); } } diff --git a/tests/phpunit/integration/api/term-meta/fixtures/test-field-outout-html.php b/tests/phpunit/integration/api/term-meta/fixtures/test-field-outout-html.php deleted file mode 100644 index e184e6cf..00000000 --- a/tests/phpunit/integration/api/term-meta/fixtures/test-field-outout-html.php +++ /dev/null @@ -1,55 +0,0 @@ - - - - -
      -
      - Layout - - - - -
      -
      - - - - - -
      - - -Enable the checkbox test -
      - - - - - -
      - -FIELDSHTML; diff --git a/tests/phpunit/integration/api/term-meta/includes/class-beans-term-meta-test-case.php b/tests/phpunit/integration/api/term-meta/includes/class-beans-term-meta-test-case.php index 99b04c5d..1b670e13 100644 --- a/tests/phpunit/integration/api/term-meta/includes/class-beans-term-meta-test-case.php +++ b/tests/phpunit/integration/api/term-meta/includes/class-beans-term-meta-test-case.php @@ -10,14 +10,13 @@ namespace Beans\Framework\Tests\Integration\API\Term_Meta\Includes; use Beans\Framework\Tests\Integration\Test_Case; -use WP_UnitTestCase; /** * Abstract Class Beans_Term_Meta_Test_Case * * @package Beans\Framework\Tests\Integration\API\Term_Meta\Includes */ -abstract class Beans_Term_Meta_Test_Case extends WP_UnitTestCase { +abstract class Beans_Term_Meta_Test_Case extends Test_Case { /** * An array of test data. diff --git a/tests/phpunit/unit/api/term-meta/beans-term-meta/renderFields.php b/tests/phpunit/unit/api/term-meta/beans-term-meta/renderFields.php index d3c3e103..b89f9766 100644 --- a/tests/phpunit/unit/api/term-meta/beans-term-meta/renderFields.php +++ b/tests/phpunit/unit/api/term-meta/beans-term-meta/renderFields.php @@ -28,6 +28,22 @@ class Tests_BeansTermMeta_RenderFields extends Beans_Term_Meta_Test_Case { * Tests _beans_term_meta::render_fields() should render fields HTML. */ public function test_should_render_fields_html() { + Monkey\Functions\expect( 'beans_remove_action' ) + ->once() + ->with( 'beans_field_label' ) + ->andReturn(); + Monkey\Functions\expect( 'beans_modify_action_hook' ) + ->once() + ->with( 'beans_field_description', 'beans_field_wrap_after_markup' ) + ->andReturn(); + Monkey\Functions\expect( 'beans_modify_markup' ) + ->once() + ->with( 'beans_field_description', 'p' ) + ->andReturn(); + Monkey\Functions\expect( 'beans_add_attribute' ) + ->once() + ->with( 'beans_field_description', 'class', 'description' ) + ->andReturn(); Monkey\Functions\expect( 'beans_get_fields' ) ->once() ->with( 'term_meta', 'tm-beans' ) diff --git a/tests/phpunit/unit/api/term-meta/includes/class-beans-term-meta-test-case.php b/tests/phpunit/unit/api/term-meta/includes/class-beans-term-meta-test-case.php index 103f2ce0..dcfbc6e6 100644 --- a/tests/phpunit/unit/api/term-meta/includes/class-beans-term-meta-test-case.php +++ b/tests/phpunit/unit/api/term-meta/includes/class-beans-term-meta-test-case.php @@ -4,7 +4,7 @@ * * @package Beans\Framework\Tests\Unit\API\Term_Meta\Includes * - * @since 1.5.0 + * @since 1.5.0 */ namespace Beans\Framework\Tests\Unit\API\Term_Meta\Includes; @@ -41,13 +41,14 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ + 'api/actions/functions.php', 'api/term-meta/class-beans-term-meta.php', 'api/term-meta/functions.php', 'api/term-meta/functions-admin.php', 'api/fields/functions.php', 'api/utilities/functions.php', - ) ); + ] ); $this->setup_common_wp_stubs(); Monkey\Functions\when( '_beans_pre_standardize_fields' )->returnArg(); From e9509c82214826e5e562ebd39d9fab32db933b5e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 17:46:25 -0500 Subject: [PATCH 605/800] Moved current_screen reset to Resetter. --- tests/phpunit/class-beans-resetter.php | 1 + .../api/term-meta/beans-term-meta/renderFields.php | 2 +- .../includes/class-beans-term-meta-test-case.php | 10 ---------- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/class-beans-resetter.php b/tests/phpunit/class-beans-resetter.php index 78d828c3..30cdf413 100644 --- a/tests/phpunit/class-beans-resetter.php +++ b/tests/phpunit/class-beans-resetter.php @@ -39,6 +39,7 @@ public function reset() { protected function reset_global_state() { $_GET = []; $_POST = []; + unset( $GLOBALS['current_screen'] ); } /** diff --git a/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php b/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php index 54fff466..5e4f7d96 100644 --- a/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php +++ b/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php @@ -51,7 +51,7 @@ public function test_should_render_field_html() { // Check output is as expected. $beans_theme_url = BEANS_THEME_URL; - $expected_html = << diff --git a/tests/phpunit/integration/api/term-meta/includes/class-beans-term-meta-test-case.php b/tests/phpunit/integration/api/term-meta/includes/class-beans-term-meta-test-case.php index 1b670e13..7b6a5c2a 100644 --- a/tests/phpunit/integration/api/term-meta/includes/class-beans-term-meta-test-case.php +++ b/tests/phpunit/integration/api/term-meta/includes/class-beans-term-meta-test-case.php @@ -33,14 +33,4 @@ public static function setUpBeforeClass() { static::$test_data = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-fields.php'; } - - /** - * Fixture to clean up after tests. - */ - public function tearDown() { - unset( $GLOBALS['current_screen'] ); - $this->clean_up_global_scope(); - - parent::tearDown(); - } } From 1ecfb573c7fc1258b1c19bdaf2bdce6b8b4c4456 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 19:19:42 -0500 Subject: [PATCH 606/800] Moved Compiler unit test resets to the Resetter. --- tests/phpunit/class-beans-resetter.php | 2 ++ .../includes/class-compiler-test-case.php | 18 ------------------ 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/class-beans-resetter.php b/tests/phpunit/class-beans-resetter.php index 30cdf413..0912ffa2 100644 --- a/tests/phpunit/class-beans-resetter.php +++ b/tests/phpunit/class-beans-resetter.php @@ -78,6 +78,8 @@ protected function reset_compiler_api() { 'less' => [], 'js' => [], ]; + + unset( $GLOBALS['wp_filesystem'] ); } /** diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 3adf0a69..4690f708 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -86,24 +86,6 @@ protected function setUp() { ) ); } - /** - * Tear down the test fixture. - */ - protected function tearDown() { - // Reset the global fragments container. - global $_beans_compiler_added_fragments; - $_beans_compiler_added_fragments = array( - 'css' => array(), - 'less' => array(), - 'js' => array(), - ); - - unset( $GLOBALS['wp_filesystem'] ); - - Mockery::close(); - parent::tearDown(); - } - /** * Set up the virtual filesystem. */ From d02f6bd2a08673dd52bfbac6fceacb26a94b7f59 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 18 May 2018 20:42:15 -0500 Subject: [PATCH 607/800] Fixed Compiler's CSS minifier for cross-platform consistency. On a non-Windows machine, the CSS last rule still had its semi-colon + the closing } was a separate line. But on a Windows machine, it was correct. This change corrects the minifier to: 1. strip out all of the new lines, tabs, and empty spaces. 2. strips the last rule's semi-colon. 3. Puts each block one a single line. --- lib/api/compiler/class-beans-compiler.php | 7 ++++-- .../compiler/beans-compiler/formatContent.php | 9 ++++---- .../includes/class-compiler-test-case.php | 12 ++++------ .../beans-compiler/combineFragments.php | 6 ++++- .../compiler/beans-compiler/formatContent.php | 3 +-- .../beans-compiler/getInternalContent.php | 2 +- .../includes/class-compiler-test-case.php | 23 ++++++++++++------- 7 files changed, 36 insertions(+), 26 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 0765fed8..d6eadb22 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -571,6 +571,7 @@ public function format_content( $content ) { } $js_min = new JSMin( $content ); + return $js_min->min(); } @@ -785,12 +786,14 @@ private function remove_modified_files( $hash, $filemtime_hash ) { private function strip_whitespace( $content ) { $replace = array( '#/\*.*?\*/#s' => '', // Strip comments. - '#\s\s+#' => ' ', // Strip excess whitespace. ); $search = array_keys( $replace ); $content = preg_replace( $search, $replace, $content ); + // Strip all new lines, tabs, and whitespace. + $content = str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', $content ); + $replace = array( ': ' => ':', '; ' => ';', @@ -801,7 +804,7 @@ private function strip_whitespace( $content ) { ';}' => '}', // Strip optional semicolons. ',\n' => ',', // Don't wrap multiple selectors. '\n}' => '}', // Don't wrap closing braces. - '} ' => "}\n", // Put each rule on it's own line. + '}' => "}\n", // Put each rule on it's own line. '\n' => '', // Remove all line breaks. ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php index 129dc38b..98d9fe9d 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -111,11 +111,12 @@ public function test_should_return_minified_compiled_css() { // Turn off development mode. update_option( 'beans_dev_mode', false ); + $expected_css = <<assertContains( - 'body{background-color:#fff;color:#000;font-size:18px;', - $compiler->format_content( $this->less ) - ); + $this->assertSame( $expected_css, $compiler->format_content( $this->less ) ); } /** diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index 8e2a08a3..ce1a2afe 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -278,12 +278,9 @@ class MyGameClock{constructor(maxTime){this.maxTime=maxTime;this.currentClock=0; */ protected function get_compiled_css() { return <<once()->andReturn( false ); $this->mock_filesystem_for_fragments( $compiler ); + $expected_css = <<combine_fragments(); - $this->assertContains( 'body{background-color:#fff;color:#000;font-size:18px;', $compiler->compiled_content ); + $this->assertSame( $expected_css, $compiler->compiled_content ); } /** diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php index d22b5d01..d1333cdc 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -127,8 +127,7 @@ public function test_should_return_minified_compiled_css() { // Run the test. $expected_css = <<assertSame( $expected_css, $compiler->format_content( $this->less ) ); } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php index babf6aa7..36378434 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php @@ -78,6 +78,6 @@ public function test_should_return_fragment_contents() { } EOB; - $this->assertSame( $expected, $compiler->get_internal_content() ); + $this->assertSame( $this->strip_characters( $expected ), $this->strip_characters( $compiler->get_internal_content() ) ); } } diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 4690f708..a6a0f942 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -301,12 +301,9 @@ class MyGameClock{constructor(maxTime){this.maxTime=maxTime;this.currentClock=0; */ protected function get_compiled_css() { return << Date: Sat, 19 May 2018 10:18:15 -0500 Subject: [PATCH 608/800] Fixed class='hndle'. (#228) Newer versions of WordPress' metabox code has fixed the single quotation marks around the class attribute 'hndle'. This commit formats the rendered HTML by converting the single quotes to doubles, thereby, allowing our tests to pass on multiple versions of WordPress. --- .../api/options/beans-options/renderPage.php | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/integration/api/options/beans-options/renderPage.php b/tests/phpunit/integration/api/options/beans-options/renderPage.php index 947941fb..2356f22e 100644 --- a/tests/phpunit/integration/api/options/beans-options/renderPage.php +++ b/tests/phpunit/integration/api/options/beans-options/renderPage.php @@ -46,7 +46,7 @@ public function test_should_render_form_when_context_normal() { ob_start(); ( new _Beans_Options() )->render_page( 'themesphppagebeans_settings' ); $html = ob_get_clean(); - $html = $this->format_the_html( $html ); + $html = $this->prepare_html( $html ); // Run the tests. Exclude checking for the nonce fields. $expected = <<Toggle panel: Compiler options -

      Compiler options

      +

      Compiler options

      @@ -95,9 +95,9 @@ public function test_should_render_form_when_column_context() { ob_start(); ( new _Beans_Options() )->render_page( 'themesphppagebeans_settings' ); $html = ob_get_clean(); - $html = $this->format_the_html( $html ); + $html = $this->prepare_html( $html ); - // Run the tests. Exclude checking for the nonce fields. + // Run the tests. $expected = << EOB; @@ -111,7 +111,7 @@ public function test_should_render_form_when_column_context() { Toggle panel: Compiler options -

      Compiler options

      +

      Compiler options

      @@ -121,7 +121,7 @@ public function test_should_render_form_when_column_context() { Toggle panel: Images options -

      Images options

      +

      Images options

      @@ -129,7 +129,7 @@ public function test_should_render_form_when_column_context() { Toggle panel: Mode options -

      Mode options

      +

      Mode options

      @@ -142,4 +142,23 @@ public function test_should_render_form_when_column_context() { EOB; $this->assertContains( $this->format_the_html( $expected ), $html ); } + + /** + * Prepares the HTML by: + * 1. formatting it + * 2. Converting each instance of class='hndle' to class="hndle" + * + * @param string $html The given HTML to prepare. + * + * @return string + */ + protected function prepare_html( $html ) { + $html = $this->format_the_html( $html ); + + if ( strpos( $html, "class='hndle'>" ) === false ) { + return $html; + } + + return str_replace( "class='hndle'>", 'class="hndle">', $html ); + } } From d83d2fde566352024e7e43c79bffaf650d118ce5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 19 May 2018 12:08:19 -0500 Subject: [PATCH 609/800] Added WP latest and trunk versions to Travis. --- .travis.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8079701..707cb7b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,12 +6,17 @@ cache: node_modules vendor -matrix: - include: - - php: '5.6' - - php: '7.0' - - php: '7.1' - - php: '7.2' +php: + - 5.6 + - 7.0 + - 7.1 + - 7.2 + +env: + - WP_VERSION=latest WP_MULTISITE=0 + - WP_VERSION=latest WP_MULTISITE=1 + - WP_VERSION=trunk WP_MULqTISITE=0 + - WP_VERSION=trunk WP_MULTISITE=1 install: - composer install From d575377e57efce85c368df567c51b72c5f742d70 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 19 May 2018 12:10:38 -0500 Subject: [PATCH 610/800] Changed to test only on PHP 5.6 and 7.2. Why? If it runs on 5.6 and 7.2, then it will run on 7.0 and 7.1. --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 707cb7b2..81ec7602 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,6 @@ cache: php: - 5.6 - - 7.0 - - 7.1 - 7.2 env: From dd5de5369273a11df3bc0a2d0012f7a41bd4d3fe Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 19 May 2018 12:11:19 -0500 Subject: [PATCH 611/800] Removed @group from each of the test bootstraps. --- tests/phpunit/integration/bootstrap.php | 2 -- tests/phpunit/unit/bootstrap.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index 28927d58..5ab07932 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -6,8 +6,6 @@ * @since 1.5.0 * @link http://www.getbeans.io * @license GNU-2.0+ - * - * @group integration-tests */ if ( ! file_exists( '../../../wp-content' ) ) { diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index 33531e28..63454dab 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -6,8 +6,6 @@ * @since 1.5.0 * @link http://www.getbeans.io * @license GNU-2.0+ - * - * @group unit-tests */ if ( version_compare( phpversion(), '5.6.0', '<' ) ) { From aa5dfa2714d0c56747f98ea2af47c1b0c054752c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 19 May 2018 12:11:51 -0500 Subject: [PATCH 612/800] Added namespace to test bootstraps. --- tests/phpunit/integration/bootstrap.php | 2 ++ tests/phpunit/unit/bootstrap.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index 5ab07932..ec643c68 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -8,6 +8,8 @@ * @license GNU-2.0+ */ +namespace Beans\Framework\Tests\Integration; + if ( ! file_exists( '../../../wp-content' ) ) { trigger_error( 'Unable to run the integration tests, because the wp-content folder does not exist.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. } diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index 63454dab..16fd2718 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -8,6 +8,8 @@ * @license GNU-2.0+ */ +namespace Beans\Framework\Tests\Unit; + if ( version_compare( phpversion(), '5.6.0', '<' ) ) { trigger_error( 'Beans Unit Tests require PHP 5.6 or higher.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. } From 12041943a0029f37de2cf781c368333c5df968ad Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Thu, 17 May 2018 16:50:52 -0400 Subject: [PATCH 613/800] Improved consistency of Fields API tests --- ...elds.php => beansPreStandardizeFields.php} | 0 .../api/fields/fixtures/test-fields.php | 2 +- .../includes/class-fields-test-case.php | 2 +- ...nsGetImageAlt.php => beansGetImageAlt.php} | 0 ...nsGetImageUrl.php => beansGetImageUrl.php} | 0 ...IsRadioImage.php => beansIsRadioImage.php} | 0 ...age.php => beansStandardizeRadioImage.php} | 0 .../fixtures/test-field-output-html.php | 55 ++++++++++++++ ...elds.php => beansPreStandardizeFields.php} | 0 .../unit/api/fields/fixtures/test-fields.php | 2 +- .../includes/class-fields-test-case.php | 2 +- ...nsGetImageAlt.php => beansGetImageAlt.php} | 0 ...nsGetImageUrl.php => beansGetImageUrl.php} | 0 ...IsRadioImage.php => beansIsRadioImage.php} | 0 ...age.php => beansStandardizeRadioImage.php} | 0 .../phpunit/unit/api/utilities/beansIsUri.php | 74 +++++++++++++++++++ 16 files changed, 133 insertions(+), 4 deletions(-) rename tests/phpunit/integration/api/fields/{_beansPreStandardizeFields.php => beansPreStandardizeFields.php} (100%) rename tests/phpunit/integration/api/fields/types/{_BeansGetImageAlt.php => beansGetImageAlt.php} (100%) rename tests/phpunit/integration/api/fields/types/{_BeansGetImageUrl.php => beansGetImageUrl.php} (100%) rename tests/phpunit/integration/api/fields/types/{_beansIsRadioImage.php => beansIsRadioImage.php} (100%) rename tests/phpunit/integration/api/fields/types/{_beansStandardizeRadioImage.php => beansStandardizeRadioImage.php} (100%) create mode 100644 tests/phpunit/integration/api/term-meta/fixtures/test-field-output-html.php rename tests/phpunit/unit/api/fields/{_beansPreStandardizeFields.php => beansPreStandardizeFields.php} (100%) rename tests/phpunit/unit/api/fields/types/{_BeansGetImageAlt.php => beansGetImageAlt.php} (100%) rename tests/phpunit/unit/api/fields/types/{_BeansGetImageUrl.php => beansGetImageUrl.php} (100%) rename tests/phpunit/unit/api/fields/types/{_beansIsRadioImage.php => beansIsRadioImage.php} (100%) rename tests/phpunit/unit/api/fields/types/{_beansStandardizeRadioImage.php => beansStandardizeRadioImage.php} (100%) create mode 100644 tests/phpunit/unit/api/utilities/beansIsUri.php diff --git a/tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php b/tests/phpunit/integration/api/fields/beansPreStandardizeFields.php similarity index 100% rename from tests/phpunit/integration/api/fields/_beansPreStandardizeFields.php rename to tests/phpunit/integration/api/fields/beansPreStandardizeFields.php diff --git a/tests/phpunit/integration/api/fields/fixtures/test-fields.php b/tests/phpunit/integration/api/fields/fixtures/test-fields.php index acc418ad..84a33a75 100644 --- a/tests/phpunit/integration/api/fields/fixtures/test-fields.php +++ b/tests/phpunit/integration/api/fields/fixtures/test-fields.php @@ -1,6 +1,6 @@ + + + +
      +
      + Layout + + + + +
      +
      + + + + + +
      + + +Enable the checkbox test +
      + + + + + +
      + +FIELDSHTML; diff --git a/tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php b/tests/phpunit/unit/api/fields/beansPreStandardizeFields.php similarity index 100% rename from tests/phpunit/unit/api/fields/_beansPreStandardizeFields.php rename to tests/phpunit/unit/api/fields/beansPreStandardizeFields.php diff --git a/tests/phpunit/unit/api/fields/fixtures/test-fields.php b/tests/phpunit/unit/api/fields/fixtures/test-fields.php index 17469fad..57b14eac 100644 --- a/tests/phpunit/unit/api/fields/fixtures/test-fields.php +++ b/tests/phpunit/unit/api/fields/fixtures/test-fields.php @@ -1,6 +1,6 @@ assertFalse( _beans_is_uri( __FILE__ ) ); + $this->assertFalse( _beans_is_uri( __DIR__ ) ); + $this->assertFalse( _beans_is_uri( '/blog' ) ); + $this->assertFalse( _beans_is_uri( ':,Hello%2C%20World!' ) ); + $this->assertFalse( _beans_is_uri( ':text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) ); + } + + /** + * Test _beans_is_uri() should return true when input starts with http. + */ + public function test_should_return_true_when_http() { + $this->assertTrue( _beans_is_uri( 'http://getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( 'http://www.getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( 'http://getbeans.io/blog/' ) ); + $this->assertTrue( _beans_is_uri( 'http://8.8.8.8' ) ); + $this->assertTrue( _beans_is_uri( 'http://8000:8.8.8.8' ) ); + } + + /** + * Test _beans_is_uri() should return true when input starts with https. + */ + public function test_should_return_true_when_https() { + $this->assertTrue( _beans_is_uri( 'https://getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( 'https://www.getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( 'https://getbeans.io/blog/' ) ); + $this->assertTrue( _beans_is_uri( 'http://8.8.8.8' ) ); + $this->assertTrue( _beans_is_uri( 'http://8000:8.8.8.8' ) ); + } + + /** + * Test _beans_is_uri() should return true when input is a relative URL. + */ + public function test_should_return_true_when_relative_url() { + $this->assertTrue( _beans_is_uri( '//getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( '//www.getbeans.io' ) ); + $this->assertTrue( _beans_is_uri( '//getbeans.io/blog/' ) ); + $this->assertTrue( _beans_is_uri( '//8.8.8.8' ) ); + $this->assertTrue( _beans_is_uri( '//8000:8.8.8.8' ) ); + } + + /** + * Test _beans_is_uri() should return true when Data URI. + */ + public function test_should_return_true_when_data_url() { + $this->assertTrue( _beans_is_uri( 'data:,Hello%2C%20World!' ) ); + $this->assertTrue( _beans_is_uri( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) ); + } +} From d94e7b7c77d660061b8764b24fc549b6f59dbd6a Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Thu, 17 May 2018 16:51:36 -0400 Subject: [PATCH 614/800] Improved consistency of Actions API tests --- tests/phpunit/integration/api/actions/beansAddAction.php | 4 ++-- .../integration/api/actions/beansGetCurrentAction.php | 4 ++-- .../phpunit/integration/api/actions/beansMergeAction.php | 2 +- .../api/actions/includes/class-actions-test-case.php | 2 +- .../api/actions/beans-anonymous-action/__construct.php | 2 +- .../unit/api/actions/beans-anonymous-action/callback.php | 8 ++++---- tests/phpunit/unit/api/actions/beansAddAction.php | 4 ++-- tests/phpunit/unit/api/actions/beansBuildActionArray.php | 6 +++--- tests/phpunit/unit/api/actions/beansGetCurrentAction.php | 4 ++-- tests/phpunit/unit/api/actions/beansMergeAction.php | 2 +- .../unit/api/actions/beansModifyActionCallback.php | 2 +- tests/phpunit/unit/api/actions/beansRenderAction.php | 6 +++--- tests/phpunit/unit/api/actions/beansReplaceAction.php | 2 +- .../unit/api/actions/beansReplaceActionCallback.php | 2 +- tests/phpunit/unit/api/actions/beansSetAction.php | 2 +- tests/phpunit/unit/api/actions/beansUniqueActionId.php | 2 +- tests/phpunit/unit/api/actions/beansUnsetAction.php | 2 +- 17 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansAddAction.php b/tests/phpunit/integration/api/actions/beansAddAction.php index 6726af71..ab5ad1f1 100644 --- a/tests/phpunit/integration/api/actions/beansAddAction.php +++ b/tests/phpunit/integration/api/actions/beansAddAction.php @@ -25,7 +25,7 @@ class Tests_BeansAddAction extends Actions_Test_Case { /** * Test beans_add_action() should add the action in both Beans and WordPress. */ - public function test_should_add_action() { + public function test_should_add_action_in_beans_and_wordpress() { foreach ( static::$test_actions as $beans_id => $action ) { // Test that the action has not yet been added. @@ -47,7 +47,7 @@ public function test_should_add_action() { * This test makes sure nothing breaks if beans_add_action() is called more than once * with the exact same set of conditions. */ - public function test_should_overwrite_add_action() { + public function test_should_overwrite_add_action_in_beans_and_wordpress() { foreach ( static::$test_actions as $beans_id => $action ) { // Let's add it the first time. diff --git a/tests/phpunit/integration/api/actions/beansGetCurrentAction.php b/tests/phpunit/integration/api/actions/beansGetCurrentAction.php index b93f25fa..04785660 100644 --- a/tests/phpunit/integration/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/integration/api/actions/beansGetCurrentAction.php @@ -55,7 +55,7 @@ public function test_should_return_added_action() { /** * Test _beans_get_current_action() should return false when there's a "modified" action but no "added" action. */ - public function test_should_return_false_when_modified_but_no_added() { + public function test_should_return_false_when_modified_but_no_added_action() { global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { @@ -72,7 +72,7 @@ public function test_should_return_false_when_modified_but_no_added() { /** * Test _beans_get_current_action() should return the merged "added" and "modified" action. */ - public function test_should_return_merged_added_and_modified() { + public function test_should_return_merged_added_and_modified_action() { global $_beans_registered_actions; $modified_action = array( diff --git a/tests/phpunit/integration/api/actions/beansMergeAction.php b/tests/phpunit/integration/api/actions/beansMergeAction.php index 8bebfd50..8a8520b9 100644 --- a/tests/phpunit/integration/api/actions/beansMergeAction.php +++ b/tests/phpunit/integration/api/actions/beansMergeAction.php @@ -51,7 +51,7 @@ public function test_should_merge_and_return() { } /** - * Test _beans_merge_action() should store a unregistered action. + * Test _beans_merge_action() should store an unregistered action. */ public function test_should_store_new_action() { global $_beans_registered_actions; diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index 6eae4167..c4cd5bbb 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -165,7 +165,7 @@ protected function check_parameters_registered_in_wp( array $action, $remove_act } /** - * Setup the original action. + * Set up the original action. * * @since 1.5.0 * diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php index e3a39456..37607274 100644 --- a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php @@ -1,6 +1,6 @@ callback(); ob_get_clean(); - // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. + // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. $this->assertTrue( true ); } /** - * Test callback() should echo the returned content. + * Test _Beans_Anonymous_Action::callback() should echo the returned content. */ public function test_should_echo_returned_content() { $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', array( diff --git a/tests/phpunit/unit/api/actions/beansAddAction.php b/tests/phpunit/unit/api/actions/beansAddAction.php index 320bcb80..3a0be3ad 100644 --- a/tests/phpunit/unit/api/actions/beansAddAction.php +++ b/tests/phpunit/unit/api/actions/beansAddAction.php @@ -26,7 +26,7 @@ class Tests_BeansAddAction extends Actions_Test_Case { /** * Test beans_add_action() should add the action in both Beans and WordPress. */ - public function test_should_add_action() { + public function test_should_add_action_in_beans_and_wordpress() { global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { @@ -79,7 +79,7 @@ public function test_should_add_action() { * This test makes sure nothing breaks if beans_add_action() is called more than once * with the exact same set of conditions. */ - public function test_should_overwrite_add_action() { + public function test_should_overwrite_add_action_in_beans_and_wordpress() { global $_beans_registered_actions; Monkey\Functions\when( '_beans_get_action' )->justReturn( false ); diff --git a/tests/phpunit/unit/api/actions/beansBuildActionArray.php b/tests/phpunit/unit/api/actions/beansBuildActionArray.php index 7db8390d..1b6a28eb 100644 --- a/tests/phpunit/unit/api/actions/beansBuildActionArray.php +++ b/tests/phpunit/unit/api/actions/beansBuildActionArray.php @@ -22,7 +22,7 @@ class Tests_BeansBuildActionArray extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); @@ -31,7 +31,7 @@ protected function setUp() { } /** - * Test _beans_build_action_array() should return empty array when all of the arguments are invalid. + * Test _beans_build_action_array() should return an empty array when all of the arguments are invalid. */ public function test_should_return_empty_array_when_invalid_arguments() { $this->assertEmpty( _beans_build_action_array() ); @@ -94,7 +94,7 @@ public function test_should_return_only_args() { /** * Test _beans_build_action_array() should return only the valid arguments. */ - public function test_should_return_valid_args() { + public function test_should_return_valid_arguments() { $this->assertEquals( array( 'hook' => 'foo', diff --git a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php index d1bfc6c1..9b044a28 100644 --- a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php @@ -71,7 +71,7 @@ public function test_should_return_added_action() { /** * Test _beans_get_current_action() should return false when there's a "modified" action but no "added" action. */ - public function test_should_return_false_when_modified_but_no_added() { + public function test_should_return_false_when_modified_but_no_added_action() { foreach ( static::$test_actions as $beans_id => $action ) { Monkey\Functions\expect( '_beans_get_action' ) @@ -95,7 +95,7 @@ public function test_should_return_false_when_modified_but_no_added() { /** * Test _beans_get_current_action() should return the merged "added" and "modified" action. */ - public function test_should_return_merged_added_and_modified() { + public function test_should_return_merged_added_and_modified_action() { $modified_action = array( 'callback' => 'callback', 'priority' => 27, diff --git a/tests/phpunit/unit/api/actions/beansMergeAction.php b/tests/phpunit/unit/api/actions/beansMergeAction.php index f6333d18..7944a1ef 100644 --- a/tests/phpunit/unit/api/actions/beansMergeAction.php +++ b/tests/phpunit/unit/api/actions/beansMergeAction.php @@ -61,7 +61,7 @@ public function test_should_merge_and_return() { } /** - * Test _beans_merge_action() should store a unregistered action. + * Test _beans_merge_action() should store an unregistered action. */ public function test_should_store_new_action() { diff --git a/tests/phpunit/unit/api/actions/beansModifyActionCallback.php b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php index e4ef5587..5768c2d6 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionCallback.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionCallback.php @@ -26,7 +26,7 @@ class Tests_BeansModifyActionCallback extends Actions_Test_Case { /** * Test beans_modify_action_callback() should return false when the callable is empty. */ - public function test_should_return_false_when_not_callable() { + public function test_should_return_false_when_callable_empty() { foreach ( static::$test_ids as $beans_id ) { Monkey\Functions\expect( 'beans_modify_action' )->never(); diff --git a/tests/phpunit/unit/api/actions/beansRenderAction.php b/tests/phpunit/unit/api/actions/beansRenderAction.php index e800e89b..97edf65f 100644 --- a/tests/phpunit/unit/api/actions/beansRenderAction.php +++ b/tests/phpunit/unit/api/actions/beansRenderAction.php @@ -22,7 +22,7 @@ class Tests_BeansRenderAction extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); @@ -48,7 +48,7 @@ public function test_should_return_false_when_a_callback_is_not_registered() { /** * Test _beans_render_action() should return after calling the hook with no sub-hook. */ - public function test_should_return_after_calling_hook_no_subhook() { + public function test_should_return_after_calling_hook_with_no_subhook() { // Testing with a closure. $expected_args = array( array( 'foo' ), @@ -60,7 +60,7 @@ public function test_should_return_after_calling_hook_no_subhook() { $this->assertTrue( doing_action( 'beans_stub' ) ); $this->assertEquals( $expected_args[ $args[0] ], $args[1] ); - // Let's echo out to ensure this callback will was called. + // Let's echo out to ensure this callback was called. echo $args[1][0]; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Not testing escaping functionality. }; add_action( 'beans_stub', $callback ); diff --git a/tests/phpunit/unit/api/actions/beansReplaceAction.php b/tests/phpunit/unit/api/actions/beansReplaceAction.php index 04b5bec1..2a0945fd 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceAction.php +++ b/tests/phpunit/unit/api/actions/beansReplaceAction.php @@ -27,7 +27,7 @@ class Tests_BeansReplaceAction extends Replace_Action_Test_Case { * Test beans_replace_action() should return false when there's nothing to replace, * i.e. no arguments passed. */ - public function test_should_return_false_when_nothing_to_modify() { + public function test_should_return_false_when_nothing_to_replace() { foreach ( static::$test_actions as $beans_id => $original_action ) { // Check that neither of these functions are called. diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php index 40c16d31..9c39fdbd 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionCallback.php @@ -26,7 +26,7 @@ class Tests_BeansReplaceActionCallback extends Replace_Action_Test_Case { /** * Test beans_replace_action_callback() should return false when the callable is empty. */ - public function test_should_return_false_when_not_callable() { + public function test_should_return_false_when_callable_empty() { foreach ( static::$test_ids as $beans_id ) { Monkey\Functions\expect( 'beans_replace_action' )->never(); diff --git a/tests/phpunit/unit/api/actions/beansSetAction.php b/tests/phpunit/unit/api/actions/beansSetAction.php index ed496a77..17527598 100644 --- a/tests/phpunit/unit/api/actions/beansSetAction.php +++ b/tests/phpunit/unit/api/actions/beansSetAction.php @@ -31,7 +31,7 @@ class Tests_BeansSetAction extends Actions_Test_Case { protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); /** - * Test _beans_set_action() should set (registered) the action and then return it. + * Test _beans_set_action() should set (register) the action and then return it. */ public function test_should_set_and_return_action() { global $_beans_registered_actions; diff --git a/tests/phpunit/unit/api/actions/beansUniqueActionId.php b/tests/phpunit/unit/api/actions/beansUniqueActionId.php index cc2eddb9..56719795 100644 --- a/tests/phpunit/unit/api/actions/beansUniqueActionId.php +++ b/tests/phpunit/unit/api/actions/beansUniqueActionId.php @@ -21,7 +21,7 @@ class Tests_BeansUniqueActionId extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/unit/api/actions/beansUnsetAction.php b/tests/phpunit/unit/api/actions/beansUnsetAction.php index 6c1be885..5227db9c 100644 --- a/tests/phpunit/unit/api/actions/beansUnsetAction.php +++ b/tests/phpunit/unit/api/actions/beansUnsetAction.php @@ -33,7 +33,7 @@ class Tests_BeansUnsetAction extends Actions_Test_Case { /** * Test _beans_unset_action() should return false when action is not registered. */ - public function test_should_return_false_when_not_registered() { + public function test_should_return_false_when_action_not_registered() { global $_beans_registered_actions; foreach ( static::$test_actions as $beans_id => $action ) { From edd0ac655df259f1a65ec981ba763cc0b1f478fc Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Thu, 17 May 2018 16:52:02 -0400 Subject: [PATCH 615/800] Improved consistency of Compiler API tests --- .../compiler/beans-compiler-options/flush.php | 2 +- .../beans-compiler-options/register.php | 2 +- .../renderFlushButton.php | 2 +- .../renderScriptsNotCompiledNotice.php | 4 ++-- .../renderStylesNotCompiledNotice.php | 4 ++-- .../renderSuccessNotice.php | 2 +- .../beans-compiler/addContentMediaQuery.php | 2 +- .../api/compiler/beans-compiler/cacheFile.php | 2 +- .../beans-compiler/combineFragments.php | 2 +- .../api/compiler/beans-compiler/fileystem.php | 2 +- .../compiler/beans-compiler/formatContent.php | 2 +- .../beans-compiler/getInternalContent.php | 2 +- .../beans-compiler/getRemoteContent.php | 2 +- .../compiler/beans-compiler/replaceCssUrl.php | 2 +- .../compiler/beans-compiler/runCompiler.php | 2 +- .../compiler/beans-compiler/setFilename.php | 2 +- .../beans-page-compiler/compilePageScripts.php | 4 ++-- .../beans-page-compiler/compilePageStyles.php | 2 +- .../beans-page-compiler/dequeueScripts.php | 4 ++-- .../compiler/includes/class-base-test-case.php | 2 +- .../includes/class-compiler-test-case.php | 2 +- .../compiler/beans-compiler-options/flush.php | 2 +- .../beans-compiler-options/register.php | 6 +++--- .../renderFlushButton.php | 2 +- .../renderScriptsNotCompiledNotice.php | 4 ++-- .../renderStylesNotCompiledNotice.php | 4 ++-- .../renderSuccessNotice.php | 2 +- .../beans-compiler/addContentMediaQuery.php | 2 +- .../api/compiler/beans-compiler/cacheFile.php | 2 +- .../compiler/beans-compiler/cacheFileExist.php | 2 +- .../beans-compiler/combineFragments.php | 4 ++-- .../api/compiler/beans-compiler/fileystem.php | 2 +- .../compiler/beans-compiler/formatContent.php | 18 +++++++++--------- .../unit/api/compiler/beans-compiler/get.php | 2 +- .../compiler/beans-compiler/getExtension.php | 2 +- .../beans-compiler/getFunctionContent.php | 2 +- .../beans-compiler/getInternalContent.php | 4 ++-- .../beans-compiler/getRemoteContent.php | 2 +- .../compiler/beans-compiler/replaceCssUrl.php | 4 ++-- .../compiler/beans-compiler/runCompiler.php | 14 +++++++------- .../compiler/beans-compiler/setFilename.php | 2 +- .../compiler/beans-compiler/setFragments.php | 8 ++++---- .../beans-page-compiler/compilePageScripts.php | 2 +- .../beans-page-compiler/compilePageStyles.php | 2 +- .../beans-page-compiler/dequeueScripts.php | 4 ++-- .../beansAddCompilerOptionsToSettings.php | 2 +- 46 files changed, 75 insertions(+), 75 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/flush.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/flush.php index b51f455a..da805f17 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/flush.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler-options/flush.php @@ -1,6 +1,6 @@ +
      Scripts are not compiled in development mode. EOB; $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php index fd3115fe..b0c9f31c 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php @@ -1,6 +1,6 @@ +
      Styles are not compiled in development mode. EOB; $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderSuccessNotice.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/renderSuccessNotice.php index 6ea9f781..ab75fd2d 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderSuccessNotice.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler-options/renderSuccessNotice.php @@ -1,6 +1,6 @@ var testParams = "hello-beans"; - + EOB; $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $inline_script ) ); diff --git a/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php index a8ad472d..dee9913a 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php @@ -55,7 +55,7 @@ public function setUp() { } /** - * Tear down the test fixture. + * Cleans up the test environment after each test. */ public function tearDown() { Mockery::close(); diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index ce1a2afe..f49cae32 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -64,7 +64,7 @@ public static function setUpBeforeClass() { } /** - * Tear down the test fixture. + * Cleans up the test environment after each test. */ public function tearDown() { wp_dequeue_script( 'test-jquery' ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler-options/flush.php b/tests/phpunit/unit/api/compiler/beans-compiler-options/flush.php index a9c04a38..45de82de 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler-options/flush.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler-options/flush.php @@ -1,6 +1,6 @@ fields['beans_compile_all_styles'] ); unset( $this->fields['beans_compile_all_scripts_group'] ); @@ -135,7 +135,7 @@ public function test_should_not_register_scripts_options_when_not_supported() { /** * Test _Beans_Compiler_Options::register() should register all options when styles and scripts are supported. */ - public function test_should_register_all_options_when_styles_scripts_supported() { + public function test_should_register_all_options_when_styles_and_scripts_supported() { Monkey\Functions\expect( 'beans_get_component_support' ) ->once() ->with( 'wp_styles_compiler' ) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler-options/renderFlushButton.php b/tests/phpunit/unit/api/compiler/beans-compiler-options/renderFlushButton.php index 2b42a25d..1b709cab 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler-options/renderFlushButton.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler-options/renderFlushButton.php @@ -1,6 +1,6 @@ +
      Scripts are not compiled in development mode. EOB; $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php b/tests/phpunit/unit/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php index 4c26c9ec..96a2eb22 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php @@ -1,6 +1,6 @@ +
      Styles are not compiled in development mode. EOB; $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler-options/renderSuccessNotice.php b/tests/phpunit/unit/api/compiler/beans-compiler-options/renderSuccessNotice.php index 39010796..90a7fc4e 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler-options/renderSuccessNotice.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler-options/renderSuccessNotice.php @@ -1,6 +1,6 @@ true, ) ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); Monkey\Functions\when( 'wp_remote_get' )->justReturn(); Monkey\Functions\when( 'is_wp_error' )->justReturn( true ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php index f37f8233..ad7ec876 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php @@ -1,6 +1,6 @@ once()->andReturn( true ); $mock = \Mockery::mock( 'Beans_Lessc' ); $mock->shouldReceive( 'compile' )->andReturn( $compiled_css ); @@ -120,7 +120,7 @@ public function test_should_return_minified_compiled_css() { } EOB; - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); $mock = \Mockery::mock( 'Beans_Lessc' ); $mock->shouldReceive( 'compile' )->andReturn( $compiled_css ); @@ -143,7 +143,7 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { 'minify_js' => false, ) ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); \Mockery::mock( 'JSMin' )->shouldNotReceive( 'min' ); @@ -162,7 +162,7 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { 'minify_js' => true, ) ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); \Mockery::mock( 'JSMin' )->shouldNotReceive( 'min' ); @@ -188,7 +188,7 @@ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_mini EOB; $compiled_jquery = str_replace( '/$', '$', $compiled_jquery ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); $mock = \Mockery::mock( 'JSMin' ); $mock->shouldReceive( 'min' )->andReturn( $compiled_jquery ); @@ -208,7 +208,7 @@ public function test_should_return_original_js_when_minify_js_disabled() { 'minify_js' => false, ) ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); \Mockery::mock( 'JSMin' )->shouldNotReceive( 'min' ); @@ -227,7 +227,7 @@ public function test_should_always_return_original_js_when_in_dev_mode() { 'minify_js' => true, ) ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); \Mockery::mock( 'JSMin' )->shouldNotReceive( 'min' ); @@ -250,7 +250,7 @@ public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_j class MyGameClock{constructor(maxTime){this.maxTime=maxTime;this.currentClock=0;} getRemainingTime(){return this.maxTime-this.currentClock;}} EOB; - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); $mock = \Mockery::mock( 'JSMin' ); $mock->shouldReceive( 'min' )->andReturn( $compiled_js ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/get.php b/tests/phpunit/unit/api/compiler/beans-compiler/get.php index d580e5cb..da69087a 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/get.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/get.php @@ -1,6 +1,6 @@ array( $fragment ), ) ); - // Setup the mocks. + // Set up the mocks. $this->set_reflective_property( $fragment, 'current_fragment', $compiler ); $this->mock_filesystem_for_fragments( $compiler ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index fabc6365..ae67783e 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -1,6 +1,6 @@ create_compiler(); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index b6493e29..d42ab1a5 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -1,6 +1,6 @@ create_compiler( $config ); - // Setup the mock. + // Set up the mock. Monkey\Functions\expect( 'beans_get' ) ->once() ->with( 'test', array() ) @@ -79,7 +79,7 @@ public function test_should_return_fragments_merged_with_global() { ), ); - // Setup the mock. + // Set up the mock. Monkey\Functions\expect( 'beans_get' ) ->once() ->with( 'test', $_beans_compiler_added_fragments['less'] ) @@ -110,7 +110,7 @@ public function test_should_fire_event() { $compiler = $this->create_compiler( $config ); - // Setup the mock. + // Set up the mock. Monkey\Functions\expect( 'beans_get' ) ->once() ->with( 'test', array() ) diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php index 8f9f1969..3d7176f0 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php @@ -1,6 +1,6 @@ var testParams = "hello-beans"; - + EOB; $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $inline_script ) ); diff --git a/tests/phpunit/unit/api/compiler/beansAddCompilerOptionsToSettings.php b/tests/phpunit/unit/api/compiler/beansAddCompilerOptionsToSettings.php index 8b065514..cc471664 100644 --- a/tests/phpunit/unit/api/compiler/beansAddCompilerOptionsToSettings.php +++ b/tests/phpunit/unit/api/compiler/beansAddCompilerOptionsToSettings.php @@ -1,6 +1,6 @@ Date: Thu, 17 May 2018 16:53:22 -0400 Subject: [PATCH 616/800] Improved consistency of Filters API tests --- .../api/filters/includes/class-filters-test-case.php | 2 +- .../filters/beans-anonymous-filters/_construct.php | 12 ++++++------ .../api/filters/includes/class-filters-test-case.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php index f921be1d..a116fa01 100644 --- a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php @@ -27,7 +27,7 @@ abstract class Filters_Test_Case extends Test_Case { protected static $test_filters; /** - * Setup the test before we run the test setups. + * Set up the test before we run the test setups. */ public static function setUpBeforeClass() { parent::setUpBeforeClass(); diff --git a/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php b/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php index 6a10966a..66790f29 100644 --- a/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php +++ b/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php @@ -1,6 +1,6 @@ Date: Thu, 17 May 2018 16:53:46 -0400 Subject: [PATCH 617/800] Improved consistency of HTML API tests --- .../api/html/beans-attribute/init.php | 10 +++++----- .../integration/api/html/beansAddAttributes.php | 2 +- .../integration/api/html/beansOpenMarkupE.php | 2 +- .../integration/api/html/beansOutputE.php | 6 +++--- .../integration/api/html/beansRemoveOutput.php | 2 +- .../api/html/beansReplaceAttribute.php | 2 +- .../api/html/fixtures/test-attachment.php | 2 +- .../api/html/fixtures/test-markup.php | 2 +- .../api/html/includes/class-html-test-case.php | 2 +- .../unit/api/html/beans-attribute/add.php | 12 ++++++------ .../unit/api/html/beans-attribute/init.php | 10 +++++----- .../unit/api/html/beans-attribute/remove.php | 14 +++++++------- .../unit/api/html/beans-attribute/replace.php | 16 ++++++++-------- .../phpunit/unit/api/html/beansCloseMarkupE.php | 2 +- .../phpunit/unit/api/html/beansIsHtmlDevMode.php | 2 +- .../phpunit/unit/api/html/beansModifyMarkup.php | 2 +- tests/phpunit/unit/api/html/beansOpenMarkup.php | 2 +- tests/phpunit/unit/api/html/beansOpenMarkupE.php | 4 ++-- tests/phpunit/unit/api/html/beansOutputE.php | 2 +- .../phpunit/unit/api/html/beansRemoveOutput.php | 2 +- .../unit/api/html/beansSelfcloseMarkup.php | 2 +- .../unit/api/html/beansSelfcloseMarkupE.php | 4 ++-- .../unit/api/html/beansWrapInnerMarkup.php | 10 +++++----- tests/phpunit/unit/api/html/beansWrapMarkup.php | 10 +++++----- .../fixtures/class-anonymous-action-stub.php | 2 +- .../fixtures/class-anonymous-filter-stub.php | 2 +- .../api/html/includes/class-html-test-case.php | 2 +- 27 files changed, 65 insertions(+), 65 deletions(-) diff --git a/tests/phpunit/integration/api/html/beans-attribute/init.php b/tests/phpunit/integration/api/html/beans-attribute/init.php index 92f696d8..c4d72836 100644 --- a/tests/phpunit/integration/api/html/beans-attribute/init.php +++ b/tests/phpunit/integration/api/html/beans-attribute/init.php @@ -1,6 +1,6 @@ 'foo' ); Monkey\Functions\expect( 'foo_attributes_callback' ) ->with( $attributes ) diff --git a/tests/phpunit/integration/api/html/beansOpenMarkupE.php b/tests/phpunit/integration/api/html/beansOpenMarkupE.php index 7f45d3c4..93e8ed6f 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkupE.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkupE.php @@ -25,7 +25,7 @@ class Tests_BeansOpenMarkupE extends HTML_Test_Case { /** * Test beans_open_markup_e() should echo an empty string when the tag is set to null. */ - public function test_should_echo_empty_when_tag_set_to_null() { + public function test_should_echo_empty_string_when_tag_set_to_null() { ob_start(); beans_open_markup_e( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ); $this->assertEquals( '', ob_get_clean() ); diff --git a/tests/phpunit/integration/api/html/beansOutputE.php b/tests/phpunit/integration/api/html/beansOutputE.php index 49abc571..5e729315 100644 --- a/tests/phpunit/integration/api/html/beansOutputE.php +++ b/tests/phpunit/integration/api/html/beansOutputE.php @@ -26,7 +26,7 @@ class Tests_BeansOutputE extends HTML_Test_Case { /** * Test beans_output_e() should echo an empty string when the output is empty. */ - public function test_should_echo_null_when_output_is_empty() { + public function test_should_echo_empty_string_when_output_is_empty() { $ids = array( 'beans_post_meta_item_date' => null, 'beans_post_meta_item_author' => '', @@ -84,9 +84,9 @@ public function test_should_echo_comment_wrapped_html_when_in_html_dev_mode() { } /** - * Test beans_output() should pass the additional arguments. + * Test beans_output_e() should pass the additional arguments. */ - public function test_should_pass_additional_args() { + public function test_should_pass_additional_arguments() { add_filter( 'beans_breadcrumb_item_text_output', 'return_fired_output', 10, 3 ); Monkey\Functions\expect( 'return_fired_output' ) ->twice() diff --git a/tests/phpunit/integration/api/html/beansRemoveOutput.php b/tests/phpunit/integration/api/html/beansRemoveOutput.php index b7afea07..57fc99d2 100644 --- a/tests/phpunit/integration/api/html/beansRemoveOutput.php +++ b/tests/phpunit/integration/api/html/beansRemoveOutput.php @@ -31,7 +31,7 @@ public function test_should_return_anonymous_filter_instance() { } /** - * Test beans_remove_output() should register callback to the "{$id}_output" filter hook. + * Test beans_remove_output() should register a callback to the "{$id}_output" filter hook. */ public function test_should_return_register_callback_to_id_output_filter() { $anonymous_filter = beans_remove_output( 'beans_post_meta_item_date' ); diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index 8027c884..8dbb90e2 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -110,7 +110,7 @@ public function test_should_overwrite_attribute_values_when_target_value_is_empt * Test the end result of beans_replace_attribute() by firing the expected filter event for the given ID. Test should add the * attribute when it does not exists in the given attributes. */ - public function test_should_add_attribute_when_does_not_exist() { + public function test_should_add_attribute_when_it_does_not_exist() { foreach ( static::$test_attributes as $beans_id => $markup ) { $instance = beans_replace_attribute( $beans_id, 'data-test', 'foo', 'beans-test' ); diff --git a/tests/phpunit/integration/api/html/fixtures/test-attachment.php b/tests/phpunit/integration/api/html/fixtures/test-attachment.php index 5151fca2..00a0e571 100644 --- a/tests/phpunit/integration/api/html/fixtures/test-attachment.php +++ b/tests/phpunit/integration/api/html/fixtures/test-attachment.php @@ -1,6 +1,6 @@ $markup ) { @@ -103,7 +103,7 @@ public function test_should_add_attribute_when_does_not_exist() { } /** - * Test replace() should add the attribute when an empty array is given. + * Test _Beans_Attribute::replace() should add the attribute when an empty array is given. */ public function test_should_add_attribute_when_an_empty_array_given() { diff --git a/tests/phpunit/unit/api/html/beansCloseMarkupE.php b/tests/phpunit/unit/api/html/beansCloseMarkupE.php index be04ea27..efa06cc9 100644 --- a/tests/phpunit/unit/api/html/beansCloseMarkupE.php +++ b/tests/phpunit/unit/api/html/beansCloseMarkupE.php @@ -26,7 +26,7 @@ class Tests_BeansCloseMarkupE extends HTML_Test_Case { /** * Test beans_close_markup_e() should echo an empty string when the tag is set to null. */ - public function test_should_echo_empty_when_tag_set_to_null() { + public function test_should_echo_empty_string_when_tag_set_to_null() { Monkey\Functions\expect( 'beans_apply_filters' ) ->once() ->with( 'beans_archive_title_markup', null ) diff --git a/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php b/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php index 4e4a40b3..3114d4af 100644 --- a/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php +++ b/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php @@ -26,7 +26,7 @@ class Tests_BeansIsHtmlDevMode extends HTML_Test_Case { /** * Test _beans_is_html_dev_mode() should return false when the option does not exist. */ - public function test_should_false_when_option_does_not_exist() { + public function test_should_return_false_when_option_does_not_exist() { $this->assertFalse( defined( 'BEANS_HTML_DEV_MODE' ) ); Monkey\Functions\expect( 'get_option' ) diff --git a/tests/phpunit/unit/api/html/beansModifyMarkup.php b/tests/phpunit/unit/api/html/beansModifyMarkup.php index bc8ff712..fdaeebc5 100644 --- a/tests/phpunit/unit/api/html/beansModifyMarkup.php +++ b/tests/phpunit/unit/api/html/beansModifyMarkup.php @@ -53,7 +53,7 @@ public function test_should_call_beans_add_filter_to_register_callback() { ->with( 'beans_archive_title_markup', 'h2', 10, 1 ); beans_modify_markup( 'beans_archive_title', 'h2' ); - // Test is focused above on ensuring beans_add_filter() is called with the right arguments. + // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. $this->assertTrue( true ); } } diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php index 95b1b4eb..b77c761e 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkup.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkup.php @@ -117,7 +117,7 @@ public function test_should_return_built_html_with_data_markup_id_when_in_dev_mo } /** - * Test beans_open_markup() should return a built HTML when before or prepend hooks are registered. + * Test beans_open_markup() should return the built HTML when before or prepend hooks are registered. */ public function test_should_return_built_html_when_before_or_prepend_hooks() { Monkey\Functions\expect( 'beans_add_attributes' ) diff --git a/tests/phpunit/unit/api/html/beansOpenMarkupE.php b/tests/phpunit/unit/api/html/beansOpenMarkupE.php index 970b37d5..c8160dd0 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkupE.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkupE.php @@ -24,9 +24,9 @@ class Tests_BeansOpenMarkupE extends HTML_Test_Case { /** - * Test beans_open_markup_e() should echo empty when the tag is set to null. + * Test beans_open_markup_e() should echo empty string when the tag is set to null. */ - public function test_should_echo_empty_when_tag_set_to_null() { + public function test_should_echo_empty_string_when_tag_set_to_null() { Monkey\Functions\expect( 'beans_open_markup' ) ->once() ->with( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) diff --git a/tests/phpunit/unit/api/html/beansOutputE.php b/tests/phpunit/unit/api/html/beansOutputE.php index 4de75b9f..a49deb7c 100644 --- a/tests/phpunit/unit/api/html/beansOutputE.php +++ b/tests/phpunit/unit/api/html/beansOutputE.php @@ -26,7 +26,7 @@ class Tests_BeansOutputE extends HTML_Test_Case { /** * Test beans_output_e() should echo an empty string when the output is empty. */ - public function test_should_echo_null_when_output_is_empty() { + public function test_should_echo_empty_string_when_output_is_empty() { Monkey\Functions\expect( 'beans_output' )->times( 3 )->andReturnUsing( function( $id, $output ) { return $output; } ); diff --git a/tests/phpunit/unit/api/html/beansRemoveOutput.php b/tests/phpunit/unit/api/html/beansRemoveOutput.php index 84b15cc6..50367398 100644 --- a/tests/phpunit/unit/api/html/beansRemoveOutput.php +++ b/tests/phpunit/unit/api/html/beansRemoveOutput.php @@ -63,7 +63,7 @@ public function test_should_call_beans_add_filter_to_register_callback() { beans_remove_output( $id ); } - // Tests are focused above on ensuring beans_add_filter() is called with the right arguments. + // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. $this->assertTrue( true ); } } diff --git a/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php b/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php index ca3890e4..fea702a0 100644 --- a/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php +++ b/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php @@ -54,7 +54,7 @@ public function test_should_invoke_beans_open_markup() { beans_selfclose_markup( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ); } - // The assertions are above. This assertion is a placeholder, as PHPUnit requires a specific assert to run. + // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. $this->assertTrue( true ); } } diff --git a/tests/phpunit/unit/api/html/beansSelfcloseMarkupE.php b/tests/phpunit/unit/api/html/beansSelfcloseMarkupE.php index 5f4934a2..a1b1a165 100644 --- a/tests/phpunit/unit/api/html/beansSelfcloseMarkupE.php +++ b/tests/phpunit/unit/api/html/beansSelfcloseMarkupE.php @@ -26,7 +26,7 @@ class Tests_BeansSelfcloseMarkupE extends HTML_Test_Case { /** * Test beans_selfclose_markup_e() should invoke beans_selfclose_markup(). */ - public function test_should_invoke_beans_open_markup() { + public function test_should_invoke_beans_selfclose_markup() { foreach ( static::$test_attachments as $attachment ) { Monkey\Functions\expect( 'beans_selfclose_markup' ) @@ -39,7 +39,7 @@ public function test_should_invoke_beans_open_markup() { ob_get_clean(); } - // The assertions are above. This assertion is a placeholder, as PHPUnit requires a specific assert to run. + // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. $this->assertTrue( true ); } } diff --git a/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php b/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php index 6b63f120..d6c4cc4f 100644 --- a/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php +++ b/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php @@ -46,7 +46,7 @@ public function test_should_return_false_when_empty_tag_is_given() { * Test beans_wrap_inner_markup() should register beans_open_markup() to the given ID's '_prepend_markup' hook. */ public function test_should_register_beans_open_markup_to_given_id_prepend_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_open_markup', array( @@ -73,7 +73,7 @@ public function test_should_register_beans_open_markup_to_given_id_prepend_marku * Test beans_wrap_inner_markup() should register beans_close_markup() to the given ID's '_append_markup' hook. */ public function test_should_register_beans_close_markup_to_given_id_append_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_close_markup', array( @@ -99,7 +99,7 @@ public function test_should_register_beans_close_markup_to_given_id_append_marku * Test beans_wrap_inner_markup() should not pass the given attributes to anonymous action. */ public function test_should_not_pass_attributes_for_append_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_close_markup', array( @@ -125,7 +125,7 @@ public function test_should_not_pass_attributes_for_append_markup_hook() { * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's '_prepend_markup' hook. */ public function test_should_pass_extra_arguments_for_prepend_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_open_markup', array( @@ -154,7 +154,7 @@ public function test_should_pass_extra_arguments_for_prepend_markup_hook() { * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's '_append_markup' hook. */ public function test_should_pass_extra_arguments_for_append_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_close_markup', array( diff --git a/tests/phpunit/unit/api/html/beansWrapMarkup.php b/tests/phpunit/unit/api/html/beansWrapMarkup.php index 881438f7..17f562e1 100644 --- a/tests/phpunit/unit/api/html/beansWrapMarkup.php +++ b/tests/phpunit/unit/api/html/beansWrapMarkup.php @@ -46,7 +46,7 @@ public function test_should_return_false_when_empty_tag_is_given() { * Test beans_wrap_markup() should register beans_open_markup() to the given ID's '_before_markup' hook. */ public function test_should_register_beans_open_markup_to_given_id_before_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_open_markup', array( @@ -73,7 +73,7 @@ public function test_should_register_beans_open_markup_to_given_id_before_markup * Test beans_wrap_markup() should register beans_close_markup() to the given ID's '_after_markup' hook. */ public function test_should_register_beans_close_markup_to_given_id_after_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_close_markup', array( @@ -99,7 +99,7 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup * Test beans_wrap_markup() should not pass the given attributes to anonymous action. */ public function test_should_not_pass_attributes_for_after_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_close_markup', array( @@ -125,7 +125,7 @@ public function test_should_not_pass_attributes_for_after_markup_hook() { * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's '_before_markup' hook. */ public function test_should_pass_extra_arguments_for_before_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_open_markup', array( @@ -154,7 +154,7 @@ public function test_should_pass_extra_arguments_for_before_markup_hook() { * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's '_after_markup' hook. */ public function test_should_pass_extra_arguments_for_after_markup_hook() { - // Setup the tests. + // Set up the tests. $args = array( 'beans_close_markup', array( diff --git a/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php b/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php index 32fcd8ff..d165a35e 100644 --- a/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php +++ b/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php @@ -1,6 +1,6 @@ Date: Thu, 17 May 2018 16:54:08 -0400 Subject: [PATCH 618/800] Improved consistency of Image API tests --- .../beans-image-editor/createEditedImage.php | 13 +++--- .../api/image/beans-image-editor/run.php | 38 +++++++-------- .../api/image/beans-image-options/flush.php | 2 +- .../image/beans-image-options/register.php | 6 +-- .../beans-image-options/renderFlushButton.php | 2 +- .../renderSuccessNotice.php | 2 +- .../image/includes/class-base-test-case.php | 2 +- .../beans-image-editor/createEditedImage.php | 13 +++--- .../unit/api/image/beans-image-editor/run.php | 46 +++++++++---------- .../api/image/beans-image-options/flush.php | 2 +- .../image/beans-image-options/register.php | 2 +- .../beans-image-options/renderFlushButton.php | 2 +- .../renderSuccessNotice.php | 2 +- .../image/includes/class-image-test-case.php | 2 +- 14 files changed, 66 insertions(+), 68 deletions(-) diff --git a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php index 9458f984..fc3e8289 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php @@ -1,6 +1,6 @@ get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); @@ -70,7 +69,7 @@ public function test_should_edit_create_and_store_image() { } /** - * Test create_edited_image() should return false when the image does not exist. + * Test _Beans_Image_Editor::create_edited_image() should return false when the image does not exist. */ public function test_should_return_false_when_no_image() { $created_edited_image = $this->get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php index 214db150..ec6f1320 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -1,6 +1,6 @@ get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $image_sources = array( static::$fixtures_dir . '/image1.jpg', @@ -69,7 +69,7 @@ public function test_should_edit_store_and_return_its_url() { } /** - * Test init() should return original src when the image does not exist. + * Test _Beans_Image_Editor::run() should return original src when the image does not exist. */ public function test_should_return_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -81,7 +81,7 @@ public function test_should_return_original_src_when_no_image() { } /** - * Test run() should return the URL when the edited image exists, meaning that it has already been edited and + * Test _Beans_Image_Editor::run() should return the URL when the edited image exists, meaning that it has already been edited and * stored. */ public function test_should_return_url_when_edited_image_exists() { @@ -106,10 +106,10 @@ public function test_should_return_url_when_edited_image_exists() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of its + * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of its * image info. */ - public function test_should_edit_store_and_return_indexed_array() { + public function test_should_edit_store_image_and_return_indexed_array() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $image_sources = array( static::$fixtures_dir . '/image1.jpg', @@ -135,7 +135,7 @@ public function test_should_edit_store_and_return_indexed_array() { } /** - * Test run() should return an indexed array with the original src when the image does not exist. + * Test _Beans_Image_Editor::run() should return an indexed array with the original src when the image does not exist. */ public function test_should_return_indexed_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -147,7 +147,7 @@ public function test_should_return_indexed_array_with_original_src_when_no_image } /** - * Test run() should return return an indexed array when the edited image exists, meaning that it has already been + * Test _Beans_Image_Editor::run() should return an indexed array when the edited image exists, meaning that it has already been * edited and stored. */ public function test_should_return_index_array_when_edited_image_exists() { @@ -172,10 +172,10 @@ public function test_should_return_index_array_when_edited_image_exists() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an + * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an * object. */ - public function test_should_edit_store_and_return_object() { + public function test_should_edit_store_image_and_return_object() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $image_sources = array( static::$fixtures_dir . '/image1.jpg', @@ -204,7 +204,7 @@ public function test_should_edit_store_and_return_object() { } /** - * Test run() should return an object with the original src when the image does not exist. + * Test _Beans_Image_Editor::run() should return an object with the original src when the image does not exist. */ public function test_should_return_object_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -220,7 +220,7 @@ public function test_should_return_object_with_original_src_when_no_image() { } /** - * Test run() should return an object when the edited image exists, meaning that it has already been + * Test _Beans_Image_Editor::run() should return an object when the edited image exists, meaning that it has already been * edited and stored. */ public function test_should_return_object_when_edited_image_exists() { @@ -250,10 +250,10 @@ public function test_should_return_object_when_edited_image_exists() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an + * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an * associative array. */ - public function test_should_edit_image_and_return_associative_array() { + public function test_should_edit_store_image_and_return_associative_array() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $image_sources = array( static::$fixtures_dir . '/image1.jpg', @@ -286,7 +286,7 @@ public function test_should_edit_image_and_return_associative_array() { } /** - * Test run() should return an array with the original src when the image does not exist. + * Test _Beans_Image_Editor::run() should return an array with the original src when the image does not exist. */ public function test_should_return_associative_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; @@ -305,7 +305,7 @@ public function test_should_return_associative_array_with_original_src_when_no_i } /** - * Test run() should return an associative array when the edited image exists, meaning that it has already + * Test _Beans_Image_Editor::run() should return an associative array when the edited image exists, meaning that it has already * been edited and stored. */ public function test_should_return_associatve_array_when_edited_image_exists() { diff --git a/tests/phpunit/integration/api/image/beans-image-options/flush.php b/tests/phpunit/integration/api/image/beans-image-options/flush.php index 9c2a2ef5..6338fa71 100644 --- a/tests/phpunit/integration/api/image/beans-image-options/flush.php +++ b/tests/phpunit/integration/api/image/beans-image-options/flush.php @@ -1,6 +1,6 @@ get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); @@ -79,7 +78,7 @@ public function test_should_edit_create_and_store_image() { } /** - * Test create_edited_image() should return false when the image does not exist. + * Test _Beans_Image_Editor::create_edited_image() should return false when the image does not exist. */ public function test_should_return_false_when_no_image() { $create_edited_image = $this->get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php index 03ca0a67..077fab43 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -1,6 +1,6 @@ get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $args = array( 'resize' => array( 800, false ) ); @@ -66,13 +66,13 @@ public function test_should_edit_store_and_return_its_url() { } /** - * Test init() should return original src when the image does not exist. + * Test _Beans_Image_Editor::run() should return original src when the image does not exist. */ public function test_should_return_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ) ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); Monkey\Functions\expect( 'beans_path_to_url' )->never(); @@ -83,7 +83,7 @@ public function test_should_return_original_src_when_no_image() { } /** - * Test run() should return the URL when the edited image exists, meaning that it has already been edited and + * Test _Beans_Image_Editor::run() should return the URL when the edited image exists, meaning that it has already been edited and * stored. */ public function test_should_return_url_when_edited_image_exists() { @@ -106,10 +106,10 @@ public function test_should_return_url_when_edited_image_exists() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of + * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of * its image info. */ - public function test_should_edit_store_and_return_indexed_array() { + public function test_should_edit_store_image_and_return_indexed_array() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $args = array( 'resize' => array( 800, false ) ); @@ -138,13 +138,13 @@ public function test_should_edit_store_and_return_indexed_array() { } /** - * Test run() should return an indexed array with the original src when the image does not exist. + * Test _Beans_Image_Editor::run() should return an indexed array with the original src when the image does not exist. */ public function test_should_return_indexed_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); Monkey\Functions\expect( 'beans_path_to_url' )->never(); @@ -155,7 +155,7 @@ public function test_should_return_indexed_array_with_original_src_when_no_image } /** - * Test run() should return return an indexed array when the edited image exists, meaning that it has already been + * Test _Beans_Image_Editor::run() should return return an indexed array when the edited image exists, meaning that it has already been * edited and stored. */ public function test_should_return_index_array_when_edited_image_exists() { @@ -178,10 +178,10 @@ public function test_should_return_index_array_when_edited_image_exists() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an + * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an * object. */ - public function test_should_edit_store_and_return_object() { + public function test_should_edit_store_image_and_return_object() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $args = array( 'resize' => array( 400, false ) ); @@ -213,13 +213,13 @@ public function test_should_edit_store_and_return_object() { } /** - * Test run() should return an object with the original src when the image does not exist. + * Test _Beans_Image_Editor::run() should return an object with the original src when the image does not exist. */ public function test_should_return_object_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), OBJECT ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); Monkey\Functions\expect( 'beans_path_to_url' )->never(); @@ -234,7 +234,7 @@ public function test_should_return_object_with_original_src_when_no_image() { } /** - * Test run() should return an object when the edited image exists, meaning that it has already been + * Test _Beans_Image_Editor::run() should return an object when the edited image exists, meaning that it has already been * edited and stored. */ public function test_should_return_object_when_edited_image_exists() { @@ -261,10 +261,10 @@ public function test_should_return_object_when_edited_image_exists() { } /** - * Test run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an + * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an * associative array. */ - public function test_should_edit_image_and_return_associative_array() { + public function test_should_edit_store_image_and_return_associative_array() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $args = array( 'resize' => array( 600, false ) ); @@ -300,13 +300,13 @@ public function test_should_edit_image_and_return_associative_array() { } /** - * Test run() should return an associative array with the original src when the image does not exist. + * Test _Beans_Image_Editor::run() should return an associative array with the original src when the image does not exist. */ public function test_should_return_associative_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ); - // Setup the mocks. + // Set up the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); Monkey\Functions\expect( 'beans_path_to_url' )->never(); @@ -324,7 +324,7 @@ public function test_should_return_associative_array_with_original_src_when_no_i } /** - * Test run() should return an associative array when the edited image exists, meaning that it has already + * Test _Beans_Image_Editor::run() should return an associative array when the edited image exists, meaning that it has already * been edited and stored. */ public function test_should_return_associative_array_when_edited_image_exists() { diff --git a/tests/phpunit/unit/api/image/beans-image-options/flush.php b/tests/phpunit/unit/api/image/beans-image-options/flush.php index 6dea33a9..029897dd 100644 --- a/tests/phpunit/unit/api/image/beans-image-options/flush.php +++ b/tests/phpunit/unit/api/image/beans-image-options/flush.php @@ -1,6 +1,6 @@ Date: Thu, 17 May 2018 16:54:27 -0400 Subject: [PATCH 619/800] Improved consistency of Layout API tests --- tests/phpunit/unit/api/layout/beansGetDefaultLayout.php | 2 +- tests/phpunit/unit/api/layout/beansGetLayout.php | 2 +- tests/phpunit/unit/api/layout/beansGetLayoutClass.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php index 83d2f469..3194d242 100644 --- a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php @@ -7,7 +7,7 @@ * @since 1.5.0 */ -namespace Beans\Framework\Tests\Unit\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Layout; use Beans\Framework\Tests\Unit\Test_Case; use Brain\Monkey; diff --git a/tests/phpunit/unit/api/layout/beansGetLayout.php b/tests/phpunit/unit/api/layout/beansGetLayout.php index 47c70f51..b5408b7e 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetLayout.php @@ -7,7 +7,7 @@ * @since 1.5.0 */ -namespace Beans\Framework\Tests\Unit\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Layout; use Beans\Framework\Tests\Unit\Test_Case; use Brain\Monkey; diff --git a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php index ca6c2f5e..41f48172 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php @@ -7,7 +7,7 @@ * @since 1.5.0 */ -namespace Beans\Framework\Tests\Unit\API\Utilities; +namespace Beans\Framework\Tests\Unit\API\Layout; use Beans\Framework\Tests\Unit\Test_Case; use Brain\Monkey; From 880d7d24ce721e3de312655585dfe17db872f67e Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Thu, 17 May 2018 16:54:51 -0400 Subject: [PATCH 620/800] Improved consistency of Options API tests --- .../options/beans-options/processActions.php | 20 +++++++++---------- .../api/options/beans-options/register.php | 10 +++++----- .../options/beans-options/renderMetabox.php | 10 +++++----- .../api/options/beans-options/renderPage.php | 14 ++++++------- .../api/options/fixtures/test-options.php | 2 +- .../includes/class-options-test-case.php | 2 +- .../api/options/beans-options/register.php | 12 +++++------ .../options/beans-options/renderMetabox.php | 10 +++++----- .../api/options/beans-options/renderPage.php | 12 +++++------ .../beans-options/renderRenderNotice.php | 10 +++++----- .../beans-options/renderSaveNotice.php | 10 +++++----- .../api/options/fixtures/test-options.php | 2 +- .../includes/class-options-test-case.php | 2 +- 13 files changed, 58 insertions(+), 58 deletions(-) diff --git a/tests/phpunit/integration/api/options/beans-options/processActions.php b/tests/phpunit/integration/api/options/beans-options/processActions.php index 01e48680..c7394e77 100644 --- a/tests/phpunit/integration/api/options/beans-options/processActions.php +++ b/tests/phpunit/integration/api/options/beans-options/processActions.php @@ -1,6 +1,6 @@ assertNull( ( new _Beans_Options() )->render_page( 'beans_settings' ) ); } /** - * Test render_page() should render the form when "normal" context is configured. + * Test _Beans_Options::render_page() should render the form when "normal" context is configured. */ public function test_should_render_form_when_context_normal() { $instance = new _Beans_Options(); @@ -77,7 +77,7 @@ public function test_should_render_form_when_context_normal() { } /** - * Test render_page() should render the form when "column" context is configured. + * Test _Beans_Options::render_page() should render the form when "column" context is configured. */ public function test_should_render_form_when_column_context() { $instance = new _Beans_Options(); @@ -131,7 +131,7 @@ public function test_should_render_form_when_column_context() {

      Mode options

      - +

      diff --git a/tests/phpunit/integration/api/options/fixtures/test-options.php b/tests/phpunit/integration/api/options/fixtures/test-options.php index 62efd8cc..8d87247d 100644 --- a/tests/phpunit/integration/api/options/fixtures/test-options.php +++ b/tests/phpunit/integration/api/options/fixtures/test-options.php @@ -1,6 +1,6 @@ get_reflective_property( 'args', '_Beans_Options' ); @@ -46,7 +46,7 @@ public function test_should_merge_default_args_and_set_property() { } /** - * Test register() should register the callback to the 'admin_enqueue_scripts' hook. + * Test _Beans_Options::register() should register the callback to the 'admin_enqueue_scripts' hook. */ public function test_should_register_callback_to_admin_enqueue_scripts_hook() { $instance = new _Beans_Options(); @@ -56,7 +56,7 @@ public function test_should_register_callback_to_admin_enqueue_scripts_hook() { } /** - * Test register() should register the metabox with WordPress. + * Test _Beans_Options::register() should register the metabox with WordPress. */ public function test_should_register_metabox_with_wp() { $instance = new _Beans_Options(); diff --git a/tests/phpunit/unit/api/options/beans-options/renderMetabox.php b/tests/phpunit/unit/api/options/beans-options/renderMetabox.php index a720b08d..2632ce9a 100644 --- a/tests/phpunit/unit/api/options/beans-options/renderMetabox.php +++ b/tests/phpunit/unit/api/options/beans-options/renderMetabox.php @@ -1,6 +1,6 @@ with( 'beans_tests', array() )->once()->andReturn( null ); @@ -34,7 +34,7 @@ public function test_should_return_null_when_page_does_not_have_metabox() { } /** - * Test render_page() should render the form when "normal" context is configured. + * Test _Beans_Options::render_page() should render the form when "normal" context is configured. */ public function test_should_render_form_when_context_normal() { Monkey\Functions\expect( 'beans_get' ) @@ -73,7 +73,7 @@ public function test_should_render_form_when_context_normal() { } /** - * Test render_page() should render the form when "column" context is configured. + * Test _Beans_Options::render_page() should render the form when "column" context is configured. */ public function test_should_render_form_when_column_context() { Monkey\Functions\expect( 'beans_get' ) diff --git a/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php b/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php index 45bb0fed..8f8be9a2 100644 --- a/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php +++ b/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php @@ -1,6 +1,6 @@ get_reflective_property( 'success', '_Beans_Options' ); diff --git a/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php b/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php index a1c0176e..35a9471b 100644 --- a/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php +++ b/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php @@ -1,6 +1,6 @@ get_reflective_property( 'success', '_Beans_Options' ); diff --git a/tests/phpunit/unit/api/options/fixtures/test-options.php b/tests/phpunit/unit/api/options/fixtures/test-options.php index 62efd8cc..1476a707 100644 --- a/tests/phpunit/unit/api/options/fixtures/test-options.php +++ b/tests/phpunit/unit/api/options/fixtures/test-options.php @@ -1,6 +1,6 @@ Date: Thu, 17 May 2018 16:55:15 -0400 Subject: [PATCH 621/800] Improved consistency of Post Meta API tests --- .../post-meta/beans-post-meta/construct.php | 4 +- .../post-meta/beans-post-meta/okToSave.php | 2 +- .../beans-post-meta/registerMetabox.php | 2 +- .../beans-post-meta/renderMetaboxContent.php | 6 +-- .../post-meta/beans-post-meta/renderNonce.php | 10 ++--- .../api/post-meta/beans-post-meta/save.php | 8 ++-- .../beans-post-meta/saveAttachment.php | 4 +- .../post-meta/beansIsPostMetaConditions.php | 36 ++++++++--------- .../beansPostMetaPageTemplateReload.php | 8 ++-- .../api/post-meta/beansRegisterPostMeta.php | 4 +- .../api/post-meta/fixtures/test-fields.php | 2 +- .../post-meta/beans-post-meta/okToSave.php | 2 +- .../beans-post-meta/registerMetabox.php | 2 +- .../beans-post-meta/renderMetaboxContent.php | 4 +- .../post-meta/beans-post-meta/renderNonce.php | 6 +-- .../api/post-meta/beans-post-meta/save.php | 10 ++--- .../beans-post-meta/saveAttachment.php | 7 ++-- .../post-meta/beansIsPostMetaConditions.php | 39 ++++++++++--------- .../beansPostMetaPageTemplateReload.php | 5 ++- .../api/post-meta/beansRegisterPostMeta.php | 5 ++- .../class-beans-post-meta-test-case.php | 2 +- 21 files changed, 85 insertions(+), 83 deletions(-) diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php index 04193e59..449544f0 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php @@ -1,6 +1,6 @@ 'Post Options' ) ); diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php index 1118109e..54bd2104 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php @@ -1,6 +1,6 @@ 'Post Options' ) ); $expected_html_output = ''; diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php index dd4d6ee9..b9dcf27d 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php @@ -1,6 +1,6 @@ 'Post Options' ) ); $post_id = $this->factory()->post->create(); @@ -37,7 +37,7 @@ public function test_save_should_return_post_id_when_ok_to_save_is_false() { /** * Test _Beans_Post_Meta::save() should run update_post_meta() and return null when ok_to_save() is true. */ - public function test_save_should_run_update_post_meta_and_return_null_when_ok_to_save() { + public function test_should_run_update_post_meta_and_return_null_when_ok_to_save() { $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); $post_id = $this->factory()->post->create(); diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php index 5c85608b..b342b236 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php @@ -1,6 +1,6 @@ 'Post Options' ) ); $attachment_id = $this->factory()->attachment->create(); $attachment_data = get_post( $attachment_id, ARRAY_A ); diff --git a/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php b/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php index 6b8bc688..255529bc 100644 --- a/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php +++ b/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php @@ -1,6 +1,6 @@ assertTrue( _beans_is_post_meta_conditions( true ) ); } /** - * Tests is_post_meta_conditions() should return true when is a new post and $conditions include 'post'. + * Test _beans_is_post_meta_conditions() should return true when it's a new post and $conditions include 'post'. */ public function test_should_return_true_when_new_post_and_conditions_include_post() { set_current_screen( 'post' ); @@ -44,7 +44,7 @@ public function test_should_return_true_when_new_post_and_conditions_include_pos } /** - * Tests is_post_meta_conditions() should return false when is a new post and $conditions don't include 'post'. + * Test _beans_is_post_meta_conditions() should return false when it's a new post and $conditions don't include 'post'. */ public function test_should_return_false_when_new_post_and_conditions_do_not_include_post() { set_current_screen( 'post' ); @@ -57,7 +57,7 @@ public function test_should_return_false_when_new_post_and_conditions_do_not_inc } /** - * Tests is_post_meta_conditions() should return false when post_id can't be found. + * Test _beans_is_post_meta_conditions() should return false when post_ID can't be found. */ public function test_should_return_false_when_post_id_not_found() { set_current_screen( 'edit' ); @@ -66,13 +66,13 @@ public function test_should_return_false_when_post_id_not_found() { } /** - * Tests is_post_meta_conditions() should return true when $conditions match post type. + * Test _beans_is_post_meta_conditions() should return true when $conditions match post type. */ public function test_should_return_true_when_conditions_match_post_type() { $post_id = $this->factory()->post->create( array( 'post_type' => 'cpt' ) ); set_current_screen( 'cpt' ); - // Setup for when post_id is in GET. + // Setup for when post_ID is in GET. $_GET['post'] = $post_id; $this->assertTrue( _beans_is_post_meta_conditions( array( 'cpt' ) ) ); @@ -80,7 +80,7 @@ public function test_should_return_true_when_conditions_match_post_type() { // Clear Global GET. $_GET['post'] = null; - // Set up for when post_id is in POST. + // Setup for when post_ID is in POST. $_POST['post_ID'] = $post_id; $this->assertTrue( _beans_is_post_meta_conditions( array( 'cpt' ) ) ); @@ -90,13 +90,13 @@ public function test_should_return_true_when_conditions_match_post_type() { } /** - * Tests is_post_meta_conditions() should return true when conditions match post ID. + * Test _beans_is_post_meta_conditions() should return true when conditions match post_ID. */ public function test_should_return_true_when_conditions_match_post_id() { $post_id = $this->factory()->post->create(); set_current_screen( 'edit' ); - // Setup for when post_id is in GET. + // Setup for when post_ID is in GET. $_GET['post'] = $post_id; $this->assertTrue( _beans_is_post_meta_conditions( array( $post_id ) ) ); @@ -104,7 +104,7 @@ public function test_should_return_true_when_conditions_match_post_id() { // Clear Global GET. $_GET['post'] = null; - // Set up for when post_id is in POST. + // Setup for when post_ID is in POST. $_POST['post_ID'] = $post_id; $this->assertTrue( _beans_is_post_meta_conditions( array( $post_id ) ) ); @@ -114,14 +114,14 @@ public function test_should_return_true_when_conditions_match_post_id() { } /** - * Tests is_post_meta_conditions() should return true when conditions match a page template name. + * Test _beans_is_post_meta_conditions() should return true when conditions match a page template name. */ public function test_should_return_true_when_conditions_match_page_template_name() { $page_id = $this->factory()->post->create( array( 'post_type' => 'page' ) ); set_current_screen( 'edit' ); add_post_meta( $page_id, '_wp_page_template', 'page-template-name' ); - // Setup for when post_id is in GET. + // Setup for when post_ID is in GET. $_GET['post'] = $page_id; $this->assertTrue( _beans_is_post_meta_conditions( array( 'page-template-name' ) ) ); @@ -129,7 +129,7 @@ public function test_should_return_true_when_conditions_match_page_template_name // Clear Global GET. $_GET['post'] = null; - // Set up for when post_id is in POST. + // Setup for when post_ID is in POST. $_POST['post_ID'] = $page_id; $this->assertTrue( _beans_is_post_meta_conditions( array( 'page-template-name' ) ) ); @@ -139,7 +139,7 @@ public function test_should_return_true_when_conditions_match_page_template_name } /** - * Tests is_post_meta_conditions() should return false when no conditions match. + * Test _beans_is_post_meta_conditions() should return false when no conditions match. */ public function test_should_return_false_when_no_conditions_match() { @@ -147,7 +147,7 @@ public function test_should_return_false_when_no_conditions_match() { set_current_screen( 'edit' ); add_post_meta( $page_id, '_wp_page_template', 'page-template-name' ); - // Setup for when post_id is in GET. + // Setup for when post_ID is in GET. $_GET['post'] = $page_id; $this->assertFalse( _beans_is_post_meta_conditions( array( 'some-other-conditions' ) ) ); @@ -155,7 +155,7 @@ public function test_should_return_false_when_no_conditions_match() { // Clear Global GET. $_GET['post'] = null; - // Set up for when post_id is in POST. + // Setup for when post_ID is in POST. $_POST['post_ID'] = $page_id; $this->assertFalse( _beans_is_post_meta_conditions( array( 'some-other-conditions' ) ) ); diff --git a/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php b/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php index 80bd2da3..aad59112 100644 --- a/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php +++ b/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php @@ -1,6 +1,6 @@ once()->with( 'beans_post_meta_nonce' )->andReturn( '123456' ); $expected_html_output = ''; diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php index 5a7963c1..1398949c 100644 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php +++ b/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php @@ -1,6 +1,6 @@ 'Post Options' ) ); Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( true ); @@ -35,9 +35,9 @@ public function test_save_should_return_false_when_doing_autosave() { } /** - * Test _Beans_Post_Meta::save() should return post_id when ok_to_save() is false. + * Test _Beans_Post_Meta::save() should return the post_ID when ok_to_save() is false. */ - public function test_save_should_return_post_id_when_ok_to_save_false() { + public function test_should_return_post_id_when_ok_to_save_false() { $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( false ); @@ -48,7 +48,7 @@ public function test_save_should_return_post_id_when_ok_to_save_false() { /** * Test _Beans_Post_Meta::save() should run update_post_meta() and return null when ok_to_save() is true. */ - public function test_save_should_run_update_post_meta_and_return_null_when_ok_to_save() { + public function test_should_run_update_post_meta_and_return_null_when_ok_to_save() { $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); $fields = array( 'beans_post_test_field' => 'beans_test_post_field_value' ); diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php index 12aa970a..64d140fa 100644 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php +++ b/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php @@ -1,6 +1,6 @@ 'Post Options' ) ); $attachment = array( 'ID' => 543 ); @@ -39,7 +39,7 @@ public function test_save_attachment_should_not_update_post_meta_when_doing_auto /** * Test _Beans_Post_Meta::save_attachment() should run update_post_meta() and return attachment when ok_to_save() is true. */ - public function test_save_attachment_should_run_update_post_meta_and_return_attachment_when_ok_to_save() { + public function test_should_run_update_post_meta_and_return_attachment_when_ok_to_save() { $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); $attachment = array( 'ID' => 543 ); $fields = array( 'beans_post_test_field' => 'beans_test_post_field_value' ); @@ -55,4 +55,3 @@ public function test_save_attachment_should_run_update_post_meta_and_return_atta $this->assertEquals( $attachment, $post_meta->save_attachment( $attachment ) ); } } - diff --git a/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php b/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php index a3423b3e..0af5e62e 100644 --- a/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php +++ b/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php @@ -1,5 +1,6 @@ assertTrue( _beans_is_post_meta_conditions( true ) ); } /** - * Tests is_post_meta_conditions() should return true when it's a new post and $conditions include 'post'. + * Test _beans_is_post_meta_conditions() should return true when it's a new post and $conditions include 'post'. */ public function test_shold_return_true_when_new_post_and_conditions_include_post() { $_SERVER['REQUEST_URI'] = 'post-new.php'; @@ -41,7 +42,7 @@ public function test_shold_return_true_when_new_post_and_conditions_include_post } /** - * Tests is_post_meta_conditions() should return false when it's a new post and $conditions don't include 'post'. + * Test _beans_is_post_meta_conditions() should return false when it's a new post and $conditions don't include 'post'. */ public function test_should_return_false_when_new_post_and_conditions_do_not_include_post() { $_SERVER['REQUEST_URI'] = 'post-new.php'; @@ -54,7 +55,7 @@ public function test_should_return_false_when_new_post_and_conditions_do_not_inc } /** - * Tests is_post_meta_conditions() should return false when post_id can't be found. + * Test _beans_is_post_meta_conditions() should return false when post_id can't be found. */ public function test_should_return_false_when_post_id_not_found() { @@ -65,11 +66,11 @@ public function test_should_return_false_when_post_id_not_found() { } /** - * Tests is_post_meta_conditions() should return true when $conditions match post type. + * Test _beans_is_post_meta_conditions() should return true when $conditions match post type. */ public function test_should_return_true_when_conditions_match_post_type() { - // Setup for when post_id is in GET. + // Setup for when post_ID is in GET. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 25 ); Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); Monkey\Functions\expect( 'get_post_type' )->once()->with( 25 )->andReturn( 'cpt' ); @@ -77,7 +78,7 @@ public function test_should_return_true_when_conditions_match_post_type() { $this->assertTrue( _beans_is_post_meta_conditions( array( 'cpt' ) ) ); - // Setup for when post_id is in POST. + // Setup for when post_ID is in POST. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( 25 ); Monkey\Functions\expect( 'get_post_type' )->once()->with( 25 )->andReturn( 'cpt' ); @@ -87,11 +88,11 @@ public function test_should_return_true_when_conditions_match_post_type() { } /** - * Tests is_post_meta_conditions() should return true when conditions match post ID. + * Test _beans_is_post_meta_conditions() should return true when conditions match post_ID. */ public function test_should_return_true_when_conditions_match_post_id() { - // Setup for when post_id is in GET. + // Setup for when post_ID is in GET. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 1 ); Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); Monkey\Functions\expect( 'get_post_type' )->once()->with( 1 )->andReturn( 'cpt' ); @@ -99,7 +100,7 @@ public function test_should_return_true_when_conditions_match_post_id() { $this->assertTrue( _beans_is_post_meta_conditions( array( 1 ) ) ); - // Setup for when post_id is in POST. + // Setup for when post_ID is in POST. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( 2 ); Monkey\Functions\expect( 'get_post_type' )->once()->with( 2 )->andReturn( 'cpt' ); @@ -109,11 +110,11 @@ public function test_should_return_true_when_conditions_match_post_id() { } /** - * Tests is_post_meta_conditions() should return true when conditions match a page template name. + * Test _beans_is_post_meta_conditions() should return true when conditions match a page template name. */ public function test_should_return_true_when_conditions_match_page_template_name() { - // Setup for when post_id is in GET. + // Setup for when post_ID is in GET. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 345 ); Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); Monkey\Functions\expect( 'get_post_type' )->once()->with( 345 )->andReturn( 'page' ); @@ -124,7 +125,7 @@ public function test_should_return_true_when_conditions_match_page_template_name $this->assertTrue( _beans_is_post_meta_conditions( array( 'page-template-name' ) ) ); - // Setup for when post_id is in POST. + // Setup for when post_ID is in POST. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( 543 ); Monkey\Functions\expect( 'get_post_type' )->once()->with( 543 )->andReturn( 'page' ); @@ -137,11 +138,11 @@ public function test_should_return_true_when_conditions_match_page_template_name } /** - * Tests is_post_meta_conditions() should return false when no conditions match. + * Test _beans_is_post_meta_conditions() should return false when no conditions match. */ public function test_should_return_false_when_no_conditions_match() { - // Setup for when post_id is in GET. + // Setup for when post_ID is in GET. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 345 ); Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); Monkey\Functions\expect( 'get_post_type' )->once()->with( 345 )->andReturn( 'page' ); @@ -152,7 +153,7 @@ public function test_should_return_false_when_no_conditions_match() { $this->assertFalse( _beans_is_post_meta_conditions( array( 'some-other-conditions' ) ) ); - // Setup for when post_id is in POST. + // Setup for when post_ID is in POST. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( 543 ); Monkey\Functions\expect( 'get_post_type' )->once()->with( 543 )->andReturn( 'page' ); diff --git a/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php b/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php index ea7f7bfb..87d84225 100644 --- a/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php +++ b/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php @@ -1,5 +1,6 @@ returnArg(); diff --git a/tests/phpunit/unit/api/post-meta/includes/class-beans-post-meta-test-case.php b/tests/phpunit/unit/api/post-meta/includes/class-beans-post-meta-test-case.php index 9d713694..185bc855 100644 --- a/tests/phpunit/unit/api/post-meta/includes/class-beans-post-meta-test-case.php +++ b/tests/phpunit/unit/api/post-meta/includes/class-beans-post-meta-test-case.php @@ -19,7 +19,7 @@ abstract class Beans_Post_Meta_Test_Case extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); From dec67c4310cf03e27d0f877c6e68729dadcd0655 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Thu, 17 May 2018 16:55:36 -0400 Subject: [PATCH 622/800] Improved consistency of Template API tests --- .../integration/api/template/beansLoadDefaultTemplate.php | 4 ++-- .../integration/api/template/beansLoadFragmentFile.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php index 95505dd5..02acb30e 100644 --- a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php @@ -9,7 +9,7 @@ namespace Beans\Framework\Tests\Integration\API\Template; -use WP_UnitTestCase; +use Beans\Framework\Tests\Integration\Test_Case; /** * Class Tests_BeansLoadDefaultTemplate @@ -18,7 +18,7 @@ * @group api * @group api-template */ -class Tests_BeansLoadDefaultTemplate extends WP_UnitTestCase { +class Tests_BeansLoadDefaultTemplate extends Test_Case { /** * Test beans_load_default_template() should return false when the template does not exist. diff --git a/tests/phpunit/integration/api/template/beansLoadFragmentFile.php b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php index cc8e8452..dcd01eaf 100644 --- a/tests/phpunit/integration/api/template/beansLoadFragmentFile.php +++ b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php @@ -10,7 +10,7 @@ namespace Beans\Framework\Tests\Integration\API\Template; use Brain\Monkey; -use WP_UnitTestCase; +use Beans\Framework\Tests\Integration\Test_Case; /** * Class Tests_BeansLoadFragmentFile @@ -19,7 +19,7 @@ * @group api * @group api-template */ -class Tests_BeansLoadFragmentFile extends WP_UnitTestCase { +class Tests_BeansLoadFragmentFile extends Test_Case { /** * Test beans_load_fragment_file() should return false when short-circuiting the function. From 2b288bb32b6c5b71026f1121dd9882d448526183 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Thu, 17 May 2018 16:55:59 -0400 Subject: [PATCH 623/800] Improved consistency of Term Meta API tests --- .../api/term-meta/beans-term-meta/construct.php | 4 ++-- .../api/term-meta/beans-term-meta/delete.php | 6 +++--- .../term-meta/beans-term-meta/renderFields.php | 12 ++++++------ .../term-meta/beans-term-meta/renderNonce.php | 2 +- .../api/term-meta/beans-term-meta/save.php | 6 +++--- .../api/term-meta/beansGetTermMeta.php | 16 ++++++++-------- .../api/term-meta/beansRegisterTermMeta.php | 16 ++++++++-------- .../fixtures/test-field-output-html.php | 8 ++++---- .../api/term-meta/fixtures/test-fields.php | 2 +- .../class-beans-term-meta-test-case.php | 2 +- .../term-meta/beans-term-meta/renderFields.php | 2 +- .../term-meta/beans-term-meta/renderNonce.php | 4 ++-- .../unit/api/term-meta/beans-term-meta/save.php | 10 +++++----- .../unit/api/term-meta/beansGetTermMeta.php | 6 +++--- .../unit/api/term-meta/beansIsAdminTerm.php | 11 ++++++----- .../api/term-meta/beansRegisterTermMeta.php | 17 +++++++++-------- .../unit/api/term-meta/fixtures/test-fields.php | 2 +- .../class-beans-term-meta-test-case.php | 4 ++-- 18 files changed, 66 insertions(+), 64 deletions(-) diff --git a/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php b/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php index 7444c60d..60136747 100644 --- a/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php +++ b/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php @@ -1,6 +1,6 @@ delete( 123 ); - // Clean the options cache so we're sure to go fresh to the database. + // Clean the options cache to make sure we are calling the database. wp_cache_delete( 'beans_term_123_field', 'options' ); $this->assertFalse( get_option( 'beans_term_123_field' ) ); diff --git a/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php b/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php index 5e4f7d96..090eb442 100644 --- a/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php +++ b/tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php @@ -1,6 +1,6 @@ render_fields(); @@ -66,17 +66,17 @@ public function test_should_render_field_html() {

      diff --git a/tests/phpunit/integration/api/term-meta/beans-term-meta/renderNonce.php b/tests/phpunit/integration/api/term-meta/beans-term-meta/renderNonce.php index aa693666..d3761524 100644 --- a/tests/phpunit/integration/api/term-meta/beans-term-meta/renderNonce.php +++ b/tests/phpunit/integration/api/term-meta/beans-term-meta/renderNonce.php @@ -1,6 +1,6 @@ assertFalse( beans_get_term_meta( 'beans_layout' ) ); $_GET['tag_ID'] = 1; // a tag_ID is set. @@ -38,7 +38,7 @@ public function test_should_return_false_when_no_optional_arguments_given_and_te /** * Test beans_get_term_meta() should return default when given and term meta does not exist. */ - public function test_should_return_default_when_default_given_and_term_meta_not_set() { + public function test_should_return_default_when_default_given_and_term_meta_does_not_exist() { $default_term_id = $this->factory()->category->create(); $provided_term_id = $this->factory()->category->create(); $this->go_to( ( '?cat=' . $default_term_id ) ); @@ -50,7 +50,7 @@ public function test_should_return_default_when_default_given_and_term_meta_not_ /** * Test beans_get_term_meta() should return term's meta value when it exists. */ - public function test_should_return_term_meta_when_meta_is_set() { + public function test_should_return_term_meta_when_it_exists() { $default_term_id = $this->factory()->category->create(); update_option( "beans_term_{$default_term_id}_beans_layout", 'sp-c' ); $provided_term_id = $this->factory()->category->create(); @@ -62,18 +62,18 @@ public function test_should_return_term_meta_when_meta_is_set() { } /** - * Test beans_get_term_meta() should return default when given and tag_ID set but term meta does not exist. + * Test beans_get_term_meta() should return default when given, tag_ID set but term meta does not exist. */ - public function test_should_return_default_when_given_and_tag_id_exists_but_term_meta_not_set() { + public function test_should_return_default_when_given_tag_id_set_but_term_meta_does_not_exist() { $_GET['tag_ID'] = 2; $this->assertSame( 'default_fallback', beans_get_term_meta( 'beans_layout', 'default_fallback' ) ); } /** - * Test beans_get_term_meta() should return meta term's value when given and tag_ID set and meta exists. + * Test beans_get_term_meta() should return meta term's value when given, tag_ID is set and meta exists. */ - public function test_should_return_term_meta_when_given_and_tag_id_exists_but_term_meta_not_set() { + public function test_should_return_term_meta_when_given_tag_id_set_and_term_meta_exist() { $_GET['tag_ID'] = 3; update_option( 'beans_term_3_beans_layout', 'sp-c' ); diff --git a/tests/phpunit/integration/api/term-meta/beansRegisterTermMeta.php b/tests/phpunit/integration/api/term-meta/beansRegisterTermMeta.php index 0e1dbe2f..2f8c0ad6 100644 --- a/tests/phpunit/integration/api/term-meta/beansRegisterTermMeta.php +++ b/tests/phpunit/integration/api/term-meta/beansRegisterTermMeta.php @@ -25,16 +25,16 @@ class Tests_BeansRegisterTermMeta extends Beans_Term_Meta_Test_Case { /** - * Tests beans_register_term_meta() should return false when taxonomy is not concerned. + * Test beans_register_term_meta() should return false when current taxonomy is not concerned. */ - public function tests_should_return_false_when_current_taxonomy_not_concerned() { + public function test_should_return_false_when_current_taxonomy_not_concerned() { $this->assertFalse( beans_register_term_meta( static::$test_data['fields'], array( 'sample-taxonomy' ), 'tm-beans' ) ); } /** - * Tests beans_register_term_meta() should return false when not is_admin(). + * Test beans_register_term_meta() should return false when not is_admin(). */ - public function tests_should_return_false_when_not_is_admin() { + public function test_should_return_false_when_not_is_admin() { $_POST['taxonomy'] = 'sample-taxonomy'; $this->assertFalse( @@ -47,9 +47,9 @@ public function tests_should_return_false_when_not_is_admin() { } /** - * Tests beans_register_term_meta() should return false when fields cannot be registered. + * Test beans_register_term_meta() should return false when term meta fields cannot be registered. */ - public function test_should_return_false_when_fields_cannot_be_registered() { + public function test_should_return_false_when_term_meta_fields_cannot_be_registered() { $_POST['taxonomy'] = 'sample-taxonomy'; set_current_screen( 'edit' ); @@ -57,9 +57,9 @@ public function test_should_return_false_when_fields_cannot_be_registered() { } /** - * Tests beans_register_term_meta() should return true when term meta fields are successfully registered. + * Test beans_register_term_meta() should return true when term meta fields are successfully registered. */ - public function test_should_return_true_when_fields_are_successfully_registered() { + public function test_should_return_true_when_term_meta_fields_are_successfully_registered() { $_POST['taxonomy'] = 'sample-taxonomy'; set_current_screen( 'edit' ); diff --git a/tests/phpunit/integration/api/term-meta/fixtures/test-field-output-html.php b/tests/phpunit/integration/api/term-meta/fixtures/test-field-output-html.php index 754f2296..b65ffffb 100644 --- a/tests/phpunit/integration/api/term-meta/fixtures/test-field-output-html.php +++ b/tests/phpunit/integration/api/term-meta/fixtures/test-field-output-html.php @@ -16,22 +16,22 @@
      Layout
      diff --git a/tests/phpunit/integration/api/term-meta/fixtures/test-fields.php b/tests/phpunit/integration/api/term-meta/fixtures/test-fields.php index af2155c5..495703be 100644 --- a/tests/phpunit/integration/api/term-meta/fixtures/test-fields.php +++ b/tests/phpunit/integration/api/term-meta/fixtures/test-fields.php @@ -1,6 +1,6 @@ once()->andReturn( true ); @@ -36,7 +36,7 @@ public function test_should_return_term_id_when_doing_ajax() { } /** - * Tests _Beans_Term_Meta::save() should return term_id when nonce is invalid. + * Test _Beans_Term_Meta::save() should return term_ID when nonce is invalid. */ public function test_should_return_term_id_when_nonce_is_invalid() { Monkey\Functions\expect( '_beans_doing_ajax' )->once()->andReturn( false ); @@ -55,7 +55,7 @@ public function test_should_return_term_id_when_nonce_is_invalid() { } /** - * Tests _Beans_Term_Meta::save() should return term_id when fields are falsey. + * Test _Beans_Term_Meta::save() should return term_ID when fields are falsey. */ public function test_should_return_term_id_when_fields_are_falsey() { Monkey\Functions\expect( '_beans_doing_ajax' )->once()->andReturn( false ); @@ -78,7 +78,7 @@ public function test_should_return_term_id_when_fields_are_falsey() { } /** - * Tests _Beans_Term_Meta::save() should return null when fields are updated. + * Test _Beans_Term_Meta::save() should return null when fields are updated. */ public function test_should_return_null_when_fields_are_updated() { Monkey\Functions\when( 'stripslashes_deep' )->justReturn( 'sample-value' ); diff --git a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php index 51cf10d8..31570bf7 100644 --- a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php +++ b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php @@ -24,9 +24,9 @@ class Tests_BeansGetTermMeta extends Beans_Term_Meta_Test_Case { /** - * Test beans_get_term_meta() should return false when default not given and term meta does not exist. + * Test beans_get_term_meta() should return false when no default given and term meta does not exist. */ - public function test_should_return_false_when_no_optional_arguments_given_and_term_meta_not_set() { + public function test_should_return_false_when_no_default_given_and_term_meta_not_set() { Monkey\Functions\expect( 'get_queried_object' ) ->once() ->andReturn( (object) array( 'post_id' => 1 ) ); // return an object with no term_id. @@ -54,7 +54,7 @@ public function test_should_return_default_when_default_given_and_queried_obj_ha /** * Test beans_get_term_meta() should return meta term's value when queried object has a term_id and meta for that - * id exists. + * ID exists. */ public function test_should_return_term_meta_when_queried_object_has_term_id_and_meta_is_set() { Monkey\Functions\expect( 'get_queried_object' ) diff --git a/tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php b/tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php index ee414b42..09fc4075 100644 --- a/tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php +++ b/tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php @@ -1,5 +1,6 @@ assertTrue( _beans_is_admin_term( true ) ); } /** - * Tests beans_register_term_meta() should return false when current taxonomies cannot be found. + * Test _beans_is_admin_term() should return false when current taxonomies cannot be found. */ public function tests_should_return_false_when_current_taxonomies_not_found() { Monkey\Functions\expect( 'beans_get_or_post' ) @@ -42,7 +43,7 @@ public function tests_should_return_false_when_current_taxonomies_not_found() { } /** - * Tests beans_register_term_meta() should return true when current taxonomy is in taxonomy array. + * Test _beans_is_admin_term() should return true when current taxonomy is in taxonomy array. */ public function tests_should_return_true_when_current_taxonomy_in_taxonomy_array() { Monkey\Functions\expect( 'beans_get_or_post' ) @@ -54,7 +55,7 @@ public function tests_should_return_true_when_current_taxonomy_in_taxonomy_array } /** - * Tests beans_register_term_meta() should return false when current taxonomy is not in taxonomy array. + * Test _beans_is_admin_term() should return false when current taxonomy is not in taxonomy array. */ public function tests_should_return_false_when_current_taxonomy_not_in_taxonomy_array() { Monkey\Functions\expect( 'beans_get_or_post' ) diff --git a/tests/phpunit/unit/api/term-meta/beansRegisterTermMeta.php b/tests/phpunit/unit/api/term-meta/beansRegisterTermMeta.php index 6ab3f17a..cc8d2b14 100644 --- a/tests/phpunit/unit/api/term-meta/beansRegisterTermMeta.php +++ b/tests/phpunit/unit/api/term-meta/beansRegisterTermMeta.php @@ -1,5 +1,6 @@ once() ->with( array( 'sample-taxonomy' ) ) @@ -34,9 +35,9 @@ public function tests_should_return_false_when_current_taxonomy_not_concerned() } /** - * Tests beans_register_term_meta() should return false when not is_admin(). + * Test beans_register_term_meta() should return false when not is_admin(). */ - public function tests_should_return_false_when_not_is_admin() { + public function test_should_return_false_when_not_is_admin() { Monkey\Functions\expect( '_beans_is_admin_term' ) ->once() ->with( array( 'sample-taxonomy' ) ) @@ -53,7 +54,7 @@ public function tests_should_return_false_when_not_is_admin() { } /** - * Tests beans_register_term_meta() should return false when fields cannot be registered. + * Test beans_register_term_meta() should return false when fields cannot be registered. */ public function test_should_return_false_when_fields_cannot_be_registered() { Monkey\Functions\expect( '_beans_is_admin_term' ) @@ -76,7 +77,7 @@ public function test_should_return_false_when_fields_cannot_be_registered() { } /** - * Tests beans_register_term_meta() should return true when term meta fields are successfully registered. + * Test beans_register_term_meta() should return true when term meta fields are successfully registered. */ public function test_should_return_true_when_fields_are_successfully_registered() { Monkey\Functions\expect( '_beans_is_admin_term' ) diff --git a/tests/phpunit/unit/api/term-meta/fixtures/test-fields.php b/tests/phpunit/unit/api/term-meta/fixtures/test-fields.php index ecb32cc5..f9d83507 100644 --- a/tests/phpunit/unit/api/term-meta/fixtures/test-fields.php +++ b/tests/phpunit/unit/api/term-meta/fixtures/test-fields.php @@ -1,6 +1,6 @@ Date: Thu, 17 May 2018 16:56:50 -0400 Subject: [PATCH 624/800] Improved consistency of Utilities API tests --- tests/phpunit/unit/api/utilities/beansGet.php | 2 +- tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php | 2 +- tests/phpunit/unit/api/utilities/beansPathToUrl.php | 4 ++-- tests/phpunit/unit/api/utilities/beansRemoveDir.php | 2 +- tests/phpunit/unit/api/utilities/beansRenderFunction.php | 2 +- tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php | 2 +- tests/phpunit/unit/api/utilities/beansSanitizePath.php | 4 ++-- tests/phpunit/unit/api/utilities/beansUrlToPath.php | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/unit/api/utilities/beansGet.php b/tests/phpunit/unit/api/utilities/beansGet.php index f623d165..fdaedf4e 100644 --- a/tests/phpunit/unit/api/utilities/beansGet.php +++ b/tests/phpunit/unit/api/utilities/beansGet.php @@ -21,7 +21,7 @@ class Tests_BeansGet extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php index cdc67df0..9e2bf4a9 100644 --- a/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php +++ b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php @@ -21,7 +21,7 @@ class Tests_BeansMultiArrayKeyExists extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/unit/api/utilities/beansPathToUrl.php b/tests/phpunit/unit/api/utilities/beansPathToUrl.php index 394613ff..44fae5d2 100644 --- a/tests/phpunit/unit/api/utilities/beansPathToUrl.php +++ b/tests/phpunit/unit/api/utilities/beansPathToUrl.php @@ -36,7 +36,7 @@ class Tests_BeansPathToUrl extends Test_Case { protected $beans_tests_relative_path; /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); @@ -75,7 +75,7 @@ public function test_should_bail_out_when_relative_url() { /** * Test beans_path_to_url() should bail out when Data URI. */ - public function test_should_bail_out_when_data_url() { + public function test_should_bail_out_when_data_uri() { $this->assertSame( 'data:,Hello%2C%20World!', beans_path_to_url( 'data:,Hello%2C%20World!' ) ); $this->assertSame( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D', diff --git a/tests/phpunit/unit/api/utilities/beansRemoveDir.php b/tests/phpunit/unit/api/utilities/beansRemoveDir.php index 7cf1f2fa..abb57a86 100644 --- a/tests/phpunit/unit/api/utilities/beansRemoveDir.php +++ b/tests/phpunit/unit/api/utilities/beansRemoveDir.php @@ -22,7 +22,7 @@ class Tests_BeansRemoveDir extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunction.php b/tests/phpunit/unit/api/utilities/beansRenderFunction.php index bde18d9d..a69fb4c5 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunction.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunction.php @@ -22,7 +22,7 @@ class Tests_BeansRenderFunction extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php index 3457aec8..26e8f24b 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php @@ -21,7 +21,7 @@ class Tests_BeansRenderFunctionArray extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/unit/api/utilities/beansSanitizePath.php b/tests/phpunit/unit/api/utilities/beansSanitizePath.php index c385e36d..3171faf0 100644 --- a/tests/phpunit/unit/api/utilities/beansSanitizePath.php +++ b/tests/phpunit/unit/api/utilities/beansSanitizePath.php @@ -21,7 +21,7 @@ class Tests_BeansSanitizePath extends Test_Case { /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); @@ -44,7 +44,7 @@ public function test_should_sanitize_for_filesystem() { $this->assertSame( $this->prepare_path( BEANS_TESTS_DIR ), beans_sanitize_path( BEANS_TESTS_DIR ) ); $this->assertSame( $this->prepare_path( __DIR__ ), beans_sanitize_path( __DIR__ ) ); - // Test phpunit's path. + // Test PHPUnit's path. $this->assertSame( $this->prepare_path( BEANS_TESTS_DIR ) . '/bootstrap.php', beans_sanitize_path( BEANS_TESTS_DIR . DIRECTORY_SEPARATOR . 'bootstrap.php' ) diff --git a/tests/phpunit/unit/api/utilities/beansUrlToPath.php b/tests/phpunit/unit/api/utilities/beansUrlToPath.php index 73d6724a..21cd4eff 100644 --- a/tests/phpunit/unit/api/utilities/beansUrlToPath.php +++ b/tests/phpunit/unit/api/utilities/beansUrlToPath.php @@ -29,7 +29,7 @@ class Tests_BeansUrlToPath extends Test_Case { protected $abspath; /** - * Setup test fixture. + * Prepares the test environment before each test. */ protected function setUp() { parent::setUp(); From ae0af828a848532aa3b468dc9ebf88a1f4644fcf Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Thu, 17 May 2018 16:57:37 -0400 Subject: [PATCH 625/800] Improved consistency of WP Customize API tests --- .../api/term-meta/beans-term-meta/construct.php | 2 +- .../api/wp-customize/beans-wp-customize/add.php | 6 +++--- .../wp-customize/beansRegisterWPCustomizeOptions.php | 4 ++-- .../api/wp-customize/fixtures/test-fields.php | 2 +- .../includes/class-wp-customize-test-case.php | 2 +- .../unit/api/wp-customize/beans-wp-customize/add.php | 6 +++--- .../wp-customize/beans-wp-customize/add_control.php | 6 +++--- .../beans-wp-customize/add_group_setting.php | 10 +++++----- .../wp-customize/beans-wp-customize/add_section.php | 6 +++--- .../wp-customize/beans-wp-customize/add_setting.php | 6 +++--- .../wp-customize/beansRegisterWPCustomizeOptions.php | 4 ++-- .../unit/api/wp-customize/fixtures/test-fields.php | 2 +- .../includes/class-wp-customize-test-case.php | 2 +- tests/phpunit/unit/class-test-case.php | 2 +- 14 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php b/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php index 60136747..5e0e032e 100644 --- a/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php +++ b/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php @@ -25,7 +25,7 @@ class Tests_BeansTermMeta_Construct extends Beans_Term_Meta_Test_Case { /** - * Test __construct() should set the correct hooks the when class is instantiated. + * Test __construct() should set the correct hooks when the class is instantiated. */ public function test_should_set_correct_hooks_when_class_is_instantiated() { $_GET['taxonomy'] = 'sample-taxonomy'; diff --git a/tests/phpunit/integration/api/wp-customize/beans-wp-customize/add.php b/tests/phpunit/integration/api/wp-customize/beans-wp-customize/add.php index dcef3634..2c036f50 100644 --- a/tests/phpunit/integration/api/wp-customize/beans-wp-customize/add.php +++ b/tests/phpunit/integration/api/wp-customize/beans-wp-customize/add.php @@ -1,6 +1,6 @@ assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); diff --git a/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php b/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php index b3fd0490..93d63ea9 100644 --- a/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php +++ b/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php @@ -1,6 +1,6 @@ withNoArgs() ->once() diff --git a/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php index 3766524f..f4b13e08 100644 --- a/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php +++ b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php @@ -1,6 +1,6 @@ Date: Sat, 19 May 2018 13:22:08 -0500 Subject: [PATCH 626/800] Moved redundant test suite initializations to root. (PR #230) Added common functionality to initialize each of the test suites. These initializers keep our bootstrap files DRY and easier to read. --- tests/phpunit/functions.php | 60 +++++++++++++++++++++++++ tests/phpunit/integration/bootstrap.php | 12 +++-- tests/phpunit/unit/bootstrap.php | 20 ++------- 3 files changed, 69 insertions(+), 23 deletions(-) diff --git a/tests/phpunit/functions.php b/tests/phpunit/functions.php index 0823552c..f7a839cf 100644 --- a/tests/phpunit/functions.php +++ b/tests/phpunit/functions.php @@ -9,6 +9,66 @@ namespace Beans\Framework\Tests; +/** + * Initialize the test suite. + * + * @since 1.5.0 + * + * @param string $test_suite Directory name of the test suite. + * + * @return void + */ +function init_test_suite( $test_suite ) { + check_readiness(); + + init_constants( $test_suite ); + + // Load the files. + $beans_root_dir = rtrim( BEANS_THEME_DIR, DIRECTORY_SEPARATOR ); + require_once $beans_root_dir . '/vendor/autoload.php'; + require_once __DIR__ . '/test-case-trait.php'; + + // Load Patchwork before everything else in order to allow us to redefine WordPress and Beans functions. + require_once $beans_root_dir . '/vendor/brain/monkey/inc/patchwork-loader.php'; +} + +/** + * Check the system's readiness to run the tests. + * + * @since 1.5.0 + * + * @return void + */ +function check_readiness() { + + if ( version_compare( phpversion(), '5.6.0', '<' ) ) { + trigger_error( 'Beans Unit Tests require PHP 5.6 or higher.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. + } + + if ( ! file_exists( dirname( dirname( __DIR__ ) ) . '/vendor/autoload.php' ) ) { + trigger_error( 'Whoops, we need Composer before we start running tests. Please type: `composer install`. When done, try running `phpunit` again.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. + } +} + +/** + * Initialize the constants. + * + * @since 1.5.0 + * + * @param string $test_suite_folder Directory name of the test suite. + * + * @return void + */ +function init_constants( $test_suite_folder ) { + define( 'BEANS_TESTS_DIR', __DIR__ . DIRECTORY_SEPARATOR . $test_suite_folder ); + + $beans_root_dir = dirname( dirname( __DIR__ ) ); + if ( 'unit' === $test_suite_folder ) { + $beans_root_dir .= DIRECTORY_SEPARATOR; + } + define( 'BEANS_THEME_DIR', $beans_root_dir ); +} + /** * Resets Beans for the test suite. * diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index ec643c68..48fc288c 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -10,21 +10,21 @@ namespace Beans\Framework\Tests\Integration; +use function Beans\Framework\Tests\init_test_suite; + if ( ! file_exists( '../../../wp-content' ) ) { trigger_error( 'Unable to run the integration tests, because the wp-content folder does not exist.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. } -define( 'BEANS_TESTS_DIR', __DIR__ ); -define( 'BEANS_THEME_DIR', dirname( dirname( dirname( __DIR__ ) ) ) ); +require_once dirname( dirname( __FILE__ ) ) . '/functions.php'; +init_test_suite( 'integration' ); + define( 'WP_CONTENT_DIR', dirname( dirname( dirname( getcwd() ) ) ) . '/wp-content/' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Our tests need to define this constant. if ( ! defined( 'WP_PLUGIN_DIR' ) ) { define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . 'plugins/' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- When this constant is not already defined, we define it here. It's a valid use case for our testing suite. } -// Load Patchwork before everything else in order to allow us to redefine WordPress and Beans functions. -require_once BEANS_THEME_DIR . '/vendor/brain/monkey/inc/patchwork-loader.php'; - /** * Get the WordPress' tests suite directory. * @@ -73,6 +73,4 @@ function beans_get_wp_tests_dir() { require_once $beans_tests_dir . '/includes/bootstrap.php'; // Load the Integration Test Case. -require_once dirname( __DIR__ ) . '/functions.php'; -require_once dirname( __DIR__ ) . '/test-case-trait.php'; require_once BEANS_TESTS_DIR . '/class-test-case.php'; diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index 16fd2718..126edab5 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -10,12 +10,11 @@ namespace Beans\Framework\Tests\Unit; -if ( version_compare( phpversion(), '5.6.0', '<' ) ) { - trigger_error( 'Beans Unit Tests require PHP 5.6 or higher.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. -} +use function Beans\Framework\Tests\init_test_suite; + +require_once dirname( dirname( __FILE__ ) ) . '/functions.php'; +init_test_suite( 'unit' ); -define( 'BEANS_TESTS_DIR', __DIR__ ); -define( 'BEANS_THEME_DIR', dirname( dirname( dirname( __DIR__ ) ) ) . DIRECTORY_SEPARATOR ); define( 'BEANS_TESTS_LIB_DIR', BEANS_THEME_DIR . 'lib' . DIRECTORY_SEPARATOR ); define( 'BEANS_API_PATH', BEANS_TESTS_LIB_DIR . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR ); @@ -24,15 +23,4 @@ define( 'ABSPATH', dirname( dirname( dirname( BEANS_THEME_DIR ) ) ) . '/' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Valid use case for our testing suite. } -// Time to load Composer's autoloader. -$beans_autoload_path = BEANS_THEME_DIR . 'vendor/'; - -if ( ! file_exists( $beans_autoload_path . 'autoload.php' ) ) { - trigger_error( 'Whoops, we need Composer before we start running tests. Please type: `composer install`. When done, try running `phpunit` again.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite. -} -require_once $beans_autoload_path . 'autoload.php'; -unset( $beans_autoload_path ); - -require_once dirname( __DIR__ ) . '/functions.php'; -require_once dirname( __DIR__ ) . '/test-case-trait.php'; require_once BEANS_TESTS_DIR . '/class-test-case.php'; From 24f9edc51c3c8dacdd002dabb264a7a8842339c7 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 18 May 2018 22:53:01 -0400 Subject: [PATCH 627/800] Refactored vfs cross-platform path handling --- .../compiler/beans-compiler/runCompiler.php | 16 +++++---- .../compiler/beans-compiler/setFilename.php | 18 ++++++++-- .../api/compiler/beansGetCompilerDir.php | 31 +++++++--------- .../includes/class-compiler-test-case.php | 25 ------------- .../beans-image-editor/createEditedImage.php | 4 +++ .../api/image/beans-image-editor/run.php | 11 ++++++ .../image/includes/class-image-test-case.php | 36 ------------------- .../image/includes/class-image-test-case.php | 36 ------------------- 8 files changed, 53 insertions(+), 124 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php index 41ea49fd..ee97ff3d 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -12,6 +12,7 @@ use _Beans_Compiler; use Beans\Framework\Tests\Integration\API\Compiler\Includes\Compiler_Test_Case; use org\bovigo\vfs\vfsStream; +use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -72,6 +73,9 @@ public function setUp() { ->getContent(); $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); + + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. + Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); } /** @@ -90,7 +94,7 @@ public function test_should_enqueue_existing_cached_file_when_no_modifications() 'minify_js' => true, 'version' => '1.5.0', ); - $compiler = $this->create_compiler( $config ); + $compiler = new _Beans_Compiler( $config ); // Store the cached file into the virtual filesystem. $this->add_virtual_directory( $config['id'] ); @@ -131,7 +135,7 @@ public function test_should_recompile_when_fragments_change() { 'minify_js' => true, 'version' => null, ); - $compiler = $this->create_compiler( $config ); + $compiler = new _Beans_Compiler( $config ); /** * Set up the original "compiled" file. This is the file that should get removed during this @@ -205,7 +209,7 @@ public function test_should_compile_save_and_enqueue_jquery() { 'minify_js' => true, 'version' => null, ); - $compiler = $this->create_compiler( $config ); + $compiler = new _Beans_Compiler( $config ); // Set up the mocks. $this->add_virtual_directory( $config['id'] ); @@ -239,7 +243,7 @@ public function test_should_compile_save_and_enqueue_js() { 'minify_js' => true, 'version' => null, ); - $compiler = $this->create_compiler( $config ); + $compiler = new _Beans_Compiler( $config ); // Set up the mocks. $this->add_virtual_directory( $config['id'] ); @@ -272,7 +276,7 @@ public function test_should_compile_save_and_enqueue_css() { 'minify_js' => false, 'version' => '1.5.0', ); - $compiler = $this->create_compiler( $config ); + $compiler = new _Beans_Compiler( $config ); // Set up the mocks. $this->add_virtual_directory( $config['id'] ); @@ -307,7 +311,7 @@ public function test_should_compile_save_and_enqueue_less() { 'minify_js' => false, 'version' => '1.5.0', ); - $compiler = $this->create_compiler( $config ); + $compiler = new _Beans_Compiler( $config ); // Set up the mocks. $this->add_virtual_directory( $config['id'] ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php index 2434bb95..9651c31f 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php @@ -10,7 +10,9 @@ namespace Beans\Framework\Tests\Integration\API\Compiler; use Beans\Framework\Tests\Integration\API\Compiler\Includes\Compiler_Test_Case; +use _Beans_Compiler; use org\bovigo\vfs\vfsStream; +use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-compiler-test-case.php'; @@ -23,6 +25,16 @@ */ class Tests_BeansCompiler_SetFilename extends Compiler_Test_Case { + /** + * Set up the test fixture. + */ + public function setUp() { + parent::setUp(); + + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. + Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); + } + /** * Test _Beans_Compiler::set_filename() should return the hash created with the modification time from each of the * fragments. @@ -39,7 +51,7 @@ public function test_should_return_hash_created_with_fragments_filemtime() { 'minify_js' => true, 'version' => null, ); - $compiler = $this->create_compiler( $config ); + $compiler = new _Beans_Compiler( $config ); // Set up the mocks. $this->set_dev_mode( true ); @@ -69,7 +81,7 @@ public function test_should_exclude_external_fragments() { 'minify_js' => true, 'version' => null, ); - $compiler = $this->create_compiler( $config ); + $compiler = new _Beans_Compiler( $config ); // Set up the mocks. $this->set_dev_mode( true ); @@ -101,7 +113,7 @@ public function test_should_remove_old_file() { 'minify_js' => true, 'version' => null, ); - $compiler = $this->create_compiler( $config ); + $compiler = new _Beans_Compiler( $config ); // Set up the mocks. $this->set_dev_mode( true ); diff --git a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php index 2dc6c2d9..fdfc40db 100644 --- a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php +++ b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php @@ -11,6 +11,7 @@ use Beans\Framework\Tests\Integration\API\Compiler\Includes\Compiler_Test_Case; use org\bovigo\vfs\vfsStream; +use Brain\Monkey; require_once __DIR__ . '/includes/class-compiler-test-case.php'; @@ -23,13 +24,23 @@ */ class Test_BeansGetCompilerDir extends Compiler_Test_Case { + /** + * Prepares the test environment before each test. + */ + public function setUp() { + parent::setUp(); + + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. + Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); + } + /** * Test beans_get_compiler_dir() should return the absolute path to the Beans' uploads compiler folder. */ public function test_should_return_absolute_path_to_compiler_folder() { $this->assertSame( vfsStream::url( 'compiled/beans/compiler/' ), - $this->fix_virtual_dir( beans_get_compiler_dir() ) + beans_get_compiler_dir() ); } @@ -39,23 +50,7 @@ public function test_should_return_absolute_path_to_compiler_folder() { public function test_should_return_absolute_path_to_compiler_admin_folder() { $this->assertSame( vfsStream::url( 'compiled/beans/admin-compiler/' ), - $this->fix_virtual_dir( beans_get_compiler_dir( true ) ) + beans_get_compiler_dir( true ) ); } - - /** - * Fix the virtual directory. Modify the root, as wp_normalize_path changes it. - * - * @since 1.5.0 - * - * @param string $path The path to fix. - * - * @return string - */ - protected function fix_virtual_dir( $path ) { - if ( substr( $path, 0, 6 ) === 'vfs://' ) { - return $path; - } - return str_replace( 'vfs:/', 'vfs://', $path ); - } } diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index f49cae32..d3d8f582 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -148,31 +148,6 @@ protected function set_current_fragment( $compiler, $fragment ) { $current_fragment->setAccessible( false ); } - /** - * Fix the compiler's "dir" property, as the wp_normalize_path() converts "vfs://" to "vfs:/". - * - * @since 1.5.0 - * - * @param array $config Compiler's configuration. - * - * @return _Beans_Compiler - * @throws \ReflectionException Throws reflection error. - */ - protected function create_compiler( $config ) { - $compiler = new _Beans_Compiler( $config ); - - $dir = ( new \ReflectionClass( $compiler ) )->getProperty( 'dir' ); - $dir->setAccessible( true ); - - if ( substr( $compiler->dir, 0, 6 ) !== 'vfs://' ) { - $dir->setValue( $compiler, str_replace( 'vfs:/', 'vfs://', $compiler->dir ) ); - } - - $dir->setAccessible( false ); - - return $compiler; - } - /** * Get the filename. * diff --git a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php index fc3e8289..8c65d719 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php @@ -11,6 +11,7 @@ use _Beans_Image_Editor; use Beans\Framework\Tests\Integration\API\Image\Includes\Image_Test_Case; +use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-image-test-case.php'; require_once BEANS_API_PATH . 'image/class-beans-image-editor.php'; @@ -53,6 +54,9 @@ public function test_should_edit_create_and_store_image() { ); $args = array( 'resize' => array( 800, false ) ); + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. + Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); + foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php index ec6f1320..98ed9714 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -11,6 +11,7 @@ use _Beans_Image_Editor; use Beans\Framework\Tests\Integration\API\Image\Includes\Image_Test_Case; +use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-image-test-case.php'; require_once BEANS_API_PATH . 'image/class-beans-image-editor.php'; @@ -40,6 +41,16 @@ public static function setUpBeforeClass() { static::$fixtures_dir = realpath( __DIR__ . '/../fixtures' ); } + /** + * Prepares the test environment before each test. + */ + public function setUp() { + parent::setUp(); + + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. + Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); + } + /** * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its URL. */ diff --git a/tests/phpunit/integration/api/image/includes/class-image-test-case.php b/tests/phpunit/integration/api/image/includes/class-image-test-case.php index b7fc4aa4..6f334fbc 100644 --- a/tests/phpunit/integration/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/integration/api/image/includes/class-image-test-case.php @@ -44,43 +44,7 @@ protected function init_virtual_image( $rebuilt_path, $editor, $path = null ) { $path = $rebuilt_path->getValue( $editor ); } - $path = $this->fix_virtual_dir( $path ); $rebuilt_path->setValue( $editor, $path ); return $rebuilt_path->getValue( $editor ); } - - /** - * Fix the virtual directory. Modify the root, as wp_normalize_path changes it. - * - * @since 1.5.0 - * - * @param string $path The path to fix. - * - * @return string - */ - protected function fix_virtual_dir( $path ) { - - if ( substr( $path, 0, 6 ) === 'vfs://' ) { - return $path; - } - - return str_replace( 'vfs:/', 'vfs://', $path ); - } - - /** - * Removes the vfsStream's root, i.e. vfs:// or vfs:/. - * - * @since 1.5.0 - * - * @param string $path The path to fix. - * - * @return string - */ - protected function remove_virtual_dir_root( $path ) { - $pattern = substr( $path, 0, 6 ) === 'vfs://' - ? 'vfs://' - : 'vfs:/'; - - return str_replace( $pattern, '', $path ); - } } diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index ebd133a1..9cb54a99 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -111,47 +111,11 @@ protected function init_virtual_image( $rebuilt_path, $editor, $path = null ) { $path = $rebuilt_path->getValue( $editor ); } - $path = $this->fix_virtual_dir( $path ); $rebuilt_path->setValue( $editor, $path ); return $rebuilt_path->getValue( $editor ); } - /** - * Fix the virtual directory. Modify the root, as wp_normalize_path changes it. - * - * @since 1.5.0 - * - * @param string $path The path to fix. - * - * @return string - */ - protected function fix_virtual_dir( $path ) { - - if ( substr( $path, 0, 6 ) === 'vfs://' ) { - return $path; - } - - return str_replace( 'vfs:/', 'vfs://', $path ); - } - - /** - * Removes the vfsStream's root, i.e. vfs:// or vfs:/. - * - * @since 1.5.0 - * - * @param string $path The path to fix. - * - * @return string - */ - protected function remove_virtual_dir_root( $path ) { - $pattern = substr( $path, 0, 6 ) === 'vfs://' - ? 'vfs://' - : 'vfs:/'; - - return str_replace( $pattern, '', $path ); - } - /** * Set up the mocks. * From d0f6bfd547a526da00e34d9d48ace189b8faf042 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 19 May 2018 16:14:39 -0400 Subject: [PATCH 628/800] Changed rel=designer to nofollow --- lib/templates/fragments/footer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/templates/fragments/footer.php b/lib/templates/fragments/footer.php index de133600..35f43d52 100644 --- a/lib/templates/fragments/footer.php +++ b/lib/templates/fragments/footer.php @@ -37,7 +37,7 @@ function beans_footer_content() { 'a', array( 'href' => 'http://www.getbeans.io', // Automatically escaped. - 'rel' => 'designer', + 'rel' => 'nofollow', ) ); From 9401fd5bd058c3207b239bbbad876f884dc33cf6 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 19 May 2018 16:27:54 -0400 Subject: [PATCH 629/800] Added nav container and aria-labels --- lib/templates/fragments/comments.php | 88 +++++---- lib/templates/fragments/menu.php | 14 +- lib/templates/fragments/post.php | 268 ++++++++++++++------------- 3 files changed, 201 insertions(+), 169 deletions(-) diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index a81a1c55..41f60a22 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -286,57 +286,67 @@ function beans_comments_navigation() { } beans_open_markup_e( - 'beans_comments_navigation', - 'ul', + 'beans_comments_navigation_nav_container', + 'nav', array( - 'class' => 'uk-pagination', - 'role' => 'navigation', + 'role' => 'navigation', + 'aria-label' => 'Comments Pagination Navigation', ) ); - // Previous. - if ( get_previous_comments_link() ) { - beans_open_markup_e( 'beans_comments_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); + beans_open_markup_e( + 'beans_comments_navigation', + 'ul', + array( + 'class' => 'uk-pagination', + ) + ); - $previous_icon = beans_open_markup( - 'beans_previous_icon[_comments_navigation]', - 'span', - array( - 'class' => 'uk-icon-angle-double-left uk-margin-small-right', - 'aria-hidden' => 'true', - ) - ); - $previous_icon .= beans_close_markup( 'beans_previous_icon[_comments_navigation]', 'span' ); + // Previous. + if ( get_previous_comments_link() ) { + beans_open_markup_e( 'beans_comments_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); + + $previous_icon = beans_open_markup( + 'beans_previous_icon[_comments_navigation]', + 'span', + array( + 'class' => 'uk-icon-angle-double-left uk-margin-small-right', + 'aria-hidden' => 'true', + ) + ); + $previous_icon .= beans_close_markup( 'beans_previous_icon[_comments_navigation]', 'span' ); - echo get_previous_comments_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. - $previous_icon . beans_output( 'beans_previous_text[_comments_navigation]', __( 'Previous Comments', 'tm-beans' ) ) - ); + echo get_previous_comments_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + $previous_icon . beans_output( 'beans_previous_text[_comments_navigation]', __( 'Previous Comments', 'tm-beans' ) ) + ); - beans_close_markup_e( 'beans_comments_navigation_item[_previous]', 'li' ); - } + beans_close_markup_e( 'beans_comments_navigation_item[_previous]', 'li' ); + } - // Next. - if ( get_next_comments_link() ) { - beans_open_markup_e( 'beans_comments_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); + // Next. + if ( get_next_comments_link() ) { + beans_open_markup_e( 'beans_comments_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); + + $next_icon = beans_open_markup( + 'beans_next_icon[_comments_navigation]', + 'span', + array( + 'class' => 'uk-icon-angle-double-right uk-margin-small-right', + 'aria-hidden' => 'true', + ) + ); + $next_icon .= beans_close_markup( 'beans_next_icon[_comments_navigation]', 'span' ); - $next_icon = beans_open_markup( - 'beans_next_icon[_comments_navigation]', - 'span', - array( - 'class' => 'uk-icon-angle-double-right uk-margin-small-right', - 'aria-hidden' => 'true', - ) - ); - $next_icon .= beans_close_markup( 'beans_next_icon[_comments_navigation]', 'span' ); + echo get_next_comments_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + beans_output( 'beans_next_text[_comments_navigation]', __( 'Next Comments ', 'tm-beans' ) ) . $next_icon + ); - echo get_next_comments_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. - beans_output( 'beans_next_text[_comments_navigation]', __( 'Next Comments ', 'tm-beans' ) ) . $next_icon - ); + beans_close_markup_e( 'beans_comments_navigation_item_[_next]', 'li' ); + } - beans_close_markup_e( 'beans_comments_navigation_item_[_next]', 'li' ); - } + beans_close_markup_e( 'beans_comments_navigation', 'ul' ); - beans_close_markup_e( 'beans_comments_navigation', 'ul' ); + beans_close_markup_e( 'beans_comments_navigation_nav_container', 'nav' ); } beans_add_smart_action( 'beans_after_open_comments', 'beans_comment_form_divider' ); diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index 2b3c8a50..e00014fc 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -22,10 +22,11 @@ function beans_primary_menu() { 'beans_primary_menu', 'nav', array( - 'class' => 'tm-primary-menu uk-float-right uk-navbar', - 'role' => 'navigation', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/SiteNavigationElement', + 'class' => 'tm-primary-menu uk-float-right uk-navbar', + 'role' => 'navigation', + 'itemscope' => 'itemscope', + 'itemtype' => 'http://schema.org/SiteNavigationElement', + 'aria-label' => 'Primary Navigation Menu', ) ); @@ -112,8 +113,9 @@ function beans_primary_offcanvas_menu() { 'beans_primary_offcanvas_menu', 'nav', array( - 'class' => 'tm-primary-offcanvas-menu uk-margin uk-margin-top', - 'role' => 'navigation', + 'class' => 'tm-primary-offcanvas-menu uk-margin uk-margin-top', + 'role' => 'navigation', + 'aria-label' => 'Off-Canvas Primary Navigation Menu', ) ); diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 3a19c6bb..353f07f0 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -534,39 +534,49 @@ function beans_post_navigation() { } beans_open_markup_e( - 'beans_post_navigation', - 'ul', + 'beans_post_navigation_nav_container', + 'nav', array( - 'class' => 'uk-pagination', - 'role' => 'navigation', + 'role' => 'navigation', + 'aria-label' => 'Pagination Navigation', ) ); - if ( $previous ) { - beans_open_markup_e( 'beans_post_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); + beans_open_markup_e( + 'beans_post_navigation', + 'ul', + array( + 'class' => 'uk-pagination', + ) + ); - // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. - echo get_previous_post_link( - '%link', - beans_output( 'beans_previous_text[_post_navigation_item]', __( 'Previous Page', 'tm-beans' ) ) - ); + if ( $previous ) { + beans_open_markup_e( 'beans_post_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); - beans_close_markup_e( 'beans_post_navigation_item[_previous]', 'li' ); - } + // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + echo get_previous_post_link( + '%link', + beans_output( 'beans_previous_text[_post_navigation_item]', __( 'Previous Page', 'tm-beans' ) ) + ); - if ( $next ) { - beans_open_markup_e( 'beans_post_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); + beans_close_markup_e( 'beans_post_navigation_item[_previous]', 'li' ); + } - // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. - echo get_next_post_link( - '%link', - beans_output( 'beans_next_text[_post_navigation_item]', __( 'Next Page', 'tm-beans' ) ) - ); + if ( $next ) { + beans_open_markup_e( 'beans_post_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); - beans_close_markup_e( 'beans_post_navigation_item[_next]', 'li' ); - } + // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + echo get_next_post_link( + '%link', + beans_output( 'beans_next_text[_post_navigation_item]', __( 'Next Page', 'tm-beans' ) ) + ); + + beans_close_markup_e( 'beans_post_navigation_item[_next]', 'li' ); + } - beans_close_markup_e( 'beans_post_navigation', 'ul' ); + beans_close_markup_e( 'beans_post_navigation', 'ul' ); + + beans_close_markup_e( 'beans_post_navigation_nav_container', 'nav' ); } beans_add_smart_action( 'beans_after_posts_loop', 'beans_posts_pagination' ); @@ -600,146 +610,156 @@ function beans_posts_pagination() { $count = intval( $wp_query->max_num_pages ); beans_open_markup_e( - 'beans_posts_pagination', - 'ul', + 'beans_posts_pagination_nav_container', + 'nav', array( - 'class' => 'uk-pagination uk-grid-margin', - 'role' => 'navigation', + 'role' => 'navigation', + 'aria-label' => 'Posts Pagination Navigation' ) ); - // Previous. - if ( get_previous_posts_link() ) { - beans_open_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); - - beans_open_markup_e( - 'beans_previous_link[_posts_pagination]', - 'a', - array( - 'href' => previous_posts( false ), // Automatically escaped. - ), - $current - ); + beans_open_markup_e( + 'beans_posts_pagination', + 'ul', + array( + 'class' => 'uk-pagination uk-grid-margin', + ) + ); + + // Previous. + if ( get_previous_posts_link() ) { + beans_open_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); beans_open_markup_e( - 'beans_previous_icon[_posts_pagination]', - 'span', + 'beans_previous_link[_posts_pagination]', + 'a', array( - 'class' => 'uk-icon-angle-double-left uk-margin-small-right', - 'aria-hidden' => 'true', - ) + 'href' => previous_posts( false ), // Automatically escaped. + ), + $current ); - beans_close_markup_e( 'beans_previous_icon[_posts_pagination]', 'span' ); - - beans_output_e( 'beans_previous_text[_posts_pagination]', __( 'Previous Page', 'tm-beans' ) ); + beans_open_markup_e( + 'beans_previous_icon[_posts_pagination]', + 'span', + array( + 'class' => 'uk-icon-angle-double-left uk-margin-small-right', + 'aria-hidden' => 'true', + ) + ); - beans_close_markup_e( 'beans_previous_link[_posts_pagination]', 'a' ); + beans_close_markup_e( 'beans_previous_icon[_posts_pagination]', 'span' ); - beans_close_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); - } + beans_output_e( 'beans_previous_text[_posts_pagination]', __( 'Previous Page', 'tm-beans' ) ); - // Links. - foreach ( range( 1, (int) $wp_query->max_num_pages ) as $link ) { + beans_close_markup_e( 'beans_previous_link[_posts_pagination]', 'a' ); - // Skip if next is set. - if ( isset( $next ) && $link !== $next ) { - continue; - } else { - $next = $link + 1; + beans_close_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); } - $is_separator = array( - 1 !== $link, // Not first. - 1 === $current && 3 === $link ? false : true, // Force first 3 items. - $count > 3, // More. - $count !== $link, // Not last. - ( $current - 1 ) !== $link, // Not previous. - $current !== $link, // Not current. - ( $current + 1 ) !== $link, // Not next. - ); + // Links. + foreach ( range( 1, (int) $wp_query->max_num_pages ) as $link ) { - // Separator. - if ( ! in_array( false, $is_separator, true ) ) { - beans_open_markup_e( 'beans_posts_pagination_item[_separator]', 'li' ); + // Skip if next is set. + if ( isset( $next ) && $link !== $next ) { + continue; + } else { + $next = $link + 1; + } - beans_output_e( 'beans_posts_pagination_item_separator_text', '...' ); + $is_separator = array( + 1 !== $link, // Not first. + 1 === $current && 3 === $link ? false : true, // Force first 3 items. + $count > 3, // More. + $count !== $link, // Not last. + ( $current - 1 ) !== $link, // Not previous. + $current !== $link, // Not current. + ( $current + 1 ) !== $link, // Not next. + ); - beans_close_markup_e( 'beans_posts_pagination_item[_separator]', 'li' ); + // Separator. + if ( ! in_array( false, $is_separator, true ) ) { + beans_open_markup_e( 'beans_posts_pagination_item[_separator]', 'li' ); - // Jump. - if ( $link < $current ) { - $next = $current - 1; - } elseif ( $link > $current ) { - $next = $count; - } + beans_output_e( 'beans_posts_pagination_item_separator_text', '...' ); - continue; - } + beans_close_markup_e( 'beans_posts_pagination_item[_separator]', 'li' ); - // Integer. - if ( $link === $current ) { - beans_open_markup_e( 'beans_posts_pagination_item[_active]', 'li', array( 'class' => 'uk-active' ) ); + // Jump. + if ( $link < $current ) { + $next = $current - 1; + } elseif ( $link > $current ) { + $next = $count; + } - beans_open_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); + continue; + } - beans_output_e( 'beans_posts_pagination_item[_active]_text', $link ); + // Integer. + if ( $link === $current ) { + beans_open_markup_e( 'beans_posts_pagination_item[_active]', 'li', array( 'class' => 'uk-active' ) ); - beans_close_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); + beans_open_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); - beans_close_markup_e( 'beans_posts_pagination_item[_active]', 'li' ); - } else { - beans_open_markup_e( 'beans_posts_pagination_item', 'li' ); + beans_output_e( 'beans_posts_pagination_item[_active]_text', $link ); - beans_open_markup_e( - 'beans_posts_pagination_item_link', - 'a', - array( - 'href' => get_pagenum_link( $link ), // Automatically escaped. - ), - $link - ); + beans_close_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); - beans_output_e( 'beans_posts_pagination_item_link_text', $link ); + beans_close_markup_e( 'beans_posts_pagination_item[_active]', 'li' ); + } else { + beans_open_markup_e( 'beans_posts_pagination_item', 'li' ); - beans_close_markup_e( 'beans_posts_pagination_item_link', 'a' ); + beans_open_markup_e( + 'beans_posts_pagination_item_link', + 'a', + array( + 'href' => get_pagenum_link( $link ), // Automatically escaped. + ), + $link + ); - beans_close_markup_e( 'beans_posts_pagination_item', 'li' ); - } - } + beans_output_e( 'beans_posts_pagination_item_link_text', $link ); - // Next. - if ( get_next_posts_link() ) { - beans_open_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); - - beans_open_markup_e( - 'beans_next_link[_posts_pagination]', - 'a', - array( - 'href' => next_posts( $count, false ), // Automatically escaped. - ), - $current - ); + beans_close_markup_e( 'beans_posts_pagination_item_link', 'a' ); - beans_output_e( 'beans_next_text[_posts_pagination]', __( 'Next Page', 'tm-beans' ) ); + beans_close_markup_e( 'beans_posts_pagination_item', 'li' ); + } + } + + // Next. + if ( get_next_posts_link() ) { + beans_open_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); beans_open_markup_e( - 'beans_next_icon[_posts_pagination]', - 'span', + 'beans_next_link[_posts_pagination]', + 'a', array( - 'class' => 'uk-icon-angle-double-right uk-margin-small-left', - 'aria-hidden' => 'true', - ) + 'href' => next_posts( $count, false ), // Automatically escaped. + ), + $current ); - beans_close_markup_e( 'beans_next_icon[_posts_pagination]', 'span' ); + beans_output_e( 'beans_next_text[_posts_pagination]', __( 'Next Page', 'tm-beans' ) ); - beans_close_markup_e( 'beans_next_link[_posts_pagination]', 'a' ); + beans_open_markup_e( + 'beans_next_icon[_posts_pagination]', + 'span', + array( + 'class' => 'uk-icon-angle-double-right uk-margin-small-left', + 'aria-hidden' => 'true', + ) + ); - beans_close_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); - } + beans_close_markup_e( 'beans_next_icon[_posts_pagination]', 'span' ); + + beans_close_markup_e( 'beans_next_link[_posts_pagination]', 'a' ); + + beans_close_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); + } + + beans_close_markup_e( 'beans_posts_pagination', 'ul' ); - beans_close_markup_e( 'beans_posts_pagination', 'ul' ); + beans_close_markup_e( 'beans_posts_pagination_nav_container', 'nav' ); } beans_add_smart_action( 'beans_no_post', 'beans_no_post' ); From 3f8ee0b2a7a463379cabd24c79bc3749af5e3421 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 19 May 2018 17:02:43 -0400 Subject: [PATCH 630/800] Fixed code sniffer errors --- lib/templates/fragments/comments.php | 6 ++++-- lib/templates/fragments/post.php | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index 41f60a22..06bd2434 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -278,6 +278,8 @@ function beans_comments_closed() { * @since 1.0.0 * * @return void + * + * phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Layout mirrors HTML markup. */ function beans_comments_navigation() { @@ -442,7 +444,7 @@ function beans_comment_cancel_reply_link( $html, $link, $text ) { * @return string */ function beans_comment_form_comment() { - $output = beans_open_markup( 'beans_comment_form[_comment]', 'p', array( 'class' => 'uk-margin-top' ) ); + $output = beans_open_markup( 'beans_comment_form[_comment]', 'fieldset', array( 'class' => 'uk-margin-top' ) ); /** * Filter whether the comment form textarea legend should load or not. @@ -470,7 +472,7 @@ function beans_comment_form_comment() { $output .= beans_close_markup( 'beans_comment_form_field[_comment]', 'textarea' ); - $output .= beans_close_markup( 'beans_comment_form[_comment]', 'p' ); + $output .= beans_close_markup( 'beans_comment_form[_comment]', 'fieldset' ); return $output; } diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 353f07f0..5d5cf999 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -512,6 +512,8 @@ function beans_next_post_link( $output, $format, $link, $post ) { * @since 1.0.0 * * @return void + * + * phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Layout mirrors HTML markup */ function beans_post_navigation() { @@ -614,7 +616,7 @@ function beans_posts_pagination() { 'nav', array( 'role' => 'navigation', - 'aria-label' => 'Posts Pagination Navigation' + 'aria-label' => 'Posts Pagination Navigation', ) ); From 52311f756fcda0dac90e676b452dfa7498cbcc99 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 19 May 2018 21:50:17 -0400 Subject: [PATCH 631/800] Corrected multisite (#233) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 81ec7602..9f650cdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ php: env: - WP_VERSION=latest WP_MULTISITE=0 - WP_VERSION=latest WP_MULTISITE=1 - - WP_VERSION=trunk WP_MULqTISITE=0 + - WP_VERSION=trunk WP_MULTISITE=0 - WP_VERSION=trunk WP_MULTISITE=1 install: From 33a621ae9ccf8697ad13b316455d65968385046b Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 19 May 2018 22:55:01 -0400 Subject: [PATCH 632/800] Moved mock into Test Cases --- .../integration/api/compiler/beansGetCompilerDir.php | 11 ----------- .../compiler/includes/class-compiler-test-case.php | 11 +++++++++++ .../image/beans-image-editor/createEditedImage.php | 4 ---- .../integration/api/image/beans-image-editor/run.php | 11 ----------- .../api/image/includes/class-image-test-case.php | 11 +++++++++++ 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php index fdfc40db..59aae7d0 100644 --- a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php +++ b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php @@ -11,7 +11,6 @@ use Beans\Framework\Tests\Integration\API\Compiler\Includes\Compiler_Test_Case; use org\bovigo\vfs\vfsStream; -use Brain\Monkey; require_once __DIR__ . '/includes/class-compiler-test-case.php'; @@ -24,16 +23,6 @@ */ class Test_BeansGetCompilerDir extends Compiler_Test_Case { - /** - * Prepares the test environment before each test. - */ - public function setUp() { - parent::setUp(); - - // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. - Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); - } - /** * Test beans_get_compiler_dir() should return the absolute path to the Beans' uploads compiler folder. */ diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index d3d8f582..9d1053a3 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Integration\API\Compiler\Includes; use _Beans_Compiler; +use Brain\Monkey; use Mockery; use org\bovigo\vfs\vfsStream; @@ -63,6 +64,16 @@ public static function setUpBeforeClass() { : dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR; } + /** + * Prepares the test environment before each test. + */ + public function setUp() { + parent::setUp(); + + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. + Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); + } + /** * Cleans up the test environment after each test. */ diff --git a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php index 8c65d719..fc3e8289 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php @@ -11,7 +11,6 @@ use _Beans_Image_Editor; use Beans\Framework\Tests\Integration\API\Image\Includes\Image_Test_Case; -use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-image-test-case.php'; require_once BEANS_API_PATH . 'image/class-beans-image-editor.php'; @@ -54,9 +53,6 @@ public function test_should_edit_create_and_store_image() { ); $args = array( 'resize' => array( 800, false ) ); - // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. - Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); - foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php index 98ed9714..ec6f1320 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -11,7 +11,6 @@ use _Beans_Image_Editor; use Beans\Framework\Tests\Integration\API\Image\Includes\Image_Test_Case; -use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-image-test-case.php'; require_once BEANS_API_PATH . 'image/class-beans-image-editor.php'; @@ -41,16 +40,6 @@ public static function setUpBeforeClass() { static::$fixtures_dir = realpath( __DIR__ . '/../fixtures' ); } - /** - * Prepares the test environment before each test. - */ - public function setUp() { - parent::setUp(); - - // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. - Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); - } - /** * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its URL. */ diff --git a/tests/phpunit/integration/api/image/includes/class-image-test-case.php b/tests/phpunit/integration/api/image/includes/class-image-test-case.php index 6f334fbc..e68d56e6 100644 --- a/tests/phpunit/integration/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/integration/api/image/includes/class-image-test-case.php @@ -9,6 +9,7 @@ namespace Beans\Framework\Tests\Integration\API\Image\Includes; +use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once __DIR__ . '/class-base-test-case.php'; @@ -27,6 +28,16 @@ abstract class Image_Test_Case extends Base_Test_Case { */ protected $just_return_path = true; + /** + * Prepares the test environment before each test. + */ + public function setUp() { + parent::setUp(); + + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. + Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); + } + /** * Initialize the virtual "edited" image. * From 53fcf82c58ef39063da1458c89fef8b83e6b4b2f Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Tue, 22 May 2018 14:03:26 -0400 Subject: [PATCH 633/800] Improve test beans_deregister_widget_area() --- .../widget/beansDeregisterWidgetArea.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/integration/widget/beansDeregisterWidgetArea.php b/tests/phpunit/integration/widget/beansDeregisterWidgetArea.php index 28d6dfea..ddc31e12 100644 --- a/tests/phpunit/integration/widget/beansDeregisterWidgetArea.php +++ b/tests/phpunit/integration/widget/beansDeregisterWidgetArea.php @@ -25,18 +25,12 @@ class Tests_BeansDeregisterWidgetArea extends Beans_Widget_Test_Case { public function test_should_unregister_sidebar() { global $wp_registered_sidebars; - $wp_registered_sidebars['unwanted-sidebar'] = array( - 'beans_type' => 'stack', - 'beans_show_widget_title' => true, - 'beans_show_widget_badge' => false, - 'beans_widget_badge_content' => __( 'Hello', 'tm-beans' ), - 'id' => 'unwanted-sidebar', - ); + register_sidebar( array( 'id' => 'unwanted-sidebar' ) ); + + $this->assertTrue( isset( $wp_registered_sidebars['unwanted-sidebar'] ) ); beans_deregister_widget_area( 'unwanted-sidebar' ); - $this->assertArrayNotHasKey( 'unwanted-sidebar', $wp_registered_sidebars ); + $this->assertFalse( isset( $wp_registered_sidebars['unwanted-sidebar'] ) ); } - - } \ No newline at end of file From 2411c9f340f8d7f072170231a733f5006cadc1f8 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Tue, 22 May 2018 14:04:17 -0400 Subject: [PATCH 634/800] Improve test beans_register_widget_area() --- .../integration/widget/beansRegisterWidgetArea.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/integration/widget/beansRegisterWidgetArea.php b/tests/phpunit/integration/widget/beansRegisterWidgetArea.php index 3296d3eb..6ab97045 100644 --- a/tests/phpunit/integration/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/integration/widget/beansRegisterWidgetArea.php @@ -33,12 +33,20 @@ public function test_should_return_empty_string_when_ID_not_set() { * Test beans_register_widget_area() should return the widget area id when the widget area is registered. */ public function test_should_return_widget_area_ID_when_widget_area_registered() { + global $wp_registered_sidebars; + + // Verify new widget area is not yet added. + $this->assertFalse( isset( $wp_registered_sidebars['new-widget-area'] ) ); + $this->assertEquals( 'new-widget-area', beans_register_widget_area( array( 'id' => 'new-widget-area', 'beans_type' => 'grid', ) ) ); - } + // Confirm that the sidebar is now in the WP global sidebar array. + $this->assertTrue( isset( $wp_registered_sidebars['new-widget-area'] ) ); + $this->assertContains( 'grid', $wp_registered_sidebars['new-widget-area']); + } } \ No newline at end of file From 8b92385f426c20c9e9616542fb154d97e71b6ccf Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Tue, 22 May 2018 14:04:46 -0400 Subject: [PATCH 635/800] Improve test beans_has_widget_area() --- .../integration/widget/beansHasWidgetArea.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/integration/widget/beansHasWidgetArea.php b/tests/phpunit/integration/widget/beansHasWidgetArea.php index 3e3a7a67..5ca81e05 100644 --- a/tests/phpunit/integration/widget/beansHasWidgetArea.php +++ b/tests/phpunit/integration/widget/beansHasWidgetArea.php @@ -33,6 +33,17 @@ public function testShouldReturnFalseWhenWidgetAreaNotRegistered() { * Test beans_has_widget_area() should return true when widget area is registered. */ public function testShouldReturnTrueWhenWidgetAreaRegistered() { - $this->assertTrue( beans_has_widget_area( 'sidebar_primary' ) ); + global $wp_registered_sidebars; + + register_sidebar( array( + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ) ); + + // Confirm we have a test sidebar registered. + $this->assertTrue( isset( $wp_registered_sidebars['test_sidebar'] ) ); + + // Run test. + $this->assertTrue( beans_has_widget_area( 'test_sidebar' ) ); } } \ No newline at end of file From 6ec7de88e5c17151746effe62d123dcc6b4402a6 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Tue, 22 May 2018 14:06:38 -0400 Subject: [PATCH 636/800] Add tests beans_get_widget_area() --- .../integration/widget/beansGetWidgetArea.php | 71 +++++++++++++++++++ .../unit/api/widget/beansGetWidgetArea.php | 31 ++++++++ 2 files changed, 102 insertions(+) create mode 100644 tests/phpunit/integration/widget/beansGetWidgetArea.php create mode 100644 tests/phpunit/unit/api/widget/beansGetWidgetArea.php diff --git a/tests/phpunit/integration/widget/beansGetWidgetArea.php b/tests/phpunit/integration/widget/beansGetWidgetArea.php new file mode 100644 index 00000000..48679755 --- /dev/null +++ b/tests/phpunit/integration/widget/beansGetWidgetArea.php @@ -0,0 +1,71 @@ +assertFalse( beans_get_widget_area( 'bogus-needle' ) ); + $this->assertFalse( beans_get_widget_area() ); + } + + /** + * Test beans_get_widget_area() should return all widget area data when needle is not specified. + */ + public function test_should_return_all_data_when_needle_not_specified() { + global $_beans_widget_area; + + register_sidebar( array( 'id' => 'beans_test_sidebar', 'name' => 'Beans Test Sidebar') ); + _beans_setup_widget_area( 'beans_test_sidebar' ); + + $this->assertSame( $this->get_expected_sidebar_data(), beans_get_widget_area() ); + } + + /** + * Test beans_get_widget_area() should return specific widget data when a needle is specified. + */ + public function test_should_return_specific_widget_data_when_needle_specified() { + global $_beans_widget_area; + + register_sidebar( array( 'id' => 'beans_test_sidebar', 'name' => 'Beans Test Sidebar') ); + _beans_setup_widget_area( 'beans_test_sidebar' ); + + $this->assertEquals( 'beans_test_sidebar', beans_get_widget_area( 'id' ) ); + } + + protected function get_expected_sidebar_data() { + return array( + 'name' => 'Beans Test Sidebar', + 'id' => 'beans_test_sidebar', + 'description' => '', + 'class' => '', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '', + 'after_title' => '', + 'widgets_count' => 0, + 'current_widget' => 0, + ); + } +} \ No newline at end of file diff --git a/tests/phpunit/unit/api/widget/beansGetWidgetArea.php b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php new file mode 100644 index 00000000..98540990 --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php @@ -0,0 +1,31 @@ + Date: Tue, 22 May 2018 14:08:15 -0400 Subject: [PATCH 637/800] Fix beans_get_widget_area() return consistancy Was sometimes returning null rather than false. --- lib/api/widget/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index df43e2e4..cbede75e 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -182,16 +182,16 @@ function beans_get_widget_area_output( $id ) { * * @param string|bool $needle Optional. The searched widget area needle. * - * @return string The current widget area data, or field data if the needle is specified. False if not found. + * @return string|bool The current widget area data, or field data if the needle is specified. False if not found. */ function beans_get_widget_area( $needle = false ) { global $_beans_widget_area; if ( ! $needle ) { - return $_beans_widget_area; + return $_beans_widget_area ?: false; } - return beans_get( $needle, $_beans_widget_area ); + return beans_get( $needle, $_beans_widget_area, false ); } /** From bff3f1cd6f43dacb9d80061618c08f96a49a4081 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 24 May 2018 11:32:43 -0500 Subject: [PATCH 638/800] Renamed and commented tests to make intent more clear. The tests are checking that when a invalid file is given but it has a valid basename...Beans loads its internal structure. --- .../api/template/beansLoadDefaultTemplate.php | 25 +++++++++++++++---- .../api/template/beansLoadDefaultTemplate.php | 25 +++++++++++++++---- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php index 02acb30e..8932f9fb 100644 --- a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php @@ -32,19 +32,34 @@ public function test_should_return_false_when_template_does_not_exist() { } /** - * Test beans_load_default_template() should return true after loading the given structure. + * Test beans_load_default_template() should load the default structure when the given file does not exist, but its + * basename is a Beans' structure. */ - public function test_should_return_true_after_loading_structure() { - // Check with an invalid path to the structure. + public function test_should_load_default_structure_when_given_file_does_not_exist_but_basename_is_beans_structure() { + // Check with a relative invalid path. $file = '/path/to/structure/content.php'; + + // Check that the given file does not exist. + $this->assertFileNotExists( $file ); + + // Check that 'content.php' does exist in Beans. $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); + + // Check that it renders. ob_start(); $this->assertTrue( beans_load_default_template( $file ) ); $this->assertStringStartsWith( '
      assertFileNotExists( $file ); + + // Check that 'header.php' does exist in Beans. $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); + + // Check that it renders. ob_start(); $this->assertTrue( beans_load_default_template( $file ) ); $this->assertStringStartsWith( '', ob_get_clean() ); diff --git a/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php index 36993dff..635873be 100644 --- a/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php @@ -38,19 +38,34 @@ public function test_should_return_false_when_template_does_not_exist() { } /** - * Test beans_load_default_template() should return true after loading the given structure. + * Test beans_load_default_template() should load the default structure when the given file does not exist, but its + * basename is a Beans' structure. */ - public function test_should_return_true_after_loading_structure() { - // Check with an invalid path to the structure. + public function test_should_load_default_structure_when_given_file_does_not_exist_but_basename_is_beans_structure() { + // Check with a relative invalid path. $file = '/path/to/structure/content.php'; + + // Check that the given file does not exist. + $this->assertFileNotExists( $file ); + + // Check that 'content.php' does exist in Beans. $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); + + // Check that it renders. ob_start(); $this->assertTrue( beans_load_default_template( $file ) ); $this->assertSame( $this->mock_filesystem->getChild( 'structure/content.php' )->getContent(), ob_get_clean() ); - // Check with an absolute path to the structure. - $file = __DIR__ . 'fixtures/structure/header.php'; + // Check with an invalid absolute path. + $file = __DIR__ . '/fixtures/structure/header.php'; + + // Check that the given file does not exist. + $this->assertFileNotExists( $file ); + + // Check that 'header.php' does exist in Beans. $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); + + // Check that it renders. ob_start(); $this->assertTrue( beans_load_default_template( $file ) ); $this->assertSame( $this->mock_filesystem->getChild( 'structure/header.php' )->getContent(), ob_get_clean() ); From c9ca1faf733cd49230b64ac12898502a534d539c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 24 May 2018 12:18:31 -0500 Subject: [PATCH 639/800] Mock non-essential functions for test. Mock the do_action() and wp_head() as neither of these are important for the integration test. --- .../api/template/beansLoadDefaultTemplate.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php index 8932f9fb..b1dd6a9d 100644 --- a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Integration\API\Template; use Beans\Framework\Tests\Integration\Test_Case; +use Brain\Monkey; /** * Class Tests_BeansLoadDefaultTemplate @@ -46,9 +47,16 @@ public function test_should_load_default_structure_when_given_file_does_not_exis $this->assertFileExists( BEANS_STRUCTURE_PATH . basename( $file ) ); // Check that it renders. + $this->go_to( '/' ); + Monkey\Functions\expect( 'do_action' )->once()->with( 'beans_content' )->andReturn(); ob_start(); $this->assertTrue( beans_load_default_template( $file ) ); - $this->assertStringStartsWith( '
      +EOB; + $this->assertStringStartsWith( $expected, trim( $html ) ); // Check with an invalid absolute path. $file = __DIR__ . '/fixtures/structure/header.php'; @@ -61,6 +69,8 @@ public function test_should_load_default_structure_when_given_file_does_not_exis // Check that it renders. ob_start(); + Monkey\Functions\expect( 'do_action' )->with( 'beans_head' )->andReturn(); + Monkey\Functions\expect( 'wp_head' )->andReturn(); $this->assertTrue( beans_load_default_template( $file ) ); $this->assertStringStartsWith( '', ob_get_clean() ); } From e92d4a090c760050ae7f64843613220eec0aad2f Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Sat, 26 May 2018 17:01:32 -0400 Subject: [PATCH 640/800] Add test widget and sidebar setup --- .../integration/widget/beansHaveWidgets.php | 45 +++++++++++++++++++ .../includes/class-beans-widget-test-case.php | 34 ++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/phpunit/integration/widget/beansHaveWidgets.php diff --git a/tests/phpunit/integration/widget/beansHaveWidgets.php b/tests/phpunit/integration/widget/beansHaveWidgets.php new file mode 100644 index 00000000..9d402587 --- /dev/null +++ b/tests/phpunit/integration/widget/beansHaveWidgets.php @@ -0,0 +1,45 @@ + 'test_sidebar', 'name' => 'Test Sidebar' ) ); + $this->add_test_widget_to_test_sidebar(); + + // Run the beans widget area setup + _beans_setup_widget_area( 'test_sidebar' ); + + // Run the test. + $this->assertTrue( beans_have_widgets() ); + } + +// public function test_should_return_false_when_widgets_gone() { +// +// } +} \ No newline at end of file diff --git a/tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php index 2c0c8dbf..99cc5fb6 100644 --- a/tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php +++ b/tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php @@ -27,4 +27,38 @@ public function tearDown() { parent::tearDown(); } + + /** + * Register a test widget into a test sidebar. + */ + protected function add_test_widget_to_test_sidebar() { + global $wp_registered_widgets; + + $widgetObject = new \WP_Widget_Text(); + $widgetObject->id = 'text-2'; + $widgetObject->name = 'Test Widget'; + $widgetObject->widget_options['text'] = 'Test Text Content'; + $widgetObject->widget_options['name'] = 'Test Sidebar'; + $widgetObject->widget_options['id'] = 'test_sidebar'; + + $wp_registered_widgets[ $widgetObject->id ] = array( + 'name' => $widgetObject->name, + 'id' => $widgetObject->id, + 'callback' => array( $widgetObject, 'widget' ), + 'params' => array( $widgetObject->widget_options ), + 'classname' => $widgetObject->widget_options['classname'] + ); + + add_filter( 'sidebars_widgets', array( $this, 'add_a_widget' ) ); + } + + /** + * Callback to add test widget via 'sidebars_widgets' filter. + */ + public function add_a_widget( $sidebars_widgets ) { + $sidebars_widgets['test_sidebar'] = array( 0 => 'text-2' ); + + return $sidebars_widgets; + } + } From 03d174500618c767963702e147f5cd2a4b002bea Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Sun, 27 May 2018 14:14:45 -0400 Subject: [PATCH 641/800] Add test for beans_have_widgets() when false --- .../integration/widget/beansHaveWidgets.php | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/integration/widget/beansHaveWidgets.php b/tests/phpunit/integration/widget/beansHaveWidgets.php index 9d402587..76551fff 100644 --- a/tests/phpunit/integration/widget/beansHaveWidgets.php +++ b/tests/phpunit/integration/widget/beansHaveWidgets.php @@ -26,20 +26,32 @@ class Tests_BeansHaveWidgets extends Beans_Widget_Test_Case { * Test beans_have_widget() should return true when more widgets are available. */ public function test_should_return_true_when_widgets_available() { - global $wp_registered_widgets, $sidebars_widgets; - // Add a test sidebar with a test widget. - beans_register_widget_area( array( 'id' => 'test_sidebar', 'name' => 'Test Sidebar' ) ); + beans_register_widget_area( + array( + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar' + ) ); $this->add_test_widget_to_test_sidebar(); - // Run the beans widget area setup + // Run the beans widget area setup. _beans_setup_widget_area( 'test_sidebar' ); // Run the test. $this->assertTrue( beans_have_widgets() ); } -// public function test_should_return_false_when_widgets_gone() { -// -// } + public function test_should_return_false_when_widgets_gone() { + // Add a test sidebar with no widgets. + beans_register_widget_area( + array( + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar' ) ); + + // Run the beans widget area setup. + _beans_setup_widget_area( 'test_sidebar' ); + + // Run the test. + $this->assertFalse( beans_have_widgets() ); + } } \ No newline at end of file From fad31fcbd183f9dac140f6a9a836d1ab092449e4 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Sun, 27 May 2018 14:29:46 -0400 Subject: [PATCH 642/800] Fix int test for beans_get_widget_area_output() --- .../widget/beansGetWidgetAreaOutput.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php index a87ccd81..821db78f 100644 --- a/tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php +++ b/tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php @@ -33,7 +33,17 @@ public function test_should_return_false_when_widget_area_not_registered() { * Test beans_get_widget_area_output() should return output when a widget area is registered. */ public function test_should_return_widget_output_when_widget_area_is_registered() { - $this->assertEquals( $this->get_expected_output(), beans_get_widget_area_output( 'sidebar_primary' ) ); + global $wp_registered_sidebars; + + beans_register_widget_area( array( + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ) ); + $this->add_test_widget_to_test_sidebar(); + $this->assertSame( + $this->format_the_html( $this->get_expected_output() ), + $this->format_the_html( beans_get_widget_area_output( 'test_sidebar' ) ) + ); } /** @@ -41,16 +51,7 @@ public function test_should_return_widget_output_when_widget_area_is_registered( */ protected function get_expected_output() { return <<

      Recent Comments

        Archives

          -
        -

        Categories

          -
        • No categories
        -
        +
        OUTPUT; } } From fb6d61c9c26aa6d04c351f5a0a92afa99b5bdcfc Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Sun, 27 May 2018 14:32:17 -0400 Subject: [PATCH 643/800] Fix in test for beans_get_widget_area() --- .../integration/widget/beansGetWidgetArea.php | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/integration/widget/beansGetWidgetArea.php b/tests/phpunit/integration/widget/beansGetWidgetArea.php index 48679755..d971decb 100644 --- a/tests/phpunit/integration/widget/beansGetWidgetArea.php +++ b/tests/phpunit/integration/widget/beansGetWidgetArea.php @@ -26,7 +26,10 @@ class Tests_BeansGetWidgetArea extends Beans_Widget_Test_Case { * Test beans_get_widget_area() should return false when widget area data is not found. */ public function test_should_return_false_when_widget_area_data_not_found() { + // Test for when needle is given. $this->assertFalse( beans_get_widget_area( 'bogus-needle' ) ); + + // Test for when needle is not given. $this->assertFalse( beans_get_widget_area() ); } @@ -34,10 +37,8 @@ public function test_should_return_false_when_widget_area_data_not_found() { * Test beans_get_widget_area() should return all widget area data when needle is not specified. */ public function test_should_return_all_data_when_needle_not_specified() { - global $_beans_widget_area; - - register_sidebar( array( 'id' => 'beans_test_sidebar', 'name' => 'Beans Test Sidebar') ); - _beans_setup_widget_area( 'beans_test_sidebar' ); + register_sidebar( array( 'id' => 'test_sidebar', 'name' => 'Test Sidebar') ); + _beans_setup_widget_area( 'test_sidebar' ); $this->assertSame( $this->get_expected_sidebar_data(), beans_get_widget_area() ); } @@ -46,18 +47,19 @@ public function test_should_return_all_data_when_needle_not_specified() { * Test beans_get_widget_area() should return specific widget data when a needle is specified. */ public function test_should_return_specific_widget_data_when_needle_specified() { - global $_beans_widget_area; - - register_sidebar( array( 'id' => 'beans_test_sidebar', 'name' => 'Beans Test Sidebar') ); - _beans_setup_widget_area( 'beans_test_sidebar' ); + register_sidebar( array( 'id' => 'test_sidebar', 'name' => 'Test Sidebar') ); + _beans_setup_widget_area( 'test_sidebar' ); - $this->assertEquals( 'beans_test_sidebar', beans_get_widget_area( 'id' ) ); + $this->assertEquals( 'test_sidebar', beans_get_widget_area( 'id' ) ); } + /** + * Return an array of expected sidebar data. + */ protected function get_expected_sidebar_data() { return array( - 'name' => 'Beans Test Sidebar', - 'id' => 'beans_test_sidebar', + 'name' => 'Test Sidebar', + 'id' => 'test_sidebar', 'description' => '', 'class' => '', 'before_widget' => '', From ca4861ec2ac1fb19e0402b9ddbb5e2116eb631e4 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Sun, 27 May 2018 14:33:56 -0400 Subject: [PATCH 644/800] Move widget API integration test to correct dir --- .../integration/{ => api}/widget/beansDeregisterWidgetArea.php | 0 tests/phpunit/integration/{ => api}/widget/beansGetWidgetArea.php | 0 .../integration/{ => api}/widget/beansGetWidgetAreaOutput.php | 0 tests/phpunit/integration/{ => api}/widget/beansHasWidgetArea.php | 0 tests/phpunit/integration/{ => api}/widget/beansHaveWidgets.php | 0 .../integration/{ => api}/widget/beansIsActiveWidgetArea.php | 0 .../integration/{ => api}/widget/beansRegisterWidgetArea.php | 0 .../{ => api}/widget/includes/class-beans-widget-test-case.php | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename tests/phpunit/integration/{ => api}/widget/beansDeregisterWidgetArea.php (100%) rename tests/phpunit/integration/{ => api}/widget/beansGetWidgetArea.php (100%) rename tests/phpunit/integration/{ => api}/widget/beansGetWidgetAreaOutput.php (100%) rename tests/phpunit/integration/{ => api}/widget/beansHasWidgetArea.php (100%) rename tests/phpunit/integration/{ => api}/widget/beansHaveWidgets.php (100%) rename tests/phpunit/integration/{ => api}/widget/beansIsActiveWidgetArea.php (100%) rename tests/phpunit/integration/{ => api}/widget/beansRegisterWidgetArea.php (100%) rename tests/phpunit/integration/{ => api}/widget/includes/class-beans-widget-test-case.php (100%) diff --git a/tests/phpunit/integration/widget/beansDeregisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php similarity index 100% rename from tests/phpunit/integration/widget/beansDeregisterWidgetArea.php rename to tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php diff --git a/tests/phpunit/integration/widget/beansGetWidgetArea.php b/tests/phpunit/integration/api/widget/beansGetWidgetArea.php similarity index 100% rename from tests/phpunit/integration/widget/beansGetWidgetArea.php rename to tests/phpunit/integration/api/widget/beansGetWidgetArea.php diff --git a/tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php similarity index 100% rename from tests/phpunit/integration/widget/beansGetWidgetAreaOutput.php rename to tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php diff --git a/tests/phpunit/integration/widget/beansHasWidgetArea.php b/tests/phpunit/integration/api/widget/beansHasWidgetArea.php similarity index 100% rename from tests/phpunit/integration/widget/beansHasWidgetArea.php rename to tests/phpunit/integration/api/widget/beansHasWidgetArea.php diff --git a/tests/phpunit/integration/widget/beansHaveWidgets.php b/tests/phpunit/integration/api/widget/beansHaveWidgets.php similarity index 100% rename from tests/phpunit/integration/widget/beansHaveWidgets.php rename to tests/phpunit/integration/api/widget/beansHaveWidgets.php diff --git a/tests/phpunit/integration/widget/beansIsActiveWidgetArea.php b/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php similarity index 100% rename from tests/phpunit/integration/widget/beansIsActiveWidgetArea.php rename to tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php diff --git a/tests/phpunit/integration/widget/beansRegisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php similarity index 100% rename from tests/phpunit/integration/widget/beansRegisterWidgetArea.php rename to tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php diff --git a/tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php similarity index 100% rename from tests/phpunit/integration/widget/includes/class-beans-widget-test-case.php rename to tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php From 9085d92d60ac7441e47e31a3b9380f40c03393b8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 28 May 2018 10:13:11 -0500 Subject: [PATCH 645/800] Renamed class to compile with WPCS. --- lib/api/components.php | 2 +- lib/api/uikit/{class.php => class-beans-uikit.php} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/api/uikit/{class.php => class-beans-uikit.php} (100%) diff --git a/lib/api/components.php b/lib/api/components.php index b0b0eccb..8bb06808 100644 --- a/lib/api/components.php +++ b/lib/api/components.php @@ -47,7 +47,7 @@ function beans_load_api_components( $components ) { ), 'uikit' => array( $root . 'uikit/functions.php', - $root . 'uikit/class.php', + $root . 'uikit/class-beans-uikit.php', ), 'layout' => $root . 'layout/functions.php', 'template' => $root . 'template/functions.php', diff --git a/lib/api/uikit/class.php b/lib/api/uikit/class-beans-uikit.php similarity index 100% rename from lib/api/uikit/class.php rename to lib/api/uikit/class-beans-uikit.php From 445fb38699bf6b2686673eaea25cc7fc21ef50a3 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Mon, 28 May 2018 15:58:34 -0400 Subject: [PATCH 646/800] Add integration tests for 3 functions beans_setup_widget() beans_widget_area_shortcodes() _beans_setup_widget() --- .../api/widget/_beansSetupWidget.php | 25 ++++++++ .../api/widget/beansSetupWidget.php | 60 +++++++++++++++++++ .../api/widget/beansWidgetAreaShortcodes.php | 47 +++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 tests/phpunit/integration/api/widget/_beansSetupWidget.php create mode 100644 tests/phpunit/integration/api/widget/beansSetupWidget.php create mode 100644 tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php diff --git a/tests/phpunit/integration/api/widget/_beansSetupWidget.php b/tests/phpunit/integration/api/widget/_beansSetupWidget.php new file mode 100644 index 00000000..f6643d6c --- /dev/null +++ b/tests/phpunit/integration/api/widget/_beansSetupWidget.php @@ -0,0 +1,25 @@ + 'test_sidebar' ) ); + $this->add_test_widget_to_test_sidebar(); + + _beans_setup_widget_area( 'test_sidebar' ); + + // Advance the widget counter to a non-existent widget. + $_beans_widget_area['current_widget'] = 1; + $this->assertFalse( beans_setup_widget() ); + } + + /** + * Test beans_setup_widget() should return advance widget pointer and true when a widget ID is found. + */ + public function test_should_return_advance_widget_pointer_and_return_true_when_widget_id_is_found() { + global $_beans_widget_area; + + beans_register_widget_area( array( 'id' => 'test_sidebar' ) ); + $this->add_test_widget_to_test_sidebar(); + _beans_setup_widget_area( 'test_sidebar' ); + + // Check widget pointer is at 0. + $this->assertEquals( 0, $_beans_widget_area['current_widget'] ); + + // Run test. + $this->assertTrue( beans_setup_widget() ); + + // Verify widget pointer has advanced to 1. + $this->assertEquals( 1, $_beans_widget_area['current_widget'] ); + } +} diff --git a/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php b/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php new file mode 100644 index 00000000..488ec65d --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php @@ -0,0 +1,47 @@ +assertEquals( + 'Content with a shortcode value.', + beans_widget_area_shortcodes( 'Content with a {key}.' ) + ); + + // Run test for content as an array. + $this->assertEquals( + 'someURLparemetername=URL content with a shortcode value.', + beans_widget_area_shortcodes( + array( 'someURLparemetername' => 'URL content with a {key}.' ) + ) + ); + } +} From a22d4b98f5c871f22357136de963f524863668bc Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Mon, 28 May 2018 15:58:52 -0400 Subject: [PATCH 647/800] Improve test format for WPCS --- lib/api/widget/functions.php | 4 +-- .../api/widget/beansDeregisterWidgetArea.php | 5 ++- .../api/widget/beansGetWidgetArea.php | 14 ++++++--- .../api/widget/beansHasWidgetArea.php | 2 +- .../api/widget/beansHaveWidgets.php | 20 +++++++----- .../api/widget/beansIsActiveWidgetArea.php | 4 +-- .../api/widget/beansRegisterWidgetArea.php | 7 +++-- .../includes/class-beans-widget-test-case.php | 31 +++++++++++-------- .../unit/api/widget/beansGetWidgetArea.php | 9 +++--- .../api/widget/beansRegisterWidgetArea.php | 11 +++++-- 10 files changed, 68 insertions(+), 39 deletions(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index cbede75e..b3482d6e 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -188,7 +188,7 @@ function beans_get_widget_area( $needle = false ) { global $_beans_widget_area; if ( ! $needle ) { - return $_beans_widget_area ?: false; + return $_beans_widget_area ? $_beans_widget_area : false; } return beans_get( $needle, $_beans_widget_area, false ); @@ -202,7 +202,7 @@ function beans_get_widget_area( $needle = false ) { * * @since 1.0.0 * - * @param string $content Content containing the shortcode(s) delimited with curly brackets (e.g. {key}). + * @param string|array $content Content containing the shortcode(s) delimited with curly brackets (e.g. {key}). * Shortcode(s) correspond to the searched array key and will be replaced by the array * value if found. * diff --git a/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php index ddc31e12..72f00805 100644 --- a/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php @@ -22,6 +22,9 @@ */ class Tests_BeansDeregisterWidgetArea extends Beans_Widget_Test_Case { + /** + * Test beans_deregister_widget_area should unregister a sidebar. + */ public function test_should_unregister_sidebar() { global $wp_registered_sidebars; @@ -33,4 +36,4 @@ public function test_should_unregister_sidebar() { $this->assertFalse( isset( $wp_registered_sidebars['unwanted-sidebar'] ) ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/integration/api/widget/beansGetWidgetArea.php b/tests/phpunit/integration/api/widget/beansGetWidgetArea.php index d971decb..473dd9fe 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansGetWidgetArea.php @@ -14,7 +14,7 @@ require_once dirname( __FILE__ ) . '/includes/class-beans-widget-test-case.php'; /** - * Class Tests_BeansGeteWidgetArea + * Class Tests_BeansGetWidgetArea * * @package Beans\Framework\Tests\Integration\API\Widget * @group api @@ -37,7 +37,10 @@ public function test_should_return_false_when_widget_area_data_not_found() { * Test beans_get_widget_area() should return all widget area data when needle is not specified. */ public function test_should_return_all_data_when_needle_not_specified() { - register_sidebar( array( 'id' => 'test_sidebar', 'name' => 'Test Sidebar') ); + register_sidebar( array( + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ) ); _beans_setup_widget_area( 'test_sidebar' ); $this->assertSame( $this->get_expected_sidebar_data(), beans_get_widget_area() ); @@ -47,7 +50,10 @@ public function test_should_return_all_data_when_needle_not_specified() { * Test beans_get_widget_area() should return specific widget data when a needle is specified. */ public function test_should_return_specific_widget_data_when_needle_specified() { - register_sidebar( array( 'id' => 'test_sidebar', 'name' => 'Test Sidebar') ); + register_sidebar( array( + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ) ); _beans_setup_widget_area( 'test_sidebar' ); $this->assertEquals( 'test_sidebar', beans_get_widget_area( 'id' ) ); @@ -70,4 +76,4 @@ protected function get_expected_sidebar_data() { 'current_widget' => 0, ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/integration/api/widget/beansHasWidgetArea.php b/tests/phpunit/integration/api/widget/beansHasWidgetArea.php index 5ca81e05..b99578a0 100644 --- a/tests/phpunit/integration/api/widget/beansHasWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansHasWidgetArea.php @@ -46,4 +46,4 @@ public function testShouldReturnTrueWhenWidgetAreaRegistered() { // Run test. $this->assertTrue( beans_has_widget_area( 'test_sidebar' ) ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/integration/api/widget/beansHaveWidgets.php b/tests/phpunit/integration/api/widget/beansHaveWidgets.php index 76551fff..4b298a29 100644 --- a/tests/phpunit/integration/api/widget/beansHaveWidgets.php +++ b/tests/phpunit/integration/api/widget/beansHaveWidgets.php @@ -14,7 +14,7 @@ require_once dirname( __FILE__ ) . '/includes/class-beans-widget-test-case.php'; /** - * Class Tests_BeansGeteWidgetArea + * Class Tests_BeansHaveWidgetArea * * @package Beans\Framework\Tests\Integration\API\Widget * @group api @@ -30,8 +30,9 @@ public function test_should_return_true_when_widgets_available() { beans_register_widget_area( array( 'id' => 'test_sidebar', - 'name' => 'Test Sidebar' - ) ); + 'name' => 'Test Sidebar', + ) + ); $this->add_test_widget_to_test_sidebar(); // Run the beans widget area setup. @@ -41,12 +42,17 @@ public function test_should_return_true_when_widgets_available() { $this->assertTrue( beans_have_widgets() ); } - public function test_should_return_false_when_widgets_gone() { + /** + * Test beans_have_widget() should return false when no widgets are available. + */ + public function test_should_return_false_when_no_widgets_are_available() { // Add a test sidebar with no widgets. beans_register_widget_area( array( - 'id' => 'test_sidebar', - 'name' => 'Test Sidebar' ) ); + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ) + ); // Run the beans widget area setup. _beans_setup_widget_area( 'test_sidebar' ); @@ -54,4 +60,4 @@ public function test_should_return_false_when_widgets_gone() { // Run the test. $this->assertFalse( beans_have_widgets() ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php b/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php index ab8c46ef..f798aea4 100644 --- a/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php @@ -36,11 +36,11 @@ public function testShouldReturnTrueWhenWidgetAreaIsActive() { global $_wp_sidebars_widgets; // Clear global widget areas registry so we can start clean. - $_wp_sidebars_widgets = []; + $_wp_sidebars_widgets = []; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: we need test to start with clean sidebars_widgets. // Prime the WP database with an active sidebar. update_option( 'sidebars_widgets', array( 'an-active-sidebar' => array( 'text-2' ) ) ); $this->assertTrue( beans_is_active_widget_area( 'an-active-sidebar' ) ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php index 6ab97045..9716cf13 100644 --- a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php @@ -43,10 +43,11 @@ public function test_should_return_widget_area_ID_when_widget_area_registered() beans_register_widget_area( array( 'id' => 'new-widget-area', 'beans_type' => 'grid', - ) ) ); + ) ) + ); // Confirm that the sidebar is now in the WP global sidebar array. $this->assertTrue( isset( $wp_registered_sidebars['new-widget-area'] ) ); - $this->assertContains( 'grid', $wp_registered_sidebars['new-widget-area']); + $this->assertContains( 'grid', $wp_registered_sidebars['new-widget-area'] ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php index 99cc5fb6..aa21c310 100644 --- a/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php +++ b/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php @@ -34,31 +34,36 @@ public function tearDown() { protected function add_test_widget_to_test_sidebar() { global $wp_registered_widgets; - $widgetObject = new \WP_Widget_Text(); - $widgetObject->id = 'text-2'; - $widgetObject->name = 'Test Widget'; - $widgetObject->widget_options['text'] = 'Test Text Content'; - $widgetObject->widget_options['name'] = 'Test Sidebar'; - $widgetObject->widget_options['id'] = 'test_sidebar'; + $widget_object = new \WP_Widget_Text(); + $widget_object->id = 'text-2'; + $widget_object->name = 'Test Widget'; + $widget_object->widget_options['text'] = 'Test Text Content'; + $widget_object->widget_options['name'] = 'Test Sidebar'; + $widget_object->widget_options['id'] = 'test_sidebar'; - $wp_registered_widgets[ $widgetObject->id ] = array( - 'name' => $widgetObject->name, - 'id' => $widgetObject->id, - 'callback' => array( $widgetObject, 'widget' ), - 'params' => array( $widgetObject->widget_options ), - 'classname' => $widgetObject->widget_options['classname'] + $widget_registration_args = array( + 'name' => $widget_object->name, + 'id' => $widget_object->id, + 'callback' => array( $widget_object, 'widget' ), + 'params' => array( $widget_object->widget_options ), + 'classname' => $widget_object->widget_options['classname'], ); + $wp_registered_widgets[ $widget_object->id ] = $widget_registration_args; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: we need to explicitly set the widget registration for widget API tests. + add_filter( 'sidebars_widgets', array( $this, 'add_a_widget' ) ); } /** * Callback to add test widget via 'sidebars_widgets' filter. + * + * @param array $sidebars_widgets The WP sidebars_widgets array. + * + * @return array Modified sidebars_widgets. */ public function add_a_widget( $sidebars_widgets ) { $sidebars_widgets['test_sidebar'] = array( 0 => 'text-2' ); return $sidebars_widgets; } - } diff --git a/tests/phpunit/unit/api/widget/beansGetWidgetArea.php b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php index 98540990..fb6de8b4 100644 --- a/tests/phpunit/unit/api/widget/beansGetWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php @@ -23,9 +23,10 @@ */ class Tests_BeansGetWidgetArea extends Beans_Widget_Test_Case { - public function test_should_return_widget_area_data_when_needle_unspecified() { + /** + * Test beans_get_widget_area() should return all widget area data when the needle is unspecified. + */ + public function test_should_return_all_widget_area_data_when_needle_unspecified() { global $_beans_widget_area; - - } -} \ No newline at end of file +} diff --git a/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php index 2aea2fe4..e67edcae 100644 --- a/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php @@ -40,7 +40,13 @@ public function test_should_return_empty_string_when_ID_not_set() { */ public function test_should_return_widget_area_ID_when_widget_area_registered() { Monkey\Functions\expect( 'beans_get' ) - ->once()->with( 'id', array( 'id' => 'new-widget-area', 'beans_type' => 'grid', ) ) + ->once()->with( + 'id', + array( + 'id' => 'new-widget-area', + 'beans_type' => 'grid', + ) + ) ->andReturn( 'new-widget-area' ); Monkey\Functions\expect( 'beans_apply_filters' ) @@ -58,7 +64,8 @@ public function test_should_return_widget_area_ID_when_widget_area_registered() beans_register_widget_area( array( 'id' => 'new-widget-area', 'beans_type' => 'grid', - ) ) ); + ) ) + ); } /** From b24fdfeadb642d7b311a9109c118473c26c56524 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 28 May 2018 19:38:12 -0500 Subject: [PATCH 648/800] Added _Beans_Uikit::get_components_from_directory() unit tests. --- lib/api/uikit/class-beans-uikit.php | 14 +- .../getComponentsFromDirectory.php | 224 ++++++++++++++++++ .../uikit/includes/class-uikit-test-case.php | 133 +++++++++++ 3 files changed, 365 insertions(+), 6 deletions(-) create mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getComponentsFromDirectory.php create mode 100644 tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 460629f8..26778e13 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -4,7 +4,7 @@ * * @package Beans\Framework\API\UIkit * - * @since 1.0.0 + * @since 1.0.0 */ /** @@ -197,21 +197,20 @@ public function get_js_directories( $type ) { * * @since 1.0.0 * - * @param array $components Array of UIkit Components. + * @param array $components Array of UIkit Components. * @param array $directories Array of directories containing the UIkit Components. - * @param string $format File format. + * @param string $format File format. * * @return array */ public function get_components_from_directory( $components, $directories, $format ) { - $extension = 'styles' === $format ? 'less' : 'min.js'; $return = array(); foreach ( $components as $component ) { - // Fectch components from all directories set. + // Fetch the components from all directories set. foreach ( $directories as $directory ) { $file = trailingslashit( $directory ) . $component . '.' . $extension; @@ -252,7 +251,10 @@ public function get_all_components( $type ) { unset( $scandir[0], $scandir[1] ); // Only return the filname and remove empty elements. - $components = array_merge( $components, array_filter( array_map( array( $this, 'to_filename' ), $scandir ) ) ); + $components = array_merge( $components, array_filter( array_map( array( + $this, + 'to_filename', + ), $scandir ) ) ); } return $components; diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getComponentsFromDirectory.php b/tests/phpunit/unit/api/uikit/beans-uikit/getComponentsFromDirectory.php new file mode 100644 index 00000000..52d7ab82 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getComponentsFromDirectory.php @@ -0,0 +1,224 @@ +get_components_from_directory( + [ 'foo', 'bar', 'baz' ], + [ BEANS_API_PATH . 'uikit/src/less/core' ], + 'styles' + ); + $this->assertEmpty( $actual ); + + // Check for scripts. + $actual = $beans_uikit->get_components_from_directory( + [ 'foo', 'bar', 'baz' ], + [ BEANS_API_PATH . 'uikit/src/js/core' ], + 'scripts' + ); + $this->assertEmpty( $actual ); + } + + /** + * Test _Beans_Uikit::get_components_from_directory() should return an empty array when no components are requested. + */ + public function test_should_return_empty_array_when_no_components_requested() { + $beans_uikit = new _Beans_Uikit(); + + // Check for styles. + $actual = $beans_uikit->get_components_from_directory( + [], + [ BEANS_API_PATH . 'uikit/src/less/core' ], + 'styles' + ); + $this->assertEmpty( $actual ); + + // Check for scripts. + $actual = $beans_uikit->get_components_from_directory( + [], + [ BEANS_API_PATH . 'uikit/src/js/core' ], + 'scripts' + ); + $this->assertEmpty( $actual ); + } + + /** + * Test _Beans_Uikit::get_components_from_directory() should return an array of LESS files when the component + * exists in core. + */ + public function test_should_return_array_of_less_files_when_component_exists_in_core() { + $beans_uikit = new _Beans_Uikit(); + $actual = $beans_uikit->get_components_from_directory( + [ 'variables', 'badge', 'panel', 'doesnotexist', 'alert' ], + [ BEANS_API_PATH . 'uikit/src/less/core' ], + 'styles' + ); + $expected = [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_API_PATH . 'uikit/src/less/core/badge.less', + BEANS_API_PATH . 'uikit/src/less/core/panel.less', + BEANS_API_PATH . 'uikit/src/less/core/alert.less', + ]; + $this->assertSame( $expected, $actual ); + } + + /** + * Test _Beans_Uikit::get_components_from_directory() should return an array of LESS files when the component + * exists in the child theme. + */ + public function test_should_return_array_of_less_files_when_component_exists_in_child_theme() { + $child_theme = vfsStream::url( 'themes/beans-child/assets/less/theme' ); + $beans_uikit = new _Beans_Uikit(); + $actual = $beans_uikit->get_components_from_directory( + [ 'variables', 'badge', 'panel', 'doesnotexist', 'alert' ], + [ $child_theme ], + 'styles' + ); + $expected = [ + $child_theme . '/variables.less', + $child_theme . '/panel.less', + $child_theme . '/alert.less', + ]; + $this->assertSame( $expected, $actual ); + } + + /** + * Test _Beans_Uikit::get_components_from_directory() should return an array of LESS files when the component + * exists in the assets overwrite. + */ + public function test_should_return_array_of_less_files_when_component_exists_in_asset_overwrite() { + $beans_uikit = new _Beans_Uikit(); + $actual = $beans_uikit->get_components_from_directory( + [ 'variables', 'badge', 'panel', 'doesnotexist', 'alert' ], + [ BEANS_THEME_DIR . 'lib/assets/less/uikit-overwrite' ], + 'styles' + ); + $expected = [ + BEANS_THEME_DIR . 'lib/assets/less/uikit-overwrite/variables.less', + BEANS_THEME_DIR . 'lib/assets/less/uikit-overwrite/panel.less', + ]; + $this->assertSame( $expected, $actual ); + } + + /** + * Test _Beans_Uikit::get_components_from_directory() should return an array of LESS files when the component + * exists in the given directories. + */ + public function test_should_return_array_of_less_files_when_components_exist_in_given_directories() { + $child_theme = vfsStream::url( 'themes/beans-child/assets/less/theme' ); + $beans_uikit = new _Beans_Uikit(); + $actual = $beans_uikit->get_components_from_directory( + [ 'variables', 'badge', 'panel', 'doesnotexist', 'alert' ], + [ + BEANS_API_PATH . 'uikit/src/less/core', + BEANS_THEME_DIR . 'lib/assets/less/uikit-overwrite', + $child_theme, + ], + 'styles' + ); + $expected = [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_THEME_DIR . 'lib/assets/less/uikit-overwrite/variables.less', + $child_theme . '/variables.less', + BEANS_API_PATH . 'uikit/src/less/core/badge.less', + BEANS_API_PATH . 'uikit/src/less/core/panel.less', + BEANS_THEME_DIR . 'lib/assets/less/uikit-overwrite/panel.less', + $child_theme . '/panel.less', + BEANS_API_PATH . 'uikit/src/less/core/alert.less', + $child_theme . '/alert.less', + ]; + $this->assertSame( $expected, $actual ); + } + + /** + * Test _Beans_Uikit::get_components_from_directory() should return an array of JavaScript files when the component + * exists in core. + */ + public function test_should_return_array_of_js_files_when_component_exists_in_core() { + $beans_uikit = new _Beans_Uikit(); + $actual = $beans_uikit->get_components_from_directory( + [ 'core', 'offcanvas', 'alert', 'doesnotexist', 'button' ], + [ BEANS_API_PATH . 'uikit/src/js/core' ], + 'scripts' + ); + $expected = [ + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/offcanvas.min.js', + BEANS_API_PATH . 'uikit/src/js/core/alert.min.js', + BEANS_API_PATH . 'uikit/src/js/core/button.min.js', + ]; + $this->assertSame( $expected, $actual ); + } + + /** + * Test _Beans_Uikit::get_components_from_directory() should return an array of JavaScript files when the component + * exists in child theme. + */ + public function test_should_return_array_of_js_files_when_component_exists_in_child_theme() { + $child_theme = vfsStream::url( 'themes/beans-child/assets/js' ); + $beans_uikit = new _Beans_Uikit(); + $actual = $beans_uikit->get_components_from_directory( + [ 'core', 'offcanvas', 'alert', 'doesnotexist', 'button' ], + [ $child_theme ], + 'scripts' + ); + $expected = [ + $child_theme . '/alert.min.js', + ]; + $this->assertSame( $expected, $actual ); + } + + /** + * Test _Beans_Uikit::get_components_from_directory() should return an array of JavaScript files when the component + * exists in the given directories. + */ + public function test_should_return_array_of_js_files_when_components_exist_in_given_directories() { + $child_theme = vfsStream::url( 'themes/beans-child/assets/js' ); + $beans_uikit = new _Beans_Uikit(); + $actual = $beans_uikit->get_components_from_directory( + [ 'core', 'offcanvas', 'alert', 'doesnotexist', 'button' ], + [ + BEANS_API_PATH . 'uikit/src/js/core', + $child_theme, + ], + 'scripts' + ); + $expected = [ + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/offcanvas.min.js', + BEANS_API_PATH . 'uikit/src/js/core/alert.min.js', + $child_theme . '/alert.min.js', + BEANS_API_PATH . 'uikit/src/js/core/button.min.js', + ]; + $this->assertSame( $expected, $actual ); + } +} diff --git a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php new file mode 100644 index 00000000..2b6a535b --- /dev/null +++ b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php @@ -0,0 +1,133 @@ +set_up_virtual_filesystem(); + $this->set_up_mocked_functions(); + + $this->load_original_functions( array( + 'api/utilities/functions.php', + 'api/compiler/functions.php', + 'api/uikit/functions.php', + 'api/uikit/class-beans-uikit.php', + ) ); + + $this->reset_globals(); + } + + /** + * Set up the virtual filesystem. + */ + protected function set_up_virtual_filesystem() { + $this->mock_filesystem = vfsStream::setup( + 'themes', + 0755, + $this->get_virtual_structure() + ); + } + + /** + * Get the virtual filesystem's structure. + */ + protected function get_virtual_structure() { + return [ + 'beans-child' => [ + 'assets' => [ + 'js' => [ + 'alert.min.js' => '', + ], + 'less' => [ + 'theme' => [ + 'alert.less' => '', + 'article.less' => '', + 'panel.less' => '', + 'variables.less' => '', + 'style.less' => '', + 'variables.less' => '', + ], + ], + ], + 'functions.php' => '', + 'style.css' => '', + ], + ]; + } + + /** + * Sets up the mocked functions. + */ + protected function set_up_mocked_functions() { + Monkey\Functions\when( 'trailingslashit' )->alias( function( $file ) { + return $file . '/'; + } ); + } + + /** + * Reset the global containers. + */ + protected function reset_globals() { + global $_beans_uikit_enqueued_items, $_beans_uikit_registered_items; + + $_beans_uikit_enqueued_items = array( + 'components' => array( + 'core' => array(), + 'add-ons' => array(), + ), + 'themes' => array(), + ); + + $_beans_uikit_registered_items = array( + 'themes' => array( + 'default' => BEANS_API_PATH . 'uikit/src/themes/default', + 'almost-flat' => BEANS_API_PATH . 'uikit/src/themes/almost-flat', + 'gradient' => BEANS_API_PATH . 'uikit/src/themes/gradient', + 'wordpress-admin' => BEANS_API_PATH . 'uikit/themes/wordpress-admin', + ), + ); + } +} From 20abc58cd2021cac174d03d673b6ba1f37bee393 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 29 May 2018 09:15:49 -0500 Subject: [PATCH 649/800] Added guard clause to Beans_Uikit::get_components_from_directory(). When no components are requested, bail out. Why? If the incoming array is empty, then there's no work to do. Making this change provides a slight performance bump. --- lib/api/uikit/class-beans-uikit.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 26778e13..cb8323f0 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -204,6 +204,11 @@ public function get_js_directories( $type ) { * @return array */ public function get_components_from_directory( $components, $directories, $format ) { + + if ( empty( $components ) ) { + return array(); + } + $extension = 'styles' === $format ? 'less' : 'min.js'; $return = array(); From 2f3313a6d0c112cbbe15bb9f647ce6a77c59b6aa Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 29 May 2018 09:18:11 -0500 Subject: [PATCH 650/800] Added type hinting for _Beans_Uikit::get_components_from_directory() parameters. --- lib/api/uikit/class-beans-uikit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index cb8323f0..b7c81599 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -203,7 +203,7 @@ public function get_js_directories( $type ) { * * @return array */ - public function get_components_from_directory( $components, $directories, $format ) { + public function get_components_from_directory( array $components, array $directories, $format ) { if ( empty( $components ) ) { return array(); From 00390bcb00a0bd4bbe74aa232a8d0c8b578ee7e0 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 29 May 2018 09:18:31 -0500 Subject: [PATCH 651/800] Switched `file_exists` to `is_readable` for _Beans_Uikit::get_components_from_directory(). Why? `is_readable` checks that the file exists and it's readable. As the API will pass the files to the Compiler for processing, we want to know that each file's permissions are correct in order to open the file. --- lib/api/uikit/class-beans-uikit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index b7c81599..b5e0314b 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -220,7 +220,7 @@ public function get_components_from_directory( array $components, array $directo $file = trailingslashit( $directory ) . $component . '.' . $extension; // Make sure the file exists. - if ( file_exists( $file ) ) { + if ( is_readable( $file ) ) { $return[] = $file; } } From ea5e6e2e898fddb8c152da0de2c95b209a951265 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Tue, 29 May 2018 10:57:34 -0400 Subject: [PATCH 652/800] Rename private _beans_setup_widget with int test. --- lib/api/widget/functions.php | 4 ++-- ...SetupWidget.php => beansPrepareWidgetData.php} | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) rename tests/phpunit/integration/api/widget/{_beansSetupWidget.php => beansPrepareWidgetData.php} (53%) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index b3482d6e..ee2660d5 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -267,7 +267,7 @@ function beans_setup_widget() { // Set next current widget integer. $_beans_widget_area['current_widget'] = $_beans_widget_area['current_widget'] + 1; - _beans_setup_widget( $id ); + _beans_prepare_widget_data( $id ); return true; } @@ -485,7 +485,7 @@ function _beans_setup_widgets( $widget_area_content ) { * * @return void */ -function _beans_setup_widget( $id ) { +function _beans_prepare_widget_data( $id ) { global $_beans_widget; $widgets = beans_get_widget_area( 'widgets' ); $_beans_widget = $widgets[ $id ]; diff --git a/tests/phpunit/integration/api/widget/_beansSetupWidget.php b/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php similarity index 53% rename from tests/phpunit/integration/api/widget/_beansSetupWidget.php rename to tests/phpunit/integration/api/widget/beansPrepareWidgetData.php index f6643d6c..68e87445 100644 --- a/tests/phpunit/integration/api/widget/_beansSetupWidget.php +++ b/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php @@ -21,5 +21,20 @@ * @group api-widget */ class Tests_BeansPrepareWidgetData extends Beans_Widget_Test_Case { + public function test_widget_data_should_be_prepared() { + global $_beans_widget; + beans_register_widget_area( array( 'id' => 'test_sidebar' ) ); + $this->add_test_widget_to_test_sidebar(); + _beans_setup_widget_area( 'test_sidebar' ); + + // Verify that no widget data exists before test. + $this->assertEmpty( $_beans_widget ); + + // Call the function. + _beans_prepare_widget_data( 'text-2' ); + + // Verify that widget data is now prepared. + $this->assertContains( 'Test Widget', $_beans_widget ); + } } From c75e7942b3f6fddb85cb859cb48437801d0e4c62 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Tue, 29 May 2018 10:58:25 -0400 Subject: [PATCH 653/800] Add assertion for preparing widget data --- .../phpunit/integration/api/widget/beansSetupWidget.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/integration/api/widget/beansSetupWidget.php b/tests/phpunit/integration/api/widget/beansSetupWidget.php index 3cba6785..4cc4a4f5 100644 --- a/tests/phpunit/integration/api/widget/beansSetupWidget.php +++ b/tests/phpunit/integration/api/widget/beansSetupWidget.php @@ -39,10 +39,10 @@ public function test_should_return_false_when_widget_id_not_found() { } /** - * Test beans_setup_widget() should return advance widget pointer and true when a widget ID is found. + * Test beans_setup_widget() should advance widget pointer, prepare widget data, and return true when a widget ID is found. */ - public function test_should_return_advance_widget_pointer_and_return_true_when_widget_id_is_found() { - global $_beans_widget_area; + public function test_should_return_advance_widget_pointer_prepare_widget_data_and_return_true_when_widget_id_is_found() { + global $_beans_widget_area, $_beans_widget; beans_register_widget_area( array( 'id' => 'test_sidebar' ) ); $this->add_test_widget_to_test_sidebar(); @@ -54,6 +54,9 @@ public function test_should_return_advance_widget_pointer_and_return_true_when_w // Run test. $this->assertTrue( beans_setup_widget() ); + // Verify widget data has been prepared. + $this->assertContains( 'Test Widget', $_beans_widget ); + // Verify widget pointer has advanced to 1. $this->assertEquals( 1, $_beans_widget_area['current_widget'] ); } From 4d8e64d47230c3d9bb004f70af0a05f275bdcd26 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 29 May 2018 11:49:57 -0500 Subject: [PATCH 654/800] Added _Beans_Uikit::to_filename() unit tests. --- .../unit/api/uikit/beans-uikit/toFilename.php | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php b/tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php new file mode 100644 index 00000000..6c14ac66 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php @@ -0,0 +1,100 @@ +assertNull( $beans_uikit->to_filename( 'uikit-customizer.less' ) ); + $this->assertNull( $beans_uikit->to_filename( BEANS_API_PATH . 'uikit/src/less/themes/default/uikit.less' ) ); + } + + /** + * Test _Beans_Uikit::to_filename() should remove the .min extension from the filename. + */ + public function test_should_return_remove_min_extension_from_filename() { + $beans_uikit = new _Beans_Uikit(); + + $this->assertSame( + 'parallax', + $beans_uikit->to_filename( BEANS_API_PATH . 'uikit/src/js/component/parallax.min.js' ) + ); + $this->assertSame( + 'tooltip', + $beans_uikit->to_filename( BEANS_API_PATH . 'uikit/src/js/component/tooltip.min.js' ) + ); + } + + /** + * Test _Beans_Uikit::to_filename() should return the component's filename when given absolute path. + */ + public function test_should_return_component_filename_when_given_absolute_path() { + $beans_uikit = new _Beans_Uikit(); + + $this->assertSame( + 'accordion', + $beans_uikit->to_filename( BEANS_API_PATH . 'uikit/src/less/component/accordion.less' ) + ); + $this->assertSame( + 'accordion', + $beans_uikit->to_filename( BEANS_API_PATH . 'uikit/src/js/component/accordion.min.js' ) + ); + $this->assertSame( + 'sortable', + $beans_uikit->to_filename( BEANS_API_PATH . 'uikit/src/less/component/sortable.less' ) + ); + $this->assertSame( + 'sortable', + $beans_uikit->to_filename( BEANS_API_PATH . 'uikit/src/js/component/sortable.min.js' ) + ); + } + + /** + * Test _Beans_Uikit::to_filename() should return the component's filename when given relative path. + */ + public function test_should_return_component_filename_when_given_relative_path() { + $beans_uikit = new _Beans_Uikit(); + + $this->assertSame( + 'accordion', + $beans_uikit->to_filename( 'less/component/accordion.less' ) + ); + $this->assertSame( + 'accordion', + $beans_uikit->to_filename( 'js/component/accordion.min.js' ) + ); + $this->assertSame( + 'sortable', + $beans_uikit->to_filename( 'sortable.less' ) + ); + $this->assertSame( + 'sortable', + $beans_uikit->to_filename( 'sortable.min.js' ) + ); + } +} From eb7f744c2f387b751e0b0eb3bae7cc222036665e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 29 May 2018 11:54:19 -0500 Subject: [PATCH 655/800] Made _Beans_Uikit::to_filename() more readable and optimized. 1. By moving the first guard clause to the top, we eliminate needing to create the ignore array and variable in memory. Results: a. That gives us a slight improvement in memory and processing time. b. It's more readable as the intent is clear. 2. Abstracted the ignore checker to a private function. Result: a. Makes the intent more clear when used. b. It's more readable and understandable. c. It's eliminates the variable assignment to give us a slight improvement in both memory and processing time. 3. Moved the ignored components array to a private property. This step eliminates the need to recreate the temporary array over and over again whenever `ignore_component()` is called. --- lib/api/uikit/class-beans-uikit.php | 31 ++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index b5e0314b..03632edc 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -18,6 +18,13 @@ */ final class _Beans_Uikit { + /** + * Components to ignore. + * + * @var array + */ + private $ignored_components = array( 'uikit-customizer', 'uikit' ); + /** * Compile enqueued items. * @@ -389,17 +396,31 @@ public function get_autoload_components( $components ) { public function to_filename( $file ) { $pathinfo = pathinfo( $file ); - $ignore = array( - 'uikit-customizer', - 'uikit', - ); + + // If the given file is not valid, bail out. + if ( ! isset( $pathinfo['filename'] ) ) { + return null; + } // Stop here if it isn't a valid file or if it should be ignored. - if ( ! isset( $pathinfo['filename'] ) || in_array( $pathinfo['filename'], $ignore, true ) ) { + if ( $this->ignore_component( $pathinfo['filename'] ) ) { return null; } // Return the filename without the .min to avoid duplicates. return str_replace( '.min', '', $pathinfo['filename'] ); } + + /** + * Checks if the given component's filename should be ignored. + * + * @since 1.5.0 + * + * @param string $filename The filename to check against the ignored components. + * + * @return bool + */ + private function ignore_component( $filename ) { + return in_array( $filename, $this->ignored_components, true ); + } } From 96e347f363f8d61137ab02886ae6ab6d528c086e Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 30 May 2018 11:14:56 -0400 Subject: [PATCH 656/800] Add int tests for 2 functions _beans_setup_widget_area() _beans_setup_widgets() --- .../api/widget/beansSetupWidgetArea.php | 55 +++++++++++++ .../api/widget/beansSetupWidgets.php | 80 +++++++++++++++++++ .../includes/class-beans-widget-test-case.php | 1 + 3 files changed, 136 insertions(+) create mode 100644 tests/phpunit/integration/api/widget/beansSetupWidgetArea.php create mode 100644 tests/phpunit/integration/api/widget/beansSetupWidgets.php diff --git a/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php b/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php new file mode 100644 index 00000000..c8b0ece8 --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php @@ -0,0 +1,55 @@ +assertFalse( _beans_setup_widget_area( 'missing_sidebar' ) ); + } + + /** + * Test _beans_setup_widget_area() should build widget area data and return true when widget area exists. + */ + public function test_should_build_widget_area_data_and_return_true_when_widget_area_exists() { + global $_beans_widget_area; + + beans_register_widget_area( 'test_sidebar' ); + $this->add_test_widget_to_test_sidebar(); + + // Clear test widget area data global before running test. + $_beans_widget_area = array(); + + // Run test. + $this->assertTrue( _beans_setup_widget_area( 'test_sidebar' ) ); + + // Verify widget area data has been set up. + $this->assertContains( 'test_sidebar', $_beans_widget_area ); + $this->assertArrayHasKey( 'widgets_count', $_beans_widget_area ); + $this->assertArrayHasKey( 'current_widget', $_beans_widget_area ); + $this->assertArrayHasKey( 'before_widgets', $_beans_widget_area ); + $this->assertArrayHasKey( 'widgets', $_beans_widget_area ); + $this->assertArrayHasKey( 'after_widgets', $_beans_widget_area ); + } +} diff --git a/tests/phpunit/integration/api/widget/beansSetupWidgets.php b/tests/phpunit/integration/api/widget/beansSetupWidgets.php new file mode 100644 index 00000000..5e1f92d6 --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansSetupWidgets.php @@ -0,0 +1,80 @@ +assertEmpty( _beans_setup_widgets( 'random non-widget string' ) ); + } + + /** + * Test _beans_setup_widgets() should skip a widget if it has not been registered. + */ + public function test_should_ignore_widget_when_widget_not_registered() { + global $wp_registered_widgets; + + $wp_registered_widgets = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: ensures no widgets are registered for this test. + + $this->assertEmpty( _beans_setup_widgets( 'widget output' ) ); + } + + /** + * Test _beans_setup_widgets() should return widget data when the widget is registered. + */ + public function test_should_return_widget_data_when_widget_is_registered() { + beans_register_widget_area( 'test_sidebar' ); + $this->add_test_widget_to_test_sidebar(); + + $this->assertSame( + $this->get_expected_widget_setup_data(), + _beans_setup_widgets( 'widget output' + ) + ); + } + + /** + * Get an array of expected widget setup data. + * + * @return array Expected widget setup data + */ + protected function get_expected_widget_setup_data() { + return array( + 'text-2' => array( + 'options' => array(), + 'type' => 'text', + 'title' => '', + 'count' => 1, + 'id' => 'text-2', + 'name' => 'Test Widget', + 'classname' => 'widget_text', + 'description' => null, + 'content' => 'widget output', + 'show_title' => true, + 'badge' => false, + 'badge_content' => 'Hello', + ), + ); + } +} diff --git a/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php index aa21c310..df04dafe 100644 --- a/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php +++ b/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php @@ -22,6 +22,7 @@ abstract class Beans_Widget_Test_Case extends Test_Case { * Fixture to clean up after tests. */ public function tearDown() { + unset( $GLOBALS['$_beans_widget_area'] ); unset( $GLOBALS['current_screen'] ); $this->clean_up_global_scope(); From 26a8f8613cff380615701eb5234f4636b27cda1f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 30 May 2018 13:48:54 -0500 Subject: [PATCH 657/800] Added _Beans_Uikit::get_autoload_components() unit tests. --- .../beans-uikit/getAutoloadComponents.php | 288 ++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getAutoloadComponents.php diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getAutoloadComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/getAutoloadComponents.php new file mode 100644 index 00000000..985a2077 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getAutoloadComponents.php @@ -0,0 +1,288 @@ +assertSame( [ + 'core' => [], + 'add-ons' => [], + ], $beans_uikit->get_autoload_components( $components ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the panel. + */ + public function test_should_return_dependencies_for_panel() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ 'badge' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'panel' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the cover. + */ + public function test_should_return_dependencies_for_cover() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ 'flex' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'cover' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the overlay. + */ + public function test_should_return_dependencies_for_overlay() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ 'flex' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'overlay' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the tab. + */ + public function test_should_return_dependencies_for_tab() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ 'switcher' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'tab' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the modal. + */ + public function test_should_return_dependencies_for_modal() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ 'close' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'modal' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the scrollspy. + */ + public function test_should_return_dependencies_for_scrollspy() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ 'animation' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'scrollspy' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the lightbox. + */ + public function test_should_return_dependencies_for_lightbox() { + $beans_uikit = new _Beans_Uikit(); + $expected = [ + 'core' => [ + 'animation', + 'flex', + 'close', + 'modal', + 'overlay', + ], + 'add-ons' => [ + 'slidenav', + ], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'lightbox' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the slider. + */ + public function test_should_return_dependencies_for_slider() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [], + 'add-ons' => [ 'slidenav' ], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'slider' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the slideset. + */ + public function test_should_return_dependencies_for_slideset() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ + 'animation', + 'flex', + ], + 'add-ons' => [ + 'dotnav', + 'slidenav', + ], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'slideset' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the slideshow. + */ + public function test_should_return_dependencies_for_slideshow() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ + 'animation', + 'flex', + ], + 'add-ons' => [ + 'dotnav', + 'slidenav', + ], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'slideshow' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the parallax. + */ + public function test_should_return_dependencies_for_parallax() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ 'flex' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'parallax' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return dependencies for the notify. + */ + public function test_should_return_dependencies_for_notify() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ 'close' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ 'notify' ] ) ); + } + + /** + * Test _Beans_Uikit::get_autoload_components() should return all dependencies for the given components. + */ + public function test_should_return_all_dependencies_for_given_components() { + $beans_uikit = new _Beans_Uikit(); + + $expected = [ + 'core' => [ + 'badge', + 'flex', + ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ + 'panel', + 'overlay', + ] ) ); + + $expected = [ + 'core' => [ 'switcher' ], + 'add-ons' => [ 'slidenav' ], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ + 'tab', + 'slider', + ] ) ); + + $expected = [ + 'core' => [ + 'close', + 'animation', + 'flex', + ], + 'add-ons' => [ + 'dotnav', + 'slidenav', + ], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ + 'modal', + 'slideshow', + 'notify', + ] ) ); + + $expected = [ + 'core' => [ + 'animation', + 'flex', + 'close', + 'modal', + 'overlay', + 'badge', + 'switcher', + ], + 'add-ons' => [ + 'slidenav', + 'dotnav', + ], + ]; + $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ + 'lightbox', + 'notify', + 'panel', + 'slideshow', + 'tab', + ] ) ); + } +} From 1823c5d57e7557a7c74548386e97ebcccfc54619 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 30 May 2018 14:56:53 -0500 Subject: [PATCH 658/800] Optimized, improved, and fixed #239 for building component dependencies. 1. Fixed #239. 2. Got rid of redundant and unused code to reduce complexity and make it more readable. 3. Optimized by getting rid of the array_flips. Instead, we merge in the building loop. Then we remove the duplicates after we've built an array of all dependencies for all given components. This solution is faster by 0.007ms. ------------------------- MICRO PROFILER REPORT: ------------------------- PHP version: 5.6.20 Sample Size: 100,000 (per function) Time Increments: milliseconds, where 1 ms equals 0.001 second. ------------- ------------- ------------- | Result | Avg Time | v1.4.0 | | (ms) | (ms) | (ms) | | ------------- | ------------- | ------------- | | -0.007319 | 0.014701 | 0.022020 | ------------- ------------- ------------- --- lib/api/uikit/class-beans-uikit.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 03632edc..ba80d0f3 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -367,19 +367,24 @@ public function get_autoload_components( $components ) { ), ); + // Build dependencies for each component. foreach ( (array) $components as $component ) { - $this_dependencies = beans_get( $component, $dependencies, array() ); - foreach ( $this_dependencies as $dependency ) { - $autoload['core'] = array_merge( $autoload['core'], array_flip( beans_get( 'core', $this_dependencies, array() ) ) ); - $autoload['add-ons'] = array_merge( $autoload['add-ons'], array_flip( beans_get( 'add-ons', $this_dependencies, array() ) ) ); + foreach ( $this_dependencies as $type => $dependency ) { + $autoload[ $type ] = array_merge( $autoload[ $type ], $dependency ); } } - // Format autoload back to associative key value array. - $autoload['core'] = array_flip( $autoload['core'] ); - $autoload['add-ons'] = array_flip( $autoload['add-ons'] ); + // Remove the duplicates. + foreach ( $autoload as $type => $dependencies ) { + + if ( empty( $dependencies ) ) { + continue; + } + + $autoload[ $type ] = array_values( array_unique( $dependencies ) ); + } return $autoload; } From 5e54c04e8630e4a6d6519c1f1372d5e3f8c51b13 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 30 May 2018 16:25:11 -0500 Subject: [PATCH 659/800] Improved & optimized _Beans_Uikit::get_autoload_components(). Reworked the hard-coded component dependencies: 1. Moved to a configuration file. 2. Added them to a static property. 3. Loaded from the config file just once and into the static property, as these dependencies are for ALL objects. Abstracted the duplication removal code. Why? 1. Reusable 2. More readable as the method's name tells you what it does. Quality Improvements: 1. Improved the DocBlock. 2. Improved variable naming to be more clear of the value each represents. ========== Results ========== 1. More readable. 2. Performance bump as it runs 0.0092ms faster. ------------------------- MICRO PROFILER REPORT: ------------------------- PHP version: 5.6.20 Sample Size: 100,000 (per function) Time Increments: milliseconds, where 1 ms equals 0.001 second. ------------- ------------- ------------- | Result | Avg Time | v1.4.0 | (ms) | (ms) | (ms) | ------------- | ------------- | ------------- | -0.009173 | 0.012847 | 0.022020 ------------- ------------- ------------- --- lib/api/uikit/class-beans-uikit.php | 140 ++++++------------ .../uikit/config/component-dependencies.php | 88 +++++++++++ 2 files changed, 137 insertions(+), 91 deletions(-) create mode 100644 lib/api/uikit/config/component-dependencies.php diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index ba80d0f3..99597ebe 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -25,6 +25,13 @@ final class _Beans_Uikit { */ private $ignored_components = array( 'uikit-customizer', 'uikit' ); + /** + * The configured components' dependencies. + * + * @var array + */ + private static $configured_components_dependencies; + /** * Compile enqueued items. * @@ -273,120 +280,71 @@ public function get_all_components( $type ) { } /** - * Auto detect the required components. + * Gets all of the required dependencies for the given components. * * @since 1.0.0 * - * @param array $components Array of components to autoload. + * @param array $components The given components to search for dependencies. * * @return array */ - public function get_autoload_components( $components ) { - $autoload = array( + public function get_autoload_components( array $components ) { + $dependencies = array( 'core' => array(), 'add-ons' => array(), ); - $dependencies = array( - 'panel' => array( - 'core' => array( - 'badge', - ), - ), - 'cover' => array( - 'core' => array( - 'flex', - ), - ), - 'overlay' => array( - 'core' => array( - 'flex', - ), - ), - 'tab' => array( - 'core' => array( - 'switcher', - ), - ), - 'modal' => array( - 'core' => array( - 'close', - ), - ), - 'scrollspy' => array( - 'core' => array( - 'animation', - ), - ), - 'lightbox' => array( - 'core' => array( - 'animation', - 'flex', - 'close', - 'modal', - 'overlay', - ), - 'add-ons' => array( - 'slidenav', - ), - ), - 'slider' => array( - 'add-ons' => array( - 'slidenav', - ), - ), - 'slideset' => array( - 'core' => array( - 'animation', - 'flex', - ), - 'add-ons' => array( - 'dotnav', - 'slidenav', - ), - ), - 'slideshow' => array( - 'core' => array( - 'animation', - 'flex', - ), - 'add-ons' => array( - 'dotnav', - 'slidenav', - ), - ), - 'parallax' => array( - 'core' => array( - 'flex', - ), - ), - 'notify' => array( - 'core' => array( - 'close', - ), - ), - ); + $this->init_component_dependencies(); // Build dependencies for each component. foreach ( (array) $components as $component ) { - $this_dependencies = beans_get( $component, $dependencies, array() ); + $component_dependencies = beans_get( $component, self::$configured_components_dependencies, array() ); - foreach ( $this_dependencies as $type => $dependency ) { - $autoload[ $type ] = array_merge( $autoload[ $type ], $dependency ); + foreach ( $component_dependencies as $type => $dependency ) { + $dependencies[ $type ] = array_merge( $dependencies[ $type ], $dependency ); } } - // Remove the duplicates. - foreach ( $autoload as $type => $dependencies ) { + return $this->remove_duplicate_values( $dependencies ); + } - if ( empty( $dependencies ) ) { + /** + * Removes duplicate values from the given source array. + * + * @since 1.5.0 + * + * @param array $source The given array to iterate and remove duplicate values. + * + * @return array + */ + private function remove_duplicate_values( array $source ) { + + foreach ( $source as $key => $value ) { + + if ( empty( $value ) || ! is_array( $value ) ) { continue; } - $autoload[ $type ] = array_values( array_unique( $dependencies ) ); + $source[ $key ] = array_values( array_unique( $value ) ); + } + + return $source; + } + + /** + * Initialize the components' dependencies, by loading from its configuration file when null. + * + * @since 1.5.0 + * + * @return void + */ + private function init_component_dependencies() { + + if ( ! is_null( self::$configured_components_dependencies ) ) { + return; } - return $autoload; + self::$configured_components_dependencies = require dirname( __FILE__ ) . '/config/component-dependencies.php'; } /** diff --git a/lib/api/uikit/config/component-dependencies.php b/lib/api/uikit/config/component-dependencies.php new file mode 100644 index 00000000..e46c337e --- /dev/null +++ b/lib/api/uikit/config/component-dependencies.php @@ -0,0 +1,88 @@ + array( + 'core' => array( + 'flex', + ), + ), + 'lightbox' => array( + 'core' => array( + 'animation', + 'flex', + 'close', + 'modal', + 'overlay', + ), + 'add-ons' => array( + 'slidenav', + ), + ), + 'modal' => array( + 'core' => array( + 'close', + ), + ), + 'notify' => array( + 'core' => array( + 'close', + ), + ), + 'overlay' => array( + 'core' => array( + 'flex', + ), + ), + 'panel' => array( + 'core' => array( + 'badge', + ), + ), + 'parallax' => array( + 'core' => array( + 'flex', + ), + ), + 'scrollspy' => array( + 'core' => array( + 'animation', + ), + ), + 'slider' => array( + 'add-ons' => array( + 'slidenav', + ), + ), + 'slideset' => array( + 'core' => array( + 'animation', + 'flex', + ), + 'add-ons' => array( + 'dotnav', + 'slidenav', + ), + ), + 'slideshow' => array( + 'core' => array( + 'animation', + 'flex', + ), + 'add-ons' => array( + 'dotnav', + 'slidenav', + ), + ), + 'tab' => array( + 'core' => array( + 'switcher', + ), + ), +); From dababe9d7cda9557c812493390b571f9b5c99137 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 30 May 2018 18:33:06 -0500 Subject: [PATCH 660/800] Added _Beans_Uikit::get_less_directories() unit tests. --- .../uikit/beans-uikit/getLessDirectories.php | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getLessDirectories.php diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getLessDirectories.php b/tests/phpunit/unit/api/uikit/beans-uikit/getLessDirectories.php new file mode 100644 index 00000000..0c77a86a --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getLessDirectories.php @@ -0,0 +1,94 @@ +assertEmpty( $_beans_uikit_enqueued_items['themes'] ); + $this->assertSame( + [ BEANS_API_PATH . 'uikit/src/less/core' ], + $beans_uikit->get_less_directories( 'core' ) + ); + $this->assertSame( + [ BEANS_API_PATH . 'uikit/src/less/components' ], + $beans_uikit->get_less_directories( 'components' ) + ); + } + + /** + * Test _Beans_Uikit::get_less_directories() should return path to 'components' directory when the type is + * 'add-ons'. + */ + public function test_should_return_path_to_components_directory_when_type_is_add_ons() { + $beans_uikit = new _Beans_Uikit(); + + $this->assertSame( + [ BEANS_API_PATH . 'uikit/src/less/components' ], + $beans_uikit->get_less_directories( 'add-ons' ) + ); + } + + /** + * Test _Beans_Uikit::get_less_directories() should return the UIkit type directory and each theme's directory. + */ + public function test_should_return_uikit_type_directory_and_each_theme_directory() { + $beans_uikit = new _Beans_Uikit(); + + global $_beans_uikit_enqueued_items; + + $themes = [ + BEANS_API_PATH . 'uikit/src/themes/almost-flat', + BEANS_API_PATH . 'uikit/src/themes/default', + BEANS_API_PATH . 'uikit/src/themes/gradient', + ]; + $_beans_uikit_enqueued_items['themes'] = $themes; + $this->assertSame( + array_merge( [ BEANS_API_PATH . 'uikit/src/less/core' ], $themes ), + $beans_uikit->get_less_directories( 'core' ) + ); + $this->assertSame( + array_merge( [ BEANS_API_PATH . 'uikit/src/less/components' ], $themes ), + $beans_uikit->get_less_directories( 'components' ) + ); + + $child_theme = vfsStream::url( 'themes/beans-child/assets/less/theme' ); + $themes[] = $child_theme; + $_beans_uikit_enqueued_items['themes'][] = $child_theme; + $this->assertSame( + array_merge( [ BEANS_API_PATH . 'uikit/src/less/core' ], $themes ), + $beans_uikit->get_less_directories( 'core' ) + ); + $this->assertSame( + array_merge( [ BEANS_API_PATH . 'uikit/src/less/components' ], $themes ), + $beans_uikit->get_less_directories( 'components' ) + ); + } +} From a8cd68d7a7a637c9369a842a8ac8f1f981155847 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 30 May 2018 18:47:34 -0500 Subject: [PATCH 661/800] Added _Beans_Uikit::get_js_directories() unit tests. --- .../uikit/beans-uikit/getJsDirectories.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getJsDirectories.php diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getJsDirectories.php b/tests/phpunit/unit/api/uikit/beans-uikit/getJsDirectories.php new file mode 100644 index 00000000..217f87fa --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getJsDirectories.php @@ -0,0 +1,56 @@ +assertSame( + [ BEANS_API_PATH . 'uikit/src/js/core' ], + $beans_uikit->get_js_directories( 'core' ) + ); + $this->assertSame( + [ BEANS_API_PATH . 'uikit/src/js/components' ], + $beans_uikit->get_js_directories( 'components' ) + ); + } + + /** + * Test _Beans_Uikit::get_js_directories() should return path to 'components' directory when the type is + * 'add-ons'. + */ + public function test_should_return_path_to_components_directory_when_type_is_add_ons() { + $beans_uikit = new _Beans_Uikit(); + + $this->assertSame( + [ BEANS_API_PATH . 'uikit/src/js/components' ], + $beans_uikit->get_js_directories( 'add-ons' ) + ); + } +} From 4e77a9b7d78f909920e86441f2e3cc30e1043a9c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 13:35:17 -0500 Subject: [PATCH 662/800] Added _Beans_Uikit::register_less_components() unit tests. --- .../beans-uikit/registerLessComponents.php | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php new file mode 100644 index 00000000..2205a7f0 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php @@ -0,0 +1,141 @@ + [] ]; + + // Run the test. + $this->assertEmpty( ( new _Beans_Uikit() )->register_less_components() ); + } + + /** + * Test _Beans_Uikit::register_less_components() should return variables and fixes when no theme or components are + * registered. + */ + public function test_should_return_variables_and_fixes_when_no_theme_or_components_registered() { + // Check the global. + global $_beans_uikit_enqueued_items; + $this->assertSame( [ + 'core' => [], + 'add-ons' => [], + ], $_beans_uikit_enqueued_items['components'] ); + + // Run the test. + $this->assertSame( + [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], + ( new _Beans_Uikit() )->register_less_components() + ); + } + + /** + * Test _Beans_Uikit::register_less_components() should return an array of core paths when components are + * registered. + */ + public function test_should_return_array_of_core_paths_when_components_are_registered() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['core'] = [ 'article', 'base', 'block', 'grid' ]; + + $this->assertSame( + [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_API_PATH . 'uikit/src/less/core/article.less', + BEANS_API_PATH . 'uikit/src/less/core/base.less', + BEANS_API_PATH . 'uikit/src/less/core/block.less', + BEANS_API_PATH . 'uikit/src/less/core/grid.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], + ( new _Beans_Uikit() )->register_less_components() + ); + } + + /** + * Test _Beans_Uikit::register_less_components() should return an array of add-ons paths when components are + * registered. + */ + public function test_should_return_array_of_add_ons_paths_when_components_are_registered() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['add-ons'] = [ 'slidenav' ]; + + $this->assertSame( + [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_API_PATH . 'uikit/src/less/components/slidenav.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], + ( new _Beans_Uikit() )->register_less_components() + ); + } + + /** + * Test _Beans_Uikit::register_less_components() should return an array of paths when components are registered. + */ + public function test_should_return_array_of_paths_when_components_are_registered() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['core'] = [ 'badge', 'close', 'animation', 'flex' ]; + $_beans_uikit_enqueued_items['components']['add-ons'] = [ 'slideshow', 'dotnav', 'slidenav' ]; + + $this->assertSame( + [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_API_PATH . 'uikit/src/less/core/badge.less', + BEANS_API_PATH . 'uikit/src/less/core/close.less', + BEANS_API_PATH . 'uikit/src/less/core/animation.less', + BEANS_API_PATH . 'uikit/src/less/core/flex.less', + BEANS_API_PATH . 'uikit/src/less/components/slideshow.less', + BEANS_API_PATH . 'uikit/src/less/components/dotnav.less', + BEANS_API_PATH . 'uikit/src/less/components/slidenav.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], + ( new _Beans_Uikit() )->register_less_components() + ); + } + + /** + * Test _Beans_Uikit::register_less_components() should include theme components when a theme is registered. + */ + public function test_should_include_theme_components_when_theme_is_registered() { + $theme = BEANS_API_PATH . 'uikit/src/themes/default'; + + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['themes'] = [ $theme ]; + $_beans_uikit_enqueued_items['components']['core'] = [ 'badge', 'close', 'animation', 'flex' ]; + $_beans_uikit_enqueued_items['components']['add-ons'] = [ 'slideshow', 'dotnav', 'slidenav' ]; + + $components = ( new _Beans_Uikit() )->register_less_components(); + $this->assertContains( $theme . '/variables.less', $components ); + $this->assertContains( $theme . '/badge.less', $components ); + $this->assertContains( $theme . '/close.less', $components ); + $this->assertContains( $theme . '/dotnav.less', $components ); + $this->assertContains( $theme . '/slidenav.less', $components ); + } +} From f6a0bfe5810100cd7a7a4bfd4d2943d463384f2e Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Thu, 31 May 2018 14:54:16 -0400 Subject: [PATCH 663/800] Add remaining integration tests --- .../api/widget/beansForceTheWidget.php | 60 +++++++++++++++++++ .../api/widget/beansResetWidget.php | 41 +++++++++++++ .../api/widget/beansResetWidgetArea.php | 44 ++++++++++++++ .../api/widget/beansWidgetAreaSubfilters.php | 35 +++++++++++ .../api/widget/beansWidgetSubfilters.php | 36 +++++++++++ 5 files changed, 216 insertions(+) create mode 100644 tests/phpunit/integration/api/widget/beansForceTheWidget.php create mode 100644 tests/phpunit/integration/api/widget/beansResetWidget.php create mode 100644 tests/phpunit/integration/api/widget/beansResetWidgetArea.php create mode 100644 tests/phpunit/integration/api/widget/beansWidgetAreaSubfilters.php create mode 100644 tests/phpunit/integration/api/widget/beansWidgetSubfilters.php diff --git a/tests/phpunit/integration/api/widget/beansForceTheWidget.php b/tests/phpunit/integration/api/widget/beansForceTheWidget.php new file mode 100644 index 00000000..5220366d --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansForceTheWidget.php @@ -0,0 +1,60 @@ +widgets['unorthodox'] = new \stdClass(); + + ob_start(); + _beans_force_the_widget( 'unorthodox', array(), array( 'before_widget' => '
        assertEmpty( $output ); + } + + public function test_should_do_nothing_when_widget_has_id_registered() { + add_action( 'cg', [$this, 'check']); + ob_start(); + _beans_force_the_widget( 'WP_Widget_Text', array(), array( 'before_widget' => '
        assertEmpty( $output ); + } + + + public function test_should_output_widget_id_html_when_widget_registered_without_id_arg() { + ob_start(); + _beans_force_the_widget( 'WP_Widget_Text', '', array() ); + $output = ob_get_clean(); + + $this->assertEquals( '', $output ); + } + + public function check( $data ) { + var_dump( $data ); + } + +} diff --git a/tests/phpunit/integration/api/widget/beansResetWidget.php b/tests/phpunit/integration/api/widget/beansResetWidget.php new file mode 100644 index 00000000..1b3587f4 --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansResetWidget.php @@ -0,0 +1,41 @@ + 'text-2', 'name' => 'Test Widget' ) ); + $_beans_widget = $test_widget; + + // Confirm that it's stored in the GLOBALS superglobal. + $this->assertSame( $test_widget, $GLOBALS['_beans_widget'] ); + + // Run the function. + _beans_reset_widget(); + + // Test that the superglobal is no longer set. + $this->assertFalse( isset( $GLOBALS['_beans_widget'] ) ); + } +} diff --git a/tests/phpunit/integration/api/widget/beansResetWidgetArea.php b/tests/phpunit/integration/api/widget/beansResetWidgetArea.php new file mode 100644 index 00000000..2bc60504 --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansResetWidgetArea.php @@ -0,0 +1,44 @@ + array( 'id' => 'text-2' ), ) ); + $_beans_widget_area = $test_widget_area; + + // Confirm that it's stored in the GLOBALS superglobal. + $this->assertSame( $test_widget_area, $GLOBALS['_beans_widget_area'] ); + + // Run the function. + _beans_reset_widget_area(); + + // Test that the superglobal is no longer set. + $this->assertFalse( isset( $GLOBALS['_beans_widget_area'] ) ); + } +} diff --git a/tests/phpunit/integration/api/widget/beansWidgetAreaSubfilters.php b/tests/phpunit/integration/api/widget/beansWidgetAreaSubfilters.php new file mode 100644 index 00000000..b3db2ec2 --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansWidgetAreaSubfilters.php @@ -0,0 +1,35 @@ +assertEquals( '[_test_sidebar]', _beans_widget_area_subfilters() ); + } +} diff --git a/tests/phpunit/integration/api/widget/beansWidgetSubfilters.php b/tests/phpunit/integration/api/widget/beansWidgetSubfilters.php new file mode 100644 index 00000000..e845fa8b --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansWidgetSubfilters.php @@ -0,0 +1,36 @@ +add_test_widget_to_test_sidebar(); + + _beans_setup_widget_area( 'test_sidebar' ); + + $this->assertEquals( '[_test_sidebar][_text][_text-2]', _beans_widget_subfilters() ); + } +} From 3ea1526cb5754720d7e5feb55d68b7e37999ba4a Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Thu, 31 May 2018 14:54:56 -0400 Subject: [PATCH 664/800] Fix needle/haystach reversed in force_the_widget --- lib/api/widget/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index ee2660d5..2adb3381 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -578,7 +578,7 @@ function _beans_force_the_widget( $widget, $instance, $args ) { } // Stop here if the widget correctly contains an id. - if ( false !== stripos( $widget_obj->id, beans_get( 'before_widget', $args ) ) ) { + if ( false !== stripos( beans_get( 'before_widget', $args ), $widget_obj->id ) ) { return; } From e447e69f0d7115f5c6da9b1275f34be7b022e041 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Thu, 31 May 2018 15:09:55 -0400 Subject: [PATCH 665/800] Update integration tests to pass WPCS --- .../api/widget/beansForceTheWidget.php | 16 +++++++++------- .../api/widget/beansPrepareWidgetData.php | 6 +++++- .../integration/api/widget/beansResetWidget.php | 11 ++++++++++- .../api/widget/beansResetWidgetArea.php | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/integration/api/widget/beansForceTheWidget.php b/tests/phpunit/integration/api/widget/beansForceTheWidget.php index 5220366d..28caa609 100644 --- a/tests/phpunit/integration/api/widget/beansForceTheWidget.php +++ b/tests/phpunit/integration/api/widget/beansForceTheWidget.php @@ -23,6 +23,9 @@ */ class Tests_BeansForceTheWidget extends Beans_Widget_Test_Case { + /** + * Test beans_force_the_widget() should do nothing when not an instance of class WP_Widget. + */ public function test_should_do_nothing_when_widget_not_instance_of_WP_Widget() { global $wp_widget_factory; @@ -35,8 +38,10 @@ public function test_should_do_nothing_when_widget_not_instance_of_WP_Widget() { $this->assertEmpty( $output ); } + /** + * Test beans_force_the_widget() should do nothing when widget already has an id registered. + */ public function test_should_do_nothing_when_widget_has_id_registered() { - add_action( 'cg', [$this, 'check']); ob_start(); _beans_force_the_widget( 'WP_Widget_Text', array(), array( 'before_widget' => '
        assertEmpty( $output ); } - + /** + * Test beans_force_the_widget() should render widget id html when the widget is registered without an id argument. + */ public function test_should_output_widget_id_html_when_widget_registered_without_id_arg() { ob_start(); _beans_force_the_widget( 'WP_Widget_Text', '', array() ); @@ -52,9 +59,4 @@ public function test_should_output_widget_id_html_when_widget_registered_without $this->assertEquals( '', $output ); } - - public function check( $data ) { - var_dump( $data ); - } - } diff --git a/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php b/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php index 68e87445..88b9d6f1 100644 --- a/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php +++ b/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php @@ -21,7 +21,11 @@ * @group api-widget */ class Tests_BeansPrepareWidgetData extends Beans_Widget_Test_Case { - public function test_widget_data_should_be_prepared() { + + /** + * Test _beans_prepare_widget_data() should prepare widget data. + */ + public function test_should_prepared_widget_data() { global $_beans_widget; beans_register_widget_area( array( 'id' => 'test_sidebar' ) ); diff --git a/tests/phpunit/integration/api/widget/beansResetWidget.php b/tests/phpunit/integration/api/widget/beansResetWidget.php index 1b3587f4..e83d96ed 100644 --- a/tests/phpunit/integration/api/widget/beansResetWidget.php +++ b/tests/phpunit/integration/api/widget/beansResetWidget.php @@ -22,11 +22,20 @@ */ class Tests_BeansResetWidget extends Beans_Widget_Test_Case { + /** + * Test beans_reset_widget should unset widget data. + */ public function test_should_unset_widget_data() { global $_beans_widget; // We'll set the data via the function's view of the global since that's how it's ordinarily set in the API. - $test_widget = array( array( 'id' => 'text-2', 'name' => 'Test Widget' ) ); + $test_widget = array( + array( + 'id' => 'text-2', + 'name' => 'Test Widget', + ), + ); + $_beans_widget = $test_widget; // Confirm that it's stored in the GLOBALS superglobal. diff --git a/tests/phpunit/integration/api/widget/beansResetWidgetArea.php b/tests/phpunit/integration/api/widget/beansResetWidgetArea.php index 2bc60504..799d678b 100644 --- a/tests/phpunit/integration/api/widget/beansResetWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansResetWidgetArea.php @@ -29,7 +29,7 @@ public function test_should_unset_all_widget_area_data() { global $_beans_widget_area; // We'll set the data via the function's view of the global since that's how it's ordinarily set in the API. - $test_widget_area = array( array( 'text-2' => array( 'id' => 'text-2' ), ) ); + $test_widget_area = array( array( 'text-2' => array( 'id' => 'text-2' ) ) ); $_beans_widget_area = $test_widget_area; // Confirm that it's stored in the GLOBALS superglobal. From 66ec3d04e21c981d2a7807233c565b38561c4731 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 13:36:50 -0500 Subject: [PATCH 666/800] Improved and optimized _Beans_Uikit::register_less_components(). `array_merge()` is an expensive construct. We only want to do it when: 1. there's a new array of components (emphasis on more than 1 component) AND 2. the target array is not empty. This commit optimizes this process by creating a new private method to handle joining two arrays. --- lib/api/uikit/class-beans-uikit.php | 36 ++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 99597ebe..bd396503 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -113,18 +113,48 @@ public function register_less_components() { $items = array_merge( array( 'variables' ), $items ); } - // Fetch components from directories. - $components = array_merge( $components, $this->get_components_from_directory( $items, $this->get_less_directories( $type ), 'styles' ) ); + $this->maybe_join_arrays( + $components, + $this->get_components_from_directory( $items, $this->get_less_directories( $type ), 'styles' ) + ); } // Add fixes. if ( ! empty( $components ) ) { - $components = array_merge( $components, array( BEANS_API_PATH . 'uikit/src/fixes.less' ) ); + $this->maybe_join_arrays( $components, array( BEANS_API_PATH . 'uikit/src/fixes.less' ) ); } return $components; } + /** + * Maybe joins two arrays together without requiring an additional variable assignment upon return. + * + * @since 1.5.0 + * + * @param array $array1 Initial array, which becomes the final array. + * @param array $array2 The array to merge into $array1. + * + * @return void Nothing is returned. + */ + private function maybe_join_arrays( array &$array1, array $array2 ) { + + // Bail out if the 2nd array is empty, as there's no work to do. + if ( empty( $array2 ) ) { + return; + } + + // If the 1st array is empty, set it to the 2nd array. + if ( empty( $array1 ) ) { + $array1 = $array2; + + return; + } + + // Both arrays have elements. Let's join them together. + $array1 = array_merge( $array1, $array2 ); + } + /** * Register JavaScript components. * From d911eb6296cb8576853576803ba3b70f46e69868 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 14:33:41 -0500 Subject: [PATCH 667/800] Moved maybe_join_arrays() to new beans_join_arrays(). This new function is useful for more than just the UIkit API. Created a new utility function and unit tests for it. --- lib/api/uikit/class-beans-uikit.php | 32 +---- lib/api/utilities/functions.php | 28 ++++ .../beans-uikit/registerLessComponents.php | 12 ++ .../unit/api/utilities/beansJoinArrays.php | 123 ++++++++++++++++++ 4 files changed, 165 insertions(+), 30 deletions(-) create mode 100644 tests/phpunit/unit/api/utilities/beansJoinArrays.php diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index bd396503..42785ed1 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -113,7 +113,7 @@ public function register_less_components() { $items = array_merge( array( 'variables' ), $items ); } - $this->maybe_join_arrays( + beans_join_arrays( $components, $this->get_components_from_directory( $items, $this->get_less_directories( $type ), 'styles' ) ); @@ -121,40 +121,12 @@ public function register_less_components() { // Add fixes. if ( ! empty( $components ) ) { - $this->maybe_join_arrays( $components, array( BEANS_API_PATH . 'uikit/src/fixes.less' ) ); + beans_join_arrays( $components, array( BEANS_API_PATH . 'uikit/src/fixes.less' ) ); } return $components; } - /** - * Maybe joins two arrays together without requiring an additional variable assignment upon return. - * - * @since 1.5.0 - * - * @param array $array1 Initial array, which becomes the final array. - * @param array $array2 The array to merge into $array1. - * - * @return void Nothing is returned. - */ - private function maybe_join_arrays( array &$array1, array $array2 ) { - - // Bail out if the 2nd array is empty, as there's no work to do. - if ( empty( $array2 ) ) { - return; - } - - // If the 1st array is empty, set it to the 2nd array. - if ( empty( $array1 ) ) { - $array1 = $array2; - - return; - } - - // Both arrays have elements. Let's join them together. - $array1 = array_merge( $array1, $array2 ); - } - /** * Register JavaScript components. * diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index d1fce9a5..17306e11 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -514,6 +514,34 @@ function beans_esc_attributes( $attributes ) { return trim( $string ); } +/** + * Maybe joins two arrays together without requiring an additional variable assignment upon return. + * + * @since 1.5.0 + * + * @param array $array1 Initial array (passed by reference), which becomes the final array. + * @param array $array2 The array to merge into $array1. + * + * @return void Nothing is returned. + */ +function beans_join_arrays( array &$array1, array $array2 ) { + + // Bail out if the 2nd array is empty, as there's no work to do. + if ( empty( $array2 ) ) { + return; + } + + // If the 1st array is empty, set it to the 2nd array. Then bail out as we're done. + if ( empty( $array1 ) ) { + $array1 = $array2; + + return; + } + + // Both arrays have elements. Let's join them together. + $array1 = array_merge( $array1, $array2 ); +} + /** * Checks if the given input is a URL or data URI. It checks that the given input begins with: * - http diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php index 2205a7f0..04eb9ef0 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php @@ -11,6 +11,7 @@ use _Beans_Uikit; use Beans\Framework\Tests\Unit\API\UIkit\Includes\UIkit_Test_Case; +use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-uikit-test-case.php'; @@ -23,6 +24,17 @@ */ class Tests_BeansUikit_RegisterLessComponents extends UIkit_Test_Case { + /** + * Prepares the test environment before each test. + */ + protected function setUp() { + parent::setUp(); + + Monkey\Functions\when( 'beans_join_arrays' )->alias( function( &$array1, $array2 ) { + $array1 = array_merge( $array1, $array2 ); + }); + } + /** * Test _Beans_Uikit::register_less_components() should return empty array when no theme or components are registered and no 'core' in the global. */ diff --git a/tests/phpunit/unit/api/utilities/beansJoinArrays.php b/tests/phpunit/unit/api/utilities/beansJoinArrays.php new file mode 100644 index 00000000..13eb190b --- /dev/null +++ b/tests/phpunit/unit/api/utilities/beansJoinArrays.php @@ -0,0 +1,123 @@ +assertNull( beans_join_arrays( $array1, $array2 ) ); + $this->assertSame( [], $array1 ); + } + + /** + * Test beans_join_arrays() should not change array 1 when array 2 is empty. + */ + public function test_should_not_change_array1_when_array2_is_empty() { + // Check with associative array. + $array1 = [ + 'post_type' => 'foo', + 'number_of_posts' => 5, + ]; + $array2 = []; + $expected = $array1; + $this->assertNull( beans_join_arrays( $array1, $array2 ) ); + $this->assertSame( $expected, $array1 ); + + // Check with indexed array. + $array1 = [ 'foo', 'bar' ]; + $array2 = []; + $expected = $array1; + $this->assertNull( beans_join_arrays( $array1, $array2 ) ); + $this->assertSame( $expected, $array1 ); + } + + /** + * Test beans_join_arrays() should do nothing when both arrays are empty. + */ + public function test_should_set_array1_to_array2_when_array1_is_empty() { + // Check with associative array. + $array1 = []; + $array2 = [ + 'post_type' => 'foo', + 'number_of_posts' => 5, + ]; + $expected = $array2; + $this->assertNull( beans_join_arrays( $array1, $array2 ) ); + $this->assertSame( $expected, $array1 ); + + // Check with indexed array. + $array1 = []; + $array2 = [ 'foo', 'bar' ]; + $expected = $array2; + $this->assertNull( beans_join_arrays( $array1, $array2 ) ); + $this->assertSame( $expected, $array1 ); + } + + /** + * Test beans_join_arrays() should merge the arrays when both are not empty. + */ + public function test_should_merge_the_arrays_when_both_are_not_empty() { + $array1 = [ + 'post_type' => 'foo', + 'number_of_posts' => 5, + ]; + $array2 = [ + 'foo' => 'bar', + 'baz' => 'Hello', + ]; + $expected = array_merge( $array1, $array2 ); + $this->assertNull( beans_join_arrays( $array1, $array2 ) ); + $this->assertSame( $expected, $array1 ); + + // Check with indexed array. + $array1 = [ 'foo', 'bar' ]; + $array2 = [ 'baz', 98 ]; + $expected = array_merge( $array1, $array2 ); + $this->assertNull( beans_join_arrays( $array1, $array2 ) ); + $this->assertSame( $expected, $array1 ); + + // Check with mixed arrays. + $array1 = [ + 'post_type' => 'foo', + 'number_of_posts' => 5, + ]; + $array2 = [ + 5, + 'bar' => 'foo', + ]; + $expected = array_merge( $array1, $array2 ); + $this->assertNull( beans_join_arrays( $array1, $array2 ) ); + $this->assertSame( $expected, $array1 ); + } +} From d1db7902a5a9c6c63a17df03d4928c9956957c47 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 14:35:39 -0500 Subject: [PATCH 668/800] Optimized adding fixes to _Beans_Uikit::get_less_directories(). If the components array is empty, bail out and return an empty array. Using an empty array here to avoid an additional PHP lookup of the variable. If there are components, then instead of doing an array merge, which is expensive, just add the fixes.less file to the array. Then return the components array. Result: Tiny bit faster. Result of last 3 commits: faster by 0.0004ms (tiny bit faster) ------------------------- MICRO PROFILER REPORT: ------------------------- PHP version: 5.6.20 Sample Size: 100,000 (per function) Time Increments: milliseconds, where 1 ms equals 0.001 second. ------------- ------------- -------------- | Result | Avg Time | v1.4.0 | | (ms) | (ms) | (ms) | | ------------- | ------------- | ------------- | | -0.000433 | 0.014435 | 0.014868 | ------------- -------------- -------------- --- lib/api/uikit/class-beans-uikit.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 42785ed1..1e3e12f0 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -113,17 +113,20 @@ public function register_less_components() { $items = array_merge( array( 'variables' ), $items ); } + // Fetch components from directories. beans_join_arrays( $components, $this->get_components_from_directory( $items, $this->get_less_directories( $type ), 'styles' ) ); } - // Add fixes. - if ( ! empty( $components ) ) { - beans_join_arrays( $components, array( BEANS_API_PATH . 'uikit/src/fixes.less' ) ); + if ( empty( $components ) ) { + return array(); } + // Add fixes. + $components[] = BEANS_API_PATH . 'uikit/src/fixes.less'; + return $components; } From d978957b43d338eae2a3080034b83612247c3023 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 15:30:19 -0500 Subject: [PATCH 669/800] Added _Beans_Uikit::register_js_components() unit tests. --- lib/api/uikit/class-beans-uikit.php | 10 +- .../beans-uikit/registerJsComponents.php | 145 ++++++++++++++++++ 2 files changed, 146 insertions(+), 9 deletions(-) create mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 1e3e12f0..b7a3c29a 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -146,15 +146,7 @@ public function register_js_components() { // Add core before the components. if ( 'core' === $type ) { - $items = array_merge( - array( - 'core', - 'component', - 'utility', - 'touch', - ), - $items - ); + $items = array_merge( array( 'core', 'component', 'utility', 'touch' ), $items ); } // Fetch components from directories. diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php new file mode 100644 index 00000000..ccf5ef70 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php @@ -0,0 +1,145 @@ +alias( function( &$array1, $array2 ) { + $array1 = array_merge( $array1, $array2 ); + }); + } + + /** + * Test _Beans_Uikit::register_js_components() should return empty array when no components are registered and no 'core' in the global. + */ + public function test_should_return_empty_array_when_no_components_registered_and_no_core() { + // Remove "core" from the components. + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components'] = [ 'add-ons' => [] ]; + + // Run the test. + $this->assertEmpty( ( new _Beans_Uikit() )->register_js_components() ); + } + + /** + * Test _Beans_Uikit::register_js_components() should return the base core components when no theme or components are + * registered. + */ + public function test_should_return_base_core_components_when_no_components_registered() { + // Check the global. + global $_beans_uikit_enqueued_items; + $this->assertSame( [ + 'core' => [], + 'add-ons' => [], + ], $_beans_uikit_enqueued_items['components'] ); + + // Run the test. + $this->assertSame( + [ + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/utility.min.js', + BEANS_API_PATH . 'uikit/src/js/core/touch.min.js', + ], + ( new _Beans_Uikit() )->register_js_components() + ); + } + + /** + * Test _Beans_Uikit::register_js_components() should return an array of core paths when components are + * registered. + */ + public function test_should_return_array_of_core_paths_when_components_are_registered() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['core'] = [ 'alert', 'button', 'nav', 'smooth-scroll' ]; + + $this->assertSame( + [ + // Base the core items. + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/utility.min.js', + BEANS_API_PATH . 'uikit/src/js/core/touch.min.js', + // Enqueued items. + BEANS_API_PATH . 'uikit/src/js/core/alert.min.js', + BEANS_API_PATH . 'uikit/src/js/core/button.min.js', + BEANS_API_PATH . 'uikit/src/js/core/nav.min.js', + BEANS_API_PATH . 'uikit/src/js/core/smooth-scroll.min.js', + ], + ( new _Beans_Uikit() )->register_js_components() + ); + } + + /** + * Test _Beans_Uikit::register_less_components() should return an array of add-ons paths when components are + * registered. + */ + public function test_should_return_array_of_add_ons_paths_when_components_are_registered() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['add-ons'] = [ 'accordion', 'notify' ]; + + $this->assertSame( + [ + // Base the core items. + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/utility.min.js', + BEANS_API_PATH . 'uikit/src/js/core/touch.min.js', + // Enqueued items. + BEANS_API_PATH . 'uikit/src/js/components/accordion.min.js', + BEANS_API_PATH . 'uikit/src/js/components/notify.min.js', + ], + ( new _Beans_Uikit() )->register_js_components() + ); + } + + /** + * Test _Beans_Uikit::register_less_components() should return an array of paths when components are registered. + */ + public function test_should_return_array_of_paths_when_components_are_registered() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['core'] = [ 'alert', 'button', 'nav', 'smooth-scroll' ]; + $_beans_uikit_enqueued_items['components']['add-ons'] = [ 'accordion', 'notify' ]; + + $this->assertSame( + [ + // Base the core items. + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/utility.min.js', + BEANS_API_PATH . 'uikit/src/js/core/touch.min.js', + // Enqueued core items. + BEANS_API_PATH . 'uikit/src/js/core/alert.min.js', + BEANS_API_PATH . 'uikit/src/js/core/button.min.js', + BEANS_API_PATH . 'uikit/src/js/core/nav.min.js', + BEANS_API_PATH . 'uikit/src/js/core/smooth-scroll.min.js', + // Enqueued add-on items. + BEANS_API_PATH . 'uikit/src/js/components/accordion.min.js', + BEANS_API_PATH . 'uikit/src/js/components/notify.min.js', + ], + ( new _Beans_Uikit() )->register_js_components() + ); + } +} From 8d8eee32dcc5f8af723d28992211cd62fcd13ddd Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 15:31:10 -0500 Subject: [PATCH 670/800] Improved _Beans_Uikit::register_js_components(). 1. Using beans_join_arrays(). 2. 'component' is not a core JS component file. Removed. --- lib/api/uikit/class-beans-uikit.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index b7a3c29a..fcc95530 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -150,7 +150,10 @@ public function register_js_components() { } // Fetch components from directories. - $components = array_merge( $components, $this->get_components_from_directory( $items, $this->get_js_directories( $type ), 'scripts' ) ); + beans_join_arrays( + $components, + $this->get_components_from_directory( $items, $this->get_js_directories( $type ), 'scripts' ) + ); } return $components; From e0bacaeb6ecc46e58ecc13656b68ba9b672ebdd3 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 15:43:22 -0500 Subject: [PATCH 671/800] Abstracted redundant code to _Beans_Uikit::get_registered_component_paths(). Both the register_less_components() and register_js_components() methods use the same structured loop to build a collection of component file paths. To keep it DRY, this commit moves the loop to a new private method. --- lib/api/uikit/class-beans-uikit.php | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index fcc95530..000c1d7b 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -102,23 +102,7 @@ public function compile() { * @return array */ public function register_less_components() { - global $_beans_uikit_enqueued_items; - - $components = array(); - - foreach ( $_beans_uikit_enqueued_items['components'] as $type => $items ) { - - // Add core before the components. - if ( 'core' === $type ) { - $items = array_merge( array( 'variables' ), $items ); - } - - // Fetch components from directories. - beans_join_arrays( - $components, - $this->get_components_from_directory( $items, $this->get_less_directories( $type ), 'styles' ) - ); - } + $components = $this->get_registered_component_paths( array( 'variables' ) ); if ( empty( $components ) ) { return array(); @@ -138,6 +122,20 @@ public function register_less_components() { * @return array */ public function register_js_components() { + return $this->get_registered_component_paths( array( 'core', 'utility', 'touch' ), false ); + } + + /** + * Gets an array of registered component paths, i.e. absolute path to each component file. + * + * @since 1.5.0 + * + * @param array $core_components Array of core components. + * @param bool $is_less Optional. When true, registering LESS components; else, registering JavaScript components. + * + * @return array + */ + private function get_registered_component_paths( array $core_components, $is_less = true ) { global $_beans_uikit_enqueued_items; $components = array(); @@ -146,14 +144,16 @@ public function register_js_components() { // Add core before the components. if ( 'core' === $type ) { - $items = array_merge( array( 'core', 'component', 'utility', 'touch' ), $items ); + $items = array_merge( $core_components, $items ); } // Fetch components from directories. - beans_join_arrays( - $components, - $this->get_components_from_directory( $items, $this->get_js_directories( $type ), 'scripts' ) + $component_directories = $this->get_components_from_directory( + $items, + $is_less ? $this->get_less_directories( $type ) : $this->get_js_directories( $type ), + $is_less ? 'styles' : 'scripts' ); + beans_join_arrays( $components, $component_directories ); } return $components; From 7ed10d8e9cfeea464f5d24be510a95ef66b79791 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 15:49:37 -0500 Subject: [PATCH 672/800] Moved the beans_join_arrays() mock to the test case. --- .../api/uikit/beans-uikit/registerJsComponents.php | 11 ----------- .../api/uikit/beans-uikit/registerLessComponents.php | 12 ------------ .../api/uikit/includes/class-uikit-test-case.php | 9 ++++++--- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php index ccf5ef70..e3f569a4 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php @@ -24,17 +24,6 @@ */ class Tests_BeansUikit_RegisterJsComponents extends UIkit_Test_Case { - /** - * Prepares the test environment before each test. - */ - protected function setUp() { - parent::setUp(); - - Monkey\Functions\when( 'beans_join_arrays' )->alias( function( &$array1, $array2 ) { - $array1 = array_merge( $array1, $array2 ); - }); - } - /** * Test _Beans_Uikit::register_js_components() should return empty array when no components are registered and no 'core' in the global. */ diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php index 04eb9ef0..2205a7f0 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php @@ -11,7 +11,6 @@ use _Beans_Uikit; use Beans\Framework\Tests\Unit\API\UIkit\Includes\UIkit_Test_Case; -use Brain\Monkey; require_once dirname( __DIR__ ) . '/includes/class-uikit-test-case.php'; @@ -24,17 +23,6 @@ */ class Tests_BeansUikit_RegisterLessComponents extends UIkit_Test_Case { - /** - * Prepares the test environment before each test. - */ - protected function setUp() { - parent::setUp(); - - Monkey\Functions\when( 'beans_join_arrays' )->alias( function( &$array1, $array2 ) { - $array1 = array_merge( $array1, $array2 ); - }); - } - /** * Test _Beans_Uikit::register_less_components() should return empty array when no theme or components are registered and no 'core' in the global. */ diff --git a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php index 2b6a535b..fb1049f2 100644 --- a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php @@ -47,9 +47,6 @@ abstract class UIkit_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->set_up_virtual_filesystem(); - $this->set_up_mocked_functions(); - $this->load_original_functions( array( 'api/utilities/functions.php', 'api/compiler/functions.php', @@ -57,6 +54,8 @@ protected function setUp() { 'api/uikit/class-beans-uikit.php', ) ); + $this->set_up_virtual_filesystem(); + $this->set_up_mocked_functions(); $this->reset_globals(); } @@ -105,6 +104,10 @@ protected function set_up_mocked_functions() { Monkey\Functions\when( 'trailingslashit' )->alias( function( $file ) { return $file . '/'; } ); + + Monkey\Functions\when( 'beans_join_arrays' )->alias( function( &$array1, $array2 ) { + $array1 = array_merge( $array1, $array2 ); + }); } /** From d79a3f3198a1d47f5bca227a76023156f32a528b Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Thu, 31 May 2018 16:59:07 -0400 Subject: [PATCH 673/800] Add and update unit tests --- .../api/widget/beansGetWidgetArea.php | 11 --- .../api/widget/beansGetWidgetAreaOutput.php | 4 +- .../api/widget/beansDeregisterWidgetArea.php | 37 ++++++++ .../unit/api/widget/beansGetWidgetArea.php | 48 +++++++++- .../api/widget/beansGetWidgetAreaOutput.php | 7 +- .../unit/api/widget/beansHasWidgetArea.php | 47 ++++++++++ .../unit/api/widget/beansHaveWidgets.php | 89 +++++++++++++++++++ .../api/widget/beansIsActiveWidgetArea.php | 49 ++++++++++ .../unit/api/widget/beansSetupWidget.php | 77 ++++++++++++++++ .../api/widget/beansWidgetAreaShortcodes.php | 73 +++++++++++++++ 10 files changed, 425 insertions(+), 17 deletions(-) create mode 100644 tests/phpunit/unit/api/widget/beansDeregisterWidgetArea.php create mode 100644 tests/phpunit/unit/api/widget/beansHasWidgetArea.php create mode 100644 tests/phpunit/unit/api/widget/beansHaveWidgets.php create mode 100644 tests/phpunit/unit/api/widget/beansIsActiveWidgetArea.php create mode 100644 tests/phpunit/unit/api/widget/beansSetupWidget.php create mode 100644 tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php diff --git a/tests/phpunit/integration/api/widget/beansGetWidgetArea.php b/tests/phpunit/integration/api/widget/beansGetWidgetArea.php index 473dd9fe..24c8ca2e 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansGetWidgetArea.php @@ -22,17 +22,6 @@ */ class Tests_BeansGetWidgetArea extends Beans_Widget_Test_Case { - /** - * Test beans_get_widget_area() should return false when widget area data is not found. - */ - public function test_should_return_false_when_widget_area_data_not_found() { - // Test for when needle is given. - $this->assertFalse( beans_get_widget_area( 'bogus-needle' ) ); - - // Test for when needle is not given. - $this->assertFalse( beans_get_widget_area() ); - } - /** * Test beans_get_widget_area() should return all widget area data when needle is not specified. */ diff --git a/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php index 821db78f..adba24d6 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php +++ b/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php @@ -50,8 +50,6 @@ public function test_should_return_widget_output_when_widget_area_is_registered( * Get the expected output (html) of the beans default primary sidebar. */ protected function get_expected_output() { - return <<
        -OUTPUT; + return '
        '; } } diff --git a/tests/phpunit/unit/api/widget/beansDeregisterWidgetArea.php b/tests/phpunit/unit/api/widget/beansDeregisterWidgetArea.php new file mode 100644 index 00000000..e173d94b --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansDeregisterWidgetArea.php @@ -0,0 +1,37 @@ +once() + ->with( 'unwanted_sidebar' ) + ->andReturn( null ); + + $this->assertNull( beans_deregister_widget_area( 'unwanted_sidebar' ) ); + } +} diff --git a/tests/phpunit/unit/api/widget/beansGetWidgetArea.php b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php index fb6de8b4..1dfe4d91 100644 --- a/tests/phpunit/unit/api/widget/beansGetWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php @@ -24,9 +24,53 @@ class Tests_BeansGetWidgetArea extends Beans_Widget_Test_Case { /** - * Test beans_get_widget_area() should return all widget area data when the needle is unspecified. + * Test beans_get_widget_area() should return false when widget area data is not found. */ - public function test_should_return_all_widget_area_data_when_needle_unspecified() { + public function test_should_return_false_when_widget_area_data_not_found() { + // Test for when needle is given. + $this->assertFalse( beans_get_widget_area( 'bogus-needle' ) ); + + // Test for when needle is not given. + $this->assertFalse( beans_get_widget_area() ); + } + + /** + * Test beans_get_widget_area() should return all widget area data when needle is not specified. + */ + public function test_should_return_all_data_when_needle_not_specified() { + global $_beans_widget_area; + + $_beans_widget_area = $this->get_expected_sidebar_data(); + + $this->assertSame( $this->get_expected_sidebar_data(), beans_get_widget_area() ); + } + + /** + * Test beans_get_widget_area() should return specific widget data when a needle is specified. + */ + public function test_should_return_specific_widget_data_when_needle_specified() { global $_beans_widget_area; + + $_beans_widget_area = $this->get_expected_sidebar_data(); + + $this->assertEquals( 'test_sidebar', beans_get_widget_area( 'id' ) ); + } + + /** + * Return an array of expected sidebar data. + */ + protected function get_expected_sidebar_data() { + return array( + 'name' => 'Test Sidebar', + 'id' => 'test_sidebar', + 'description' => '', + 'class' => '', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '', + 'after_title' => '', + 'widgets_count' => 0, + 'current_widget' => 0, + ); } } diff --git a/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php index 51ee27dc..ebeeca9b 100644 --- a/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php +++ b/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php @@ -36,7 +36,7 @@ public function test_should_return_false_when_widget_area_not_registered() { } /** - * Test beans_get_widget_area_output() should return output when a widget area is registered. + * Test beans_get_widget_area_output() should call required functions and do required actions when a widget area is registered. */ public function test_should_return_widget_output_when_widget_area_is_registered() { Monkey\Functions\expect( 'beans_has_widget_area' ) @@ -44,6 +44,11 @@ public function test_should_return_widget_output_when_widget_area_is_registered( ->with( 'primary_sidebar' ) ->andReturn( true ); + Monkey\Functions\expect( '_beans_setup_widget_area' ) + ->once() + ->with( 'primary_sidebar' ) + ->andReturn( true ); + Monkey\Functions\expect( '_beans_reset_widget_area' ) ->once() ->andReturn(); diff --git a/tests/phpunit/unit/api/widget/beansHasWidgetArea.php b/tests/phpunit/unit/api/widget/beansHasWidgetArea.php new file mode 100644 index 00000000..c1acca3d --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansHasWidgetArea.php @@ -0,0 +1,47 @@ +assertFalse( beans_has_widget_area( 'unregistered-area' ) ); + } + + /** + * Test beans_has_widget_area() should return true when widget area is registered. + */ + public function testShouldReturnTrueWhenWidgetAreaRegistered() { + global $wp_registered_sidebars; + + $wp_registered_sidebars['test_sidebar'] = array( + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ); + + // Run test. + $this->assertTrue( beans_has_widget_area( 'test_sidebar' ) ); + } +} diff --git a/tests/phpunit/unit/api/widget/beansHaveWidgets.php b/tests/phpunit/unit/api/widget/beansHaveWidgets.php new file mode 100644 index 00000000..cff9449b --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansHaveWidgets.php @@ -0,0 +1,89 @@ +once() + ->with( 'widgets', array() ) + ->andReturn( false ); + + $this->assertFalse( beans_have_widgets() ); + } + + /** + * Test beans_have_widget() should return true when more widgets are available. + */ + public function test_should_return_true_when_widgets_available() { + global $_beans_widget_area; + + $_beans_widget_area = array( + 'widgets' => array( + 'text-1' => array( 'id' => 'text-1' ), + 'text-2' => array( 'id' => 'text-2' ), + ), + 'current_widget' => 1, + ); + + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'widgets', $_beans_widget_area ) + ->andReturn( $_beans_widget_area['widgets'] ); + + $this->assertTrue( beans_have_widgets() ); + } + + /** + * Test beans_have_widget() should return call _beans_reset_widget() and return false when at the end of the widget loop. + */ + public function test_should_call_beans_reset_widget_and_return_false_when_end_of_widget_loop() { + global $_beans_widget_area; + + $_beans_widget_area = array( + 'widgets' => array( + 'text-1' => array( 'id' => 'text-1' ), + 'text-2' => array( 'id' => 'text-2' ), + ), + 'current_widget' => 2, + ); + + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'widgets', $_beans_widget_area ) + ->andReturn( $_beans_widget_area['widgets'] ); + + Monkey\Functions\expect( '_beans_reset_widget') + ->once(); + + $this->assertFalse( beans_have_widgets() ); + } + +} diff --git a/tests/phpunit/unit/api/widget/beansIsActiveWidgetArea.php b/tests/phpunit/unit/api/widget/beansIsActiveWidgetArea.php new file mode 100644 index 00000000..90824082 --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansIsActiveWidgetArea.php @@ -0,0 +1,49 @@ +once() + ->with( 'inactive-widget-area' ) + ->andReturn( false ); + + $this->assertFalse( beans_is_active_widget_area( 'inactive-widget-area' ) ); + } + + /** + * Test beans_is_active_widget_area() should return true when widget area is active. + */ + public function testShouldReturnTrueWhenWidgetAreaIsActive() { + Monkey\Functions\expect( 'is_active_sidebar' ) + ->once() + ->with( 'active-sidebar' ) + ->andReturn( true ); + + $this->assertTrue( beans_is_active_widget_area( 'active-sidebar' ) ); + } +} diff --git a/tests/phpunit/unit/api/widget/beansSetupWidget.php b/tests/phpunit/unit/api/widget/beansSetupWidget.php new file mode 100644 index 00000000..82386e78 --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansSetupWidget.php @@ -0,0 +1,77 @@ + array( + 'text-1' => array( 'id' => 'text-1' ), + 'text-2' => array( 'id' => 'text-2' ), + ), + 'current_widget' => 2, + ); + + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( $_beans_widget_area['current_widget'], array( 'text-1', 'text-2' ) ) + ->andReturn( false ); + + $this->assertFalse( beans_setup_widget() ); + } + + /** + * Test beans_setup_widget() should advance widget pointer, prepare widget data, and return true when a widget ID is found. + */ + public function test_should_return_advance_widget_pointer_prepare_widget_data_and_return_true_when_widget_id_is_found() { + global $_beans_widget_area; + + $_beans_widget_area = array( + 'widgets' => array( + 'text-1' => array( 'id' => 'text-1' ), + 'text-2' => array( 'id' => 'text-2' ), + ), + 'current_widget' => 1, + ); + + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( $_beans_widget_area['current_widget'], array( 'text-1', 'text-2' ) ) + ->andReturn( 'text-2' ); + + Monkey\Functions\expect( '_beans_prepare_widget_data' ) + ->once() + ->with( 'text-2' ); + + // Run test. + $this->assertTrue( beans_setup_widget() ); + + // Verify widget pointer has advanced. + $this->assertEquals( 2, $_beans_widget_area['current_widget'] ); + } +} diff --git a/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php new file mode 100644 index 00000000..b26c3062 --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php @@ -0,0 +1,73 @@ +never(); + + Monkey\Functions\expect( 'beans_array_shortcodes' ) + ->once() + ->with( 'Content with a {key}.', array( 'Widget Area Data' ) ) + ->andReturn( 'Content with a shortcode value.' ); + + // Run test for content as a string. + $this->assertEquals( + 'Content with a shortcode value.', + beans_widget_area_shortcodes( 'Content with a {key}.' ) + ); + } + + /** + * Test beans_widget_area_shortcodes() should return content with shortcodes filtered out when content is given as an array. + */ + public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_arrau() { + global $_beans_widget_area; + + $_beans_widget_area = array( 'Widget Area Data' ); + + Monkey\Functions\expect( 'build_query' ) + ->once() + ->with( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) + ->andReturn( 'someURLparemetername=URL content with a {key}.' ); + + + Monkey\Functions\expect( 'beans_array_shortcodes' ) + ->once() + ->with( 'someURLparemetername=URL content with a {key}.', array( 'Widget Area Data' ) ) + ->andReturn( 'someURLparemetername=URL content with a shortcode value.' ); + + // Run test for content as a string. + $this->assertEquals( + 'someURLparemetername=URL content with a shortcode value.', + beans_widget_area_shortcodes( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) + ); + } +} From 6ec022d8d5f11b80ee43fe6fb211cb01fb11eae5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 17:27:52 -0500 Subject: [PATCH 674/800] Added _Beans_Uikit::get_all_components() unit tests. --- .../uikit/beans-uikit/getAllComponents.php | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getAllComponents.php diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getAllComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/getAllComponents.php new file mode 100644 index 00000000..00ab1a57 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getAllComponents.php @@ -0,0 +1,162 @@ +get_all_components( 'core' ); + $this->assertCount( static::$number_core_less_files + static::$number_core_js_files, $actual ); + + // Check common components. + $this->assertContains( 'alert', $actual ); + $this->assertContains( 'button', $actual ); + $this->assertContains( 'cover', $actual ); + $this->assertContains( 'grid', $actual ); + $this->assertContains( 'nav', $actual ); + $this->assertContains( 'offcanvas', $actual ); + $this->assertContains( 'tab', $actual ); + $this->assertContains( 'utility', $actual ); + + // Spot check the unique LESS components. + $this->assertContains( 'base', $actual ); + $this->assertContains( 'close', $actual ); + $this->assertContains( 'column', $actual ); + $this->assertContains( 'description-list', $actual ); + $this->assertContains( 'thumbnail', $actual ); + $this->assertContains( 'variables', $actual ); + + // Spot check the unique JS components. + $this->assertContains( 'core', $actual ); + $this->assertContains( 'scrollspy', $actual ); + $this->assertContains( 'smooth-scroll', $actual ); + $this->assertContains( 'toggle', $actual ); + $this->assertContains( 'touch', $actual ); + + // Check the components do not contain add-ons. + $this->assertNotContains( 'accordion', $actual ); + $this->assertNotContains( 'datepicker', $actual ); + $this->assertNotContains( 'notify', $actual ); + $this->assertNotContains( 'progress', $actual ); + } + + /** + * Test _Beans_Uikit::get_all_components() should return all add-ons components. + */ + public function test_should_return_all_add_ons_components() { + $beans_uikit = new _Beans_Uikit(); + + $actual = $beans_uikit->get_all_components( 'add-ons' ); + $this->assertCount( static::$number_components_less_files + static::$number_components_js_files, $actual ); + + // Check common components. + $this->assertContains( 'accordion', $actual ); + $this->assertContains( 'autocomplete', $actual ); + $this->assertContains( 'datepicker', $actual ); + $this->assertContains( 'form-password', $actual ); + $this->assertContains( 'search', $actual ); + $this->assertContains( 'sticky', $actual ); + $this->assertContains( 'tooltip', $actual ); + $this->assertContains( 'upload', $actual ); + + // Spot check the unique LESS components. + $this->assertContains( 'dotnav', $actual ); + $this->assertContains( 'form-advanced', $actual ); + $this->assertContains( 'htmleditor', $actual ); + + // Spot check the unique JS components. + $this->assertContains( 'parallax', $actual ); + $this->assertContains( 'lightbox', $actual ); + $this->assertContains( 'slideshow-fx', $actual ); + $this->assertContains( 'timepicker', $actual ); + + // Check the components do not contain add-ons. + $this->assertNotContains( 'alert', $actual ); + $this->assertNotContains( 'badge', $actual ); + $this->assertNotContains( 'base', $actual ); + $this->assertNotContains( 'close', $actual ); + } + + /** + * Counts the files in the given source directory. + * + * @since 1.5.0 + * + * @param string $dir Given directory to scan. + * + * @return int + */ + private static function count_files_in_dir( $dir ) { + $files = scandir( $dir ); + + if ( '.' === $files[0] ) { + unset( $files[0], $files[1] ); + } + + return count( $files ); + } +} From 8b6ce752270e21c3e7dcc3e6eacc0283a732ed5b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 17:46:39 -0500 Subject: [PATCH 675/800] Used beans_join_arrays() for _Beans_Uikit::get_all_components(). --- lib/api/uikit/class-beans-uikit.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 000c1d7b..584ab9bd 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -131,7 +131,8 @@ public function register_js_components() { * @since 1.5.0 * * @param array $core_components Array of core components. - * @param bool $is_less Optional. When true, registering LESS components; else, registering JavaScript components. + * @param bool $is_less Optional. When true, registering LESS components; else, registering JavaScript + * components. * * @return array */ @@ -269,11 +270,11 @@ public function get_all_components( $type ) { // Unset scandir defaults. unset( $scandir[0], $scandir[1] ); - // Only return the filname and remove empty elements. - $components = array_merge( $components, array_filter( array_map( array( - $this, - 'to_filename', - ), $scandir ) ) ); + // Only return the filename (i.e. component name) and remove empty elements. + beans_join_arrays( + $components, + array_filter( array_map( array( $this, 'to_filename' ), $scandir ) ) + ); } return $components; From 35c82bb3acecc64fbf6e833cadb3b9b421989694 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 17:49:03 -0500 Subject: [PATCH 676/800] Get rid of dot files only when on Linux-based environments. - Moved the get all files tasks to a separate method. - Added check to ensure the first file actually is a dot file. If no, don't unset the first 2 files. (such as when on a Windows machine) --- lib/api/uikit/class-beans-uikit.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 584ab9bd..0d6b0023 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -265,10 +265,7 @@ public function get_all_components( $type ) { continue; } - $scandir = scandir( $dir_path ); - - // Unset scandir defaults. - unset( $scandir[0], $scandir[1] ); + $scandir = $this->get_all_files( $dir_path ); // Only return the filename (i.e. component name) and remove empty elements. beans_join_arrays( @@ -280,6 +277,27 @@ public function get_all_components( $type ) { return $components; } + /** + * Gets all of the files and folders from the given directory. When on a Linux-based machine, + * removes the '.' and '..' files. + * + * @since 1.5.0 + * + * @param string $directory Absolute path to the source directory. + * + * @return array + */ + private function get_all_files( $directory ) { + $files = scandir( $directory ); + + // Get rid of dot files when on Linux environment. + if ( '.' === $files[0] ) { + unset( $files[0], $files[1] ); + } + + return $files; + } + /** * Gets all of the required dependencies for the given components. * From 3bef93443e191580aeaa2be1b8763848d2cf632f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 17:55:29 -0500 Subject: [PATCH 677/800] Refactored _Beans_Uikit::get_all_components() to be more readable. There's a lot going on with the array map and filter. This commit moves all the work (associated with building the array of components) to another line and stores the result in a variable. That variable name makes the code more readable and understandable. --- lib/api/uikit/class-beans-uikit.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 0d6b0023..d5d51d14 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -265,13 +265,15 @@ public function get_all_components( $type ) { continue; } - $scandir = $this->get_all_files( $dir_path ); - - // Only return the filename (i.e. component name) and remove empty elements. - beans_join_arrays( - $components, - array_filter( array_map( array( $this, 'to_filename' ), $scandir ) ) + // Build an array of component names (i.e. filenames only). + $component_names = array_filter( + array_map( + array( $this, 'to_filename' ), + $this->get_all_files( $dir_path ) + ) ); + + beans_join_arrays( $components, $component_names ); } return $components; From 09be315fa8d51116d470d23827072e4fa066390b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 17:59:17 -0500 Subject: [PATCH 678/800] Optimized by moving remove empties to last step. Previously, _Beans_Uikit::get_all_components() ran array_filter on each loop through the file builder. Moved it outside of the loop to remove all empties from the final components array, i.e. it now runs once. --- lib/api/uikit/class-beans-uikit.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index d5d51d14..3bf9664e 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -266,16 +266,14 @@ public function get_all_components( $type ) { } // Build an array of component names (i.e. filenames only). - $component_names = array_filter( - array_map( - array( $this, 'to_filename' ), - $this->get_all_files( $dir_path ) - ) - ); + $component_names = array_map( array( $this, 'to_filename' ), $this->get_all_files( $dir_path ) ); beans_join_arrays( $components, $component_names ); } + // Remove empties. + $components = array_filter( $components ); + return $components; } From 4d1aa97c8006b565194cae65c8c89432e61546ef Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 18:35:30 -0500 Subject: [PATCH 679/800] Removed duplicate components from _Beans_Uikit::get_all_components(). There are a lot of common components in the JS and LESS directories. By removing the duplicates, we gain the following: - Reduce the state memory size being passed around. - Reduce processing time later when iterating over the collection. Plus it just makes sense to return a collection with just one instance of each component. --- lib/api/uikit/class-beans-uikit.php | 21 +++-- .../uikit/beans-uikit/getAllComponents.php | 88 +++++++------------ 2 files changed, 48 insertions(+), 61 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 3bf9664e..2150d7dc 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -271,10 +271,8 @@ public function get_all_components( $type ) { beans_join_arrays( $components, $component_names ); } - // Remove empties. - $components = array_filter( $components ); - - return $components; + // Clean up by removing duplicates and empties. + return array_filter( $this->get_unique_values( $components ) ); } /** @@ -344,12 +342,25 @@ private function remove_duplicate_values( array $source ) { continue; } - $source[ $key ] = array_values( array_unique( $value ) ); + $source[ $key ] = $this->get_unique_values( $value ); } return $source; } + /** + * Get an array of unique values from the given array. + * + * @since 1.5.0 + * + * @param array $array The given array to process. + * + * @return array + */ + private function get_unique_values( array $array ) { + return array_values( array_unique( $array ) ); + } + /** * Initialize the components' dependencies, by loading from its configuration file when null. * diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getAllComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/getAllComponents.php index 00ab1a57..aeac8cef 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/getAllComponents.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getAllComponents.php @@ -24,53 +24,50 @@ class Tests_BeansUikit_GetAllComponents extends UIkit_Test_Case { /** - * Number of core LESS files. - * - * @var int + * Test _Beans_Uikit::get_all_components() should not return duplicate core components. */ - protected static $number_core_less_files = 0; + public function test_should_not_return_duplicate_core_components() { + $actual = ( new _Beans_Uikit() )->get_all_components( 'core' ); - /** - * Number of core JavaScript files. - * - * @var int - */ - protected static $number_core_js_files = 0; + // Get the number of times each component appears in the array. + $num_times_component_in_array = array_count_values( $actual ); - /** - * Number of component (add-ons) LESS files. - * - * @var int - */ - protected static $number_components_less_files = 0; + // Spot check the common components that are in both JS and LESS directories, meaning they could be duplicated. + $this->assertEquals( 1, $num_times_component_in_array['alert'] ); + $this->assertEquals( 1, $num_times_component_in_array['button'] ); + $this->assertEquals( 1, $num_times_component_in_array['cover'] ); + $this->assertEquals( 1, $num_times_component_in_array['tab'] ); - /** - * Number of component (add-ons) JavaScript files. - * - * @var int - */ - protected static $number_components_js_files = 0; + // By flipping the array, we should only have 1 element when there are no duplicates. + $this->assertCount( 1, array_flip( $num_times_component_in_array ) ); + } /** - * This method is called before the first test of this test class is run. + * Test _Beans_Uikit::get_all_components() should not return duplicate add-ons components. */ - public static function setUpBeforeClass() { - parent::setUpBeforeClass(); + public function test_should_not_return_duplicate_add_ons_components() { + $actual = ( new _Beans_Uikit() )->get_all_components( 'add-ons' ); + + // Get the number of times each component appears in the array. + $num_times_component_in_array = array_count_values( $actual ); + + // Spot check the common components that are in both JS and LESS directories, meaning they could be duplicated. + $this->assertEquals( 1, $num_times_component_in_array['accordion'] ); + $this->assertEquals( 1, $num_times_component_in_array['autocomplete'] ); + $this->assertEquals( 1, $num_times_component_in_array['datepicker'] ); + $this->assertEquals( 1, $num_times_component_in_array['sticky'] ); + $this->assertEquals( 1, $num_times_component_in_array['tooltip'] ); - static::$number_core_less_files = static::count_files_in_dir( BEANS_API_PATH . 'uikit/src/less/core' ); - static::$number_core_js_files = static::count_files_in_dir( BEANS_API_PATH . 'uikit/src/js/core' ); - static::$number_components_less_files = static::count_files_in_dir( BEANS_API_PATH . 'uikit/src/less/components' ); - static::$number_components_js_files = static::count_files_in_dir( BEANS_API_PATH . 'uikit/src/js/components' ); + // By flipping the array, we should only have 1 element when there are no duplicates. + $this->assertCount( 1, array_flip( $num_times_component_in_array ) ); } /** * Test _Beans_Uikit::get_all_components() should return all core components. */ public function test_should_return_all_core_components() { - $beans_uikit = new _Beans_Uikit(); - - $actual = $beans_uikit->get_all_components( 'core' ); - $this->assertCount( static::$number_core_less_files + static::$number_core_js_files, $actual ); + $actual = ( new _Beans_Uikit() )->get_all_components( 'core' ); + $this->assertCount( 42, $actual ); // Check common components. $this->assertContains( 'alert', $actual ); @@ -108,10 +105,8 @@ public function test_should_return_all_core_components() { * Test _Beans_Uikit::get_all_components() should return all add-ons components. */ public function test_should_return_all_add_ons_components() { - $beans_uikit = new _Beans_Uikit(); - - $actual = $beans_uikit->get_all_components( 'add-ons' ); - $this->assertCount( static::$number_components_less_files + static::$number_components_js_files, $actual ); + $actual = ( new _Beans_Uikit() )->get_all_components( 'add-ons' ); + $this->assertCount( 29, $actual ); // Check common components. $this->assertContains( 'accordion', $actual ); @@ -140,23 +135,4 @@ public function test_should_return_all_add_ons_components() { $this->assertNotContains( 'base', $actual ); $this->assertNotContains( 'close', $actual ); } - - /** - * Counts the files in the given source directory. - * - * @since 1.5.0 - * - * @param string $dir Given directory to scan. - * - * @return int - */ - private static function count_files_in_dir( $dir ) { - $files = scandir( $dir ); - - if ( '.' === $files[0] ) { - unset( $files[0], $files[1] ); - } - - return count( $files ); - } } From ac759c064099439f28904906eb7c62f502a007dd Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 31 May 2018 19:17:24 -0500 Subject: [PATCH 680/800] Fixed formatting. --- lib/api/uikit/class-beans-uikit.php | 1 - .../phpunit/unit/api/uikit/includes/class-uikit-test-case.php | 4 ++-- tests/phpunit/unit/api/utilities/beansJoinArrays.php | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 2150d7dc..e26ae328 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -389,7 +389,6 @@ private function init_component_dependencies() { public function to_filename( $file ) { $pathinfo = pathinfo( $file ); - // If the given file is not valid, bail out. if ( ! isset( $pathinfo['filename'] ) ) { return null; diff --git a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php index fb1049f2..3fc62f40 100644 --- a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php @@ -77,7 +77,7 @@ protected function get_virtual_structure() { return [ 'beans-child' => [ 'assets' => [ - 'js' => [ + 'js' => [ 'alert.min.js' => '', ], 'less' => [ @@ -107,7 +107,7 @@ protected function set_up_mocked_functions() { Monkey\Functions\when( 'beans_join_arrays' )->alias( function( &$array1, $array2 ) { $array1 = array_merge( $array1, $array2 ); - }); + } ); } /** diff --git a/tests/phpunit/unit/api/utilities/beansJoinArrays.php b/tests/phpunit/unit/api/utilities/beansJoinArrays.php index 13eb190b..78f2c20e 100644 --- a/tests/phpunit/unit/api/utilities/beansJoinArrays.php +++ b/tests/phpunit/unit/api/utilities/beansJoinArrays.php @@ -34,8 +34,8 @@ protected function setUp() { * Test beans_join_arrays() should do nothing when both arrays are empty. */ public function test_should_do_nothing_when_both_arrays_are_empty() { - $array1 = []; - $array2 = []; + $array1 = []; + $array2 = []; $this->assertNull( beans_join_arrays( $array1, $array2 ) ); $this->assertSame( [], $array1 ); } From c16e4da0a0fcbd6ca99c9bc82c51870270bb3a9a Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Fri, 1 Jun 2018 14:50:26 -0400 Subject: [PATCH 681/800] Add Unit Tests --- lib/api/widget/functions.php | 8 +- .../integration/api/widget/beansGetWidget.php | 49 ++++++++ .../api/widget/beansRegisterWidgetArea.php | 4 +- .../api/widget/beansSetupWidgetArea.php | 7 -- .../api/widget/beansSetupWidgets.php | 21 +--- .../api/widget/beansWidgetShortcodes.php | 47 ++++++++ .../unit/api/widget/beansGetWidget.php | 77 +++++++++++++ .../unit/api/widget/beansGetWidgetArea.php | 13 ++- .../api/widget/beansPrepareWidgetData.php | 43 +++++++ .../api/widget/beansResetWidget.php | 9 +- .../api/widget/beansResetWidgetArea.php | 9 +- .../unit/api/widget/beansSetupWidgetArea.php | 66 +++++++++++ .../unit/api/widget/beansSetupWidgets.php | 108 ++++++++++++++++++ .../api/widget/beansWidgetAreaSubfilters.php | 36 ++++++ .../unit/api/widget/beansWidgetShortcodes.php | 73 ++++++++++++ .../unit/api/widget/beansWidgetSubfilters.php | 40 +++++++ 16 files changed, 565 insertions(+), 45 deletions(-) create mode 100644 tests/phpunit/integration/api/widget/beansGetWidget.php create mode 100644 tests/phpunit/integration/api/widget/beansWidgetShortcodes.php create mode 100644 tests/phpunit/unit/api/widget/beansGetWidget.php create mode 100644 tests/phpunit/unit/api/widget/beansPrepareWidgetData.php rename tests/phpunit/{integration => unit}/api/widget/beansResetWidget.php (79%) rename tests/phpunit/{integration => unit}/api/widget/beansResetWidgetArea.php (80%) create mode 100644 tests/phpunit/unit/api/widget/beansSetupWidgetArea.php create mode 100644 tests/phpunit/unit/api/widget/beansSetupWidgets.php create mode 100644 tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php create mode 100644 tests/phpunit/unit/api/widget/beansWidgetShortcodes.php create mode 100644 tests/phpunit/unit/api/widget/beansWidgetSubfilters.php diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 2adb3381..7331163a 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -279,16 +279,16 @@ function beans_setup_widget() { * * @param string|bool $needle Optional. The searched widget needle. * - * @return string The current widget data, or field data if the needle is specified. False if not found. + * @return string|bool The current widget data, or field data if the needle is specified. False if not found. */ function beans_get_widget( $needle = false ) { global $_beans_widget; if ( ! $needle ) { - return $_beans_widget; + return $_beans_widget ? $_beans_widget : false; } - return beans_get( $needle, $_beans_widget ); + return beans_get( $needle, $_beans_widget, false ); } /** @@ -299,7 +299,7 @@ function beans_get_widget( $needle = false ) { * * @since 1.0.0 * - * @param string $content Content containing the shortcode(s) delimited with curly brackets (e.g. {key}). + * @param string|array $content Content containing the shortcode(s) delimited with curly brackets (e.g. {key}). * Shortcode(s) correspond to the searched array key and will be replaced by the array * value if found. * diff --git a/tests/phpunit/integration/api/widget/beansGetWidget.php b/tests/phpunit/integration/api/widget/beansGetWidget.php new file mode 100644 index 00000000..b02c1d26 --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansGetWidget.php @@ -0,0 +1,49 @@ +get_widget_test_data(); + + $this->assertEquals( 'text-2', beans_get_widget( 'id' ) ); + } + + /** + * Return an array of expected sidebar data. + */ + protected function get_widget_test_data() { + return array( + 'name' => 'Test Widget', + 'id' => 'text-2', + 'description' => 'Some description', + 'class' => 'widgettext', + 'title' => 'Test Widget Title', + 'text' => 'Arbitrary text content.', + ); + } +} \ No newline at end of file diff --git a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php index 9716cf13..a5286fb1 100644 --- a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php @@ -30,9 +30,9 @@ public function test_should_return_empty_string_when_ID_not_set() { } /** - * Test beans_register_widget_area() should return the widget area id when the widget area is registered. + * Test beans_register_widget_area() should register a sidebar and return the widget area id when the widget area is registered. */ - public function test_should_return_widget_area_ID_when_widget_area_registered() { + public function test_should_register_sidebar_and_return_widget_area_ID_when_widget_area_registered() { global $wp_registered_sidebars; // Verify new widget area is not yet added. diff --git a/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php b/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php index c8b0ece8..1f385f57 100644 --- a/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php @@ -22,13 +22,6 @@ */ class Tests_BeansSetupWidgetArea extends Beans_Widget_Test_Case { - /** - * Test _beans_setup_widget_area() should return false when the sidebar ID is not set. - */ - public function test_should_return_false_when_sidebar_id_not_set() { - $this->assertFalse( _beans_setup_widget_area( 'missing_sidebar' ) ); - } - /** * Test _beans_setup_widget_area() should build widget area data and return true when widget area exists. */ diff --git a/tests/phpunit/integration/api/widget/beansSetupWidgets.php b/tests/phpunit/integration/api/widget/beansSetupWidgets.php index 5e1f92d6..0363c3b9 100644 --- a/tests/phpunit/integration/api/widget/beansSetupWidgets.php +++ b/tests/phpunit/integration/api/widget/beansSetupWidgets.php @@ -22,24 +22,6 @@ */ class Tests_BeansSetupWidgets extends Beans_Widget_Test_Case { - /** - * Test _beans_setup_widgets() should ignore non-widgetized content. - */ - public function test_should_ignore_non_widgetized_content() { - $this->assertEmpty( _beans_setup_widgets( 'random non-widget string' ) ); - } - - /** - * Test _beans_setup_widgets() should skip a widget if it has not been registered. - */ - public function test_should_ignore_widget_when_widget_not_registered() { - global $wp_registered_widgets; - - $wp_registered_widgets = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: ensures no widgets are registered for this test. - - $this->assertEmpty( _beans_setup_widgets( 'widget output' ) ); - } - /** * Test _beans_setup_widgets() should return widget data when the widget is registered. */ @@ -49,8 +31,7 @@ public function test_should_return_widget_data_when_widget_is_registered() { $this->assertSame( $this->get_expected_widget_setup_data(), - _beans_setup_widgets( 'widget output' - ) + _beans_setup_widgets( 'widget output' ) ); } diff --git a/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php b/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php new file mode 100644 index 00000000..a9202219 --- /dev/null +++ b/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php @@ -0,0 +1,47 @@ +assertEquals( + 'Content with a shortcode value.', + beans_widget_shortcodes( 'Content with a {key}.' ) + ); + + // Run test for content as an array. + $this->assertEquals( + 'someURLparemetername=URL content with a shortcode value.', + beans_widget_shortcodes( + array( 'someURLparemetername' => 'URL content with a {key}.' ) + ) + ); + } +} diff --git a/tests/phpunit/unit/api/widget/beansGetWidget.php b/tests/phpunit/unit/api/widget/beansGetWidget.php new file mode 100644 index 00000000..86985854 --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansGetWidget.php @@ -0,0 +1,77 @@ +assertFalse( beans_get_widget( 'bogus-needle' ) ); + + // Test for when needle is not given. + $this->assertFalse( beans_get_widget() ); + } + + /** + * Test beans_get_widget() should return all widget data when needle is not specified. + */ + public function test_should_return_all_data_when_needle_not_specified() { + global $_beans_widget; + + $_beans_widget = $this->get_widget_test_data(); + + $this->assertSame( $this->get_widget_test_data(), beans_get_widget() ); + } + + /** + * Test beans_get_widget() should return specific widget data when a needle is specified. + */ + public function test_should_return_specific_widget_data_when_needle_specified() { + global $_beans_widget; + + $_beans_widget = $this->get_widget_test_data(); + + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'id', $_beans_widget, false ) + ->andReturn( 'text-2' ); + + $this->assertEquals( 'text-2', beans_get_widget( 'id' ) ); + } + + /** + * Return an array of expected sidebar data. + */ + protected function get_widget_test_data() { + return array( + 'name' => 'Test Widget', + 'id' => 'text-2', + 'description' => 'Some description', + 'class' => 'widgettext', + 'title' => 'Test Widget Title', + 'text' => 'Arbitrary text content.', + ); + } +} \ No newline at end of file diff --git a/tests/phpunit/unit/api/widget/beansGetWidgetArea.php b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php index 1dfe4d91..0b357cf5 100644 --- a/tests/phpunit/unit/api/widget/beansGetWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php @@ -40,9 +40,9 @@ public function test_should_return_false_when_widget_area_data_not_found() { public function test_should_return_all_data_when_needle_not_specified() { global $_beans_widget_area; - $_beans_widget_area = $this->get_expected_sidebar_data(); + $_beans_widget_area = $this->get_sidebar_test_data(); - $this->assertSame( $this->get_expected_sidebar_data(), beans_get_widget_area() ); + $this->assertSame( $this->get_sidebar_test_data(), beans_get_widget_area() ); } /** @@ -51,7 +51,12 @@ public function test_should_return_all_data_when_needle_not_specified() { public function test_should_return_specific_widget_data_when_needle_specified() { global $_beans_widget_area; - $_beans_widget_area = $this->get_expected_sidebar_data(); + $_beans_widget_area = $this->get_sidebar_test_data(); + + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'id', $_beans_widget_area, false ) + ->andReturn( 'test_sidebar' ); $this->assertEquals( 'test_sidebar', beans_get_widget_area( 'id' ) ); } @@ -59,7 +64,7 @@ public function test_should_return_specific_widget_data_when_needle_specified() /** * Return an array of expected sidebar data. */ - protected function get_expected_sidebar_data() { + protected function get_sidebar_test_data() { return array( 'name' => 'Test Sidebar', 'id' => 'test_sidebar', diff --git a/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php b/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php new file mode 100644 index 00000000..d3924bb6 --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php @@ -0,0 +1,43 @@ +once() + ->with( 'widgets' ) + ->andReturn( array( 'text-2' => array( 'id' => 'text-2', 'name' => 'Test Widget' ) ) ); + + // Call the function. + _beans_prepare_widget_data( 'text-2' ); + + // Verify that widget data is now prepared. + $this->assertContains( 'Test Widget', $_beans_widget ); + } +} diff --git a/tests/phpunit/integration/api/widget/beansResetWidget.php b/tests/phpunit/unit/api/widget/beansResetWidget.php similarity index 79% rename from tests/phpunit/integration/api/widget/beansResetWidget.php rename to tests/phpunit/unit/api/widget/beansResetWidget.php index e83d96ed..59553327 100644 --- a/tests/phpunit/integration/api/widget/beansResetWidget.php +++ b/tests/phpunit/unit/api/widget/beansResetWidget.php @@ -2,21 +2,22 @@ /** * Tests for _beans_reset_widget() * - * @package Beans\Framework\Tests\Integration\API\Widget + * @package Beans\Framework\Tests\Unit\API\Widget * * @since 1.5.0 */ -namespace Beans\Framework\Tests\Integration\API\Widget; +namespace Beans\Framework\Tests\Unit\API\Widget; -use Beans\Framework\Tests\Integration\API\Widget\Includes\Beans_Widget_Test_Case; +use Beans\Framework\Tests\Unit\API\Widget\Includes\Beans_Widget_Test_Case; +use Brain\Monkey; require_once dirname( __FILE__ ) . '/includes/class-beans-widget-test-case.php'; /** * Class Tests_BeansResetWidget * - * @package Beans\Framework\Tests\Integration\API\Widget + * @package Beans\Framework\Tests\Unit\API\Widget * @group api * @group api-widget */ diff --git a/tests/phpunit/integration/api/widget/beansResetWidgetArea.php b/tests/phpunit/unit/api/widget/beansResetWidgetArea.php similarity index 80% rename from tests/phpunit/integration/api/widget/beansResetWidgetArea.php rename to tests/phpunit/unit/api/widget/beansResetWidgetArea.php index 799d678b..34ae2348 100644 --- a/tests/phpunit/integration/api/widget/beansResetWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansResetWidgetArea.php @@ -2,21 +2,22 @@ /** * Tests for _beans_reset_widget_area() * - * @package Beans\Framework\Tests\Integration\API\Widget + * @package Beans\Framework\Tests\Unit\API\Widget * * @since 1.5.0 */ -namespace Beans\Framework\Tests\Integration\API\Widget; +namespace Beans\Framework\Tests\Unit\API\Widget; -use Beans\Framework\Tests\Integration\API\Widget\Includes\Beans_Widget_Test_Case; +use Beans\Framework\Tests\Unit\API\Widget\Includes\Beans_Widget_Test_Case; +use Brain\Monkey; require_once dirname( __FILE__ ) . '/includes/class-beans-widget-test-case.php'; /** * Class Tests_BeansResetWidgetArea * - * @package Beans\Framework\Tests\Integration\API\Widget + * @package Beans\Framework\Tests\Unit\API\Widget * @group api * @group api-widget */ diff --git a/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php b/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php new file mode 100644 index 00000000..c1580eac --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php @@ -0,0 +1,66 @@ +assertFalse( _beans_setup_widget_area( 'missing_sidebar' ) ); + } + + /** + * Test _beans_setup_widget_area() should build widget area data and return true when widget area exists. + */ + public function test_should_build_widget_area_data_and_return_true_when_widget_area_exists() { + global $_beans_widget_area, $wp_registered_sidebars;; + + $wp_registered_sidebars = array( + 'sidebar_primary' => array(), + 'sidebar_secondary' => array(), + 'test_sidebar' => array(), + ); + + Monkey\Functions\expect( 'beans_render_function') + ->once() + ->with( 'dynamic_sidebar', 'test_sidebar' ) + ->andReturn( 'Some widget output' ); + + Monkey\Functions\expect('_beans_setup_widgets') + ->once() + ->with('Some widget output') + ->andReturnFirstArg(); + + // Run test. + $this->assertTrue( _beans_setup_widget_area( 'test_sidebar' ) ); + + // Verify widget area data has been set up. + $this->assertContains( 'test_sidebar', $_beans_widget_area ); + $this->assertArrayHasKey( 'widgets_count', $_beans_widget_area ); + $this->assertArrayHasKey( 'current_widget', $_beans_widget_area ); + $this->assertArrayHasKey( 'before_widgets', $_beans_widget_area ); + $this->assertArrayHasKey( 'widgets', $_beans_widget_area ); + $this->assertArrayHasKey( 'after_widgets', $_beans_widget_area ); + } +} diff --git a/tests/phpunit/unit/api/widget/beansSetupWidgets.php b/tests/phpunit/unit/api/widget/beansSetupWidgets.php new file mode 100644 index 00000000..e074865e --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansSetupWidgets.php @@ -0,0 +1,108 @@ +assertEmpty( _beans_setup_widgets( 'random non-widget string' ) ); +// } + + /** + * Test _beans_setup_widgets() should skip a widget if it has not been registered. + */ +// public function test_should_ignore_widget_when_widget_not_registered() { +// global $wp_registered_widgets; +// +// $wp_registered_widgets = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: ensures no widgets are registered for this test. +// +// $this->assertEmpty( _beans_setup_widgets( 'widget output' ) ); +// } + + /** + * Test _beans_setup_widgets() should return widget data when the widget is registered. + */ + public function test_should_return_widget_data_when_widget_is_registered() { + global $wp_registered_widgets, $_beans_widget_area; + + $widget = \Mockery::mock( 'WP_Widget' ); + $widget->id_base = 'text'; + $widget->option_name = 'text'; + + // Prime the $wp_registered widgets and $_beans_widget_area globals. + $wp_registered_widgets = array( + 'text-2' => array( + 'id' => 'text-2', + 'name' => 'Test Widget', + 'classname' => 'widget_text', + 'callback' => array( $widget, 'display_callback' ), + 'params' => array( 0 => array( 'number' => 2 ) ), + ), + ); + $_beans_widget_area['widgets_count'] = 1; + $_beans_widget_area['beans_show_widget_title'] = true; + $_beans_widget_area['beans_show_widget_badge'] = false; + $_beans_widget_area['beans_widget_badge_content'] = 'Hello'; + + Monkey\Functions\expect( 'beans_get' ) + ->once() + ->with( 'text-2', $wp_registered_widgets ) + ->andReturn( $wp_registered_widgets['text-2'] ); + + Monkey\Functions\expect( 'get_option' ) + ->once() + ->with( 'text' ) + ->andReturn( array( 2 => array( 'widget_options' ) ) ); + + $this->assertSame( + $this->get_expected_widget_setup_data(), + _beans_setup_widgets( 'widget output' ) + ); + } + + /** + * Get an array of expected widget setup data. + * + * @return array Expected widget setup data + */ + protected function get_expected_widget_setup_data() { + return array( + 'text-2' => array( + 'options' => array( 0 => 'widget_options' ), + 'type' => 'text', + 'title' => '', + 'count' => 1, + 'id' => 'text-2', + 'name' => 'Test Widget', + 'classname' => 'widget_text', + 'description' => null, + 'content' => 'widget output', + 'show_title' => true, + 'badge' => false, + 'badge_content' => 'Hello', + ), + ); + } +} diff --git a/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php b/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php new file mode 100644 index 00000000..6b74e2e1 --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php @@ -0,0 +1,36 @@ + 'test_sidebar' ); + + $this->assertEquals( '[_test_sidebar]', _beans_widget_area_subfilters() ); + } +} diff --git a/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php new file mode 100644 index 00000000..a11ef48d --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php @@ -0,0 +1,73 @@ +never(); + + Monkey\Functions\expect( 'beans_array_shortcodes' ) + ->once() + ->with( 'Content with a {key}.', array( 'Widget Data' ) ) + ->andReturn( 'Content with a shortcode value.' ); + + // Run test for content as a string. + $this->assertEquals( + 'Content with a shortcode value.', + beans_widget_shortcodes( 'Content with a {key}.' ) + ); + } + + /** + * Test beans_widget_shortcodes() should return content with shortcodes filtered out when content is given as an array. + */ + public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_arrau() { + global $_beans_widget; + + $_beans_widget = array( 'Widget Data' ); + + Monkey\Functions\expect( 'build_query' ) + ->once() + ->with( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) + ->andReturn( 'someURLparemetername=URL content with a {key}.' ); + + + Monkey\Functions\expect( 'beans_array_shortcodes' ) + ->once() + ->with( 'someURLparemetername=URL content with a {key}.', array( 'Widget Data' ) ) + ->andReturn( 'someURLparemetername=URL content with a shortcode value.' ); + + // Run test for content as a string. + $this->assertEquals( + 'someURLparemetername=URL content with a shortcode value.', + beans_widget_shortcodes( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) + ); + } +} diff --git a/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php b/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php new file mode 100644 index 00000000..4ee2259c --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php @@ -0,0 +1,40 @@ + 'test_sidebar' ); + $_beans_widget = array( + 'id' => 'text-2', + 'type' => 'text' + ); + + $this->assertEquals( '[_test_sidebar][_text][_text-2]', _beans_widget_subfilters() ); + } +} From 6a7d8abedbaada96000432ece1dff92de67ddf89 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Fri, 1 Jun 2018 15:14:42 -0400 Subject: [PATCH 682/800] Update unit tests to WPCS --- .../integration/api/widget/beansGetWidget.php | 2 +- .../unit/api/widget/beansGetWidget.php | 2 +- .../unit/api/widget/beansHasWidgetArea.php | 6 +++-- .../unit/api/widget/beansHaveWidgets.php | 9 +++---- .../api/widget/beansPrepareWidgetData.php | 9 ++++++- .../unit/api/widget/beansSetupWidgetArea.php | 16 +++++++----- .../unit/api/widget/beansSetupWidgets.php | 26 ++++++++++--------- .../api/widget/beansWidgetAreaShortcodes.php | 1 - .../unit/api/widget/beansWidgetShortcodes.php | 1 - .../unit/api/widget/beansWidgetSubfilters.php | 2 +- 10 files changed, 42 insertions(+), 32 deletions(-) diff --git a/tests/phpunit/integration/api/widget/beansGetWidget.php b/tests/phpunit/integration/api/widget/beansGetWidget.php index b02c1d26..aaa7a681 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidget.php +++ b/tests/phpunit/integration/api/widget/beansGetWidget.php @@ -46,4 +46,4 @@ protected function get_widget_test_data() { 'text' => 'Arbitrary text content.', ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/unit/api/widget/beansGetWidget.php b/tests/phpunit/unit/api/widget/beansGetWidget.php index 86985854..338c3507 100644 --- a/tests/phpunit/unit/api/widget/beansGetWidget.php +++ b/tests/phpunit/unit/api/widget/beansGetWidget.php @@ -74,4 +74,4 @@ protected function get_widget_test_data() { 'text' => 'Arbitrary text content.', ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/unit/api/widget/beansHasWidgetArea.php b/tests/phpunit/unit/api/widget/beansHasWidgetArea.php index c1acca3d..198f853c 100644 --- a/tests/phpunit/unit/api/widget/beansHasWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansHasWidgetArea.php @@ -36,11 +36,13 @@ public function testShouldReturnFalseWhenWidgetAreaNotRegistered() { public function testShouldReturnTrueWhenWidgetAreaRegistered() { global $wp_registered_sidebars; - $wp_registered_sidebars['test_sidebar'] = array( - 'id' => 'test_sidebar', + $sidebars = array( + 'id' => 'test_sidebar', 'name' => 'Test Sidebar', ); + $wp_registered_sidebars['test_sidebar'] = $sidebars; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: setting up sidebars outside of WP. + // Run test. $this->assertTrue( beans_has_widget_area( 'test_sidebar' ) ); } diff --git a/tests/phpunit/unit/api/widget/beansHaveWidgets.php b/tests/phpunit/unit/api/widget/beansHaveWidgets.php index cff9449b..640196cb 100644 --- a/tests/phpunit/unit/api/widget/beansHaveWidgets.php +++ b/tests/phpunit/unit/api/widget/beansHaveWidgets.php @@ -31,7 +31,7 @@ public function test_should_return_false_when_no_widgets_are_available() { $_beans_widget_area = array(); - Monkey\Functions\expect('beans_get') + Monkey\Functions\expect( 'beans_get' ) ->once() ->with( 'widgets', array() ) ->andReturn( false ); @@ -46,7 +46,7 @@ public function test_should_return_true_when_widgets_available() { global $_beans_widget_area; $_beans_widget_area = array( - 'widgets' => array( + 'widgets' => array( 'text-1' => array( 'id' => 'text-1' ), 'text-2' => array( 'id' => 'text-2' ), ), @@ -68,7 +68,7 @@ public function test_should_call_beans_reset_widget_and_return_false_when_end_of global $_beans_widget_area; $_beans_widget_area = array( - 'widgets' => array( + 'widgets' => array( 'text-1' => array( 'id' => 'text-1' ), 'text-2' => array( 'id' => 'text-2' ), ), @@ -80,8 +80,7 @@ public function test_should_call_beans_reset_widget_and_return_false_when_end_of ->with( 'widgets', $_beans_widget_area ) ->andReturn( $_beans_widget_area['widgets'] ); - Monkey\Functions\expect( '_beans_reset_widget') - ->once(); + Monkey\Functions\expect( '_beans_reset_widget' )->once(); $this->assertFalse( beans_have_widgets() ); } diff --git a/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php b/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php index d3924bb6..8a06c32c 100644 --- a/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php +++ b/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php @@ -32,7 +32,14 @@ public function test_should_prepared_widget_data() { Monkey\Functions\expect( 'beans_get_widget_area' ) ->once() ->with( 'widgets' ) - ->andReturn( array( 'text-2' => array( 'id' => 'text-2', 'name' => 'Test Widget' ) ) ); + ->andReturn( + array( + 'text-2' => array( + 'id' => 'text-2', + 'name' => 'Test Widget', + ), + ) + ); // Call the function. _beans_prepare_widget_data( 'text-2' ); diff --git a/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php b/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php index c1580eac..dc332429 100644 --- a/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php @@ -34,22 +34,24 @@ public function test_should_return_false_when_sidebar_id_not_set() { * Test _beans_setup_widget_area() should build widget area data and return true when widget area exists. */ public function test_should_build_widget_area_data_and_return_true_when_widget_area_exists() { - global $_beans_widget_area, $wp_registered_sidebars;; + global $_beans_widget_area, $wp_registered_sidebars; - $wp_registered_sidebars = array( - 'sidebar_primary' => array(), + $sidebars = array( + 'sidebar_primary' => array(), 'sidebar_secondary' => array(), - 'test_sidebar' => array(), + 'test_sidebar' => array(), ); - Monkey\Functions\expect( 'beans_render_function') + $wp_registered_sidebars = $sidebars; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: setting up sidebars outside of WP. + + Monkey\Functions\expect( 'beans_render_function' ) ->once() ->with( 'dynamic_sidebar', 'test_sidebar' ) ->andReturn( 'Some widget output' ); - Monkey\Functions\expect('_beans_setup_widgets') + Monkey\Functions\expect( '_beans_setup_widgets' ) ->once() - ->with('Some widget output') + ->with( 'Some widget output' ) ->andReturnFirstArg(); // Run test. diff --git a/tests/phpunit/unit/api/widget/beansSetupWidgets.php b/tests/phpunit/unit/api/widget/beansSetupWidgets.php index e074865e..58c6ce9f 100644 --- a/tests/phpunit/unit/api/widget/beansSetupWidgets.php +++ b/tests/phpunit/unit/api/widget/beansSetupWidgets.php @@ -26,20 +26,20 @@ class Tests_BeansSetupWidgets extends Beans_Widget_Test_Case { /** * Test _beans_setup_widgets() should ignore non-widgetized content. */ -// public function test_should_ignore_non_widgetized_content() { -// $this->assertEmpty( _beans_setup_widgets( 'random non-widget string' ) ); -// } + public function test_should_ignore_non_widgetized_content() { + $this->assertEmpty( _beans_setup_widgets( 'random non-widget string' ) ); + } /** * Test _beans_setup_widgets() should skip a widget if it has not been registered. */ -// public function test_should_ignore_widget_when_widget_not_registered() { -// global $wp_registered_widgets; -// -// $wp_registered_widgets = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: ensures no widgets are registered for this test. -// -// $this->assertEmpty( _beans_setup_widgets( 'widget output' ) ); -// } + public function test_should_ignore_widget_when_widget_not_registered() { + global $wp_registered_widgets; + + $wp_registered_widgets = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: ensures no widgets are registered for this test. + + $this->assertEmpty( _beans_setup_widgets( 'widget output' ) ); + } /** * Test _beans_setup_widgets() should return widget data when the widget is registered. @@ -51,8 +51,7 @@ public function test_should_return_widget_data_when_widget_is_registered() { $widget->id_base = 'text'; $widget->option_name = 'text'; - // Prime the $wp_registered widgets and $_beans_widget_area globals. - $wp_registered_widgets = array( + $sidebars = array( 'text-2' => array( 'id' => 'text-2', 'name' => 'Test Widget', @@ -61,6 +60,9 @@ public function test_should_return_widget_data_when_widget_is_registered() { 'params' => array( 0 => array( 'number' => 2 ) ), ), ); + + // Prime the $wp_registered widgets and $_beans_widget_area globals. + $wp_registered_widgets = $sidebars; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: setting up sidebars outside of WP. $_beans_widget_area['widgets_count'] = 1; $_beans_widget_area['beans_show_widget_title'] = true; $_beans_widget_area['beans_show_widget_badge'] = false; diff --git a/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php index b26c3062..004c01eb 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php +++ b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php @@ -58,7 +58,6 @@ public function test_should_return_content_with_shortcodes_filtered_out_when_con ->with( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) ->andReturn( 'someURLparemetername=URL content with a {key}.' ); - Monkey\Functions\expect( 'beans_array_shortcodes' ) ->once() ->with( 'someURLparemetername=URL content with a {key}.', array( 'Widget Area Data' ) ) diff --git a/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php index a11ef48d..092a827e 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php +++ b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php @@ -58,7 +58,6 @@ public function test_should_return_content_with_shortcodes_filtered_out_when_con ->with( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) ->andReturn( 'someURLparemetername=URL content with a {key}.' ); - Monkey\Functions\expect( 'beans_array_shortcodes' ) ->once() ->with( 'someURLparemetername=URL content with a {key}.', array( 'Widget Data' ) ) diff --git a/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php b/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php index 4ee2259c..12cc3159 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php +++ b/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php @@ -32,7 +32,7 @@ public function test_should_return_widget_subfilters_as_string() { $_beans_widget_area = array( 'id' => 'test_sidebar' ); $_beans_widget = array( 'id' => 'text-2', - 'type' => 'text' + 'type' => 'text', ); $this->assertEquals( '[_test_sidebar][_text][_text-2]', _beans_widget_subfilters() ); From 1734a90204c0435b554d3712086b91135cc6a473 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Fri, 1 Jun 2018 15:45:17 -0400 Subject: [PATCH 683/800] Add unit test for `_beans_force_the_widget()` --- .../unit/api/widget/beansForceTheWidget.php | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 tests/phpunit/unit/api/widget/beansForceTheWidget.php diff --git a/tests/phpunit/unit/api/widget/beansForceTheWidget.php b/tests/phpunit/unit/api/widget/beansForceTheWidget.php new file mode 100644 index 00000000..4f59d8f4 --- /dev/null +++ b/tests/phpunit/unit/api/widget/beansForceTheWidget.php @@ -0,0 +1,78 @@ +widgets['unorthodox'] = new \stdClass(); + + ob_start(); + _beans_force_the_widget( 'unorthodox', array(), array( 'before_widget' => '
        assertEmpty( $output ); + } + + /** + * Test beans_force_the_widget() should do nothing when widget already has an id registered. + */ + public function test_should_do_nothing_when_widget_has_id_registered() { + global $wp_widget_factory; + + $widget = \Mockery::mock( 'WP_Widget' ); + $widget->id = 'text-2'; + $widget->option_name = 'text'; + + $wp_widget_factory->widgets['WP_Widget_Text'] = $widget; + + ob_start(); + _beans_force_the_widget( 'WP_Widget_Text', array(), array( 'before_widget' => '
        assertEquals( '', $output ); + } + + /** + * Test beans_force_the_widget() should render widget id html when the widget is registered without an id argument. + */ + public function test_should_output_widget_id_html_when_widget_registered_without_id_arg() { + global $wp_widget_factory; + + $widget = \Mockery::mock( 'WP_Widget' ); + $widget->id = 'text-2'; + $widget->option_name = 'text'; + + $wp_widget_factory->widgets['WP_Widget_Text'] = $widget; + + ob_start(); + _beans_force_the_widget( 'WP_Widget_Text', '', array() ); + $output = ob_get_clean(); + + $this->assertEquals( '', $output ); + } +} From f1d4808985e06d98175afef40358aecc62be8778 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 4 Jun 2018 13:04:42 -0500 Subject: [PATCH 684/800] Improved documentation per code review. --- lib/api/uikit/class-beans-uikit.php | 10 +++++----- lib/api/utilities/functions.php | 1 - .../uikit/beans-uikit/getComponentsFromDirectory.php | 2 +- .../unit/api/uikit/beans-uikit/getJsDirectories.php | 5 ++--- .../unit/api/uikit/beans-uikit/getLessDirectories.php | 2 +- .../api/uikit/beans-uikit/registerJsComponents.php | 7 ++++--- .../api/uikit/beans-uikit/registerLessComponents.php | 3 ++- .../phpunit/unit/api/uikit/beans-uikit/toFilename.php | 4 ++-- .../unit/api/uikit/includes/class-uikit-test-case.php | 4 ++-- tests/phpunit/unit/api/utilities/beansJoinArrays.php | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index e26ae328..4d85b2fd 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -126,13 +126,13 @@ public function register_js_components() { } /** - * Gets an array of registered component paths, i.e. absolute path to each component file. + * Get an array of registered component paths, i.e. absolute path to each component file. * * @since 1.5.0 * * @param array $core_components Array of core components. - * @param bool $is_less Optional. When true, registering LESS components; else, registering JavaScript - * components. + * @param bool $is_less Optional. When true, get the registered LESS components; else, get the + * registered JavaScript components. * * @return array */ @@ -276,7 +276,7 @@ public function get_all_components( $type ) { } /** - * Gets all of the files and folders from the given directory. When on a Linux-based machine, + * Get all of the files and folders from the given directory. When on a Linux-based machine, * removes the '.' and '..' files. * * @since 1.5.0 @@ -297,7 +297,7 @@ private function get_all_files( $directory ) { } /** - * Gets all of the required dependencies for the given components. + * Get all of the required dependencies for the given components. * * @since 1.0.0 * diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 17306e11..4e5f9f6a 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -534,7 +534,6 @@ function beans_join_arrays( array &$array1, array $array2 ) { // If the 1st array is empty, set it to the 2nd array. Then bail out as we're done. if ( empty( $array1 ) ) { $array1 = $array2; - return; } diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getComponentsFromDirectory.php b/tests/phpunit/unit/api/uikit/beans-uikit/getComponentsFromDirectory.php index 52d7ab82..54ec6f3a 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/getComponentsFromDirectory.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getComponentsFromDirectory.php @@ -181,7 +181,7 @@ public function test_should_return_array_of_js_files_when_component_exists_in_co /** * Test _Beans_Uikit::get_components_from_directory() should return an array of JavaScript files when the component - * exists in child theme. + * exists in the child theme. */ public function test_should_return_array_of_js_files_when_component_exists_in_child_theme() { $child_theme = vfsStream::url( 'themes/beans-child/assets/js' ); diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getJsDirectories.php b/tests/phpunit/unit/api/uikit/beans-uikit/getJsDirectories.php index 217f87fa..b8efc232 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/getJsDirectories.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getJsDirectories.php @@ -25,8 +25,7 @@ class Tests_BeansUikit_GetJsDirectories extends UIkit_Test_Case { /** - * Test _Beans_Uikit::get_js_directories() should return path to type's directory. - * registered. + * Test _Beans_Uikit::get_js_directories() should return the path to the type's directory. */ public function test_should_return_path_to_type_directory() { $beans_uikit = new _Beans_Uikit(); @@ -42,7 +41,7 @@ public function test_should_return_path_to_type_directory() { } /** - * Test _Beans_Uikit::get_js_directories() should return path to 'components' directory when the type is + * Test _Beans_Uikit::get_js_directories() should return the path to the 'components' directory when the type is * 'add-ons'. */ public function test_should_return_path_to_components_directory_when_type_is_add_ons() { diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getLessDirectories.php b/tests/phpunit/unit/api/uikit/beans-uikit/getLessDirectories.php index 0c77a86a..818cc676 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/getLessDirectories.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getLessDirectories.php @@ -44,7 +44,7 @@ public function test_should_return_only_uikit_type_directory_when_no_theme_regis } /** - * Test _Beans_Uikit::get_less_directories() should return path to 'components' directory when the type is + * Test _Beans_Uikit::get_less_directories() should return the path to the 'components' directory when the type is * 'add-ons'. */ public function test_should_return_path_to_components_directory_when_type_is_add_ons() { diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php index e3f569a4..1a369bec 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php @@ -25,7 +25,8 @@ class Tests_BeansUikit_RegisterJsComponents extends UIkit_Test_Case { /** - * Test _Beans_Uikit::register_js_components() should return empty array when no components are registered and no 'core' in the global. + * Test _Beans_Uikit::register_js_components() should return an empty array when no components are registered and + * no 'core' in the global. */ public function test_should_return_empty_array_when_no_components_registered_and_no_core() { // Remove "core" from the components. @@ -37,8 +38,8 @@ public function test_should_return_empty_array_when_no_components_registered_and } /** - * Test _Beans_Uikit::register_js_components() should return the base core components when no theme or components are - * registered. + * Test _Beans_Uikit::register_js_components() should return the base core components when no theme or components + * are registered. */ public function test_should_return_base_core_components_when_no_components_registered() { // Check the global. diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php index 2205a7f0..94d7f13a 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php @@ -24,7 +24,8 @@ class Tests_BeansUikit_RegisterLessComponents extends UIkit_Test_Case { /** - * Test _Beans_Uikit::register_less_components() should return empty array when no theme or components are registered and no 'core' in the global. + * Test _Beans_Uikit::register_less_components() should return an empty array when no theme or components are + * registered and no 'core' in the global. */ public function test_should_return_empty_array_when_no_theme_or_components_registered_and_no_core() { // Remove "core" from the components. diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php b/tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php index 6c14ac66..f964a057 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php @@ -25,7 +25,7 @@ class Tests_BeansUikit_ToFilename extends UIkit_Test_Case { /** - * Test _Beans_Uikit::to_filename() should return the component's filename when given absolute path. + * Test _Beans_Uikit::to_filename() should return null when given an ignored component. */ public function test_should_return_null_when_given_ignored_component() { $beans_uikit = new _Beans_Uikit(); @@ -37,7 +37,7 @@ public function test_should_return_null_when_given_ignored_component() { /** * Test _Beans_Uikit::to_filename() should remove the .min extension from the filename. */ - public function test_should_return_remove_min_extension_from_filename() { + public function test_should_remove_min_extension_from_filename() { $beans_uikit = new _Beans_Uikit(); $this->assertSame( diff --git a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php index 3fc62f40..44fbafa0 100644 --- a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php @@ -1,6 +1,6 @@ alias( function( $file ) { diff --git a/tests/phpunit/unit/api/utilities/beansJoinArrays.php b/tests/phpunit/unit/api/utilities/beansJoinArrays.php index 78f2c20e..a5403ac6 100644 --- a/tests/phpunit/unit/api/utilities/beansJoinArrays.php +++ b/tests/phpunit/unit/api/utilities/beansJoinArrays.php @@ -63,7 +63,7 @@ public function test_should_not_change_array1_when_array2_is_empty() { } /** - * Test beans_join_arrays() should do nothing when both arrays are empty. + * Test beans_join_arrays() should set array1 to array2 when array1 is empty. */ public function test_should_set_array1_to_array2_when_array1_is_empty() { // Check with associative array. From 827c605ab29d82fc018394e2458c9a09612c4153 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 5 Jun 2018 20:39:02 -0400 Subject: [PATCH 685/800] Added internationalization --- lib/templates/fragments/comments.php | 6 +++--- lib/templates/fragments/menu.php | 4 ++-- lib/templates/fragments/post.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index 06bd2434..7488ff87 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -292,7 +292,7 @@ function beans_comments_navigation() { 'nav', array( 'role' => 'navigation', - 'aria-label' => 'Comments Pagination Navigation', + 'aria-label' => esc_attr__( 'Comments Pagination Navigation', 'tm-beans' ), ) ); @@ -304,7 +304,7 @@ function beans_comments_navigation() { ) ); - // Previous. + // Previous. if ( get_previous_comments_link() ) { beans_open_markup_e( 'beans_comments_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); @@ -325,7 +325,7 @@ function beans_comments_navigation() { beans_close_markup_e( 'beans_comments_navigation_item[_previous]', 'li' ); } - // Next. + // Next. if ( get_next_comments_link() ) { beans_open_markup_e( 'beans_comments_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index e00014fc..6528d4c2 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -26,7 +26,7 @@ function beans_primary_menu() { 'role' => 'navigation', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/SiteNavigationElement', - 'aria-label' => 'Primary Navigation Menu', + 'aria-label' => esc_attr__( 'Primary Navigation Menu', 'tm-beans' ), ) ); @@ -115,7 +115,7 @@ function beans_primary_offcanvas_menu() { array( 'class' => 'tm-primary-offcanvas-menu uk-margin uk-margin-top', 'role' => 'navigation', - 'aria-label' => 'Off-Canvas Primary Navigation Menu', + 'aria-label' => esc_attr__( 'Off-Canvas Primary Navigation Menu', 'tm-beans' ), ) ); diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 5d5cf999..894b59c3 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -540,7 +540,7 @@ function beans_post_navigation() { 'nav', array( 'role' => 'navigation', - 'aria-label' => 'Pagination Navigation', + 'aria-label' => esc_attr__( 'Pagination Navigation', 'tm-beans' ), ) ); @@ -616,7 +616,7 @@ function beans_posts_pagination() { 'nav', array( 'role' => 'navigation', - 'aria-label' => 'Posts Pagination Navigation', + 'aria-label' => esc_attr__( 'Posts Pagination Navigation', 'tm-beans' ), ) ); From 78255b06ab8862243ad23a412f31039fce4d2b86 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 6 Jun 2018 10:09:24 -0400 Subject: [PATCH 686/800] Update tests per @christophherr code review. --- lib/api/widget/deprecated.php | 5 +++-- .../api/widget/beansDeregisterWidgetArea.php | 2 +- .../integration/api/widget/beansForceTheWidget.php | 6 +++--- .../api/widget/beansGetWidgetAreaOutput.php | 8 ++++---- .../integration/api/widget/beansHasWidgetArea.php | 4 ++-- .../integration/api/widget/beansHaveWidgets.php | 10 +++++----- .../integration/api/widget/beansIsActiveWidgetArea.php | 4 ++-- .../integration/api/widget/beansPrepareWidgetData.php | 4 ++-- .../integration/api/widget/beansRegisterWidgetArea.php | 4 ++-- .../integration/api/widget/beansSetupWidget.php | 4 ++-- .../integration/api/widget/beansSetupWidgetArea.php | 2 +- .../integration/api/widget/beansSetupWidgets.php | 2 +- .../api/widget/beansWidgetAreaShortcodes.php | 4 ++-- .../api/widget/beansWidgetAreaSubfilters.php | 2 +- .../integration/api/widget/beansWidgetShortcodes.php | 2 +- .../integration/api/widget/beansWidgetSubfilters.php | 2 +- .../widget/includes/class-beans-widget-test-case.php | 2 +- .../unit/api/widget/beansDeregisterWidgetArea.php | 2 +- tests/phpunit/unit/api/widget/beansForceTheWidget.php | 6 +++--- .../unit/api/widget/beansGetWidgetAreaOutput.php | 2 +- tests/phpunit/unit/api/widget/beansHasWidgetArea.php | 4 ++-- tests/phpunit/unit/api/widget/beansHaveWidgets.php | 6 +++--- .../unit/api/widget/beansIsActiveWidgetArea.php | 8 ++++---- .../phpunit/unit/api/widget/beansPrepareWidgetData.php | 4 ++-- .../unit/api/widget/beansRegisterWidgetArea.php | 4 ++-- tests/phpunit/unit/api/widget/beansSetupWidget.php | 2 +- tests/phpunit/unit/api/widget/beansSetupWidgetArea.php | 2 +- tests/phpunit/unit/api/widget/beansSetupWidgets.php | 2 +- .../unit/api/widget/beansWidgetAreaShortcodes.php | 6 +++--- .../unit/api/widget/beansWidgetAreaSubfilters.php | 2 +- .../phpunit/unit/api/widget/beansWidgetShortcodes.php | 4 ++-- .../phpunit/unit/api/widget/beansWidgetSubfilters.php | 2 +- 32 files changed, 62 insertions(+), 61 deletions(-) diff --git a/lib/api/widget/deprecated.php b/lib/api/widget/deprecated.php index bc69a922..e12bf7bd 100644 --- a/lib/api/widget/deprecated.php +++ b/lib/api/widget/deprecated.php @@ -3,19 +3,20 @@ * Deprecated widget functions. * * @package Beans\Framework\API\Widget + * @since 1.5.0 */ /** * Deprecated. Display a widget area. * - * This functions has been replaced with {@see beans_get_widget_area_output()}. + * This function has been replaced with {@see beans_get_widget_area_output()}. * * @since 1.0.0 * @deprecated 1.5.0 * * @param string $id The ID of the registered widget area. * - * @return string|bool The output, if a widget area was found and called. False if not found. + * @return string|bool The output if a widget area was found and called. False if not found. */ function beans_widget_area( $id ) { _deprecated_function( __FUNCTION__, '1.5.0', 'beans_get_widget_area_output()' ); diff --git a/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php index 72f00805..504b8bbe 100644 --- a/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php @@ -23,7 +23,7 @@ class Tests_BeansDeregisterWidgetArea extends Beans_Widget_Test_Case { /** - * Test beans_deregister_widget_area should unregister a sidebar. + * Test beans_deregister_widget_area() should unregister a sidebar. */ public function test_should_unregister_sidebar() { global $wp_registered_sidebars; diff --git a/tests/phpunit/integration/api/widget/beansForceTheWidget.php b/tests/phpunit/integration/api/widget/beansForceTheWidget.php index 28caa609..f9579cc2 100644 --- a/tests/phpunit/integration/api/widget/beansForceTheWidget.php +++ b/tests/phpunit/integration/api/widget/beansForceTheWidget.php @@ -24,7 +24,7 @@ class Tests_BeansForceTheWidget extends Beans_Widget_Test_Case { /** - * Test beans_force_the_widget() should do nothing when not an instance of class WP_Widget. + * Test beans_force_the_widget() should do nothing when the widget is not an instance of class WP_Widget. */ public function test_should_do_nothing_when_widget_not_instance_of_WP_Widget() { global $wp_widget_factory; @@ -39,7 +39,7 @@ public function test_should_do_nothing_when_widget_not_instance_of_WP_Widget() { } /** - * Test beans_force_the_widget() should do nothing when widget already has an id registered. + * Test beans_force_the_widget() should do nothing when the widget already has an id registered. */ public function test_should_do_nothing_when_widget_has_id_registered() { ob_start(); @@ -52,7 +52,7 @@ public function test_should_do_nothing_when_widget_has_id_registered() { /** * Test beans_force_the_widget() should render widget id html when the widget is registered without an id argument. */ - public function test_should_output_widget_id_html_when_widget_registered_without_id_arg() { + public function test_should_render_widget_id_html_when_widget_registered_without_id_arg() { ob_start(); _beans_force_the_widget( 'WP_Widget_Text', '', array() ); $output = ob_get_clean(); diff --git a/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php index adba24d6..d07ea8c2 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php +++ b/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php @@ -14,7 +14,7 @@ require_once dirname( __FILE__ ) . '/includes/class-beans-widget-test-case.php'; /** - * Class Tests_BeansGeteWidgetAreaOutput + * Class Tests_BeansGetWidgetAreaOutput * * @package Beans\Framework\Tests\Integration\API\Widget * @group api @@ -23,14 +23,14 @@ class Tests_BeansGetWidgetAreaOutput extends Beans_Widget_Test_Case { /** - * Test beans_get_widget_area_output should return false when the widget area is not registered. + * Test beans_get_widget_area_output() should return false when the widget area is not registered. */ public function test_should_return_false_when_widget_area_not_registered() { $this->assertFalse( beans_get_widget_area_output( 'unregistered-widget-area' ) ); } /** - * Test beans_get_widget_area_output() should return output when a widget area is registered. + * Test beans_get_widget_area_output() should return the widget output when a widget area is registered. */ public function test_should_return_widget_output_when_widget_area_is_registered() { global $wp_registered_sidebars; @@ -47,7 +47,7 @@ public function test_should_return_widget_output_when_widget_area_is_registered( } /** - * Get the expected output (html) of the beans default primary sidebar. + * Get the expected output (html) of the Beans default primary sidebar. */ protected function get_expected_output() { return '
        '; diff --git a/tests/phpunit/integration/api/widget/beansHasWidgetArea.php b/tests/phpunit/integration/api/widget/beansHasWidgetArea.php index b99578a0..0d398e86 100644 --- a/tests/phpunit/integration/api/widget/beansHasWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansHasWidgetArea.php @@ -25,14 +25,14 @@ class Tests_BeansHasWidgetArea extends Beans_Widget_Test_Case { /** * Test beans_has_widget_area() should return false when widget area is not registered. */ - public function testShouldReturnFalseWhenWidgetAreaNotRegistered() { + public function test_should_return_false_when_widget_area_not_registered() { $this->assertFalse( beans_has_widget_area( 'unregistered-area' ) ); } /** * Test beans_has_widget_area() should return true when widget area is registered. */ - public function testShouldReturnTrueWhenWidgetAreaRegistered() { + public function test_should_return_true_when_widget_area_registered() { global $wp_registered_sidebars; register_sidebar( array( diff --git a/tests/phpunit/integration/api/widget/beansHaveWidgets.php b/tests/phpunit/integration/api/widget/beansHaveWidgets.php index 4b298a29..8a3e1873 100644 --- a/tests/phpunit/integration/api/widget/beansHaveWidgets.php +++ b/tests/phpunit/integration/api/widget/beansHaveWidgets.php @@ -14,7 +14,7 @@ require_once dirname( __FILE__ ) . '/includes/class-beans-widget-test-case.php'; /** - * Class Tests_BeansHaveWidgetArea + * Class Tests_BeansHaveWidgets * * @package Beans\Framework\Tests\Integration\API\Widget * @group api @@ -23,7 +23,7 @@ class Tests_BeansHaveWidgets extends Beans_Widget_Test_Case { /** - * Test beans_have_widget() should return true when more widgets are available. + * Test beans_have_widgets() should return true when more widgets are available. */ public function test_should_return_true_when_widgets_available() { // Add a test sidebar with a test widget. @@ -35,7 +35,7 @@ public function test_should_return_true_when_widgets_available() { ); $this->add_test_widget_to_test_sidebar(); - // Run the beans widget area setup. + // Run the Beans widget area setup. _beans_setup_widget_area( 'test_sidebar' ); // Run the test. @@ -43,7 +43,7 @@ public function test_should_return_true_when_widgets_available() { } /** - * Test beans_have_widget() should return false when no widgets are available. + * Test beans_have_widgets() should return false when no widgets are available. */ public function test_should_return_false_when_no_widgets_are_available() { // Add a test sidebar with no widgets. @@ -54,7 +54,7 @@ public function test_should_return_false_when_no_widgets_are_available() { ) ); - // Run the beans widget area setup. + // Run the Beans widget area setup. _beans_setup_widget_area( 'test_sidebar' ); // Run the test. diff --git a/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php b/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php index f798aea4..9194051c 100644 --- a/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php @@ -25,14 +25,14 @@ class Tests_BeansIsActiveWidgetArea extends Beans_Widget_Test_Case { /** * Test beans_is_active_widget_area() should return false when widget area is not active. */ - public function testShouldReturnFalseWhenWidgetAreaNotActive() { + public function test_should_return_false_when_widget_area_not_active() { $this->assertFalse( beans_is_active_widget_area( 'inactive-widget-area' ) ); } /** * Test beans_is_active_widget_area() should return true when widget area is active. */ - public function testShouldReturnTrueWhenWidgetAreaIsActive() { + public function test_should_return_true_when_widget_area_is_active() { global $_wp_sidebars_widgets; // Clear global widget areas registry so we can start clean. diff --git a/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php b/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php index 88b9d6f1..9b29cfa0 100644 --- a/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php +++ b/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php @@ -23,9 +23,9 @@ class Tests_BeansPrepareWidgetData extends Beans_Widget_Test_Case { /** - * Test _beans_prepare_widget_data() should prepare widget data. + * Test _beans_prepare_widget_data() should prepare the widget data. */ - public function test_should_prepared_widget_data() { + public function test_should_prepare_widget_data() { global $_beans_widget; beans_register_widget_area( array( 'id' => 'test_sidebar' ) ); diff --git a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php index a5286fb1..8bc20ae9 100644 --- a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php @@ -23,14 +23,14 @@ class Tests_BeansRegisterWidgetArea extends Beans_Widget_Test_Case { /** - * Test beans_register_widget_area() should return an empty string when the id is not set. + * Test beans_register_widget_area() should return an empty string when the ID is not set. */ public function test_should_return_empty_string_when_ID_not_set() { $this->assertSame( '', beans_register_widget_area( [] ) ); } /** - * Test beans_register_widget_area() should register a sidebar and return the widget area id when the widget area is registered. + * Test beans_register_widget_area() should register a sidebar and return the widget area ID when the widget area is registered. */ public function test_should_register_sidebar_and_return_widget_area_ID_when_widget_area_registered() { global $wp_registered_sidebars; diff --git a/tests/phpunit/integration/api/widget/beansSetupWidget.php b/tests/phpunit/integration/api/widget/beansSetupWidget.php index 4cc4a4f5..1cccd739 100644 --- a/tests/phpunit/integration/api/widget/beansSetupWidget.php +++ b/tests/phpunit/integration/api/widget/beansSetupWidget.php @@ -33,7 +33,7 @@ public function test_should_return_false_when_widget_id_not_found() { _beans_setup_widget_area( 'test_sidebar' ); - // Advance the widget counter to a non-existent widget. + // Advance the widget pointer to a non-existent widget. $_beans_widget_area['current_widget'] = 1; $this->assertFalse( beans_setup_widget() ); } @@ -41,7 +41,7 @@ public function test_should_return_false_when_widget_id_not_found() { /** * Test beans_setup_widget() should advance widget pointer, prepare widget data, and return true when a widget ID is found. */ - public function test_should_return_advance_widget_pointer_prepare_widget_data_and_return_true_when_widget_id_is_found() { + public function test_should_advance_widget_pointer_prepare_widget_data_and_return_true_when_widget_id_is_found() { global $_beans_widget_area, $_beans_widget; beans_register_widget_area( array( 'id' => 'test_sidebar' ) ); diff --git a/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php b/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php index 1f385f57..a7545e63 100644 --- a/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php @@ -23,7 +23,7 @@ class Tests_BeansSetupWidgetArea extends Beans_Widget_Test_Case { /** - * Test _beans_setup_widget_area() should build widget area data and return true when widget area exists. + * Test _beans_setup_widget_area() should build the widget area data and return true when widget area exists. */ public function test_should_build_widget_area_data_and_return_true_when_widget_area_exists() { global $_beans_widget_area; diff --git a/tests/phpunit/integration/api/widget/beansSetupWidgets.php b/tests/phpunit/integration/api/widget/beansSetupWidgets.php index 0363c3b9..c3d48b19 100644 --- a/tests/phpunit/integration/api/widget/beansSetupWidgets.php +++ b/tests/phpunit/integration/api/widget/beansSetupWidgets.php @@ -23,7 +23,7 @@ class Tests_BeansSetupWidgets extends Beans_Widget_Test_Case { /** - * Test _beans_setup_widgets() should return widget data when the widget is registered. + * Test _beans_setup_widgets() should return the widget data when the widget is registered. */ public function test_should_return_widget_data_when_widget_is_registered() { beans_register_widget_area( 'test_sidebar' ); diff --git a/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php b/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php index 488ec65d..346018a0 100644 --- a/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php +++ b/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php @@ -23,9 +23,9 @@ class Tests_BeansWidgetAreaShortcodes extends Beans_Widget_Test_Case { /** - * Test beans_widget_area_shortcodes() should return content with shortcodes filtered out. + * Test beans_widget_area_shortcodes() should return the content with shortcodes filtered out. */ - public function test_should_return_content_with_shortcodes_filetered_out() { + public function test_should_return_content_with_shortcodes_filtered_out() { global $_beans_widget_area; $_beans_widget_area['key'] = 'shortcode value'; diff --git a/tests/phpunit/integration/api/widget/beansWidgetAreaSubfilters.php b/tests/phpunit/integration/api/widget/beansWidgetAreaSubfilters.php index b3db2ec2..7698aa0b 100644 --- a/tests/phpunit/integration/api/widget/beansWidgetAreaSubfilters.php +++ b/tests/phpunit/integration/api/widget/beansWidgetAreaSubfilters.php @@ -23,7 +23,7 @@ class Tests_BeansWidgetAreaSubfilters extends Beans_Widget_Test_Case { /** - * Test _beans_widget_area_subfilters() returns widget area subfilters as a string. + * Test _beans_widget_area_subfilters() should return the widget area subfilters as a string. */ public function test_should_return_widget_area_subfilters_as_string() { beans_register_widget_area( 'test_sidebar' ); diff --git a/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php b/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php index a9202219..38d5d332 100644 --- a/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php +++ b/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php @@ -23,7 +23,7 @@ class Tests_BeansWidgetShortcodes extends Beans_Widget_Test_Case { /** - * Test beans_widget_shortcodes() should return content with shortcodes filtered out. + * Test beans_widget_shortcodes() should return the content with shortcodes filtered out. */ public function test_should_return_content_with_shortcodes_filetered_out() { global $_beans_widget; diff --git a/tests/phpunit/integration/api/widget/beansWidgetSubfilters.php b/tests/phpunit/integration/api/widget/beansWidgetSubfilters.php index e845fa8b..863fdce3 100644 --- a/tests/phpunit/integration/api/widget/beansWidgetSubfilters.php +++ b/tests/phpunit/integration/api/widget/beansWidgetSubfilters.php @@ -23,7 +23,7 @@ class Tests_BeansWidgetSubfilters extends Beans_Widget_Test_Case { /** - * Test _beans_widget_subfilters() returns widget subfilters as a string. + * Test _beans_widget_subfilters() should return the widget subfilters as a string. */ public function test_should_return_widget_subfilters_as_string() { beans_register_widget_area( 'test_sidebar' ); diff --git a/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php index df04dafe..c5e79f38 100644 --- a/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php +++ b/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php @@ -19,7 +19,7 @@ abstract class Beans_Widget_Test_Case extends Test_Case { /** - * Fixture to clean up after tests. + * Fixture to clean up the test environment after each test. */ public function tearDown() { unset( $GLOBALS['$_beans_widget_area'] ); diff --git a/tests/phpunit/unit/api/widget/beansDeregisterWidgetArea.php b/tests/phpunit/unit/api/widget/beansDeregisterWidgetArea.php index e173d94b..efb1959f 100644 --- a/tests/phpunit/unit/api/widget/beansDeregisterWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansDeregisterWidgetArea.php @@ -26,7 +26,7 @@ class Tests_BeansDeregisterWidgetArea extends Beans_Widget_Test_Case { /** * Test beans_deregister_widget_area() should call unregister_sidebar() and return null. */ - public function test_should_unregister_sidebar() { + public function test_should_call_unregister_sidebar_and_return_null() { Monkey\Functions\expect( 'unregister_sidebar' ) ->once() ->with( 'unwanted_sidebar' ) diff --git a/tests/phpunit/unit/api/widget/beansForceTheWidget.php b/tests/phpunit/unit/api/widget/beansForceTheWidget.php index 4f59d8f4..b4440526 100644 --- a/tests/phpunit/unit/api/widget/beansForceTheWidget.php +++ b/tests/phpunit/unit/api/widget/beansForceTheWidget.php @@ -24,7 +24,7 @@ class Tests_BeansForceTheWidget extends Beans_Widget_Test_Case { /** - * Test beans_force_the_widget() should do nothing when not an instance of class WP_Widget. + * Test beans_force_the_widget() should do nothing when the widget is not an instance of class WP_Widget. */ public function test_should_do_nothing_when_widget_not_instance_of_WP_Widget() { global $wp_widget_factory; @@ -39,7 +39,7 @@ public function test_should_do_nothing_when_widget_not_instance_of_WP_Widget() { } /** - * Test beans_force_the_widget() should do nothing when widget already has an id registered. + * Test beans_force_the_widget() should do nothing when the widget already has an id registered. */ public function test_should_do_nothing_when_widget_has_id_registered() { global $wp_widget_factory; @@ -60,7 +60,7 @@ public function test_should_do_nothing_when_widget_has_id_registered() { /** * Test beans_force_the_widget() should render widget id html when the widget is registered without an id argument. */ - public function test_should_output_widget_id_html_when_widget_registered_without_id_arg() { + public function test_should_render_widget_id_html_when_widget_registered_without_id_arg() { global $wp_widget_factory; $widget = \Mockery::mock( 'WP_Widget' ); diff --git a/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php index ebeeca9b..8ebfc9a8 100644 --- a/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php +++ b/tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php @@ -24,7 +24,7 @@ class Tests_BeansGetWidgetAreaOutput extends Beans_Widget_Test_Case { /** - * Test beans_get_widget_area_output should return false when the widget area is not registered. + * Test beans_get_widget_area_output() should return false when the widget area is not registered. */ public function test_should_return_false_when_widget_area_not_registered() { Monkey\Functions\expect( 'beans_has_widget_area' ) diff --git a/tests/phpunit/unit/api/widget/beansHasWidgetArea.php b/tests/phpunit/unit/api/widget/beansHasWidgetArea.php index 198f853c..9313a151 100644 --- a/tests/phpunit/unit/api/widget/beansHasWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansHasWidgetArea.php @@ -26,14 +26,14 @@ class Tests_BeansHasWidgetArea extends Beans_Widget_Test_Case { /** * Test beans_has_widget_area() should return false when widget area is not registered. */ - public function testShouldReturnFalseWhenWidgetAreaNotRegistered() { + public function test_should_return_false_when_widget_area_not_registered() { $this->assertFalse( beans_has_widget_area( 'unregistered-area' ) ); } /** * Test beans_has_widget_area() should return true when widget area is registered. */ - public function testShouldReturnTrueWhenWidgetAreaRegistered() { + public function test_should_return_true_when_widget_area_registered() { global $wp_registered_sidebars; $sidebars = array( diff --git a/tests/phpunit/unit/api/widget/beansHaveWidgets.php b/tests/phpunit/unit/api/widget/beansHaveWidgets.php index 640196cb..f2f92bfd 100644 --- a/tests/phpunit/unit/api/widget/beansHaveWidgets.php +++ b/tests/phpunit/unit/api/widget/beansHaveWidgets.php @@ -24,7 +24,7 @@ class Tests_BeansHaveWidgets extends Beans_Widget_Test_Case { /** - * Test beans_have_widget() should return false when no widgets are available. + * Test beans_have_widgets() should return false when no widgets are available. */ public function test_should_return_false_when_no_widgets_are_available() { global $_beans_widget_area; @@ -40,7 +40,7 @@ public function test_should_return_false_when_no_widgets_are_available() { } /** - * Test beans_have_widget() should return true when more widgets are available. + * Test beans_have_widgets() should return true when more widgets are available. */ public function test_should_return_true_when_widgets_available() { global $_beans_widget_area; @@ -62,7 +62,7 @@ public function test_should_return_true_when_widgets_available() { } /** - * Test beans_have_widget() should return call _beans_reset_widget() and return false when at the end of the widget loop. + * Test beans_have_widgets() should return call _beans_reset_widget() and return false when at the end of the widget loop. */ public function test_should_call_beans_reset_widget_and_return_false_when_end_of_widget_loop() { global $_beans_widget_area; diff --git a/tests/phpunit/unit/api/widget/beansIsActiveWidgetArea.php b/tests/phpunit/unit/api/widget/beansIsActiveWidgetArea.php index 90824082..5d393f7a 100644 --- a/tests/phpunit/unit/api/widget/beansIsActiveWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansIsActiveWidgetArea.php @@ -24,9 +24,9 @@ class Tests_BeansIsActiveWidgetArea extends Beans_Widget_Test_Case { /** - * Test beans_is_active_widget_area() should return false when widget area is not active. + * Test beans_is_active_widget_area() should return false when the widget area is not active. */ - public function testShouldReturnFalseWhenWidgetAreaNotActive() { + public function test_should_return_false_when_widget_area_not_active() { Monkey\Functions\expect( 'is_active_sidebar' ) ->once() ->with( 'inactive-widget-area' ) @@ -36,9 +36,9 @@ public function testShouldReturnFalseWhenWidgetAreaNotActive() { } /** - * Test beans_is_active_widget_area() should return true when widget area is active. + * Test beans_is_active_widget_area() should return true when the widget area is active. */ - public function testShouldReturnTrueWhenWidgetAreaIsActive() { + public function test_should_return_true_when_widget_area_is_active() { Monkey\Functions\expect( 'is_active_sidebar' ) ->once() ->with( 'active-sidebar' ) diff --git a/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php b/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php index 8a06c32c..9ef4a485 100644 --- a/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php +++ b/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php @@ -24,9 +24,9 @@ class Tests_BeansPrepareWidgetData extends Beans_Widget_Test_Case { /** - * Test _beans_prepare_widget_data() should prepare widget data. + * Test _beans_prepare_widget_data() should prepare the widget data. */ - public function test_should_prepared_widget_data() { + public function test_should_prepare_widget_data() { global $_beans_widget; Monkey\Functions\expect( 'beans_get_widget_area' ) diff --git a/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php index e67edcae..0f2151d2 100644 --- a/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php @@ -24,7 +24,7 @@ class Tests_BeansRegisterWidgetArea extends Beans_Widget_Test_Case { /** - * Test beans_register_widget_area() should return an empty string when the id is not set. + * Test beans_register_widget_area() should return an empty string when the ID is not set. */ public function test_should_return_empty_string_when_ID_not_set() { Monkey\Functions\expect( 'beans_get' ) @@ -36,7 +36,7 @@ public function test_should_return_empty_string_when_ID_not_set() { } /** - * Test beans_register_widget_area() should return the widget area id when the widget area is registered. + * Test beans_register_widget_area() should return the widget area ID when the widget area is registered. */ public function test_should_return_widget_area_ID_when_widget_area_registered() { Monkey\Functions\expect( 'beans_get' ) diff --git a/tests/phpunit/unit/api/widget/beansSetupWidget.php b/tests/phpunit/unit/api/widget/beansSetupWidget.php index 82386e78..6488548b 100644 --- a/tests/phpunit/unit/api/widget/beansSetupWidget.php +++ b/tests/phpunit/unit/api/widget/beansSetupWidget.php @@ -48,7 +48,7 @@ public function test_should_return_false_when_widget_id_not_found() { /** * Test beans_setup_widget() should advance widget pointer, prepare widget data, and return true when a widget ID is found. */ - public function test_should_return_advance_widget_pointer_prepare_widget_data_and_return_true_when_widget_id_is_found() { + public function test_should_advance_widget_pointer_prepare_widget_data_and_return_true_when_widget_id_is_found() { global $_beans_widget_area; $_beans_widget_area = array( diff --git a/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php b/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php index dc332429..c1f6ac4a 100644 --- a/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php @@ -31,7 +31,7 @@ public function test_should_return_false_when_sidebar_id_not_set() { } /** - * Test _beans_setup_widget_area() should build widget area data and return true when widget area exists. + * Test _beans_setup_widget_area() should build the widget area data and return true when widget area exists. */ public function test_should_build_widget_area_data_and_return_true_when_widget_area_exists() { global $_beans_widget_area, $wp_registered_sidebars; diff --git a/tests/phpunit/unit/api/widget/beansSetupWidgets.php b/tests/phpunit/unit/api/widget/beansSetupWidgets.php index 58c6ce9f..0e432356 100644 --- a/tests/phpunit/unit/api/widget/beansSetupWidgets.php +++ b/tests/phpunit/unit/api/widget/beansSetupWidgets.php @@ -42,7 +42,7 @@ public function test_should_ignore_widget_when_widget_not_registered() { } /** - * Test _beans_setup_widgets() should return widget data when the widget is registered. + * Test _beans_setup_widgets() should return the widget data when the widget is registered. */ public function test_should_return_widget_data_when_widget_is_registered() { global $wp_registered_widgets, $_beans_widget_area; diff --git a/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php index 004c01eb..03d9dd72 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php +++ b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php @@ -24,7 +24,7 @@ class Tests_BeansWidgetAreaShortcodes extends Beans_Widget_Test_Case { /** - * Test beans_widget_area_shortcodes() should return content with shortcodes filtered out when content is given as a string. + * Test beans_widget_area_shortcodes() should return the content with shortcodes filtered out when content is given as a string. */ public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_string() { global $_beans_widget_area; @@ -46,9 +46,9 @@ public function test_should_return_content_with_shortcodes_filtered_out_when_con } /** - * Test beans_widget_area_shortcodes() should return content with shortcodes filtered out when content is given as an array. + * Test beans_widget_area_shortcodes() should return the content with shortcodes filtered out when content is given as an array. */ - public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_arrau() { + public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_array() { global $_beans_widget_area; $_beans_widget_area = array( 'Widget Area Data' ); diff --git a/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php b/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php index 6b74e2e1..e98f46b6 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php +++ b/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php @@ -24,7 +24,7 @@ class Tests_BeansWidgetAreaSubfilters extends Beans_Widget_Test_Case { /** - * Test _beans_widget_area_subfilters() returns widget area subfilters as a string. + * Test _beans_widget_area_subfilters() should return the widget area subfilters as a string. */ public function test_should_return_widget_area_subfilters_as_string() { global $_beans_widget_area; diff --git a/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php index 092a827e..ba6d4330 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php +++ b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php @@ -24,7 +24,7 @@ class Tests_BeansWidgetShortcodes extends Beans_Widget_Test_Case { /** - * Test beans_widget_shortcodes() should return content with shortcodes filtered out when content is given as a string. + * Test beans_widget_shortcodes() should return the content with shortcodes filtered out when content is given as a string. */ public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_string() { global $_beans_widget; @@ -46,7 +46,7 @@ public function test_should_return_content_with_shortcodes_filtered_out_when_con } /** - * Test beans_widget_shortcodes() should return content with shortcodes filtered out when content is given as an array. + * Test beans_widget_shortcodes() should return the content with shortcodes filtered out when content is given as an array. */ public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_arrau() { global $_beans_widget; diff --git a/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php b/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php index 12cc3159..b47ae095 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php +++ b/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php @@ -24,7 +24,7 @@ class Tests_BeansWidgetSubfilters extends Beans_Widget_Test_Case { /** - * Test _beans_widget_subfilters() returns widget subfilters as a string. + * Test _beans_widget_subfilters() should return the widget subfilters as a string. */ public function test_should_return_widget_subfilters_as_string() { global $_beans_widget_area, $_beans_widget; From 06436c0b0b024a6cb195d7162caf18b78546caa8 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 6 Jun 2018 10:53:33 -0400 Subject: [PATCH 687/800] Protect $GLOBALS being unset in shortcode funcs --- lib/api/widget/functions.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 7331163a..53f6e54a 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -39,11 +39,10 @@ * @type bool $beans_widget_badge_content Optional. The badge content. This may contain widget shortcodes * {@see beans_widget_shortcodes()}. Default is 'Hello'. * } - * @param array $widget_control Optional. * * @return string The widget area ID is added to the $wp_registered_sidebars globals when the widget area is setup. */ -function beans_register_widget_area( $args = array(), $widget_control = array() ) { +function beans_register_widget_area( $args = array() ) { // Stop here if the id isn't set. $id = beans_get( 'id', $args ); @@ -209,6 +208,9 @@ function beans_get_widget_area( $needle = false ) { * @return string Content with shortcodes filtered out. */ function beans_widget_area_shortcodes( $content ) { + if ( ! isset( $GLOBALS['_beans_widget_area'] ) ) { + return $content; + } if ( is_array( $content ) ) { $content = build_query( $content ); @@ -306,6 +308,9 @@ function beans_get_widget( $needle = false ) { * @return string Content with shortcodes filtered out. */ function beans_widget_shortcodes( $content ) { + if ( ! isset( $GLOBALS['_beans_widget'] ) ) { + return $content; + } if ( is_array( $content ) ) { $content = build_query( $content ); From 855b779d8ee7906621885bcb290e69908741bd0e Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 6 Jun 2018 10:53:49 -0400 Subject: [PATCH 688/800] Add Unit tests for early return on unset global. --- .../unit/api/widget/beansWidgetAreaShortcodes.php | 10 ++++++++++ .../phpunit/unit/api/widget/beansWidgetShortcodes.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php index 03d9dd72..0037db4a 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php +++ b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php @@ -23,6 +23,16 @@ */ class Tests_BeansWidgetAreaShortcodes extends Beans_Widget_Test_Case { + /** + * Test beans_widget_area_shortcodes() should return the content when _beans_widget_area global is not set. + */ + public function test_should_return_content_when_beans_widget_area_global_not_set() { + unset( $GLOBALS['_beans_widget_area'] ); + $content = 'Some widget area content with a {key}.'; + + $this->assertEquals( $content, beans_widget_area_shortcodes( $content ) ); + } + /** * Test beans_widget_area_shortcodes() should return the content with shortcodes filtered out when content is given as a string. */ diff --git a/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php index ba6d4330..07e744bb 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php +++ b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php @@ -23,6 +23,16 @@ */ class Tests_BeansWidgetShortcodes extends Beans_Widget_Test_Case { + /** + * Test beans_widget_shortcodes() should return the content when _beans_widget global is not set. + */ + public function test_should_return_content_when_beans_widget_area_global_not_set() { + unset( $GLOBALS['_beans_widget'] ); + $content = 'Some widget content with a {key}.'; + + $this->assertEquals( $content, beans_widget_area_shortcodes( $content ) ); + } + /** * Test beans_widget_shortcodes() should return the content with shortcodes filtered out when content is given as a string. */ From 8f8bcce643de861aae4d843657bc85441b2a3051 Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 6 Jun 2018 12:17:00 -0400 Subject: [PATCH 689/800] Add line before controls --- lib/api/widget/functions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 53f6e54a..954399f6 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -208,6 +208,7 @@ function beans_get_widget_area( $needle = false ) { * @return string Content with shortcodes filtered out. */ function beans_widget_area_shortcodes( $content ) { + if ( ! isset( $GLOBALS['_beans_widget_area'] ) ) { return $content; } @@ -308,6 +309,7 @@ function beans_get_widget( $needle = false ) { * @return string Content with shortcodes filtered out. */ function beans_widget_shortcodes( $content ) { + if ( ! isset( $GLOBALS['_beans_widget'] ) ) { return $content; } From b778fbd1cfce6b88404ee0dad015320dc5b68acc Mon Sep 17 00:00:00 2001 From: Caspar Green Date: Wed, 6 Jun 2018 12:25:20 -0400 Subject: [PATCH 690/800] Fix whitespace error --- lib/api/widget/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 954399f6..0b30c822 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -208,7 +208,7 @@ function beans_get_widget_area( $needle = false ) { * @return string Content with shortcodes filtered out. */ function beans_widget_area_shortcodes( $content ) { - + if ( ! isset( $GLOBALS['_beans_widget_area'] ) ) { return $content; } From ffed86e6577d402e685f2dfeb811d643dc3ace61 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 7 Jun 2018 08:42:29 -0500 Subject: [PATCH 691/800] Disabled whitespacing phpcs rules inside of view files. View files are indented for HTML structure. When inserting PHP into the files, we do not want the PHP to drive indentation for the HTML. Therefore, we disable the whitespacing rules. --- lib/api/fields/types/views/checkbox.php | 1 + lib/api/fields/types/views/image.php | 3 +-- lib/api/fields/types/views/radio.php | 7 ++----- lib/api/fields/types/views/select.php | 4 +++- lib/api/fields/types/views/slider.php | 1 + lib/api/options/views/page.php | 1 + lib/api/options/views/reset-notice-error.php | 1 + lib/api/options/views/reset-notice-success.php | 1 + lib/api/options/views/save-notice-error.php | 1 + lib/api/options/views/save-notice-success.php | 1 + lib/api/term-meta/views/term-meta-field.php | 1 + 11 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/api/fields/types/views/checkbox.php b/lib/api/fields/types/views/checkbox.php index 89cc2e83..86a218d0 100644 --- a/lib/api/fields/types/views/checkbox.php +++ b/lib/api/fields/types/views/checkbox.php @@ -8,6 +8,7 @@ * @since 1.5.0 Moved to view file. */ +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- View file is indented for HTML structure. ?> diff --git a/lib/api/fields/types/views/image.php b/lib/api/fields/types/views/image.php index 352aac51..af66576e 100644 --- a/lib/api/fields/types/views/image.php +++ b/lib/api/fields/types/views/image.php @@ -9,6 +9,7 @@ */ // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variables are used within a function's scope. +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- View file is indented for HTML structure. ?> @@ -52,5 +53,3 @@
        -
        @@ -42,9 +43,5 @@ endif; ?> - +
        - diff --git a/lib/api/fields/types/views/slider.php b/lib/api/fields/types/views/slider.php index 44c93525..7d221c3e 100644 --- a/lib/api/fields/types/views/slider.php +++ b/lib/api/fields/types/views/slider.php @@ -8,6 +8,7 @@ * @since 1.5.0 Moved to view file. */ +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- View file is indented for HTML structure. ?>
        diff --git a/lib/api/options/views/page.php b/lib/api/options/views/page.php index b3c53f41..e19dc583 100644 --- a/lib/api/options/views/page.php +++ b/lib/api/options/views/page.php @@ -8,6 +8,7 @@ * @since 1.5.0 Moved to view file. */ +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- View file is indented for HTML structure. ?>
        diff --git a/lib/api/options/views/reset-notice-error.php b/lib/api/options/views/reset-notice-error.php index 9da244b6..83459109 100644 --- a/lib/api/options/views/reset-notice-error.php +++ b/lib/api/options/views/reset-notice-error.php @@ -8,6 +8,7 @@ * @since 1.5.0 Moved to view file. */ +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- View file is indented for HTML structure. ?>
        diff --git a/lib/api/options/views/reset-notice-success.php b/lib/api/options/views/reset-notice-success.php index 50a7cebc..439b28e9 100644 --- a/lib/api/options/views/reset-notice-success.php +++ b/lib/api/options/views/reset-notice-success.php @@ -8,6 +8,7 @@ * @since 1.5.0 Moved to view file. */ +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- View file is indented for HTML structure. ?>
        diff --git a/lib/api/options/views/save-notice-error.php b/lib/api/options/views/save-notice-error.php index 0c36e85a..d39d2e79 100644 --- a/lib/api/options/views/save-notice-error.php +++ b/lib/api/options/views/save-notice-error.php @@ -8,6 +8,7 @@ * @since 1.5.0 Moved to view file. */ +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- View file is indented for HTML structure. ?>
        diff --git a/lib/api/options/views/save-notice-success.php b/lib/api/options/views/save-notice-success.php index 2763f7ac..a5c29ec2 100644 --- a/lib/api/options/views/save-notice-success.php +++ b/lib/api/options/views/save-notice-success.php @@ -8,6 +8,7 @@ * @since 1.5.0 Moved to view file. */ +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- View file is indented for HTML structure. ?>
        diff --git a/lib/api/term-meta/views/term-meta-field.php b/lib/api/term-meta/views/term-meta-field.php index 1c3d0b75..cba0aca1 100644 --- a/lib/api/term-meta/views/term-meta-field.php +++ b/lib/api/term-meta/views/term-meta-field.php @@ -8,6 +8,7 @@ * @since 1.5.0 Moved to view file. */ +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect, Generic.WhiteSpace.ScopeIndent.IncorrectExact -- View file is indented for HTML structure. ?> From 2e3c6885137d11ac3ee65c064486329ea855b22f Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Fri, 8 Jun 2018 20:13:39 -0400 Subject: [PATCH 692/800] Added skip links. --- lib/api/components.php | 1 + lib/api/html/accessibility.php | 97 ++++++++ lib/api/html/assets/js/skip-link-fix.js | 31 +++ lib/assets/less/style.less | 70 +++++- lib/templates/fragments/menu.php | 3 + lib/templates/structure/content.php | 3 + lib/templates/structure/header.php | 2 +- lib/templates/structure/sidebar-primary.php | 3 + lib/templates/structure/sidebar-secondary.php | 3 + .../api/html/beansBuildSkipLinks.php | 221 ++++++++++++++++++ .../api/template/beansLoadDefaultTemplate.php | 2 +- .../unit/api/html/beansBuildSkipLinks.php | 103 ++++++++ .../html/includes/class-html-test-case.php | 10 +- 13 files changed, 537 insertions(+), 12 deletions(-) create mode 100644 lib/api/html/accessibility.php create mode 100644 lib/api/html/assets/js/skip-link-fix.js create mode 100644 tests/phpunit/integration/api/html/beansBuildSkipLinks.php create mode 100644 tests/phpunit/unit/api/html/beansBuildSkipLinks.php diff --git a/lib/api/components.php b/lib/api/components.php index 8bb06808..a52b1cb9 100644 --- a/lib/api/components.php +++ b/lib/api/components.php @@ -32,6 +32,7 @@ function beans_load_api_components( $components ) { 'html' => array( $root . 'html/functions.php', $root . 'html/class-beans-attribute.php', + $root . 'html/accessibility.php', ), 'actions' => $root . 'actions/functions.php', 'filters' => $root . 'filters/functions.php', diff --git a/lib/api/html/accessibility.php b/lib/api/html/accessibility.php new file mode 100644 index 00000000..3e8d11ec --- /dev/null +++ b/lib/api/html/accessibility.php @@ -0,0 +1,97 @@ + 'beans-skip-links' ) ); + + foreach ( $skip_links as $link => $link_name ) { + beans_open_markup_e( 'beans_skip_links_item', 'li' ); + + beans_open_markup_e( + 'beans_skip_links_item_link', + 'a', + array( + 'href' => '#' . $link, + 'class' => 'screen-reader-shortcut', + ) + ); + + echo esc_html( $link_name ); + + beans_close_markup_e( 'beans_skip_links_item', 'a' ); + + beans_close_markup_e( 'beans_skip_links_item', 'li' ); + } + beans_close_markup_e( 'beans_skiplinks', 'ul' ); +} + + +beans_add_smart_action( 'beans_accessibility_enqueue_skip_link_fix', 'beans_accessibility_skip_link_fix' ); +/** + * Enqueue the JavaScript fix for Internet Explorer 11 + * + * @since 1.5.0 + * + * return void + */ +function beans_accessibility_skip_link_fix() { + $js = BEANS_API_URL . 'html/assets/js/skip-link-fix' . BEANS_MIN_JS . '.js'; + wp_enqueue_script( 'beans-skip-link-fix', $js, array(), BEANS_VERSION ); +} diff --git a/lib/api/html/assets/js/skip-link-fix.js b/lib/api/html/assets/js/skip-link-fix.js new file mode 100644 index 00000000..a40ebacf --- /dev/null +++ b/lib/api/html/assets/js/skip-link-fix.js @@ -0,0 +1,31 @@ +/** + * File skip-link-focus-fix.js. + * + * Helps with accessibility for keyboard only users. + * + * Learn more: https://git.io/vWdr2 + */ +(function() { + var isIe = /(trident|msie)/i.test( navigator.userAgent ); + + if ( isIe && document.getElementById && window.addEventListener ) { + window.addEventListener( 'hashchange', function() { + var id = location.hash.substring( 1 ), + element; + + if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) { + return; + } + + element = document.getElementById( id ); + + if ( element ) { + if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) { + element.tabIndex = -1; + } + + element.focus(); + } + }, false ); + } +})(); diff --git a/lib/assets/less/style.less b/lib/assets/less/style.less index 74c4232a..82f15172 100644 --- a/lib/assets/less/style.less +++ b/lib/assets/less/style.less @@ -142,18 +142,26 @@ article header > .tm-article-image:first-child { margin: 3px 0; } -.screen-reader-text { - clip: rect(1px, 1px, 1px, 1px); - position: absolute !important; - height: 1px; - width: 1px; - overflow: hidden; +/* Hide visually but not from screen readers */ +.screen-reader-text, +.screen-reader-text span { + border: 0; + clip: rect(1px, 1px, 1px, 1px); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; /* many screen reader and browser combinations announce broken words as they would appear visually */ } .screen-reader-text:focus { background-color: #f1f1f1; border-radius: 3px; - box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6); + box-shadow: 0 0 2px 2px rgba(12, 4, 4, 0.6); clip: auto !important; color: #21759b; display: block; @@ -169,3 +177,51 @@ article header > .tm-article-image:first-child { width: auto; z-index: 100000; } + +.screen-reader-shortcut { + position: absolute; + top: -1000em; +} + +.screen-reader-shortcut:focus { + left: 6px; + top: 15px; + height: auto; + width: auto; + display: block; + font-size: 14px; + font-weight: 600; + padding: 15px 23px 14px; + background: #f1f1f1; + color: #0073aa; + z-index: 100000; + line-height: normal; + box-shadow: 0 0 2px 2px rgba(0,0,0,.6); + text-decoration: none; + outline: none; +} + +.beans-skip-links { + background-color: #f1f1f1; + box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.2); + color: #21759b; + display: block; + left: -9999em; + outline: none; + text-decoration: none; + text-transform: none; + top: -9999em; + margin: 0; +} + +.beans-skip-links li { + height: 0; + width: 0; + list-style: none; +} + +/* Display outline on focus */ +:focus { + color: #333; + outline: 1px #ccc solid; +} diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index 6528d4c2..34119acf 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -12,6 +12,7 @@ * Echo primary menu. * * @since 1.0.0 + * @since 1.5.0 Added ID for skip links. * * @return void */ @@ -23,10 +24,12 @@ function beans_primary_menu() { 'nav', array( 'class' => 'tm-primary-menu uk-float-right uk-navbar', + 'id' => 'beans-primary-navigation', 'role' => 'navigation', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/SiteNavigationElement', 'aria-label' => esc_attr__( 'Primary Navigation Menu', 'tm-beans' ), + 'tabindex' => '-1', ) ); diff --git a/lib/templates/structure/content.php b/lib/templates/structure/content.php index be4c85a0..8d5ddc9d 100644 --- a/lib/templates/structure/content.php +++ b/lib/templates/structure/content.php @@ -5,13 +5,16 @@ * @package Beans\Framework\Templates\Structure * * @since 1.0.0 + * @since 1.5.0 Added ID for skip links. */ // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variable called in a function scope. $content_attributes = array( 'class' => 'tm-content', + 'id' => 'beans-content', 'role' => 'main', 'itemprop' => 'mainEntityOfPage', + 'tabindex' => '-1', ); // Blog specific attributes. diff --git a/lib/templates/structure/header.php b/lib/templates/structure/header.php index 34fd2587..aee6c649 100644 --- a/lib/templates/structure/header.php +++ b/lib/templates/structure/header.php @@ -27,7 +27,7 @@ wp_head(); beans_close_markup_e( 'beans_head', 'head' ); - + beans_build_skip_links(); beans_open_markup_e( 'beans_body', 'body', diff --git a/lib/templates/structure/sidebar-primary.php b/lib/templates/structure/sidebar-primary.php index 8d379787..1d003d41 100644 --- a/lib/templates/structure/sidebar-primary.php +++ b/lib/templates/structure/sidebar-primary.php @@ -5,6 +5,7 @@ * @package Beans\Framework\Templates\Structure * * @since 1.0.0 + * @since 1.5.0 Added ID for skip links. */ beans_open_markup_e( @@ -12,9 +13,11 @@ 'aside', array( 'class' => 'tm-secondary ' . beans_get_layout_class( 'sidebar_primary' ), // Automatically escaped. + 'id' => 'beans-primary-sidebar', 'role' => 'complementary', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/WPSideBar', + 'tabindex' => '-1', ) ); diff --git a/lib/templates/structure/sidebar-secondary.php b/lib/templates/structure/sidebar-secondary.php index d3570a2b..9797a6d0 100644 --- a/lib/templates/structure/sidebar-secondary.php +++ b/lib/templates/structure/sidebar-secondary.php @@ -5,6 +5,7 @@ * @package Beans\Framework\Templates\Structure * * @since 1.0.0 + * @since 1.5.0 Added ID for skip links. */ beans_open_markup_e( @@ -12,9 +13,11 @@ 'aside', array( 'class' => 'tm-tertiary ' . beans_get_layout_class( 'sidebar_secondary' ), // Automatically escaped. + 'id' => 'beans-secondary-sidebar', 'role' => 'complementary', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/WPSideBar', + 'tabindex' => '-1', ) ); diff --git a/tests/phpunit/integration/api/html/beansBuildSkipLinks.php b/tests/phpunit/integration/api/html/beansBuildSkipLinks.php new file mode 100644 index 00000000..0473e77e --- /dev/null +++ b/tests/phpunit/integration/api/html/beansBuildSkipLinks.php @@ -0,0 +1,221 @@ +assertEquals( beans_get_layout(), 'c' ); + + $expected = <<
      • Skip to the content.
      • +EOB; + ob_start(); + beans_build_skip_links(); + $actual = ob_get_clean(); + + $this->assertContains( $expected, $actual ); + } + + /** + * Test beans_build_skip_links() should output content and primary sidebar skip links. + */ + public function test_should_output_content_primary_sidebar_skip_links() { + Monkey\Functions\expect( 'beans_is_active_widget_area' ) + ->once() + ->with( 'sidebar_primary' ) + ->andReturn( 'true' ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_sp'; + }); + + $this->assertEquals( beans_get_layout(), 'c_sp' ); + + $expected = <<
      • Skip to the content.
      • Skip to the primary sidebar.
      • +EOB; + ob_start(); + beans_build_skip_links(); + $actual = ob_get_clean(); + + $this->assertContains( $expected, $actual ); + } + + /** + * Test beans_build_skip_links() should output content and secondary sidebar skip links. + */ + public function test_should_output_content_secondary_sidebar_skip_links() { + Monkey\Functions\expect( 'beans_is_active_widget_area' ) + ->once() + ->with( 'sidebar_secondary' ) + ->andReturn( 'true' ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_ss'; + }); + + $this->assertEquals( beans_get_layout(), 'c_ss' ); + + $expected = <<
      • Skip to the content.
      • Skip to the secondary sidebar.
      • +EOB; + ob_start(); + beans_build_skip_links(); + $actual = ob_get_clean(); + + $this->assertContains( $expected, $actual ); + } + + + /** + * Test beans_build_skip_links() should output content and both sidebar skip links. + */ + public function test_should_output_content_both_sidebar_skip_links() { + Monkey\Functions\expect( 'beans_is_active_widget_area' ) + ->once() + ->ordered() + ->with( 'sidebar_primary' ) + ->andReturn( true ) + ->andAlsoExpectIt() + ->once() + ->with( 'sidebar_secondary' ) + ->andReturn( true ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_sp_ss'; + }); + + $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); + + $expected = <<
      • Skip to the content.
      • Skip to the primary sidebar.
      • Skip to the secondary sidebar.
      • +EOB; + ob_start(); + beans_build_skip_links(); + $actual = ob_get_clean(); + + $this->assertContains( $expected, $actual ); + } + + /** + * Test beans_build_skip_links() should output content and only the primary sidebar skip links when layout is 'c_sp_ss' but secondry sidebar is not active. + */ + public function test_should_output_content_only_primary_sidebar_skip_links_when_secondary_sidebar_not_active() { + Monkey\Functions\expect( 'beans_is_active_widget_area' ) + ->once() + ->ordered() + ->with( 'sidebar_primary' ) + ->andReturn( true ) + ->andAlsoExpectIt() + ->once() + ->with( 'sidebar_secondary' ) + ->andReturn( false ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_sp_ss'; + }); + + $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); + + $expected = <<
      • Skip to the content.
      • Skip to the primary sidebar.
      • +EOB; + ob_start(); + beans_build_skip_links(); + $actual = ob_get_clean(); + + $this->assertContains( $expected, $actual ); + } + + /** + * Test beans_build_skip_links() should output content and only the secondary sidebar skip links when layout is 'c_sp_ss' but primary sidebar is not active. + */ + public function test_should_output_content_only_secondary_sidebar_skip_links_when_primary_sidebar_not_active_() { + Monkey\Functions\expect( 'beans_is_active_widget_area' ) + ->once() + ->ordered() + ->with( 'sidebar_primary' ) + ->andReturn( false ) + ->andAlsoExpectIt() + ->once() + ->with( 'sidebar_secondary' ) + ->andReturn( true ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_sp_ss'; + }); + + $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); + + $expected = <<
      • Skip to the content.
      • Skip to the secondary sidebar.
      • +EOB; + ob_start(); + beans_build_skip_links(); + $actual = ob_get_clean(); + + $this->assertContains( $expected, $actual ); + } + + /** + * Test beans_build_skip_links() should output primary navigation, content and both sidebar skip links. + */ + public function test_should_output_primary_navigation_content_and_both_sidebar_skip_links() { + Monkey\Functions\expect( 'has_nav_menu' ) + ->once() + ->with( 'primary' ) + ->andReturn( true ); + + Monkey\Functions\expect( 'beans_is_active_widget_area' ) + ->once() + ->ordered() + ->with( 'sidebar_primary' ) + ->andReturn( true ) + ->andAlsoExpectIt() + ->once() + ->with( 'sidebar_secondary' ) + ->andReturn( true ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_sp_ss'; + }); + + $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); + + $expected = <<
      • Skip to the primary navigation.
      • Skip to the content.
      • Skip to the primary sidebar.
      • Skip to the secondary sidebar.
      • +EOB; + ob_start(); + beans_build_skip_links(); + $actual = ob_get_clean(); + + $this->assertContains( $expected, $actual ); + } +} diff --git a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php index b1dd6a9d..4682b496 100644 --- a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php @@ -54,7 +54,7 @@ public function test_should_load_default_structure_when_given_file_does_not_exis $html = ob_get_clean(); $expected = << +
        EOB; $this->assertStringStartsWith( $expected, trim( $html ) ); diff --git a/tests/phpunit/unit/api/html/beansBuildSkipLinks.php b/tests/phpunit/unit/api/html/beansBuildSkipLinks.php new file mode 100644 index 00000000..d327cf30 --- /dev/null +++ b/tests/phpunit/unit/api/html/beansBuildSkipLinks.php @@ -0,0 +1,103 @@ +once()->andReturn( 'c_sp' ); + Monkey\Functions\expect( 'has_nav_menu' ) + ->once() + ->with( 'primary' ) + ->andReturn( 'true' ); + Monkey\Functions\expect( 'beans_is_active_widget_area' ) + ->once() + ->ordered() + ->with( 'sidebar_primary' ) + ->andReturn( 'true' ) + ->andAlsoExpectIt() + ->never() + ->ordered() + ->with( 'sidebar_secondary' ) + ->andReturn( 'true' ); + Monkey\Functions\expect( 'beans_output_skip_links' ) + ->once() + ->andReturn(); + + $this->assertNull( beans_build_skip_links() ); + } + + /** + * Test beans_build_skip_links() should not call beans_is_active_widget_area() when the layout is full-width. + */ + public function test_should_not_call_beans_is_active_widget_area_when_fullwith_layout() { + Monkey\Functions\expect( 'beans_get_layout' )->once()->andReturn( 'c' ); + Monkey\Functions\expect( 'has_nav_menu' ) + ->once() + ->with( 'primary' ) + ->andReturn( 'true' ); + Monkey\Functions\expect( 'beans_is_active_widget_area' ) + ->never() + ->ordered() + ->with( 'sidebar_primary' ) + ->andReturn( 'true' ) + ->andAlsoExpectIt() + ->never() + ->ordered() + ->with( 'sidebar_secondary' ) + ->andReturn( 'true' ); + Monkey\Functions\expect( 'beans_output_skip_links' ) + ->once() + ->andReturn(); + + $this->assertNull( beans_build_skip_links() ); + } + + /** + * Test beans_build_skip_links() should call beans_is_active_widget_area() twice when the layout includes a secondary sidebar. + */ + public function test_should_call_beans_is_active_widget_area_twice_when_secondary_sidebar_layout() { + Monkey\Functions\expect( 'beans_get_layout' )->once()->andReturn( 'sp_c_ss' ); + Monkey\Functions\expect( 'has_nav_menu' ) + ->once() + ->with( 'primary' ) + ->andReturn( 'true' ); + Monkey\Functions\expect( 'beans_is_active_widget_area' ) + ->once() + ->ordered() + ->with( 'sidebar_primary' ) + ->andReturn( 'true' ) + ->andAlsoExpectIt() + ->once() + ->ordered() + ->with( 'sidebar_secondary' ) + ->andReturn( 'true' ); + Monkey\Functions\expect( 'beans_output_skip_links' ) + ->once() + ->andReturn(); + + $this->assertNull( beans_build_skip_links() ); + } +} diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index 876144ea..6ba66148 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -59,15 +59,18 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); + $this->setup_function_mocks(); + $this->setup_common_wp_stubs(); + $this->load_original_functions( array( 'api/html/class-beans-attribute.php', 'api/html/functions.php', + 'api/html/accessibility.php', 'api/filters/functions.php', + 'api/layout/functions.php', + 'api/widget/functions.php', ) ); - $this->setup_function_mocks(); - $this->setup_common_wp_stubs(); - // Reset the test fixtures. reset( static::$test_markup ); reset( static::$test_attributes ); @@ -79,6 +82,7 @@ protected function setUp() { */ protected function setup_function_mocks() { Monkey\Functions\when( 'beans_esc_attributes' )->alias( array( $this, 'convert_attributes_into_html' ) ); + Monkey\Functions\when( 'beans_add_smart_action' )->justReturn(); } /** From d61041a6d66c7ee0114fb17f8b7a10a2d7e7ffcb Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sat, 9 Jun 2018 22:23:19 -0400 Subject: [PATCH 693/800] Added check for full-width layout --- lib/api/html/accessibility.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/api/html/accessibility.php b/lib/api/html/accessibility.php index 3e8d11ec..e4e93848 100644 --- a/lib/api/html/accessibility.php +++ b/lib/api/html/accessibility.php @@ -24,12 +24,15 @@ function beans_build_skip_links() { $skip_links['beans-content'] = __( 'Skip to the content.', 'tm-beans' ); - if ( in_array( $layout, array( 'c_sp', 'sp_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) && beans_is_active_widget_area( 'sidebar_primary' ) ) { - $skip_links['beans-primary-sidebar'] = __( 'Skip to the primary sidebar.', 'tm-beans' ); - } + if ( 'c' !== $layout ) { + + if ( in_array( $layout, array( 'c_sp', 'sp_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) && beans_is_active_widget_area( 'sidebar_primary' ) ) { + $skip_links['beans-primary-sidebar'] = __( 'Skip to the primary sidebar.', 'tm-beans' ); + } - if ( in_array( $layout, array( 'c_ss', 'ss_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) && beans_is_active_widget_area( 'sidebar_secondary' ) ) { - $skip_links['beans-secondary-sidebar'] = __( 'Skip to the secondary sidebar.', 'tm-beans' ); + if ( in_array( $layout, array( 'c_ss', 'ss_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) && beans_is_active_widget_area( 'sidebar_secondary' ) ) { + $skip_links['beans-secondary-sidebar'] = __( 'Skip to the secondary sidebar.', 'tm-beans' ); + } } /** From 5c41f5def054d970c41f4644ebfd10fd2db878d3 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 10 Jun 2018 14:20:03 -0400 Subject: [PATCH 694/800] Adjusted DocBlocks per code review. --- lib/api/html/accessibility.php | 2 +- lib/templates/fragments/menu.php | 2 +- lib/templates/structure/content.php | 2 +- lib/templates/structure/sidebar-primary.php | 2 +- lib/templates/structure/sidebar-secondary.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/api/html/accessibility.php b/lib/api/html/accessibility.php index e4e93848..4d3d87b3 100644 --- a/lib/api/html/accessibility.php +++ b/lib/api/html/accessibility.php @@ -40,7 +40,7 @@ function beans_build_skip_links() { * * @since 1.5.0 * - * @param array $links { + * @param array $skip_links { * Default skip links. * * @type string HTML ID attribute value to link to. diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index 34119acf..2b83a0a4 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -12,7 +12,7 @@ * Echo primary menu. * * @since 1.0.0 - * @since 1.5.0 Added ID for skip links. + * @since 1.5.0 Added ID and tabindex for skip links. * * @return void */ diff --git a/lib/templates/structure/content.php b/lib/templates/structure/content.php index 8d5ddc9d..8c2927d5 100644 --- a/lib/templates/structure/content.php +++ b/lib/templates/structure/content.php @@ -5,7 +5,7 @@ * @package Beans\Framework\Templates\Structure * * @since 1.0.0 - * @since 1.5.0 Added ID for skip links. + * @since 1.5.0 Added ID and tabindex for skip links. */ // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variable called in a function scope. diff --git a/lib/templates/structure/sidebar-primary.php b/lib/templates/structure/sidebar-primary.php index 1d003d41..252468c1 100644 --- a/lib/templates/structure/sidebar-primary.php +++ b/lib/templates/structure/sidebar-primary.php @@ -5,7 +5,7 @@ * @package Beans\Framework\Templates\Structure * * @since 1.0.0 - * @since 1.5.0 Added ID for skip links. + * @since 1.5.0 Added ID and tabindex for skip links. */ beans_open_markup_e( diff --git a/lib/templates/structure/sidebar-secondary.php b/lib/templates/structure/sidebar-secondary.php index 9797a6d0..4c2cea07 100644 --- a/lib/templates/structure/sidebar-secondary.php +++ b/lib/templates/structure/sidebar-secondary.php @@ -5,7 +5,7 @@ * @package Beans\Framework\Templates\Structure * * @since 1.0.0 - * @since 1.5.0 Added ID for skip links. + * @since 1.5.0 Added ID and tabindex for skip links. */ beans_open_markup_e( From 397997ee14bb13e18bfa5dff0e2cb1f4d63dda0a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 11 Jun 2018 12:13:49 -0500 Subject: [PATCH 695/800] Added beans_uikit_enqueue_components unit tests. --- lib/api/uikit/functions.php | 20 ++-- .../api/uikit/beansUikitEnqueueComponents.php | 113 ++++++++++++++++++ 2 files changed, 123 insertions(+), 10 deletions(-) create mode 100644 tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index 4bd32ea1..4dd8d0dd 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -11,7 +11,7 @@ * * @package Beans\Framework\API\UIkit * - * @since 1.0.0 + * @since 1.0.0 */ /** @@ -27,11 +27,11 @@ * * @since 1.0.0 * - * @param string|array $components Name of the component(s) to include as an indexed array. The name(s) must be - * the UIkit component filename without the extention (e.g. 'grid'). Set to true - * load all components. - * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). - * @param bool $autoload Optional. Automatically include components dependencies. + * @param string|array|bool $components Name of the component(s) to include as an indexed array. The name(s) must be + * the UIkit component filename without the extension (e.g. 'grid'). Set to true + * load all components. + * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). + * @param bool $autoload Optional. Automatically include components dependencies. * * @return void */ @@ -51,7 +51,7 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload } } - // Add components. + // Add components into the registry. $_beans_uikit_enqueued_items['components'][ $type ] = array_merge( (array) $_beans_uikit_enqueued_items['components'][ $type ], (array) $components ); } @@ -208,7 +208,7 @@ function beans_uikit_dequeue_theme( $id ) { /** * Get registered theme. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * @@ -233,7 +233,7 @@ function _beans_uikit_get_registered_theme( $id ) { /** * Enqueue UIkit assets. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * @@ -261,7 +261,7 @@ function _beans_uikit_enqueue_assets() { /** * Enqueue UIkit admin assets. * - * @since 1.0.0 + * @since 1.0.0 * @ignore * @access private * diff --git a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php new file mode 100644 index 00000000..1eac5a44 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php @@ -0,0 +1,113 @@ +assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); + beans_uikit_enqueue_components( 'alert', 'core', false ); + $expected = [ 'alert' ]; + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['core'] ); + + // Test when components are already in the registry. + beans_uikit_enqueue_components( 'button', 'core', false ); + $expected[] = 'button'; + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['core'] ); + beans_uikit_enqueue_components( 'overlay', 'core', false ); + $expected[] = 'overlay'; + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test beans_uikit_enqueue_components() should add then given add-ons component into registry when given a string. + */ + public function test_should_add_given_addons_component_into_registry_when_given_string() { + global $_beans_uikit_enqueued_items; + + // Test when the registry is empty. + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); + beans_uikit_enqueue_components( 'accordion', 'add-ons', false ); + $expected = [ 'accordion' ]; + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['add-ons'] ); + + // Test when components are already in the registry. + beans_uikit_enqueue_components( 'datepicker', 'add-ons', false ); + $expected[] = 'datepicker'; + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['add-ons'] ); + beans_uikit_enqueue_components( 'sticky', 'add-ons', false ); + $expected[] = 'sticky'; + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['add-ons'] ); + } + + /** + * Test beans_uikit_enqueue_components() should add the given core components into registry. + */ + public function test_should_add_given_core_components_into_registry() { + global $_beans_uikit_enqueued_items; + $components = [ + 'alert', + 'button', + 'overlay', + ]; + + // Test when the registry is empty. + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); + beans_uikit_enqueue_components( $components, 'core', false ); + $this->assertSame( $components, $_beans_uikit_enqueued_items['components']['core'] ); + + // Test when components are already in the registry. + beans_uikit_enqueue_components( [ 'tab' ], 'core', false ); + $expected = array_merge( $components, [ 'tab' ] ); + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test beans_uikit_enqueue_components() should add the given add-ons components into registry. + */ + public function test_should_add_given_addons_components_into_registry() { + global $_beans_uikit_enqueued_items; + $components = [ + 'accordion', + 'autocomplete', + 'datepicker', + 'sticky', + 'tooltip', + ]; + + // Test when the registry is empty. + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); + beans_uikit_enqueue_components( $components, 'add-ons', false ); + $this->assertSame( $components, $_beans_uikit_enqueued_items['components']['add-ons'] ); + + // Test when components are already in the registry. + beans_uikit_enqueue_components( [ 'notify' ], 'add-ons', false ); + $expected = array_merge( $components, [ 'notify' ] ); + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['add-ons'] ); + } +} From 4cd7045435b16a48aae63ecee350eb261cbedfcf Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 11 Jun 2018 14:05:15 -0500 Subject: [PATCH 696/800] Added beans_uikit_enqueue_components() integration tests. --- .../api/uikit/beansUikitEnqueueComponents.php | 89 ++++++++++++ .../uikit/includes/class-uikit-test-case.php | 129 ++++++++++++++++++ 2 files changed, 218 insertions(+) create mode 100644 tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php create mode 100644 tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php diff --git a/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php new file mode 100644 index 00000000..dc52c238 --- /dev/null +++ b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php @@ -0,0 +1,89 @@ +assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); + beans_uikit_enqueue_components( $components, 'core', true ); + $expected = array_merge( [ 'flex', 'switcher' ], $components ); + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['core'] ); + + $expected[] = 'close'; + $expected[] = 'modal'; + beans_uikit_enqueue_components( 'modal', 'core', true ); + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['core'] ); + + $expected[] = 'animation'; + $expected[] = 'scrollspy'; + beans_uikit_enqueue_components( 'scrollspy', 'core', true ); + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test beans_uikit_enqueue_components() should add the given addons components and each (autoload) dependency into + * registry. + */ + public function test_should_add_given_addons_components_and_each_dependency_into_registry() { + global $_beans_uikit_enqueued_items; + + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); + beans_uikit_enqueue_components( 'lightbox', 'add-ons', true ); + $expected = [ + 'core' => [ + 'animation', + 'flex', + 'close', + 'modal', + 'overlay', + ], + 'add-ons' => [ + 'slidenav', + 'lightbox', + ], + ]; + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); + + beans_uikit_enqueue_components( 'slider', 'add-ons', true ); + $expected['add-ons'][] = 'slidenav'; + $expected['add-ons'][] = 'slider'; + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); + + beans_uikit_enqueue_components( [ 'accordion', 'autocomplete', 'slideset' ], 'add-ons', true ); + $expected['core'] = array_merge( $expected['core'], [ 'animation', 'flex' ] ); + $expected['add-ons'] = array_merge( $expected['add-ons'], [ 'dotnav', 'slidenav', 'accordion', 'autocomplete', 'slideset' ] ); + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); + } +} diff --git a/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php new file mode 100644 index 00000000..bfbe9142 --- /dev/null +++ b/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php @@ -0,0 +1,129 @@ +set_up_virtual_filesystem(); + $this->set_up_uploads_directory(); + + $this->reset_globals(); + } + + /** + * Set up the virtual filesystem. + */ + protected function set_up_virtual_filesystem() { + $this->mock_filesystem = vfsStream::setup( + 'virtual-wp-content', + 0755, + $this->get_virtual_structure() + ); + } + + /** + * Get the virtual filesystem's structure. + */ + protected function get_virtual_structure() { + return [ + 'themes' => [ + 'beans-child' => [ + 'assets' => [ + 'js' => [ + 'alert.min.js' => '', + ], + 'less' => [ + 'theme' => [ + 'alert.less' => '', + 'article.less' => '', + 'panel.less' => '', + 'variables.less' => '', + 'style.less' => '', + 'variables.less' => '', + ], + ], + ], + 'functions.php' => '', + 'style.css' => '', + ], + ], + 'uploads' => [ + 'beans' => [ + 'compiler' => [ + 'uikit' => [ + 'index.php' => '', + ], + ], + ], + ], + ]; + } + + /** + * Set the Uploads directory to our virtual filesystem. + */ + protected function set_up_uploads_directory() { + add_filter( 'upload_dir', function( array $uploads_dir ) { + $compiled_dir = vfsStream::url( 'virtual-wp-content/uploads' ); + + $uploads_dir['path'] = $compiled_dir . $uploads_dir['subdir']; + $uploads_dir['url'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['url'] ); + $uploads_dir['basedir'] = $compiled_dir; + $uploads_dir['baseurl'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['baseurl'] ); + + return $uploads_dir; + } ); + } + + /** + * Reset the global containers. + */ + protected function reset_globals() { + global $_beans_uikit_enqueued_items, $_beans_uikit_registered_items; + + $_beans_uikit_enqueued_items = array( + 'components' => array( + 'core' => array(), + 'add-ons' => array(), + ), + 'themes' => array(), + ); + + $_beans_uikit_registered_items = array( + 'themes' => array( + 'default' => BEANS_API_PATH . 'uikit/src/themes/default', + 'almost-flat' => BEANS_API_PATH . 'uikit/src/themes/almost-flat', + 'gradient' => BEANS_API_PATH . 'uikit/src/themes/gradient', + 'wordpress-admin' => BEANS_API_PATH . 'uikit/themes/wordpress-admin', + ), + ); + } +} From 9459dc7f91c210734e1ae1c710e3bee1119d2a15 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 11 Jun 2018 15:41:07 -0500 Subject: [PATCH 697/800] Added new array utility functions. Throughout UIkit API, we join, remove duplicates and empties, and re-index the clean array. To avoid duplication, this commit adds 2 new functions: - beans_array_unique() - beans_join_arrays_clean() beans_array_unique() functions the same as PHP's array_unique in that it removes duplicate elements. However, it also re-indexes the new array before returning it. beans_join_arrays_clean() joins the 2 arrays and then cleans the joined array by removing the duplicates and empties. By default, it will re-index the clean array, though the 3rd parameter allows to preserve the keys. --- lib/api/utilities/functions.php | 42 +++++- .../api/uikit/beansUikitEnqueueComponents.php | 4 +- .../unit/api/utilities/beansArrayUnique.php | 95 ++++++++++++++ .../api/utilities/beansJoinArraysClean.php | 124 ++++++++++++++++++ 4 files changed, 260 insertions(+), 5 deletions(-) create mode 100644 tests/phpunit/unit/api/utilities/beansArrayUnique.php create mode 100644 tests/phpunit/unit/api/utilities/beansJoinArraysClean.php diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 4e5f9f6a..8075bbd1 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -534,6 +534,7 @@ function beans_join_arrays( array &$array1, array $array2 ) { // If the 1st array is empty, set it to the 2nd array. Then bail out as we're done. if ( empty( $array1 ) ) { $array1 = $array2; + return; } @@ -541,6 +542,43 @@ function beans_join_arrays( array &$array1, array $array2 ) { $array1 = array_merge( $array1, $array2 ); } +/** + * Removes duplicate values from the given array and re-indexes to start at element 0. Keys are not preserved. + * + * @since 1.5.0 + * + * @param array $array The given array to filter. + * + * @return array + */ +function beans_array_unique( array $array ) { + return array_values( array_unique( $array ) ); +} + +/** + * Join the given arrays and clean the merged array by removing duplicates and empties. By default, the clean joined + * array is re-indexed; however, setting the third parameter to `false` will preserve the keys. + * + * @since 1.5.0 + * + * @param array $array1 Initial array to join. + * @param array $array2 The array to merge into $array1. + * @param bool $reindex When true, re-indexes the clean array; else, preserves the keys. + * + * @return array + */ +function beans_join_arrays_clean( array $array1, array $array2, $reindex = true ) { + beans_join_arrays( $array1, $array2 ); + + if ( empty( $array1 ) ) { + return $array1; + } + + $array1 = array_filter( array_unique( $array1 ) ); + + return $reindex ? array_values( $array1 ) : $array1; +} + /** * Checks if the given input is a URL or data URI. It checks that the given input begins with: * - http @@ -563,7 +601,7 @@ function _beans_is_uri( $maybe_uri ) { /** * Checks if WP is doing ajax. * - * @since 1.5.0 + * @since 1.5.0 * @ignore * @access private * @@ -576,7 +614,7 @@ function _beans_doing_ajax() { /** * Checks if WP is doing an autosave. * - * @since 1.5.0 + * @since 1.5.0 * @ignore * @access private * diff --git a/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php index dc52c238..767c793e 100644 --- a/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php +++ b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php @@ -77,13 +77,11 @@ public function test_should_add_given_addons_components_and_each_dependency_into $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); beans_uikit_enqueue_components( 'slider', 'add-ons', true ); - $expected['add-ons'][] = 'slidenav'; $expected['add-ons'][] = 'slider'; $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); beans_uikit_enqueue_components( [ 'accordion', 'autocomplete', 'slideset' ], 'add-ons', true ); - $expected['core'] = array_merge( $expected['core'], [ 'animation', 'flex' ] ); - $expected['add-ons'] = array_merge( $expected['add-ons'], [ 'dotnav', 'slidenav', 'accordion', 'autocomplete', 'slideset' ] ); + $expected['add-ons'] = array_merge( $expected['add-ons'], [ 'dotnav', 'accordion', 'autocomplete', 'slideset' ] ); $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); } } diff --git a/tests/phpunit/unit/api/utilities/beansArrayUnique.php b/tests/phpunit/unit/api/utilities/beansArrayUnique.php new file mode 100644 index 00000000..663b50b5 --- /dev/null +++ b/tests/phpunit/unit/api/utilities/beansArrayUnique.php @@ -0,0 +1,95 @@ +assertSame( $array, beans_array_unique( $array ) ); + + $array = [ 'foo', 'bar', 'Beans', 'WordPress' ]; + $this->assertSame( $array, beans_array_unique( $array ) ); + } + + /** + * Test beans_array_unique() should re-indexed the original array. + */ + public function test_should_reindexed_original_array() { + $actual = [ + 'foo', + 5 => 5, + 10 => 'bar', + 15 => 47, + ]; + $this->assertSame( [ 'foo', 5, 'bar', 47 ], beans_array_unique( $actual ) ); + + $actual = [ + 'oof' => 'foo', + 'rab' => 'bar', + 'beans' => 'Beans', + 'wp' => 'WordPress', + ]; + $expected = [ 'foo', 'bar', 'Beans', 'WordPress' ]; + $this->assertSame( $expected, beans_array_unique( $actual ) ); + } + + /** + * Test beans_array_unique() should remove duplicates and re-index the array. + */ + public function test_should_remove_duplicates_and_reindex_array() { + $actual = [ + 'foo', + 5 => 5, + 10 => 'bar', + 'foo', + 15 => 47, + 'bar', + 5, + ]; + $this->assertSame( [ 'foo', 5, 'bar', 47 ], beans_array_unique( $actual ) ); + + $actual = [ + 'oof' => 'foo', + 'rab' => 'bar', + 'beans' => 'Beans', + 'bar', + 'foo', + 'wp' => 'WordPress', + 'Beans', + 'foo', + 'foo' => 'bar', + ]; + $expected = [ 'foo', 'bar', 'Beans', 'WordPress' ]; + $this->assertSame( $expected, beans_array_unique( $actual ) ); + } +} diff --git a/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php b/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php new file mode 100644 index 00000000..76fe045b --- /dev/null +++ b/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php @@ -0,0 +1,124 @@ +assertSame( [], beans_join_arrays_clean( $array1, $array2 ) ); + } + + /** + * Test beans_join_arrays_clean() should return clean array1 when array 2 is empty. + */ + public function test_should_clean_array1_when_array2_is_empty() { + $array1 = [ + 'post_type' => 'foo', + '' => '', + 'number_of_posts' => 5, + '', + ]; + $array2 = []; + $this->assertSame( [ 'foo', 5 ], beans_join_arrays_clean( $array1, $array2 ) ); + $this->assertSame( [ + 'post_type' => 'foo', + 'number_of_posts' => 5, + ], beans_join_arrays_clean( $array1, $array2, false ) ); + + $array1 = [ '', 'foo', 'bar', '', 'baz' ]; + $array2 = []; + $this->assertSame( [ 'foo', 'bar', 'baz' ], beans_join_arrays_clean( $array1, $array2 ) ); + $this->assertSame( [ + 1 => 'foo', + 2 => 'bar', + 4 => 'baz', + ], beans_join_arrays_clean( $array1, $array2, false ) ); + + } + + /** + * Test beans_join_arrays_clean() should clean array2 when array1 is empty. + */ + public function test_should_clean_array2_when_array1_is_empty() { + // Check with associative array. + $array1 = []; + $array2 = [ + 'post_type' => 'foo', + '' => '', + 'number_of_posts' => 5, + 'bar' => null, + ]; + $this->assertSame( [ 'foo', 5 ], beans_join_arrays_clean( $array1, $array2 ) ); + $this->assertSame( [ + 'post_type' => 'foo', + 'number_of_posts' => 5, + ], beans_join_arrays_clean( $array1, $array2, false ) ); + + // Check with indexed array. + $array1 = []; + $array2 = [ '', 'foo', 'bar', '', 'baz' ]; + $this->assertSame( [ 'foo', 'bar', 'baz' ], beans_join_arrays_clean( $array1, $array2 ) ); + $this->assertSame( [ + 1 => 'foo', + 2 => 'bar', + 4 => 'baz', + ], beans_join_arrays_clean( $array1, $array2, false ) ); + } + + /** + * Test beans_join_arrays_clean() should join and clean the arrays when both are not empty. + */ + public function test_should_join_and_clean_the_arrays_when_both_are_not_empty() { + $array1 = [ + 'foo' => 0, + 'baz' => '', + 'post_type' => 'foo', + 3 => '', + 'bar' => null, + 'number_of_posts' => 5, + 5 => 0, + ]; + $array2 = [ + 'foo' => 'bar', + 'baz' => 'Hello', + ]; + $this->assertSame( [ 'bar', 'Hello', 'foo', 5 ], beans_join_arrays_clean( $array1, $array2 ) ); + $this->assertSame( [ + 'foo' => 'bar', + 'baz' => 'Hello', + 'post_type' => 'foo', + 'number_of_posts' => 5, + ], beans_join_arrays_clean( $array1, $array2, false ) ); + } +} From b5c15b3ddf1a6edc8f9d9f1088d77e309d772f15 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 11 Jun 2018 15:58:39 -0500 Subject: [PATCH 698/800] Utilized beans_array_unique in _Beans_Uikit. --- lib/api/uikit/class-beans-uikit.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 4d85b2fd..d3ce4efa 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -272,7 +272,7 @@ public function get_all_components( $type ) { } // Clean up by removing duplicates and empties. - return array_filter( $this->get_unique_values( $components ) ); + return array_filter( beans_array_unique( $components ) ); } /** @@ -342,25 +342,12 @@ private function remove_duplicate_values( array $source ) { continue; } - $source[ $key ] = $this->get_unique_values( $value ); + $source[ $key ] = beans_array_unique( $value ); } return $source; } - /** - * Get an array of unique values from the given array. - * - * @since 1.5.0 - * - * @param array $array The given array to process. - * - * @return array - */ - private function get_unique_values( array $array ) { - return array_values( array_unique( $array ) ); - } - /** * Initialize the components' dependencies, by loading from its configuration file when null. * From 52532ca70d98086c3a99f3a8637e5a196de217c9 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 11 Jun 2018 16:00:17 -0500 Subject: [PATCH 699/800] Removed duplicates before storing beans_uikit_enqueue_components. Instead of storing all the duplicates, this commit uses beans_join_arrays_clean() to join the arrays (replaces array_merge), remove the duplicates and empties, and then re-index the array to save memory. The clean joined array is then stored in the components registry. --- lib/api/uikit/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index 4dd8d0dd..e3104c9b 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -52,7 +52,7 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload } // Add components into the registry. - $_beans_uikit_enqueued_items['components'][ $type ] = array_merge( (array) $_beans_uikit_enqueued_items['components'][ $type ], (array) $components ); + $_beans_uikit_enqueued_items['components'][ $type ] = beans_join_arrays_clean( (array) $_beans_uikit_enqueued_items['components'][ $type ], (array) $components ); } /** From 3ed08168768a4e8fa44c9d5205c8bf0c847196ef Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 11 Jun 2018 18:25:17 -0500 Subject: [PATCH 700/800] Added additional tests for beans_uikit_enqueue_components(). --- .../api/uikit/beansUikitEnqueueComponents.php | 94 ++++++++++++++++++- .../api/uikit/beansUikitEnqueueComponents.php | 50 ++++++++++ 2 files changed, 140 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php index 767c793e..8e8aeaeb 100644 --- a/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php +++ b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php @@ -24,7 +24,7 @@ class Tests_BeansUikitEnqueueComponents extends UIkit_Test_Case { /** * Test beans_uikit_enqueue_components() should add the given core components and each (autoload) dependency into - * registry. + * the registry. */ public function test_should_add_given_core_components_and_each_dependency_into_registry() { global $_beans_uikit_enqueued_items; @@ -53,7 +53,7 @@ public function test_should_add_given_core_components_and_each_dependency_into_r /** * Test beans_uikit_enqueue_components() should add the given addons components and each (autoload) dependency into - * registry. + * the registry. */ public function test_should_add_given_addons_components_and_each_dependency_into_registry() { global $_beans_uikit_enqueued_items; @@ -62,7 +62,7 @@ public function test_should_add_given_addons_components_and_each_dependency_into $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); beans_uikit_enqueue_components( 'lightbox', 'add-ons', true ); $expected = [ - 'core' => [ + 'core' => [ 'animation', 'flex', 'close', @@ -81,7 +81,93 @@ public function test_should_add_given_addons_components_and_each_dependency_into $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); beans_uikit_enqueue_components( [ 'accordion', 'autocomplete', 'slideset' ], 'add-ons', true ); - $expected['add-ons'] = array_merge( $expected['add-ons'], [ 'dotnav', 'accordion', 'autocomplete', 'slideset' ] ); + $expected['add-ons'] = array_merge( $expected['add-ons'], [ + 'dotnav', + 'accordion', + 'autocomplete', + 'slideset', + ] ); $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); } + + /** + * Test beans_uikit_enqueue_components() should add all core components into the registry when $components is true. + */ + public function test_should_add_all_core_components_into_registry_when_components_is_true() { + global $_beans_uikit_enqueued_items; + + beans_uikit_enqueue_components( true ); + + $this->assertCount( 42, $_beans_uikit_enqueued_items['components']['core'] ); + + // Check common components. + $this->assertContains( 'alert', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'button', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'cover', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'grid', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'nav', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'offcanvas', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'tab', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'utility', $_beans_uikit_enqueued_items['components']['core'] ); + + // Spot check the unique LESS components. + $this->assertContains( 'base', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'close', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'column', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'description-list', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'thumbnail', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'variables', $_beans_uikit_enqueued_items['components']['core'] ); + + // Spot check the unique JS components. + $this->assertContains( 'core', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'scrollspy', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'smooth-scroll', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'toggle', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertContains( 'touch', $_beans_uikit_enqueued_items['components']['core'] ); + + // Check the components do not contain add-ons. + $this->assertNotContains( 'accordion', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertNotContains( 'datepicker', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertNotContains( 'notify', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertNotContains( 'progress', $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test beans_uikit_enqueue_components() should add all add-ons components into the registry when $components is + * true. + */ + public function test_should_add_all_addons_components_into_registry_when_components_is_true() { + global $_beans_uikit_enqueued_items; + + beans_uikit_enqueue_components( true, 'add-ons' ); + + $this->assertCount( 29, $_beans_uikit_enqueued_items['components']['add-ons'] ); + + // Check common components. + $this->assertContains( 'accordion', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'autocomplete', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'datepicker', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'form-password', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'search', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'sticky', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'tooltip', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'upload', $_beans_uikit_enqueued_items['components']['add-ons'] ); + + // Spot check the unique LESS components. + $this->assertContains( 'dotnav', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'form-advanced', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'htmleditor', $_beans_uikit_enqueued_items['components']['add-ons'] ); + + // Spot check the unique JS components. + $this->assertContains( 'parallax', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'lightbox', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'slideshow-fx', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertContains( 'timepicker', $_beans_uikit_enqueued_items['components']['add-ons'] ); + + // Check the components do not contain add-ons. + $this->assertNotContains( 'alert', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertNotContains( 'badge', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertNotContains( 'base', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertNotContains( 'close', $_beans_uikit_enqueued_items['components']['add-ons'] ); + } } diff --git a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php index 1eac5a44..92a1e6d5 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php +++ b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php @@ -110,4 +110,54 @@ public function test_should_add_given_addons_components_into_registry() { $expected = array_merge( $components, [ 'notify' ] ); $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['add-ons'] ); } + + /** + * Test beans_uikit_enqueue_components() should not add duplicates into the registry. + */ + public function test_should_not_add_duplicates_into_registry() { + global $_beans_uikit_enqueued_items; + + $core = [ + 'alert', + 'button', + 'overlay', + ]; + $addons = [ + 'accordion', + 'autocomplete', + 'datepicker', + 'sticky', + 'tooltip', + ]; + $_beans_uikit_enqueued_items['components'] = [ + 'core' => $core, + 'add-ons' => $addons, + ]; + + // Check the core components. + beans_uikit_enqueue_components( 'alert', 'core', false ); + $this->assertCount( 3, $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertSame( $core, $_beans_uikit_enqueued_items['components']['core'] ); + + // Check when duplicates are in different order. + beans_uikit_enqueue_components( [ 'overlay', 'alert', 'button' ], 'core', false ); + $this->assertCount( 3, $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertSame( $core, $_beans_uikit_enqueued_items['components']['core'] ); + + // Check the add-ons components. + beans_uikit_enqueue_components( 'accordion', 'add-ons', false ); + $this->assertCount( 5, $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertSame( $addons, $_beans_uikit_enqueued_items['components']['add-ons'] ); + + // Check when duplicates are in different order. + beans_uikit_enqueue_components( [ + 'datepicker', + 'sticky', + 'tooltip', + 'autocomplete', + 'accordion', + ], 'add-ons', false ); + $this->assertCount( 5, $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertSame( $addons, $_beans_uikit_enqueued_items['components']['add-ons'] ); + } } From 6beb2c41ed2ae8dfd1d1ada78409dbf07725981c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 11 Jun 2018 18:37:40 -0500 Subject: [PATCH 701/800] Refactored to move getting all components to a new function. The task of getting all components is repeated in the file. Plus, there may be instances when a plugin or theme developer wants to get all the components. This commit refactors to create a wrapper function called beans_uikit_get_all_components(). --- lib/api/uikit/functions.php | 21 ++- .../api/uikit/beansUikitEnqueueComponents.php | 43 +++++- .../api/uikit/beansUikitGetAllComponents.php | 137 ++++++++++++++++++ 3 files changed, 196 insertions(+), 5 deletions(-) create mode 100644 tests/phpunit/unit/api/uikit/beansUikitGetAllComponents.php diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index e3104c9b..6e8ff550 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -40,8 +40,7 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload // Get all uikit components. if ( true === $components ) { - $uikit = new _Beans_Uikit(); - $components = $uikit->get_all_components( $type ); + $components = beans_uikit_get_all_components( $type ); } elseif ( $autoload ) { $uikit = new _Beans_Uikit(); $autoloads = $uikit->get_autoload_components( (array) $components ); @@ -79,8 +78,7 @@ function beans_uikit_dequeue_components( $components, $type = 'core' ) { global $_beans_uikit_enqueued_items; if ( true === $components ) { - $uikit = new _Beans_Uikit(); - $components = $uikit->get_all_components( $type ); + $components = beans_uikit_get_all_components( $type ); } // Remove components. @@ -168,6 +166,21 @@ function beans_uikit_dequeue_theme( $id ) { unset( $_beans_uikit_enqueued_items['themes'][ $id ] ); } +/** + * Gets all of the UIkit components for the given type, i.e. for core or add-ons. + * + * @since 1.5.0 + * + * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). + * + * @return array + */ +function beans_uikit_get_all_components( $type = 'core' ) { + $uikit = new _Beans_Uikit(); + + return $uikit->get_all_components( $type ); +} + /** * Initialize registered UIkit items global. * diff --git a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php index 92a1e6d5..b7c7ef12 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php +++ b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php @@ -9,8 +9,8 @@ namespace Beans\Framework\Tests\Unit\API\UIkit; -use _Beans_Uikit; use Beans\Framework\Tests\Unit\API\UIkit\Includes\UIkit_Test_Case; +use Brain\Monkey; require_once __DIR__ . '/includes/class-uikit-test-case.php'; @@ -160,4 +160,45 @@ public function test_should_not_add_duplicates_into_registry() { $this->assertCount( 5, $_beans_uikit_enqueued_items['components']['add-ons'] ); $this->assertSame( $addons, $_beans_uikit_enqueued_items['components']['add-ons'] ); } + + /** + * Test beans_uikit_enqueue_components() should add all core components into the registry when $components is true. + */ + public function test_should_add_all_core_components_into_registry_when_components_is_true() { + $components = [ + 'alert', + 'animation', + 'article', + 'badge', + 'base', + ]; + + Monkey\Functions\expect( 'beans_uikit_get_all_components' )->once()->with( 'core' )->andReturn( $components ); + + beans_uikit_enqueue_components( true ); + + global $_beans_uikit_enqueued_items; + $this->assertSame( $components, $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test beans_uikit_enqueue_components() should add all add-ons components into the registry when $components is true. + */ + public function test_should_add_all_addons_components_into_registry_when_components_is_true() { + $components = [ + 'accordion', + 'autocomplete', + 'datepicker', + 'dotnav', + 'form-advanced', + 'sticky', + ]; + + Monkey\Functions\expect( 'beans_uikit_get_all_components' )->once()->with( 'add-ons' )->andReturn( $components ); + + beans_uikit_enqueue_components( true, 'add-ons' ); + + global $_beans_uikit_enqueued_items; + $this->assertSame( $components, $_beans_uikit_enqueued_items['components']['add-ons'] ); + } } diff --git a/tests/phpunit/unit/api/uikit/beansUikitGetAllComponents.php b/tests/phpunit/unit/api/uikit/beansUikitGetAllComponents.php new file mode 100644 index 00000000..6f14760f --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beansUikitGetAllComponents.php @@ -0,0 +1,137 @@ +assertEquals( 1, $num_times_component_in_array['alert'] ); + $this->assertEquals( 1, $num_times_component_in_array['button'] ); + $this->assertEquals( 1, $num_times_component_in_array['cover'] ); + $this->assertEquals( 1, $num_times_component_in_array['tab'] ); + + // By flipping the array, we should only have 1 element when there are no duplicates. + $this->assertCount( 1, array_flip( $num_times_component_in_array ) ); + } + + /** + * Test beans_uikit_get_all_components() should not return duplicate add-ons components. + */ + public function test_should_not_return_duplicate_add_ons_components() { + $actual = beans_uikit_get_all_components( 'add-ons' ); + + // Get the number of times each component appears in the array. + $num_times_component_in_array = array_count_values( $actual ); + + // Spot check the common components that are in both JS and LESS directories, meaning they could be duplicated. + $this->assertEquals( 1, $num_times_component_in_array['accordion'] ); + $this->assertEquals( 1, $num_times_component_in_array['autocomplete'] ); + $this->assertEquals( 1, $num_times_component_in_array['datepicker'] ); + $this->assertEquals( 1, $num_times_component_in_array['sticky'] ); + $this->assertEquals( 1, $num_times_component_in_array['tooltip'] ); + + // By flipping the array, we should only have 1 element when there are no duplicates. + $this->assertCount( 1, array_flip( $num_times_component_in_array ) ); + } + + /** + * Test beans_uikit_get_all_components() should return all core components. + */ + public function test_should_return_all_core_components() { + $actual = beans_uikit_get_all_components( 'core' ); + $this->assertCount( 42, $actual ); + + // Check common components. + $this->assertContains( 'alert', $actual ); + $this->assertContains( 'button', $actual ); + $this->assertContains( 'cover', $actual ); + $this->assertContains( 'grid', $actual ); + $this->assertContains( 'nav', $actual ); + $this->assertContains( 'offcanvas', $actual ); + $this->assertContains( 'tab', $actual ); + $this->assertContains( 'utility', $actual ); + + // Spot check the unique LESS components. + $this->assertContains( 'base', $actual ); + $this->assertContains( 'close', $actual ); + $this->assertContains( 'column', $actual ); + $this->assertContains( 'description-list', $actual ); + $this->assertContains( 'thumbnail', $actual ); + $this->assertContains( 'variables', $actual ); + + // Spot check the unique JS components. + $this->assertContains( 'core', $actual ); + $this->assertContains( 'scrollspy', $actual ); + $this->assertContains( 'smooth-scroll', $actual ); + $this->assertContains( 'toggle', $actual ); + $this->assertContains( 'touch', $actual ); + + // Check the components do not contain add-ons. + $this->assertNotContains( 'accordion', $actual ); + $this->assertNotContains( 'datepicker', $actual ); + $this->assertNotContains( 'notify', $actual ); + $this->assertNotContains( 'progress', $actual ); + } + + /** + * Test beans_uikit_get_all_components() should return all add-ons components. + */ + public function test_should_return_all_add_ons_components() { + $actual = beans_uikit_get_all_components( 'add-ons' ); + $this->assertCount( 29, $actual ); + + // Check common components. + $this->assertContains( 'accordion', $actual ); + $this->assertContains( 'autocomplete', $actual ); + $this->assertContains( 'datepicker', $actual ); + $this->assertContains( 'form-password', $actual ); + $this->assertContains( 'search', $actual ); + $this->assertContains( 'sticky', $actual ); + $this->assertContains( 'tooltip', $actual ); + $this->assertContains( 'upload', $actual ); + + // Spot check the unique LESS components. + $this->assertContains( 'dotnav', $actual ); + $this->assertContains( 'form-advanced', $actual ); + $this->assertContains( 'htmleditor', $actual ); + + // Spot check the unique JS components. + $this->assertContains( 'parallax', $actual ); + $this->assertContains( 'lightbox', $actual ); + $this->assertContains( 'slideshow-fx', $actual ); + $this->assertContains( 'timepicker', $actual ); + + // Check the components do not contain add-ons. + $this->assertNotContains( 'alert', $actual ); + $this->assertNotContains( 'badge', $actual ); + $this->assertNotContains( 'base', $actual ); + $this->assertNotContains( 'close', $actual ); + } +} From 761b66ef39204da233825d903c8adf8b280ced34 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 11 Jun 2018 19:17:52 -0500 Subject: [PATCH 702/800] Refactored to move processing dependencies to new functions. There might be instances when a plugin or theme developer will need to get all of the dependencies. The new beans_uikit_get_all_dependencies() function gives them access to the private method. For processing the dependencies and loading them into the registry, this commit adds a new private function _beans_uikit_autoload_dependencies(). This refactoring makes the enqueue function easier to read and understand, while separating the task of dependencies out. --- lib/api/uikit/functions.php | 42 ++- .../uikit/beansUikitAutoloadDependencies.php | 67 +++++ .../api/uikit/beansUikitEnqueueComponents.php | 2 +- .../api/uikit/beansUikitEnqueueComponents.php | 52 +++- .../uikit/beansUikitGetAllDependencies.php | 261 ++++++++++++++++++ 5 files changed, 416 insertions(+), 8 deletions(-) create mode 100644 tests/phpunit/integration/api/uikit/beansUikitAutoloadDependencies.php create mode 100644 tests/phpunit/unit/api/uikit/beansUikitGetAllDependencies.php diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index 6e8ff550..f6a00f78 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -42,12 +42,7 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload if ( true === $components ) { $components = beans_uikit_get_all_components( $type ); } elseif ( $autoload ) { - $uikit = new _Beans_Uikit(); - $autoloads = $uikit->get_autoload_components( (array) $components ); - - foreach ( $autoloads as $autotype => $autoload ) { - beans_uikit_enqueue_components( $autoload, $autotype, false ); - } + _beans_uikit_autoload_dependencies( $components ); } // Add components into the registry. @@ -181,6 +176,41 @@ function beans_uikit_get_all_components( $type = 'core' ) { return $uikit->get_all_components( $type ); } +/** + * Gets all of the UIkit dependencies for the given component(s). + * + * @since 1.5.0 + * + * @param string|array $components Name of the component(s) to process. The name(s) must be + * the UIkit component filename without the extension (e.g. 'grid'). + * + * @return array + */ +function beans_uikit_get_all_dependencies( $components ) { + $uikit = new _Beans_Uikit(); + + return $uikit->get_autoload_components( (array) $components ); +} + +/** + * Autoload all the component dependencies. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @param string|array $components Name of the component(s) to include as an indexed array. The name(s) must be + * the UIkit component filename without the extension (e.g. 'grid'). + * + * @return void + */ +function _beans_uikit_autoload_dependencies( $components ) { + + foreach ( beans_uikit_get_all_dependencies( $components ) as $type => $autoload ) { + beans_uikit_enqueue_components( $autoload, $type, false ); + } +} + /** * Initialize registered UIkit items global. * diff --git a/tests/phpunit/integration/api/uikit/beansUikitAutoloadDependencies.php b/tests/phpunit/integration/api/uikit/beansUikitAutoloadDependencies.php new file mode 100644 index 00000000..20c0eec2 --- /dev/null +++ b/tests/phpunit/integration/api/uikit/beansUikitAutoloadDependencies.php @@ -0,0 +1,67 @@ +assertSame( [ 'flex', 'switcher' ], $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test _beans_uikit_autoload_dependencies() should add each add-ons (autoload) dependency into the registry. + */ + public function test_should_add_each_addons_dependency_into_registry() { + global $_beans_uikit_enqueued_items; + + _beans_uikit_autoload_dependencies( [ 'accordion', 'autocomplete', 'slideset' ] ); + $this->assertSame( [ 'dotnav', 'slidenav' ], $_beans_uikit_enqueued_items['components']['add-ons'] ); + } + + /** + * Test _beans_uikit_autoload_dependencies() should add each (autoload) dependency into the registry. + */ + public function test_should_add_each_dependency_into_registry() { + global $_beans_uikit_enqueued_items; + + _beans_uikit_autoload_dependencies( [ 'lightbox', 'slideshow' ] ); + $expected = [ + 'core' => [ + 'animation', + 'flex', + 'close', + 'modal', + 'overlay', + ], + 'add-ons' => [ + 'slidenav', + 'dotnav', + ], + ]; + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); + } +} diff --git a/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php index 8e8aeaeb..5dc36335 100644 --- a/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php +++ b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php @@ -62,7 +62,7 @@ public function test_should_add_given_addons_components_and_each_dependency_into $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); beans_uikit_enqueue_components( 'lightbox', 'add-ons', true ); $expected = [ - 'core' => [ + 'core' => [ 'animation', 'flex', 'close', diff --git a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php index b7c7ef12..13aa37a4 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php +++ b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php @@ -182,7 +182,8 @@ public function test_should_add_all_core_components_into_registry_when_component } /** - * Test beans_uikit_enqueue_components() should add all add-ons components into the registry when $components is true. + * Test beans_uikit_enqueue_components() should add all add-ons components into the registry when $components is + * true. */ public function test_should_add_all_addons_components_into_registry_when_components_is_true() { $components = [ @@ -201,4 +202,53 @@ public function test_should_add_all_addons_components_into_registry_when_compone global $_beans_uikit_enqueued_items; $this->assertSame( $components, $_beans_uikit_enqueued_items['components']['add-ons'] ); } + + /** + * Test beans_uikit_enqueue_components() should add the given core components and each (autoload) dependency into + * the registry. + */ + public function test_should_add_given_core_components_and_each_dependency_into_registry() { + global $_beans_uikit_enqueued_items; + $components = [ + 'alert', + 'button', + 'overlay', + 'tab', + ]; + Monkey\Functions\expect( '_beans_uikit_autoload_dependencies' ) + ->once() + ->with( $components ) + ->andReturnUsing( function() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['core'] = [ 'flex', 'switcher' ]; + + return [ 'flex', 'switcher' ]; + } ); + + beans_uikit_enqueue_components( $components, 'core', true ); + $expected = array_merge( [ 'flex', 'switcher' ], $components ); + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test beans_uikit_enqueue_components() should add the given add-ons components and each (autoload) dependency into + * the registry. + */ + public function test_should_add_given_addons_components_and_each_dependency_into_registry() { + global $_beans_uikit_enqueued_items; + $components = [ 'accordion', 'autocomplete', 'slideset' ]; + Monkey\Functions\expect( '_beans_uikit_autoload_dependencies' ) + ->once() + ->with( $components ) + ->andReturnUsing( function() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['add-ons'] = [ 'dotnav' ]; + + return [ 'dotnav' ]; + } ); + + beans_uikit_enqueue_components( $components, 'add-ons', true ); + $expected = array_merge( [ 'dotnav' ], $components ); + $this->assertSame( $expected, $_beans_uikit_enqueued_items['components']['add-ons'] ); + } } diff --git a/tests/phpunit/unit/api/uikit/beansUikitGetAllDependencies.php b/tests/phpunit/unit/api/uikit/beansUikitGetAllDependencies.php new file mode 100644 index 00000000..d52bbcb9 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beansUikitGetAllDependencies.php @@ -0,0 +1,261 @@ +assertSame( [ + 'core' => [], + 'add-ons' => [], + ], beans_uikit_get_all_dependencies( $components ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the panel. + */ + public function test_should_return_dependencies_for_panel() { + $expected = [ + 'core' => [ 'badge' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'panel' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the cover. + */ + public function test_should_return_dependencies_for_cover() { + $expected = [ + 'core' => [ 'flex' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'cover' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the overlay. + */ + public function test_should_return_dependencies_for_overlay() { + $expected = [ + 'core' => [ 'flex' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'overlay' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the tab. + */ + public function test_should_return_dependencies_for_tab() { + $expected = [ + 'core' => [ 'switcher' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'tab' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the modal. + */ + public function test_should_return_dependencies_for_modal() { + $expected = [ + 'core' => [ 'close' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'modal' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the scrollspy. + */ + public function test_should_return_dependencies_for_scrollspy() { + $expected = [ + 'core' => [ 'animation' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'scrollspy' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the lightbox. + */ + public function test_should_return_dependencies_for_lightbox() { + $expected = [ + 'core' => [ + 'animation', + 'flex', + 'close', + 'modal', + 'overlay', + ], + 'add-ons' => [ + 'slidenav', + ], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'lightbox' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the slider. + */ + public function test_should_return_dependencies_for_slider() { + $expected = [ + 'core' => [], + 'add-ons' => [ 'slidenav' ], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'slider' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the slideset. + */ + public function test_should_return_dependencies_for_slideset() { + $expected = [ + 'core' => [ + 'animation', + 'flex', + ], + 'add-ons' => [ + 'dotnav', + 'slidenav', + ], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'slideset' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the slideshow. + */ + public function test_should_return_dependencies_for_slideshow() { + $expected = [ + 'core' => [ + 'animation', + 'flex', + ], + 'add-ons' => [ + 'dotnav', + 'slidenav', + ], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'slideshow' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the parallax. + */ + public function test_should_return_dependencies_for_parallax() { + $expected = [ + 'core' => [ 'flex' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'parallax' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return dependencies for the notify. + */ + public function test_should_return_dependencies_for_notify() { + $expected = [ + 'core' => [ 'close' ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ 'notify' ] ) ); + } + + /** + * Test beans_uikit_get_all_dependencies() should return all dependencies for the given components. + */ + public function test_should_return_all_dependencies_for_given_components() { + $expected = [ + 'core' => [ + 'badge', + 'flex', + ], + 'add-ons' => [], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ + 'panel', + 'overlay', + ] ) ); + + $expected = [ + 'core' => [ 'switcher' ], + 'add-ons' => [ 'slidenav' ], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ + 'tab', + 'slider', + ] ) ); + + $expected = [ + 'core' => [ + 'close', + 'animation', + 'flex', + ], + 'add-ons' => [ + 'dotnav', + 'slidenav', + ], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ + 'modal', + 'slideshow', + 'notify', + ] ) ); + + $expected = [ + 'core' => [ + 'animation', + 'flex', + 'close', + 'modal', + 'overlay', + 'badge', + 'switcher', + ], + 'add-ons' => [ + 'slidenav', + 'dotnav', + ], + ]; + $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ + 'lightbox', + 'notify', + 'panel', + 'slideshow', + 'tab', + ] ) ); + } +} From 2858d6827d04b9439f0224ba8b24ff8e16114126 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 11 Jun 2018 19:32:08 -0500 Subject: [PATCH 703/800] Fixed formatting. --- .../integration/api/uikit/beansUikitAutoloadDependencies.php | 2 +- tests/phpunit/unit/api/utilities/beansJoinArraysClean.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/phpunit/integration/api/uikit/beansUikitAutoloadDependencies.php b/tests/phpunit/integration/api/uikit/beansUikitAutoloadDependencies.php index 20c0eec2..f2e40e44 100644 --- a/tests/phpunit/integration/api/uikit/beansUikitAutoloadDependencies.php +++ b/tests/phpunit/integration/api/uikit/beansUikitAutoloadDependencies.php @@ -49,7 +49,7 @@ public function test_should_add_each_dependency_into_registry() { global $_beans_uikit_enqueued_items; _beans_uikit_autoload_dependencies( [ 'lightbox', 'slideshow' ] ); - $expected = [ + $expected = [ 'core' => [ 'animation', 'flex', diff --git a/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php b/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php index 76fe045b..a240a64e 100644 --- a/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php +++ b/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php @@ -64,7 +64,6 @@ public function test_should_clean_array1_when_array2_is_empty() { 2 => 'bar', 4 => 'baz', ], beans_join_arrays_clean( $array1, $array2, false ) ); - } /** From 81a576c091ad6adf6bf545a77007b3c9b711a57e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 12 Jun 2018 16:57:58 -0500 Subject: [PATCH 704/800] Fixed documentation per code review. --- lib/api/uikit/functions.php | 6 +++--- lib/api/utilities/functions.php | 2 +- .../unit/api/uikit/beansUikitEnqueueComponents.php | 8 ++++---- tests/phpunit/unit/api/utilities/beansArrayUnique.php | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index f6a00f78..77cb1320 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -29,7 +29,7 @@ * * @param string|array|bool $components Name of the component(s) to include as an indexed array. The name(s) must be * the UIkit component filename without the extension (e.g. 'grid'). Set to true - * load all components. + * to load all components. * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). * @param bool $autoload Optional. Automatically include components dependencies. * @@ -162,7 +162,7 @@ function beans_uikit_dequeue_theme( $id ) { } /** - * Gets all of the UIkit components for the given type, i.e. for core or add-ons. + * Get all of the UIkit components for the given type, i.e. for core or add-ons. * * @since 1.5.0 * @@ -177,7 +177,7 @@ function beans_uikit_get_all_components( $type = 'core' ) { } /** - * Gets all of the UIkit dependencies for the given component(s). + * Get all of the UIkit dependencies for the given component(s). * * @since 1.5.0 * diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 8075bbd1..91cbabd3 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -543,7 +543,7 @@ function beans_join_arrays( array &$array1, array $array2 ) { } /** - * Removes duplicate values from the given array and re-indexes to start at element 0. Keys are not preserved. + * Remove duplicate values from the given array and re-indexes to start at element 0. Keys are not preserved. * * @since 1.5.0 * diff --git a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php index 13aa37a4..cfc2760e 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php +++ b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php @@ -24,7 +24,7 @@ class Tests_BeansUikitEnqueueComponents extends UIkit_Test_Case { /** - * Test beans_uikit_enqueue_components() should add then given core component into registry when given a string. + * Test beans_uikit_enqueue_components() should add the given core component into the registry when given a string. */ public function test_should_add_given_core_component_into_registry_when_given_string() { global $_beans_uikit_enqueued_items; @@ -45,7 +45,7 @@ public function test_should_add_given_core_component_into_registry_when_given_st } /** - * Test beans_uikit_enqueue_components() should add then given add-ons component into registry when given a string. + * Test beans_uikit_enqueue_components() should add the given add-ons component into the registry when given a string. */ public function test_should_add_given_addons_component_into_registry_when_given_string() { global $_beans_uikit_enqueued_items; @@ -66,7 +66,7 @@ public function test_should_add_given_addons_component_into_registry_when_given_ } /** - * Test beans_uikit_enqueue_components() should add the given core components into registry. + * Test beans_uikit_enqueue_components() should add the given core components into the registry. */ public function test_should_add_given_core_components_into_registry() { global $_beans_uikit_enqueued_items; @@ -88,7 +88,7 @@ public function test_should_add_given_core_components_into_registry() { } /** - * Test beans_uikit_enqueue_components() should add the given add-ons components into registry. + * Test beans_uikit_enqueue_components() should add the given add-ons components into the registry. */ public function test_should_add_given_addons_components_into_registry() { global $_beans_uikit_enqueued_items; diff --git a/tests/phpunit/unit/api/utilities/beansArrayUnique.php b/tests/phpunit/unit/api/utilities/beansArrayUnique.php index 663b50b5..1c022aad 100644 --- a/tests/phpunit/unit/api/utilities/beansArrayUnique.php +++ b/tests/phpunit/unit/api/utilities/beansArrayUnique.php @@ -31,7 +31,7 @@ protected function setUp() { } /** - * Test beans_array_unique() should return original array when no duplicates are found. + * Test beans_array_unique() should return the original array when no duplicates are found. */ public function test_should_return_original_array_when_no_duplicates() { $array = [ 'foo', 5, 'bar', 47 ]; @@ -42,9 +42,9 @@ public function test_should_return_original_array_when_no_duplicates() { } /** - * Test beans_array_unique() should re-indexed the original array. + * Test beans_array_unique() should re-index the original array. */ - public function test_should_reindexed_original_array() { + public function test_should_reindex_original_array() { $actual = [ 'foo', 5 => 5, From 6d1956eec265178735de56c7d70d3cc94e045142 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 12 Jun 2018 22:56:14 -0400 Subject: [PATCH 705/800] Changed structure and tests per code review. --- lib/api/html/accessibility.php | 4 +- lib/api/layout/functions.php | 36 +++++ .../api/html/beansBuildSkipLinks.php | 150 ++++++++++-------- .../html/includes/class-html-test-case.php | 4 +- .../api/layout/beansHasPrimarySidebar.php | 79 +++++++++ .../api/layout/beansHasSecondarySidebar.php | 78 +++++++++ .../unit/api/html/beansBuildSkipLinks.php | 66 ++------ .../api/layout/beansHasPrimarySidebar.php | 66 ++++++++ .../api/layout/beansHasSecondarySidebar.php | 66 ++++++++ 9 files changed, 433 insertions(+), 116 deletions(-) create mode 100644 tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php create mode 100644 tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php create mode 100644 tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php create mode 100644 tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php diff --git a/lib/api/html/accessibility.php b/lib/api/html/accessibility.php index 4d3d87b3..1cac514d 100644 --- a/lib/api/html/accessibility.php +++ b/lib/api/html/accessibility.php @@ -26,11 +26,11 @@ function beans_build_skip_links() { if ( 'c' !== $layout ) { - if ( in_array( $layout, array( 'c_sp', 'sp_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) && beans_is_active_widget_area( 'sidebar_primary' ) ) { + if ( beans_has_primary_sidebar( $layout ) ) { $skip_links['beans-primary-sidebar'] = __( 'Skip to the primary sidebar.', 'tm-beans' ); } - if ( in_array( $layout, array( 'c_ss', 'ss_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) && beans_is_active_widget_area( 'sidebar_secondary' ) ) { + if ( beans_has_secondary_sidebar( $layout ) ) { $skip_links['beans-secondary-sidebar'] = __( 'Skip to the secondary sidebar.', 'tm-beans' ); } } diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index 9dd0db78..d1028f16 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -286,3 +286,39 @@ function beans_get_layouts_for_options( $add_default = false ) { return $layouts; } + +/** + * Check if the given layout has a primary sidebar. + * + * @since 1.5.0 + * + * @param string $layout The layout to check. + * + * @return bool + */ +function beans_has_primary_sidebar( $layout ) { + + if ( ! in_array( $layout, array( 'c_sp', 'sp_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) ) { + return false; + } + + return beans_is_active_widget_area( 'sidebar_primary' ); +} + +/** + * Check if the given layout has a secondary sidebar. + * + * @since 1.5.0 + * + * @param string $layout The layout to check. + * + * @return bool + */ +function beans_has_secondary_sidebar( $layout ) { + + if ( ! in_array( $layout, array( 'c_ss', 'ss_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) ) { + return false; + } + + return beans_is_active_widget_area( 'sidebar_secondary' ); +} diff --git a/tests/phpunit/integration/api/html/beansBuildSkipLinks.php b/tests/phpunit/integration/api/html/beansBuildSkipLinks.php index 0473e77e..792bea8d 100644 --- a/tests/phpunit/integration/api/html/beansBuildSkipLinks.php +++ b/tests/phpunit/integration/api/html/beansBuildSkipLinks.php @@ -34,23 +34,29 @@ public function test_should_not_output_sidebar_skip_links_when_layout_c_selected $this->assertEquals( beans_get_layout(), 'c' ); $expected = <<
      • Skip to the content.
      • + EOB; ob_start(); beans_build_skip_links(); $actual = ob_get_clean(); - $this->assertContains( $expected, $actual ); + $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); } /** * Test beans_build_skip_links() should output content and primary sidebar skip links. */ public function test_should_output_content_primary_sidebar_skip_links() { - Monkey\Functions\expect( 'beans_is_active_widget_area' ) - ->once() - ->with( 'sidebar_primary' ) - ->andReturn( 'true' ); + Monkey\Functions\expect( 'beans_has_primary_sidebar' ) + ->once() + ->with( 'c_sp' ) + ->andReturn( true ); + Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) + ->once() + ->with( 'c_sp' ) + ->andReturn( false ); add_filter( 'beans_default_layout', function( $default_layout ) { return 'c_sp'; @@ -59,23 +65,30 @@ public function test_should_output_content_primary_sidebar_skip_links() { $this->assertEquals( beans_get_layout(), 'c_sp' ); $expected = <<
      • Skip to the content.
      • Skip to the primary sidebar.
      • + EOB; ob_start(); beans_build_skip_links(); $actual = ob_get_clean(); - $this->assertContains( $expected, $actual ); + $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); } /** * Test beans_build_skip_links() should output content and secondary sidebar skip links. */ public function test_should_output_content_secondary_sidebar_skip_links() { - Monkey\Functions\expect( 'beans_is_active_widget_area' ) - ->once() - ->with( 'sidebar_secondary' ) - ->andReturn( 'true' ); + Monkey\Functions\expect( 'beans_has_primary_sidebar' ) + ->once() + ->with( 'c_ss' ) + ->andReturn( false ); + Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) + ->once() + ->with( 'c_ss' ) + ->andReturn( true ); add_filter( 'beans_default_layout', function( $default_layout ) { return 'c_ss'; @@ -84,13 +97,16 @@ public function test_should_output_content_secondary_sidebar_skip_links() { $this->assertEquals( beans_get_layout(), 'c_ss' ); $expected = <<
      • Skip to the content.
      • Skip to the secondary sidebar.
      • + EOB; ob_start(); beans_build_skip_links(); $actual = ob_get_clean(); - $this->assertContains( $expected, $actual ); + $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); } @@ -98,15 +114,14 @@ public function test_should_output_content_secondary_sidebar_skip_links() { * Test beans_build_skip_links() should output content and both sidebar skip links. */ public function test_should_output_content_both_sidebar_skip_links() { - Monkey\Functions\expect( 'beans_is_active_widget_area' ) - ->once() - ->ordered() - ->with( 'sidebar_primary' ) - ->andReturn( true ) - ->andAlsoExpectIt() - ->once() - ->with( 'sidebar_secondary' ) - ->andReturn( true ); + Monkey\Functions\expect( 'beans_has_primary_sidebar' ) + ->once() + ->with( 'c_sp_ss' ) + ->andReturn( true ); + Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) + ->once() + ->with( 'c_sp_ss' ) + ->andReturn( true ); add_filter( 'beans_default_layout', function( $default_layout ) { return 'c_sp_ss'; @@ -115,28 +130,31 @@ public function test_should_output_content_both_sidebar_skip_links() { $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); $expected = <<
      • Skip to the content.
      • Skip to the primary sidebar.
      • Skip to the secondary sidebar.
      • + EOB; ob_start(); beans_build_skip_links(); $actual = ob_get_clean(); - $this->assertContains( $expected, $actual ); + $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); } /** * Test beans_build_skip_links() should output content and only the primary sidebar skip links when layout is 'c_sp_ss' but secondry sidebar is not active. */ public function test_should_output_content_only_primary_sidebar_skip_links_when_secondary_sidebar_not_active() { - Monkey\Functions\expect( 'beans_is_active_widget_area' ) - ->once() - ->ordered() - ->with( 'sidebar_primary' ) - ->andReturn( true ) - ->andAlsoExpectIt() - ->once() - ->with( 'sidebar_secondary' ) - ->andReturn( false ); + Monkey\Functions\expect( 'beans_has_primary_sidebar' ) + ->once() + ->with( 'c_sp_ss' ) + ->andReturn( true ); + Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) + ->once() + ->with( 'c_sp_ss' ) + ->andReturn( false ); add_filter( 'beans_default_layout', function( $default_layout ) { return 'c_sp_ss'; @@ -145,28 +163,30 @@ public function test_should_output_content_only_primary_sidebar_skip_links_when_ $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); $expected = <<
      • Skip to the content.
      • Skip to the primary sidebar.
      • + EOB; ob_start(); beans_build_skip_links(); $actual = ob_get_clean(); - $this->assertContains( $expected, $actual ); + $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); } /** * Test beans_build_skip_links() should output content and only the secondary sidebar skip links when layout is 'c_sp_ss' but primary sidebar is not active. */ public function test_should_output_content_only_secondary_sidebar_skip_links_when_primary_sidebar_not_active_() { - Monkey\Functions\expect( 'beans_is_active_widget_area' ) - ->once() - ->ordered() - ->with( 'sidebar_primary' ) - ->andReturn( false ) - ->andAlsoExpectIt() - ->once() - ->with( 'sidebar_secondary' ) - ->andReturn( true ); + Monkey\Functions\expect( 'beans_has_primary_sidebar' ) + ->once() + ->with( 'c_sp_ss' ) + ->andReturn( false ); + Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) + ->once() + ->with( 'c_sp_ss' ) + ->andReturn( true ); add_filter( 'beans_default_layout', function( $default_layout ) { return 'c_sp_ss'; @@ -175,13 +195,16 @@ public function test_should_output_content_only_secondary_sidebar_skip_links_whe $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); $expected = <<
      • Skip to the content.
      • Skip to the secondary sidebar.
      • + EOB; ob_start(); beans_build_skip_links(); $actual = ob_get_clean(); - $this->assertContains( $expected, $actual ); + $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); } /** @@ -189,19 +212,17 @@ public function test_should_output_content_only_secondary_sidebar_skip_links_whe */ public function test_should_output_primary_navigation_content_and_both_sidebar_skip_links() { Monkey\Functions\expect( 'has_nav_menu' ) - ->once() - ->with( 'primary' ) - ->andReturn( true ); - - Monkey\Functions\expect( 'beans_is_active_widget_area' ) - ->once() - ->ordered() - ->with( 'sidebar_primary' ) - ->andReturn( true ) - ->andAlsoExpectIt() - ->once() - ->with( 'sidebar_secondary' ) - ->andReturn( true ); + ->once() + ->with( 'primary' ) + ->andReturn( true ); + Monkey\Functions\expect( 'beans_has_primary_sidebar' ) + ->once() + ->with( 'c_sp_ss' ) + ->andReturn( true ); + Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) + ->once() + ->with( 'c_sp_ss' ) + ->andReturn( true ); add_filter( 'beans_default_layout', function( $default_layout ) { return 'c_sp_ss'; @@ -210,12 +231,17 @@ public function test_should_output_primary_navigation_content_and_both_sidebar_s $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); $expected = <<
      • Skip to the primary navigation.
      • Skip to the content.
      • Skip to the primary sidebar.
      • Skip to the secondary sidebar.
      • + EOB; ob_start(); beans_build_skip_links(); $actual = ob_get_clean(); - $this->assertContains( $expected, $actual ); + $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); } } diff --git a/tests/phpunit/integration/api/html/includes/class-html-test-case.php b/tests/phpunit/integration/api/html/includes/class-html-test-case.php index 3f92fa8d..78c0b88f 100644 --- a/tests/phpunit/integration/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/integration/api/html/includes/class-html-test-case.php @@ -9,14 +9,14 @@ namespace Beans\Framework\Tests\Integration\API\HTML\Includes; -use WP_UnitTestCase; +use Beans\Framework\Tests\Integration\Test_Case; /** * Abstract Class HTML_Test_Case * * @package Beans\Framework\Tests\Integration\API\HTML\Includes */ -abstract class HTML_Test_Case extends WP_UnitTestCase { +abstract class HTML_Test_Case extends Test_Case { /** * An array of markup to test. diff --git a/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php b/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php new file mode 100644 index 00000000..c09b8180 --- /dev/null +++ b/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php @@ -0,0 +1,79 @@ +assertEquals( beans_get_layout(), 'c' ); + + $this->assertFalse( beans_has_primary_sidebar( 'c' ) ); + } + + /** + * Test beans_has_primary_sidebar() should return false when the layout is content-secondary sidebar. + */ + public function test_should_return_false_when_content_sidebar_secondary_layout() { + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_ss'; + }); + + $this->assertEquals( beans_get_layout(), 'c_ss' ); + + $this->assertFalse( beans_has_primary_sidebar( 'c_ss' ) ); + } + + /** + * Test beans_has_primary_sidebar() should return false when the layout is content-primary sidebar without an active widget. + */ + public function test_should_return_false_when_content_primary_sidebar_layout_without_active_widget() { + Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_sp'; + }); + + $this->assertEquals( beans_get_layout(), 'c_sp' ); + + $this->assertFalse( beans_has_primary_sidebar( 'c_sp' ) ); + } + + /** + * Test beans_has_primary_sidebar() should return true when the layout is content-primary sidebar with an active widget. + */ + public function test_should_return_true_when_content_primary_sidebar_layout_with_active_widget() { + Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_sp'; + }); + + $this->assertEquals( beans_get_layout(), 'c_sp' ); + + $this->assertTrue( beans_has_primary_sidebar( 'c_sp' ) ); + } +} diff --git a/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php b/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php new file mode 100644 index 00000000..53573b55 --- /dev/null +++ b/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php @@ -0,0 +1,78 @@ +assertEquals( beans_get_layout(), 'c' ); + + $this->assertFalse( beans_has_secondary_sidebar( 'c' ) ); + } + + /** + * Test beans_has_secondary_sidebar() should return false when the layout is content-primary sidebar. + */ + public function test_should_return_false_when_content_primary_sidebar_layout() { + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_sp'; + }); + + $this->assertEquals( beans_get_layout(), 'c_sp' ); + + $this->assertFalse( beans_has_secondary_sidebar( 'c_sp' ) ); + } + + /** + * Test beans_has_secondary_sidebar() should return false when the layout is content-secondary sidebar without an active widget. + */ + public function test_should_return_false_when_content_secondary_sidebar_layout_without_active_widget() { + Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_ss'; + }); + + $this->assertEquals( beans_get_layout(), 'c_ss' ); + + $this->assertFalse( beans_has_secondary_sidebar( 'c_ss' ) ); + } + + /** + * Test beans_has_secondary_sidebar() should return true when the layout is content-secondary sidebar with an active widget. + */ + public function test_should_return_true_when_content_secondary_sidebar_layout_with_active_widget() { + Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); + + add_filter( 'beans_default_layout', function( $default_layout ) { + return 'c_ss'; + }); + + $this->assertEquals( beans_get_layout(), 'c_ss' ); + + $this->assertTrue( beans_has_secondary_sidebar( 'c_ss' ) ); + } +} diff --git a/tests/phpunit/unit/api/html/beansBuildSkipLinks.php b/tests/phpunit/unit/api/html/beansBuildSkipLinks.php index d327cf30..cf8e1a42 100644 --- a/tests/phpunit/unit/api/html/beansBuildSkipLinks.php +++ b/tests/phpunit/unit/api/html/beansBuildSkipLinks.php @@ -24,80 +24,46 @@ class Tests_BeansBuildSkipLinks extends HTML_Test_Case { /** - * Test beans_build_skip_links() should call beans_is_active_widget_area() once when the layout includes a primary-sidebar. + * Test beans_build_skip_links() should call beans_has_primary_sidebar() and beans_has_secondary_sidebar() when the layout is not full-width('c'). */ - public function test_should_call_beans_is_active_widget_area_once_when_primary_sidebar_layout() { + public function test_should_call_beans_has_primary_sidebar_and_beans_has_secondary_sidebar_when_layout_not_full_width() { Monkey\Functions\expect( 'beans_get_layout' )->once()->andReturn( 'c_sp' ); Monkey\Functions\expect( 'has_nav_menu' ) ->once() ->with( 'primary' ) ->andReturn( 'true' ); - Monkey\Functions\expect( 'beans_is_active_widget_area' ) + Monkey\Functions\expect( 'beans_has_primary_sidebar' ) ->once() - ->ordered() - ->with( 'sidebar_primary' ) - ->andReturn( 'true' ) - ->andAlsoExpectIt() - ->never() - ->ordered() - ->with( 'sidebar_secondary' ) - ->andReturn( 'true' ); + ->with( 'c_sp' ) + ->andReturn( true ); + Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) + ->once() + ->with( 'c_sp' ) + ->andReturn( false ); Monkey\Functions\expect( 'beans_output_skip_links' ) - ->once() - ->andReturn(); + ->once() + ->andReturn(); $this->assertNull( beans_build_skip_links() ); } /** - * Test beans_build_skip_links() should not call beans_is_active_widget_area() when the layout is full-width. + * Test beans_build_skip_links() should not call beans_has_primary_sidebar() or beans_has_secondary_sidebar() when the layout is full-width. */ - public function test_should_not_call_beans_is_active_widget_area_when_fullwith_layout() { + public function test_should_not_call_beans_has_primary_sidebar_or_beans_has_secondary_sidebara_when_fullwith_layout() { Monkey\Functions\expect( 'beans_get_layout' )->once()->andReturn( 'c' ); Monkey\Functions\expect( 'has_nav_menu' ) ->once() ->with( 'primary' ) ->andReturn( 'true' ); - Monkey\Functions\expect( 'beans_is_active_widget_area' ) - ->never() - ->ordered() - ->with( 'sidebar_primary' ) - ->andReturn( 'true' ) - ->andAlsoExpectIt() - ->never() - ->ordered() - ->with( 'sidebar_secondary' ) - ->andReturn( 'true' ); - Monkey\Functions\expect( 'beans_output_skip_links' ) - ->once() - ->andReturn(); - - $this->assertNull( beans_build_skip_links() ); - } + Monkey\Functions\expect( 'beans_has_primary_sidebar' )->never(); + Monkey\Functions\expect( 'beans_has_secondary_sidebar' )->never(); - /** - * Test beans_build_skip_links() should call beans_is_active_widget_area() twice when the layout includes a secondary sidebar. - */ - public function test_should_call_beans_is_active_widget_area_twice_when_secondary_sidebar_layout() { - Monkey\Functions\expect( 'beans_get_layout' )->once()->andReturn( 'sp_c_ss' ); - Monkey\Functions\expect( 'has_nav_menu' ) - ->once() - ->with( 'primary' ) - ->andReturn( 'true' ); - Monkey\Functions\expect( 'beans_is_active_widget_area' ) - ->once() - ->ordered() - ->with( 'sidebar_primary' ) - ->andReturn( 'true' ) - ->andAlsoExpectIt() - ->once() - ->ordered() - ->with( 'sidebar_secondary' ) - ->andReturn( 'true' ); Monkey\Functions\expect( 'beans_output_skip_links' ) ->once() ->andReturn(); $this->assertNull( beans_build_skip_links() ); } + } diff --git a/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php b/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php new file mode 100644 index 00000000..881d18b5 --- /dev/null +++ b/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php @@ -0,0 +1,66 @@ +load_original_functions( array( + 'api/layout/functions.php', + ) ); + } + + /** + * Test beans_has_primary_sidebar() should return false when the layout is full-width. + */ + public function test_should_return_false_when_full_width_layout() { + $this->assertFalse( beans_has_primary_sidebar( 'c' ) ); + } + + /** + * Test beans_has_primary_sidebar() should return false when the layout is content-secondary sidebar. + */ + public function test_should_return_false_when_content_secondary_sidebar_layout() { + $this->assertFalse( beans_has_primary_sidebar( 'c_ss' ) ); + } + + /** + * Test beans_has_primary_sidebar() should return false when the layout is content-primary sidebar without an active widget. + */ + public function test_should_return_false_when_content_primary_sidebar_layout_without_active_widget() { + Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); + + $this->assertFalse( beans_has_primary_sidebar( 'c_sp' ) ); + } + + /** + * Test beans_has_primary_sidebar() should return true when the layout is content-primary sidebar with an active widget. + */ + public function test_should_return_true_when_content_primary_sidebar_layout_with_active_widget() { + Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); + + $this->assertTrue( beans_has_primary_sidebar( 'c_sp' ) ); + } +} diff --git a/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php b/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php new file mode 100644 index 00000000..30c29d37 --- /dev/null +++ b/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php @@ -0,0 +1,66 @@ +load_original_functions( array( + 'api/layout/functions.php', + ) ); + } + + /** + * Test beans_has_secondary_sidebar() should return false when the layout is full-width. + */ + public function test_should_return_false_when_full_width_layout() { + $this->assertFalse( beans_has_secondary_sidebar( 'c' ) ); + } + + /** + * Test beans_has_secondary_sidebar() should return false when the layout is content-secondary sidebar. + */ + public function test_should_return_false_when_content_secondary_sidebar_layout() { + $this->assertFalse( beans_has_secondary_sidebar( 'c_sp' ) ); + } + + /** + * Test beans_has_secondary_sidebar() should return false when the layout is content-secondary sidebar without an active widget. + */ + public function test_should_return_false_when_content_secondary_sidebar_layout_without_active_widget() { + Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); + + $this->assertFalse( beans_has_secondary_sidebar( 'c_ss' ) ); + } + + /** + * Test beans_has_secondary_sidebar() should return true when the layout is content-secondary sidebar with an active widget. + */ + public function test_should_return_true_when_content_secondary_sidebar_layout_with_active_widget() { + Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); + + $this->assertTrue( beans_has_secondary_sidebar( 'c_ss' ) ); + } +} From 61c3e4104c468b8350447d854aa5d115e0848a1f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 15 Jun 2018 18:28:30 -0500 Subject: [PATCH 706/800] Added unit tests for beans_uikit_dequeue_components(). --- .../api/uikit/beansUikitDequeueComponents.php | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php diff --git a/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php new file mode 100644 index 00000000..79f055a3 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php @@ -0,0 +1,180 @@ +assertNotContains( 'alert', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertSame( [ + 1 => 'button', + 2 => 'overlay', + ], $_beans_uikit_enqueued_items['components']['core'] ); + + beans_uikit_dequeue_components( 'button' ); + $this->assertNotContains( 'button', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertSame( [ + 2 => 'overlay', + ], $_beans_uikit_enqueued_items['components']['core'] ); + + beans_uikit_dequeue_components( 'overlay' ); + $this->assertNotContains( 'button', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test beans_uikit_dequeue_components() should remove the given add-ons component from the registry when given a + * string. + */ + public function test_should_remove_given_addons_component_from_registry_when_given_string() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['add-ons'] = [ + 'accordion', + 'datepicker', + 'sticky', + ]; + + beans_uikit_dequeue_components( 'accordion', 'add-ons' ); + $this->assertNotContains( 'accordion', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertSame( [ + 1 => 'datepicker', + 2 => 'sticky', + ], $_beans_uikit_enqueued_items['components']['add-ons'] ); + + beans_uikit_dequeue_components( 'datepicker', 'add-ons' ); + $this->assertNotContains( 'datepicker', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertSame( [ + 2 => 'sticky', + ], $_beans_uikit_enqueued_items['components']['add-ons'] ); + + beans_uikit_dequeue_components( 'sticky', 'add-ons' ); + $this->assertNotContains( 'sticky', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); + } + + /** + * Test beans_uikit_dequeue_components() should remove the given core components from the registry when given an + * array. + */ + public function test_should_remove_given_core_components_from_registry_when_given_array() { + global $_beans_uikit_enqueued_items; + $components = [ + 'alert', + 'button', + 'overlay', + ]; + $_beans_uikit_enqueued_items['components']['core'] = $components; + + beans_uikit_dequeue_components( [ 'alert' ] ); + $this->assertNotContains( 'alert', $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertSame( [ + 1 => 'button', + 2 => 'overlay', + ], $_beans_uikit_enqueued_items['components']['core'] ); + + beans_uikit_dequeue_components( $components ); + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); + + // Check when there's nothing in the registry. + beans_uikit_dequeue_components( [ 'tab' ] ); + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test beans_uikit_dequeue_components() should remove the given add-ons component(s) from the registry when given + * an array. + */ + public function test_should_remove_given_addons_component_from_registry_when_given_array() { + global $_beans_uikit_enqueued_items; + $components = [ + 'accordion', + 'datepicker', + 'sticky', + ]; + $_beans_uikit_enqueued_items['components']['add-ons'] = $components; + + beans_uikit_dequeue_components( [ 'sticky' ], 'add-ons' ); + $this->assertNotContains( 'sticky', $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertSame( [ 'accordion', 'datepicker' ], $_beans_uikit_enqueued_items['components']['add-ons'] ); + + beans_uikit_dequeue_components( [ 'accordion', 'datepicker' ], 'add-ons' ); + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); + + // Check when there's nothing in the registry. + beans_uikit_dequeue_components( [ 'tooltip' ] ); + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); + } + + /** + * Test beans_uikit_dequeue_components() should remove all core components from the registry when $components is true. + */ + public function test_should_remove_all_core_components_from_registry_when_components_is_true() { + global $_beans_uikit_enqueued_items; + $components = [ + 'alert', + 'animation', + 'article', + 'badge', + 'base', + ]; + $_beans_uikit_enqueued_items['components']['core'] = $components; + + Monkey\Functions\expect( 'beans_uikit_get_all_components' )->once()->with( 'core' )->andReturn( $components ); + + beans_uikit_dequeue_components( true ); + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); + } + + /** + * Test beans_uikit_enqueue_components() should remove all add-ons components from the registry when $components is + * true. + */ + public function test_should_remove_all_addons_components_from_registry_when_components_is_true() { + global $_beans_uikit_enqueued_items; + $components = [ + 'accordion', + 'autocomplete', + 'datepicker', + 'dotnav', + 'form-advanced', + 'sticky', + ]; + $_beans_uikit_enqueued_items['components']['add-ons'] = $components; + + Monkey\Functions\expect( 'beans_uikit_get_all_components' )->once()->with( 'add-ons' )->andReturn( $components ); + + beans_uikit_dequeue_components( true, 'add-ons' ); + $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); + } +} From 7832216860c81ec5c1bf1139035d438c4bd28325 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 15 Jun 2018 18:29:52 -0500 Subject: [PATCH 707/800] Optimized dequeuing all components. When $components is true, the intent is to reset the registry by removing all of the components. Instead of calling beans_uikit_get_all_components(), we simply assign an empty array to the global and then bail out. Why? beans_uikit_get_all_components() is expensive as it iterates the filesystem, runs several array functions that rebuilds arrays (i.e. array map, merge, unique, etc.), and iterates through all the directories. This commit is faster and uses less memory. --- lib/api/uikit/functions.php | 4 +++- tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index 77cb1320..d96ffa60 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -72,8 +72,10 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload function beans_uikit_dequeue_components( $components, $type = 'core' ) { global $_beans_uikit_enqueued_items; + // When true, remove all of the components from the registry. if ( true === $components ) { - $components = beans_uikit_get_all_components( $type ); + $_beans_uikit_enqueued_items['components'][ $type ] = array(); + return; } // Remove components. diff --git a/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php index 79f055a3..dd613fc8 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php +++ b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php @@ -150,8 +150,6 @@ public function test_should_remove_all_core_components_from_registry_when_compon ]; $_beans_uikit_enqueued_items['components']['core'] = $components; - Monkey\Functions\expect( 'beans_uikit_get_all_components' )->once()->with( 'core' )->andReturn( $components ); - beans_uikit_dequeue_components( true ); $this->assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); } @@ -172,8 +170,6 @@ public function test_should_remove_all_addons_components_from_registry_when_comp ]; $_beans_uikit_enqueued_items['components']['add-ons'] = $components; - Monkey\Functions\expect( 'beans_uikit_get_all_components' )->once()->with( 'add-ons' )->andReturn( $components ); - beans_uikit_dequeue_components( true, 'add-ons' ); $this->assertEmpty( $_beans_uikit_enqueued_items['components']['add-ons'] ); } From f5a5bad71250114516e49b74437bdf88002523ee Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Fri, 15 Jun 2018 19:19:39 -0500 Subject: [PATCH 708/800] Added tests for beans_uikit_register_theme(). --- .../api/uikit/beansUikitRegisterTheme.php | 43 +++++++++ .../api/uikit/beansUikitRegisterTheme.php | 92 +++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 tests/phpunit/integration/api/uikit/beansUikitRegisterTheme.php create mode 100644 tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php diff --git a/tests/phpunit/integration/api/uikit/beansUikitRegisterTheme.php b/tests/phpunit/integration/api/uikit/beansUikitRegisterTheme.php new file mode 100644 index 00000000..97f9d4f7 --- /dev/null +++ b/tests/phpunit/integration/api/uikit/beansUikitRegisterTheme.php @@ -0,0 +1,43 @@ +assertTrue( beans_uikit_register_theme( 'sample-theme', $url ) ); + $this->assertArrayHasKey( 'sample-theme', $_beans_uikit_registered_items['themes'] ); + $this->assertSame( $path, $_beans_uikit_registered_items['themes']['sample-theme'] ); + + $url = BEANS_API_URL . 'uikit/src/themes/gradient'; + $path = trailingslashit( beans_url_to_path( $url ) ); + $this->assertTrue( beans_uikit_register_theme( 'sample-gradient', $url ) ); + $this->assertArrayHasKey( 'sample-gradient', $_beans_uikit_registered_items['themes'] ); + $this->assertSame( $path, $_beans_uikit_registered_items['themes']['sample-gradient'] ); + } +} diff --git a/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php b/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php new file mode 100644 index 00000000..53b7db82 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php @@ -0,0 +1,92 @@ +never(); + Monkey\Functions\expect( 'trailingslashit' )->never(); + + // Check the built-in themes. + $this->assertTrue( beans_uikit_register_theme( 'default', '' ) ); + $this->assertTrue( beans_uikit_register_theme( 'almost-flat', '' ) ); + $this->assertTrue( beans_uikit_register_theme( 'gradient', '' ) ); + $this->assertTrue( beans_uikit_register_theme( 'wordpress-admin', '' ) ); + + // Check the child theme. + global $_beans_uikit_registered_items; + $_beans_uikit_registered_items['themes']['beans-child'] = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + $this->assertTrue( beans_uikit_register_theme( 'beans-child', '' ) ); + $this->assertTrue( beans_uikit_register_theme( 'beans-child', vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ) ) ); + } + + /** + * Test beans_uikit_register_theme() should return false when the theme is not registered and no path is given. + */ + public function test_should_return_false_when_theme_not_registered_and_no_path_given() { + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\expect( 'trailingslashit' )->never(); + + // Check the built-in themes. + $this->assertFalse( beans_uikit_register_theme( 'foo', '' ) ); + $this->assertFalse( beans_uikit_register_theme( 'bar', '' ) ); + $this->assertFalse( beans_uikit_register_theme( 'beans-child', '' ) ); + } + + /** + * Test beans_uikit_register_theme() should register the theme when given the path. + */ + public function test_should_register_the_theme_when_given_path() { + global $_beans_uikit_registered_items; + $path = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + Monkey\Functions\expect( 'beans_url_to_path' )->never(); + Monkey\Functions\when( 'trailingslashit' )->returnArg(); + + $this->assertTrue( beans_uikit_register_theme( 'beans-child', $path ) ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_registered_items['themes'] ); + $this->assertSame( $path, $_beans_uikit_registered_items['themes']['beans-child'] ); + } + + /** + * Test beans_uikit_register_theme() should register the theme when given the URL. + */ + public function test_should_register_the_theme_when_given_url() { + global $_beans_uikit_registered_items; + + $path = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + $url = 'http://example.com/virtual-wp-content/themes/beans-child/assets/less/theme'; + Monkey\Functions\expect( 'beans_url_to_path' ) + ->once() + ->with( $url ) + ->andReturn( $path ); + Monkey\Functions\when( 'trailingslashit' )->returnArg(); + + $this->assertTrue( beans_uikit_register_theme( 'beans-child', $url ) ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_registered_items['themes'] ); + $this->assertSame( $path, $_beans_uikit_registered_items['themes']['beans-child'] ); + } +} From 0472336fbeb44c571ee2b444dc36eb9c2f672f24 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 16 Jun 2018 09:56:55 -0500 Subject: [PATCH 709/800] Added tests for beans_uikit_enqueue_theme(). --- .../api/uikit/beansUikitEnqueueTheme.php | 75 +++++++++++++ .../unit/api/uikit/beansUikitEnqueueTheme.php | 102 ++++++++++++++++++ .../uikit/includes/class-uikit-test-case.php | 37 ++++--- 3 files changed, 199 insertions(+), 15 deletions(-) create mode 100644 tests/phpunit/integration/api/uikit/beansUikitEnqueueTheme.php create mode 100644 tests/phpunit/unit/api/uikit/beansUikitEnqueueTheme.php diff --git a/tests/phpunit/integration/api/uikit/beansUikitEnqueueTheme.php b/tests/phpunit/integration/api/uikit/beansUikitEnqueueTheme.php new file mode 100644 index 00000000..0e939a51 --- /dev/null +++ b/tests/phpunit/integration/api/uikit/beansUikitEnqueueTheme.php @@ -0,0 +1,75 @@ +assertFalse( beans_uikit_enqueue_theme( $theme_id ) ); + $this->assertArrayNotHasKey( $theme_id, $_beans_uikit_registered_items['themes'] ); + $this->assertArrayNotHasKey( $theme_id, $_beans_uikit_enqueued_items['themes'] ); + } + } + + /** + * Test beans_uikit_enqueue_theme() should enqueue when the theme is already registered. + */ + public function test_should_enqueue_when_theme_is_already_registered() { + global $_beans_uikit_registered_items, $_beans_uikit_enqueued_items; + + // Check the built-in themes. + foreach ( [ 'default', 'almost-flat', 'gradient', 'wordpress-admin' ] as $theme_id ) { + $this->assertArrayHasKey( $theme_id, $_beans_uikit_registered_items['themes'] ); + $this->assertTrue( beans_uikit_enqueue_theme( $theme_id ) ); + $this->assertArrayHasKey( $theme_id, $_beans_uikit_registered_items['themes'] ); + $this->assertSame( $_beans_uikit_registered_items['themes'][ $theme_id ], $_beans_uikit_enqueued_items['themes'][ $theme_id ] ); + } + + // Check the child theme. + $_beans_uikit_registered_items['themes']['beans-child'] = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + $this->assertTrue( beans_uikit_enqueue_theme( 'beans-child' ) ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_registered_items['themes'] ); + $this->assertSame( vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ), $_beans_uikit_enqueued_items['themes']['beans-child'] ); + } + + /** + * Test beans_uikit_enqueue_theme() should register and then enqueue the theme. + */ + public function test_should_register_and_then_enqueue_theme() { + global $_beans_uikit_registered_items, $_beans_uikit_enqueued_items; + $path = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + + $this->assertArrayNotHasKey( 'beans-child', $_beans_uikit_registered_items['themes'] ); + $this->assertArrayNotHasKey( 'beans-child', $_beans_uikit_enqueued_items['themes'] ); + + $this->assertTrue( beans_uikit_enqueue_theme( 'beans-child', $path ) ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_registered_items['themes'] ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_enqueued_items['themes'] ); + $this->assertSame( trailingslashit( $path ), $_beans_uikit_enqueued_items['themes']['beans-child'] ); + } +} diff --git a/tests/phpunit/unit/api/uikit/beansUikitEnqueueTheme.php b/tests/phpunit/unit/api/uikit/beansUikitEnqueueTheme.php new file mode 100644 index 00000000..94bd7dd3 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beansUikitEnqueueTheme.php @@ -0,0 +1,102 @@ +never(); + Monkey\Functions\expect( 'beans_uikit_register_theme' ) + ->times( 3 ) + ->andReturn( false ); + + foreach ( [ 'foo', 'bar', 'beans-child' ] as $theme_id ) { + $this->assertFalse( beans_uikit_enqueue_theme( $theme_id ) ); + $this->assertArrayNotHasKey( $theme_id, $_beans_uikit_registered_items['themes'] ); + $this->assertArrayNotHasKey( $theme_id, $_beans_uikit_enqueued_items['themes'] ); + } + } + + /** + * Test beans_uikit_enqueue_theme() should enqueue when the theme is already registered. + */ + public function test_should_enqueue_when_theme_is_already_registered() { + global $_beans_uikit_registered_items, $_beans_uikit_enqueued_items; + Monkey\Functions\when( 'beans_uikit_register_theme' )->justReturn( true ); + Monkey\Functions\expect( '_beans_uikit_get_registered_theme' ) + ->times( 5 ) + ->andReturnUsing( function( $id ) { + global $_beans_uikit_registered_items; + + return $_beans_uikit_registered_items['themes'][ $id ]; + } ); + + // Check the built-in themes. + foreach ( [ 'default', 'almost-flat', 'gradient', 'wordpress-admin' ] as $theme_id ) { + $this->assertArrayHasKey( $theme_id, $_beans_uikit_registered_items['themes'] ); + $this->assertTrue( beans_uikit_enqueue_theme( $theme_id ) ); + $this->assertArrayHasKey( $theme_id, $_beans_uikit_registered_items['themes'] ); + $this->assertSame( $this->themes[ $theme_id ], $_beans_uikit_enqueued_items['themes'][ $theme_id ] ); + } + + // Check the child theme. + $_beans_uikit_registered_items['themes']['beans-child'] = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + $this->assertTrue( beans_uikit_enqueue_theme( 'beans-child' ) ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_registered_items['themes'] ); + $this->assertSame( vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ), $_beans_uikit_enqueued_items['themes']['beans-child'] ); + } + + /** + * Test beans_uikit_enqueue_theme() should register and then enqueue the theme. + */ + public function test_should_register_and_then_enqueue_theme() { + global $_beans_uikit_registered_items, $_beans_uikit_enqueued_items; + $path = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + + Monkey\Functions\expect( 'beans_uikit_register_theme' ) + ->once() + ->with( 'beans-child', $path ) + ->andReturnUsing( function( $id, $path ) { + global $_beans_uikit_registered_items; + $_beans_uikit_registered_items['themes'][ $id ] = $path; + + return true; + } ); + Monkey\Functions\expect( '_beans_uikit_get_registered_theme' ) + ->once() + ->with( 'beans-child' ) + ->andReturn( $path ); + + $this->assertArrayNotHasKey( 'beans-child', $_beans_uikit_registered_items['themes'] ); + $this->assertArrayNotHasKey( 'beans-child', $_beans_uikit_enqueued_items['themes'] ); + + $this->assertTrue( beans_uikit_enqueue_theme( 'beans-child', $path ) ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_registered_items['themes'] ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_enqueued_items['themes'] ); + $this->assertSame( $path, $_beans_uikit_enqueued_items['themes']['beans-child'] ); + } +} diff --git a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php index 44fbafa0..03b5a526 100644 --- a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php @@ -41,6 +41,13 @@ abstract class UIkit_Test_Case extends Test_Case { */ protected $mock_filesystem; + /** + * Array of default themes. + * + * @var array + */ + protected $themes; + /** * Prepares the test environment before each test. */ @@ -116,21 +123,21 @@ protected function set_up_mocked_functions() { protected function reset_globals() { global $_beans_uikit_enqueued_items, $_beans_uikit_registered_items; - $_beans_uikit_enqueued_items = array( - 'components' => array( - 'core' => array(), - 'add-ons' => array(), - ), - 'themes' => array(), - ); + $_beans_uikit_enqueued_items = [ + 'components' => [ + 'core' => [], + 'add-ons' => [], + ], + 'themes' => [], + ]; - $_beans_uikit_registered_items = array( - 'themes' => array( - 'default' => BEANS_API_PATH . 'uikit/src/themes/default', - 'almost-flat' => BEANS_API_PATH . 'uikit/src/themes/almost-flat', - 'gradient' => BEANS_API_PATH . 'uikit/src/themes/gradient', - 'wordpress-admin' => BEANS_API_PATH . 'uikit/themes/wordpress-admin', - ), - ); + $this->themes = [ + 'default' => BEANS_API_PATH . 'uikit/src/themes/default', + 'almost-flat' => BEANS_API_PATH . 'uikit/src/themes/almost-flat', + 'gradient' => BEANS_API_PATH . 'uikit/src/themes/gradient', + 'wordpress-admin' => BEANS_API_PATH . 'uikit/themes/wordpress-admin', + ]; + + $_beans_uikit_registered_items = [ 'themes' => $this->themes ]; } } From 1733eb943cf35c9b19decabf5b58e0e59bdb6896 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 16 Jun 2018 10:05:19 -0500 Subject: [PATCH 710/800] Added tests for beans_uikit_dequeue_theme(). --- .../unit/api/uikit/beansUikitDequeueTheme.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/phpunit/unit/api/uikit/beansUikitDequeueTheme.php diff --git a/tests/phpunit/unit/api/uikit/beansUikitDequeueTheme.php b/tests/phpunit/unit/api/uikit/beansUikitDequeueTheme.php new file mode 100644 index 00000000..b8c9188b --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beansUikitDequeueTheme.php @@ -0,0 +1,60 @@ +assertArrayNotHasKey( $theme_id, $_beans_uikit_enqueued_items['themes'] ); + $this->assertNull( beans_uikit_dequeue_theme( $theme_id ) ); + $this->assertArrayNotHasKey( $theme_id, $_beans_uikit_enqueued_items['themes'] ); + } + } + + /** + * Test beans_uikit_dequeue_theme() should remove the theme from the enqueue registry. + */ + public function test_should_remove_theme_from_enqueue_registry() { + global $_beans_uikit_enqueued_items; + + // Check the built-in themes. + foreach ( [ 'default', 'almost-flat', 'gradient', 'wordpress-admin' ] as $theme_id ) { + $_beans_uikit_enqueued_items['themes'][ $theme_id ] = $this->themes[ $theme_id ]; + $this->assertArrayHasKey( $theme_id, $_beans_uikit_enqueued_items['themes'] ); + $this->assertNull( beans_uikit_dequeue_theme( $theme_id ) ); + $this->assertArrayNotHasKey( $theme_id, $_beans_uikit_enqueued_items['themes'] ); + } + + // Check the child theme. + $_beans_uikit_enqueued_items['themes']['beans-child'] = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_enqueued_items['themes'] ); + $this->assertNull( beans_uikit_dequeue_theme( 'beans-child' ) ); + $this->assertArrayNotHasKey( 'beans-child', $_beans_uikit_enqueued_items['themes'] ); + } +} From 557427f430916583eefe201cb906e0c056a23702 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 16 Jun 2018 10:16:24 -0500 Subject: [PATCH 711/800] Added tests for _beans_uikit_get_registered_theme(). --- .../unit/api/uikit/beansUikitDequeueTheme.php | 1 - .../uikit/beansUikitGetRegisteredTheme.php | 56 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/unit/api/uikit/beansUikitGetRegisteredTheme.php diff --git a/tests/phpunit/unit/api/uikit/beansUikitDequeueTheme.php b/tests/phpunit/unit/api/uikit/beansUikitDequeueTheme.php index b8c9188b..ff8219f2 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitDequeueTheme.php +++ b/tests/phpunit/unit/api/uikit/beansUikitDequeueTheme.php @@ -10,7 +10,6 @@ namespace Beans\Framework\Tests\Unit\API\UIkit; use Beans\Framework\Tests\Unit\API\UIkit\Includes\UIkit_Test_Case; -use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once __DIR__ . '/includes/class-uikit-test-case.php'; diff --git a/tests/phpunit/unit/api/uikit/beansUikitGetRegisteredTheme.php b/tests/phpunit/unit/api/uikit/beansUikitGetRegisteredTheme.php new file mode 100644 index 00000000..75fe256a --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beansUikitGetRegisteredTheme.php @@ -0,0 +1,56 @@ +assertFalse( _beans_uikit_get_registered_theme( $theme_id ) ); + $this->assertArrayNotHasKey( $theme_id, $_beans_uikit_registered_items['themes'] ); + } + } + + /** + * Test _beans_uikit_get_registered_theme() should return theme's path when theme is registered. + */ + public function test_should_theme_path_when_theme_is_registered() { + global $_beans_uikit_registered_items; + + // Check the built-in themes. + foreach ( [ 'default', 'almost-flat', 'gradient', 'wordpress-admin' ] as $theme_id ) { + $this->assertArrayHasKey( $theme_id, $_beans_uikit_registered_items['themes'] ); + $this->assertSame( $this->themes[ $theme_id ], _beans_uikit_get_registered_theme( $theme_id ) ); + } + + // Check the child theme. + $_beans_uikit_registered_items['themes']['beans-child'] = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + $this->assertArrayHasKey( 'beans-child', $_beans_uikit_registered_items['themes'] ); + $this->assertSame( vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ), _beans_uikit_get_registered_theme( 'beans-child' ) ); + } +} From 06515ae507edb5274f545ebe513e8a4d1a988c32 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 16 Jun 2018 10:17:11 -0500 Subject: [PATCH 712/800] Added beans_get mock for all UIkit unit tests. --- .../unit/api/uikit/includes/class-uikit-test-case.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php index 03b5a526..cbada574 100644 --- a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php @@ -115,6 +115,12 @@ protected function set_up_mocked_functions() { Monkey\Functions\when( 'beans_join_arrays' )->alias( function( &$array1, $array2 ) { $array1 = array_merge( $array1, $array2 ); } ); + + Monkey\Functions\when( 'beans_get' )->alias( function( $needle, array $haystack, $default = null ) { + return isset( $haystack[ $needle ] ) + ? $haystack[ $needle ] + : $default; + } ); } /** From dd71945d657b6a100d50c641b22c510b7e2ac433 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 16 Jun 2018 10:18:48 -0500 Subject: [PATCH 713/800] Simplified _beans_uikit_get_registered_theme() code. By passing the default value of `false` to beans_get(), we can simply return what is passed back. beans_get will either return the theme's path or false. --- lib/api/uikit/functions.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index d96ffa60..a2c6b007 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -75,6 +75,7 @@ function beans_uikit_dequeue_components( $components, $type = 'core' ) { // When true, remove all of the components from the registry. if ( true === $components ) { $_beans_uikit_enqueued_items['components'][ $type ] = array(); + return; } @@ -251,27 +252,20 @@ function _beans_uikit_autoload_dependencies( $components ) { } /** - * Get registered theme. + * Get the path for the given theme ID, if the theme is registered. * * @since 1.0.0 * @ignore * @access private * - * @param string $id UIkit theme ID. + * @param string $id The theme ID to get. * - * @return mixed + * @return string|bool Returns false if the theme is not registered. */ function _beans_uikit_get_registered_theme( $id ) { global $_beans_uikit_registered_items; - // Stop here if the theme is already registered. - $theme = beans_get( $id, $_beans_uikit_registered_items['themes'] ); - - if ( $theme ) { - return $theme; - } - - return false; + return beans_get( $id, $_beans_uikit_registered_items['themes'], false ); } add_action( 'wp_enqueue_scripts', '_beans_uikit_enqueue_assets', 7 ); From 9efe0b483450eb19c5da130bc9c6ae5e3773579a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 16 Jun 2018 10:43:52 -0500 Subject: [PATCH 714/800] Fixed formatting. Cleanup. --- .../api/uikit/beansUikitDequeueComponents.php | 16 ++++++++-------- .../api/uikit/beansUikitGetRegisteredTheme.php | 1 - .../unit/api/uikit/beansUikitRegisterTheme.php | 7 +++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php index dd613fc8..683c7305 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php +++ b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php @@ -10,7 +10,6 @@ namespace Beans\Framework\Tests\Unit\API\UIkit; use Beans\Framework\Tests\Unit\API\UIkit\Includes\UIkit_Test_Case; -use Brain\Monkey; require_once __DIR__ . '/includes/class-uikit-test-case.php'; @@ -88,12 +87,12 @@ public function test_should_remove_given_addons_component_from_registry_when_giv * array. */ public function test_should_remove_given_core_components_from_registry_when_given_array() { - global $_beans_uikit_enqueued_items; - $components = [ + $components = [ 'alert', 'button', 'overlay', ]; + global $_beans_uikit_enqueued_items; $_beans_uikit_enqueued_items['components']['core'] = $components; beans_uikit_dequeue_components( [ 'alert' ] ); @@ -116,12 +115,12 @@ public function test_should_remove_given_core_components_from_registry_when_give * an array. */ public function test_should_remove_given_addons_component_from_registry_when_given_array() { - global $_beans_uikit_enqueued_items; - $components = [ + $components = [ 'accordion', 'datepicker', 'sticky', ]; + global $_beans_uikit_enqueued_items; $_beans_uikit_enqueued_items['components']['add-ons'] = $components; beans_uikit_dequeue_components( [ 'sticky' ], 'add-ons' ); @@ -137,10 +136,10 @@ public function test_should_remove_given_addons_component_from_registry_when_giv } /** - * Test beans_uikit_dequeue_components() should remove all core components from the registry when $components is true. + * Test beans_uikit_dequeue_components() should remove all core components from the registry when $components is + * true. */ public function test_should_remove_all_core_components_from_registry_when_components_is_true() { - global $_beans_uikit_enqueued_items; $components = [ 'alert', 'animation', @@ -148,6 +147,7 @@ public function test_should_remove_all_core_components_from_registry_when_compon 'badge', 'base', ]; + global $_beans_uikit_enqueued_items; $_beans_uikit_enqueued_items['components']['core'] = $components; beans_uikit_dequeue_components( true ); @@ -159,7 +159,6 @@ public function test_should_remove_all_core_components_from_registry_when_compon * true. */ public function test_should_remove_all_addons_components_from_registry_when_components_is_true() { - global $_beans_uikit_enqueued_items; $components = [ 'accordion', 'autocomplete', @@ -168,6 +167,7 @@ public function test_should_remove_all_addons_components_from_registry_when_comp 'form-advanced', 'sticky', ]; + global $_beans_uikit_enqueued_items; $_beans_uikit_enqueued_items['components']['add-ons'] = $components; beans_uikit_dequeue_components( true, 'add-ons' ); diff --git a/tests/phpunit/unit/api/uikit/beansUikitGetRegisteredTheme.php b/tests/phpunit/unit/api/uikit/beansUikitGetRegisteredTheme.php index 75fe256a..20717d97 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitGetRegisteredTheme.php +++ b/tests/phpunit/unit/api/uikit/beansUikitGetRegisteredTheme.php @@ -10,7 +10,6 @@ namespace Beans\Framework\Tests\Unit\API\UIkit; use Beans\Framework\Tests\Unit\API\UIkit\Includes\UIkit_Test_Case; -use Brain\Monkey; use org\bovigo\vfs\vfsStream; require_once __DIR__ . '/includes/class-uikit-test-case.php'; diff --git a/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php b/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php index 53b7db82..3d87b22d 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php +++ b/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php @@ -32,10 +32,9 @@ public function test_should_return_true_when_theme_is_already_registered() { Monkey\Functions\expect( 'trailingslashit' )->never(); // Check the built-in themes. - $this->assertTrue( beans_uikit_register_theme( 'default', '' ) ); - $this->assertTrue( beans_uikit_register_theme( 'almost-flat', '' ) ); - $this->assertTrue( beans_uikit_register_theme( 'gradient', '' ) ); - $this->assertTrue( beans_uikit_register_theme( 'wordpress-admin', '' ) ); + foreach ( [ 'default', 'almost-flat', 'gradient', 'wordpress-admin' ] as $theme_id ) { + $this->assertTrue( beans_uikit_register_theme( $theme_id, '' ) ); + } // Check the child theme. global $_beans_uikit_registered_items; From 0f9d6ce2e9760fd96beed47fc44c2f178f943994 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Sat, 16 Jun 2018 11:38:05 -0500 Subject: [PATCH 715/800] Improved documentation. --- lib/api/uikit/functions.php | 2 +- .../unit/api/uikit/beansUikitDequeueComponents.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index a2c6b007..e59f7c8d 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -64,7 +64,7 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload * * @param string|array $components Name of the component(s) to exclude as an indexed array. The name(s) must be * the UIkit component filename without the extention (e.g. 'grid'). Set to true - * exclude all components. + * to exclude all components. * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). * * @return void diff --git a/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php index 683c7305..f40d7aa6 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php +++ b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php @@ -136,8 +136,8 @@ public function test_should_remove_given_addons_component_from_registry_when_giv } /** - * Test beans_uikit_dequeue_components() should remove all core components from the registry when $components is - * true. + * Test beans_uikit_dequeue_components() should remove all core components from the registry when true is passed as + * the argument for $components. */ public function test_should_remove_all_core_components_from_registry_when_components_is_true() { $components = [ @@ -155,8 +155,8 @@ public function test_should_remove_all_core_components_from_registry_when_compon } /** - * Test beans_uikit_enqueue_components() should remove all add-ons components from the registry when $components is - * true. + * Test beans_uikit_enqueue_components() should remove all add-ons components from the registry when true is passed as + * the argument for $components. */ public function test_should_remove_all_addons_components_from_registry_when_components_is_true() { $components = [ From 526d379dfdd571e6b837c9b056b8113b87999c40 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 12:51:25 -0500 Subject: [PATCH 716/800] Changed Beans version from 1.4.1 to 1.5.0-beta. --- lib/init.php | 2 +- style.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/init.php b/lib/init.php index 61599c66..548ba217 100644 --- a/lib/init.php +++ b/lib/init.php @@ -18,7 +18,7 @@ */ function beans_define_constants() { // Define version. - define( 'BEANS_VERSION', '1.4.1' ); + define( 'BEANS_VERSION', '1.5.0-beta' ); // Define paths. if ( ! defined( 'BEANS_THEME_PATH' ) ) { diff --git a/style.css b/style.css index 299618f2..f1a5a63f 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Theme URI: http://www.getbeans.io/themes/beans/ Author: Beans Author URI: http://www.getbeans.io Description: The most innovative theme for WordPress. The real magic is under the hood. -Version: 1.4.1 +Version: 1.5.0-beta Text Domain: tm-beans Tags: white, light, one-column, two-columns, three-columns, right-sidebar, left-sidebar, responsive-layout, fluid-layout, fixed-layout, custom-header, custom-background, custom-menu, editor-style, featured-images, microformats, post-formats, translation-ready License: GNU General Public License v2 or later From 48c2adedea175ef704cefdff4216ddfc589edb8e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 17:02:16 -0500 Subject: [PATCH 717/800] Added tests for beans_compile_less_fragments(). --- lib/api/compiler/functions.php | 2 +- .../compiler/beansCompileLessFragments.php | 66 +++++++++++++++++++ .../includes/class-compiler-test-case.php | 43 ++++++++++++ .../compiler/beansCompileLessFragments.php | 33 ++++++++++ 4 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/integration/api/compiler/beansCompileLessFragments.php create mode 100644 tests/phpunit/unit/api/compiler/beansCompileLessFragments.php diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 5b9d6f98..71029a98 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -66,7 +66,7 @@ function beans_compile_css_fragments( $id, $fragments, $args = array() ) { * @param array $args { * Optional. Array of arguments used by the compiler. * - * @type array $depedencies An array of registered handles this script depends on. Default false. + * @type array $depedencies An array of registered handles this script depends on. Default is an empty array. * } * * @return void|bool diff --git a/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php b/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php new file mode 100644 index 00000000..9bbbfa77 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php @@ -0,0 +1,66 @@ +mock_filesystem->getChild( 'fixtures' ); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); + } + + /** + * Test beans_compile_less_fragments() should compile the Less fragments, saving it to the virtual filesystem and + * enqueuing it in WordPress. + */ + public function test_should_compile_save_and_enqueue_less() { + $id = 'compile-less-fragments'; + $fragments = array( + vfsStream::url( 'compiled/fixtures/test.less' ), + vfsStream::url( 'compiled/fixtures/variables.less' ), + ); + + // Set up the mocks. + $this->add_virtual_directory( $id ); + $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); + + // Run the tests. + $this->assertEmpty( $this->get_compiled_filename( $path ) ); + beans_compile_less_fragments( $id, $fragments ); + $filename = $this->get_compiled_filename( $path ); + $this->assertFileExists( $path . $filename ); + $this->assertStringEndsWith( '.css', $filename ); + $this->assertSame( $this->get_compiled_less(), $this->get_cached_contents( $filename, $id ) ); + } +} diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index 9d1053a3..11b431de 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -70,6 +70,14 @@ public static function setUpBeforeClass() { public function setUp() { parent::setUp(); + // Set up the global fragments container. + global $_beans_compiler_added_fragments; + $_beans_compiler_added_fragments = array( + 'css' => array(), + 'less' => array(), + 'js' => array(), + ); + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); } @@ -224,6 +232,41 @@ protected function mock_filesystem_for_fragments( $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case, as we are mocking the filesystem. } + /** + * Get the file's content. + * + * @since 1.5.0 + * + * @param string $filename Name of the file. + * @param string $id File's ID. + * + * @return string + */ + protected function get_cached_contents( $filename, $id ) { + return $this->mock_filesystem + ->getChild( 'beans/compiler/' . $id ) + ->getChild( $filename ) + ->getContent(); + } + + /** + * Get the compiled file's name. + * + * @param string $path The virtual filesystem's path. + * + * @return string + */ + protected function get_compiled_filename( $path ) { + $files = scandir( $path ); + unset( $files[0], $files[1] ); + + if ( empty( $files ) ) { + return ''; + } + + return array_pop( $files ); + } + /** * Get the compiled jQuery. * diff --git a/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php b/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php new file mode 100644 index 00000000..d904acea --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php @@ -0,0 +1,33 @@ +assertFalse( beans_compile_less_fragments( 'foo', '' ) ); + $this->assertFalse( beans_compile_less_fragments( 'foo', [] ) ); + $this->assertFalse( beans_compile_less_fragments( 'foo', [], [ 'arg' => '' ] ) ); + } +} From 3e0310122a22f55fc78c9167a2232d2dd136d306 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 17:19:50 -0500 Subject: [PATCH 718/800] Added tests for beans_compile_css_fragments(). --- lib/api/compiler/functions.php | 2 +- .../api/compiler/beansCompileCssFragments.php | 61 +++++++++++++++++++ .../compiler/beansCompileLessFragments.php | 2 - .../api/compiler/beansCompileCssFragments.php | 33 ++++++++++ 4 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 tests/phpunit/integration/api/compiler/beansCompileCssFragments.php create mode 100644 tests/phpunit/unit/api/compiler/beansCompileCssFragments.php diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 71029a98..2d96fec6 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -28,7 +28,7 @@ * @param array $args { * Optional. Array of arguments used by the compiler. * - * @type array $depedencies An array of registered handles this script depends on. Default false. + * @type array $depedencies An array of registered handles this script depends on. Default is an empty array. * } * * @return void|bool diff --git a/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php b/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php new file mode 100644 index 00000000..5f649b30 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php @@ -0,0 +1,61 @@ +mock_filesystem->getChild( 'fixtures' ); + $this->css = $fixtures->getChild( 'style.css' )->getContent(); + } + + /** + * Test beans_compile_css_fragments() should compile the CSS fragments, saving it to the virtual filesystem and + * enqueuing it in WordPress. + */ + public function test_should_compile_save_and_enqueue_css() { + $id = 'compile-css-fragments'; + $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); + $this->add_virtual_directory( $id ); + $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); + + // Run the tests. + $this->assertEmpty( $this->get_compiled_filename( $path ) ); + beans_compile_css_fragments( $id, $fragment ); + $filename = $this->get_compiled_filename( $path ); + $this->assertFileExists( $path . $filename ); + $this->assertStringEndsWith( '.css', $filename ); + $this->assertSame( $this->get_compiled_css(), $this->get_cached_contents( $filename, $id ) ); + } +} diff --git a/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php b/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php index 9bbbfa77..4ed264d6 100644 --- a/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php +++ b/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php @@ -50,8 +50,6 @@ public function test_should_compile_save_and_enqueue_less() { vfsStream::url( 'compiled/fixtures/test.less' ), vfsStream::url( 'compiled/fixtures/variables.less' ), ); - - // Set up the mocks. $this->add_virtual_directory( $id ); $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); diff --git a/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php b/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php new file mode 100644 index 00000000..19fe082a --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php @@ -0,0 +1,33 @@ +assertFalse( beans_compile_css_fragments( 'foo', '' ) ); + $this->assertFalse( beans_compile_css_fragments( 'foo', [] ) ); + $this->assertFalse( beans_compile_css_fragments( 'foo', [], [ 'arg' => '' ] ) ); + } +} From e99fc9fee746793128e4b88e9119c51d6e598cc5 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 17:48:47 -0500 Subject: [PATCH 719/800] Added tests for beans_compile_js_fragments(). --- .../api/compiler/beansCompileJsFragments.php | 99 +++++++++++++++++++ .../api/compiler/beansCompileJsFragments.php | 36 +++++++ 2 files changed, 135 insertions(+) create mode 100644 tests/phpunit/integration/api/compiler/beansCompileJsFragments.php create mode 100644 tests/phpunit/unit/api/compiler/beansCompileJsFragments.php diff --git a/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php b/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php new file mode 100644 index 00000000..ea83f029 --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php @@ -0,0 +1,99 @@ +add_virtual_directory( $id ); + $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); + + // Run the tests. + $this->assertEmpty( $this->get_compiled_filename( $path ) ); + beans_compile_js_fragments( $id, $fragment, [ + 'dependencies' => [ 'jquery' ], + 'in_footer' => true, + 'minify_js' => true, + ] ); + $filename = $this->get_compiled_filename( $path ); + $this->assertFileExists( $path . $filename ); + $this->assertStringEndsWith( '.js', $filename ); + $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_contents( $filename, $id ) ); + } + + /** + * Test beans_compile_js_fragments() should compile the JS fragment, saving it to the virtual filesystem and + * enqueuing it in WordPress. + */ + public function test_should_compile_save_and_enqueue_js() { + $id = 'test-js'; + $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); + $this->add_virtual_directory( $id ); + $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); + + // Run the tests. + $this->assertEmpty( $this->get_compiled_filename( $path ) ); + beans_compile_js_fragments( $id, $fragment, [ + 'in_footer' => true, + 'minify_js' => true, + ] ); + $filename = $this->get_compiled_filename( $path ); + $this->assertFileExists( $path . $filename ); + $this->assertStringEndsWith( '.js', $filename ); + $this->assertSame( $this->get_compiled_js(), $this->get_cached_contents( $filename, $id ) ); + } + + /** + * Test beans_compile_js_fragments() should compile the combined JS fragments, saving it to the virtual filesystem + * and enqueuing it in WordPress. + */ + public function test_should_compile_save_and_enqueue_combined_js() { + $id = 'test-js'; + $fragments = [ + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ]; + $this->add_virtual_directory( $id ); + $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); + + // Run the tests. + $this->assertEmpty( $this->get_compiled_filename( $path ) ); + beans_compile_js_fragments( $id, $fragments, [ + 'dependencies' => [ 'jquery' ], + 'in_footer' => true, + 'minify_js' => true, + ] ); + $filename = $this->get_compiled_filename( $path ); + $this->assertFileExists( $path . $filename ); + $this->assertStringEndsWith( '.js', $filename ); + + $contents = $this->get_cached_contents( $filename, $id ); + $this->assertContains( $this->get_compiled_js(), $contents ); + $this->assertContains( $this->get_compiled_jquery(), $contents ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php b/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php new file mode 100644 index 00000000..f269147a --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php @@ -0,0 +1,36 @@ +assertFalse( beans_compile_js_fragments( 'foo', '' ) ); + $this->assertFalse( beans_compile_js_fragments( 'foo', [] ) ); + $this->assertFalse( beans_compile_js_fragments( 'foo', [], [ + 'dependencies' => [], + 'in_footer' => true, + ] ) ); + } +} From 1f46e124c69578baaaf579901cdbdf89f3b1d0f7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 18:01:37 -0500 Subject: [PATCH 720/800] Refactored to create a new private _beans_compile_fragments() function. All 3 of the compile fragment functions used the exact same code patterns. To keep it DRY and give us the ability to manage how the compiler is configured and called, this new private function handles it. --- lib/api/compiler/functions.php | 90 +++++++++++++++++----------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 2d96fec6..3e1db9ca 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -21,14 +21,14 @@ * * @since 1.0.0 * - * @param string $id A unique string used as a reference. Similar to the WordPress scripts - * $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase - * compiling time. - * @param array $args { - * Optional. Array of arguments used by the compiler. - * - * @type array $depedencies An array of registered handles this script depends on. Default is an empty array. + * @param string $id A unique string used as a reference. Similar to the WordPress scripts + * $handle argument. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * compiling time. + * @param array $args { + * Optional. Array of arguments used by the compiler. + * + * @type array $dependencies An array of registered handles this script depends on. Default is an empty array. * } * * @return void|bool @@ -39,15 +39,7 @@ function beans_compile_css_fragments( $id, $fragments, $args = array() ) { return false; } - $params = array( - 'id' => $id, - 'type' => 'style', - 'format' => 'css', - 'fragments' => (array) $fragments, - ); - - $compiler = new _Beans_Compiler( $params + $args ); - $compiler->run_compiler(); + _beans_compile_fragments( $id, 'css', $fragments, $args ); } /** @@ -60,13 +52,13 @@ function beans_compile_css_fragments( $id, $fragments, $args = array() ) { * * @since 1.0.0 * - * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase - * compiling time. - * @param array $args { - * Optional. Array of arguments used by the compiler. + * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * compiling time. + * @param array $args { + * Optional. Array of arguments used by the compiler. * - * @type array $depedencies An array of registered handles this script depends on. Default is an empty array. + * @type array $dependencies An array of registered handles this script depends on. Default is an empty array. * } * * @return void|bool @@ -77,15 +69,7 @@ function beans_compile_less_fragments( $id, $fragments, $args = array() ) { return false; } - $params = array( - 'id' => $id, - 'type' => 'style', - 'format' => 'less', - 'fragments' => (array) $fragments, - ); - - $compiler = new _Beans_Compiler( $params + $args ); - $compiler->run_compiler(); + _beans_compile_fragments( $id, 'less', $fragments, $args ); } /** @@ -98,15 +82,15 @@ function beans_compile_less_fragments( $id, $fragments, $args = array() ) { * * @since 1.0.0 * - * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) URL accepted but may increase - * compiling time. - * @param array $args { - * Optional. Array of arguments used by the compiler. + * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) URL accepted but may increase + * compiling time. + * @param array $args { + * Optional. Array of arguments used by the compiler. * - * @type array $depedencies An array of registered handles this script depends on. Default false. - * @type bool $in_footer Whether to enqueue the script before or before . Default false. - * @type bool $minify_js Whether the JavaScript should be minified or not. Be aware that minifying + * @type array $dependencies An array of registered handles this script depends on. Default false. + * @type bool $in_footer Whether to enqueue the script before or before . Default false. + * @type bool $minify_js Whether the JavaScript should be minified or not. Be aware that minifying * the JavaScript can considerably slow down the process of compiling files. * Default false. * } @@ -119,14 +103,32 @@ function beans_compile_js_fragments( $id, $fragments, $args = array() ) { return false; } - $params = array( + _beans_compile_fragments( $id, 'js', $fragments, $args, true ); +} + +/** + * Compile the given fragments. + * + * @since 1.5.0 + * + * @param string $id The ID. + * @param string $format The format type. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) URL accepted but may increase + * compiling time. + * @param array $args Optional. An array of arguments. + * @param bool $is_script Optional. When true, the fragment(s) is(are) script(s). + * + * @return void + */ +function _beans_compile_fragments( $id, $format, $fragments, array $args = array(), $is_script = false ) { + $config = array( 'id' => $id, - 'type' => 'script', - 'format' => 'js', + 'type' => $is_script ? 'script' : 'style', + 'format' => $format, 'fragments' => (array) $fragments, ); - $compiler = new _Beans_Compiler( $params + $args ); + $compiler = new _Beans_Compiler( $config + $args ); $compiler->run_compiler(); } From d4d466e224e48c6ecae81309f8ad2c5b03ed74dd Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 18:23:43 -0500 Subject: [PATCH 721/800] Added tests for beans_compiler_add_fragment(). --- .../api/compiler/beansCompileCssFragments.php | 4 +- .../api/compiler/beansCompileJsFragments.php | 4 +- .../compiler/beansCompileLessFragments.php | 4 +- .../api/compiler/beansCompilerAddFragment.php | 92 +++++++++++++++++++ 4 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php diff --git a/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php b/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php index 19fe082a..1da426a3 100644 --- a/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php +++ b/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php @@ -23,9 +23,9 @@ class Test_BeansCompileCssFragments extends Compiler_Test_Case { /** - * Test beans_compile_css_fragments() should return false when no fragments are passed to it. + * Test beans_compile_css_fragments() should return false when no fragments when no fragments are given. */ - public function test_should_return_false_when_fragments_are_passed_to_it() { + public function test_should_return_false_when_no_fragments_given() { $this->assertFalse( beans_compile_css_fragments( 'foo', '' ) ); $this->assertFalse( beans_compile_css_fragments( 'foo', [] ) ); $this->assertFalse( beans_compile_css_fragments( 'foo', [], [ 'arg' => '' ] ) ); diff --git a/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php b/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php index f269147a..837332ff 100644 --- a/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php +++ b/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php @@ -23,9 +23,9 @@ class Test_BeansCompileJsFragments extends Compiler_Test_Case { /** - * Test beans_compile_js_fragments() should return false when no fragments are passed to it. + * Test beans_compile_js_fragments() should return false when no fragments are given. */ - public function test_should_return_false_when_fragments_are_passed_to_it() { + public function test_should_return_false_when_no_fragments_given() { $this->assertFalse( beans_compile_js_fragments( 'foo', '' ) ); $this->assertFalse( beans_compile_js_fragments( 'foo', [] ) ); $this->assertFalse( beans_compile_js_fragments( 'foo', [], [ diff --git a/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php b/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php index d904acea..62d5fce5 100644 --- a/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php +++ b/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php @@ -23,9 +23,9 @@ class Test_BeansCompileLessFragments extends Compiler_Test_Case { /** - * Test beans_compile_less_fragments() should return false when no fragments are passed to it. + * Test beans_compile_less_fragments() should return false when no fragments are given. */ - public function test_should_return_false_when_fragments_are_passed_to_it() { + public function test_should_return_false_when_no_fragments_given() { $this->assertFalse( beans_compile_less_fragments( 'foo', '' ) ); $this->assertFalse( beans_compile_less_fragments( 'foo', [] ) ); $this->assertFalse( beans_compile_less_fragments( 'foo', [], [ 'arg' => '' ] ) ); diff --git a/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php b/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php new file mode 100644 index 00000000..a2b79b89 --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php @@ -0,0 +1,92 @@ +assertFalse( beans_compiler_add_fragment( 'foo', '', 'less' ) ); + $this->assertFalse( beans_compiler_add_fragment( 'foo', [], 'css' ) ); + $this->assertFalse( beans_compiler_add_fragment( 'foo', [], 'js' ) ); + } + + /** + * Test beans_compiler_add_fragment() should not add fragments when the format is not valid. + */ + public function test_should_not_add_fragments_when_format_is_not_valid() { + global $_beans_compiler_added_fragments; + + $this->assertNull( beans_compiler_add_fragment( 'test-css', vfsStream::url( 'compiled/fixtures/style.css' ), 'style' ) ); + $this->assertArrayNotHasKey( 'style', $_beans_compiler_added_fragments ); + + $this->assertNull( beans_compiler_add_fragment( 'test-js', vfsStream::url( 'compiled/fixtures/jquery.test.js' ), 'script' ) ); + $this->assertArrayNotHasKey( 'script', $_beans_compiler_added_fragments ); + } + + /** + * Test beans_compiler_add_fragment() should add fragments when the format is valid. + */ + public function test_should_add_fragments_when_format_is_valid() { + global $_beans_compiler_added_fragments; + + $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); + $this->assertNull( beans_compiler_add_fragment( 'test-css', $fragment, 'css' ) ); + $this->assertArrayHasKey( 'test-css', $_beans_compiler_added_fragments['css'] ); + $this->assertSame( [ $fragment ], $_beans_compiler_added_fragments['css']['test-css'] ); + + $fragments = array( + vfsStream::url( 'compiled/fixtures/test.less' ), + vfsStream::url( 'compiled/fixtures/variables.less' ), + ); + $this->assertNull( beans_compiler_add_fragment( 'test-less', $fragments, 'less' ) ); + $this->assertArrayHasKey( 'test-less', $_beans_compiler_added_fragments['less'] ); + $this->assertSame( $fragments, $_beans_compiler_added_fragments['less']['test-less'] ); + + $fragments = [ + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ]; + $this->assertNull( beans_compiler_add_fragment( 'test-js', $fragments, 'js' ) ); + $this->assertArrayHasKey( 'test-js', $_beans_compiler_added_fragments['js'] ); + $this->assertSame( $fragments, $_beans_compiler_added_fragments['js']['test-js'] ); + } + + /** + * Test beans_compiler_add_fragment() should add fragment(s) to existing ID. + */ + public function test_should_add_fragment_to_existing_id() { + global $_beans_compiler_added_fragments; + + $_beans_compiler_added_fragments['less']['test-css'] = [ 'theme/base.less' ]; + + $fragments = array( + vfsStream::url( 'compiled/fixtures/test.less' ), + vfsStream::url( 'compiled/fixtures/variables.less' ), + ); + $this->assertNull( beans_compiler_add_fragment( 'test-less', $fragments, 'less' ) ); + $this->assertContains( $fragments[0], $_beans_compiler_added_fragments['less']['test-less'] ); + $this->assertContains( $fragments[1], $_beans_compiler_added_fragments['less']['test-less'] ); + } +} From 4f3958a6ffe9b6463f78de2eb1189c04df10007d Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 19:07:24 -0500 Subject: [PATCH 722/800] Added tests for beans_flush_compiler(). --- .../api/compiler/beansFlushCompiler.php | 112 ++++++++++++ .../unit/api/compiler/beansFlushCompiler.php | 165 ++++++++++++++++++ .../includes/class-base-test-case.php | 14 ++ 3 files changed, 291 insertions(+) create mode 100644 tests/phpunit/integration/api/compiler/beansFlushCompiler.php create mode 100644 tests/phpunit/unit/api/compiler/beansFlushCompiler.php diff --git a/tests/phpunit/integration/api/compiler/beansFlushCompiler.php b/tests/phpunit/integration/api/compiler/beansFlushCompiler.php new file mode 100644 index 00000000..198c7efd --- /dev/null +++ b/tests/phpunit/integration/api/compiler/beansFlushCompiler.php @@ -0,0 +1,112 @@ +never(); + + $this->assertNull( beans_flush_compiler( 'beans' ) ); + } + + /** + * Test beans_flush_compiler() should remove cached CSS file. + */ + public function test_should_remove_cached_css_file() { + $this->overwrite_virtual_filesystem(); + + // Check that both files exist before we start. + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + + // Run it. + $this->assertNull( beans_flush_compiler( 'beans', 'css' ) ); + + // Check that only the CSS file was removed. + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + } + + + /** + * Test beans_flush_compiler() should remove cached JS file. + */ + public function test_should_remove_cached_js_file() { + $this->overwrite_virtual_filesystem(); + + // Check that both files exist before we start. + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + + // Run it. + $this->assertNull( beans_flush_compiler( 'beans', 'js' ) ); + + // Check that only the JS file was removed. + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + } + + /** + * Test beans_flush_compiler() should remove all cached files. + */ + public function test_should_remove_all_cached_files() { + $this->overwrite_virtual_filesystem(); + + // Check that both files exist before we start. + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + + // Run it. + $this->assertNull( beans_flush_compiler( 'beans' ) ); + + // Check that the files and directory were removed. + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/beans' ) ); + $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/beans/' ) ); + } + + /** + * Overwrites the virtual filesystem for this test. + */ + private function overwrite_virtual_filesystem() { + $this->mock_filesystem = vfsStream::setup( + 'compiled', + 0755, + [ + 'beans' => [ + 'compiler' => [ + 'beans' => [ + '1234567-9876543.css' => $this->get_compiled_css(), + 'abcd3fg-hijklmn.js' => $this->get_compiled_js(), + ], + ], + ], + ] + ); + } +} diff --git a/tests/phpunit/unit/api/compiler/beansFlushCompiler.php b/tests/phpunit/unit/api/compiler/beansFlushCompiler.php new file mode 100644 index 00000000..f95d7a2e --- /dev/null +++ b/tests/phpunit/unit/api/compiler/beansFlushCompiler.php @@ -0,0 +1,165 @@ +twice() + ->with( false ) + ->andReturn( $compiler_dir ); + Monkey\Functions\expect( 'beans_remove_dir' )->never(); + + $this->assertNull( beans_flush_compiler( 'beans' ) ); + } + + /** + * Test beans_flush_compiler() should remove cached CSS file. + */ + public function test_should_remove_cached_css_file() { + $this->overwrite_virtual_filesystem(); + + $compiler_dir = vfsStream::url( 'compiled/beans/compiler/' ); + Monkey\Functions\expect( 'beans_get_compiler_dir' ) + ->once() + ->with( false ) + ->andReturn( $compiler_dir ); + Monkey\Functions\expect( 'beans_remove_dir' )->never(); + + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + $this->assertNull( beans_flush_compiler( 'beans', 'css' ) ); + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + } + + /** + * Test beans_flush_compiler() should remove cached JS file. + */ + public function test_should_remove_cached_js_file() { + $this->overwrite_virtual_filesystem(); + + $compiler_dir = vfsStream::url( 'compiled/beans/compiler/' ); + Monkey\Functions\expect( 'beans_get_compiler_dir' ) + ->once() + ->with( false ) + ->andReturn( $compiler_dir ); + Monkey\Functions\expect( 'beans_remove_dir' )->never(); + + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + $this->assertNull( beans_flush_compiler( 'beans', 'js' ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + } + + /** + * Test beans_flush_compiler() should remove all cached files. + */ + public function test_should_remove_all_cached_files() { + $this->overwrite_virtual_filesystem(); + + $compiler_dir = vfsStream::url( 'compiled/beans/compiler/' ); + Monkey\Functions\expect( 'beans_get_compiler_dir' ) + ->once() + ->with( false ) + ->andReturn( $compiler_dir ); + Monkey\Functions\expect( 'beans_remove_dir' ) + ->once() + ->with( trailingslashit( $compiler_dir ) . 'beans' ) + ->andReturnUsing( function( $dir_path ) { + $items = scandir( $dir_path ); + unset( $items[0], $items[1] ); + + $dir_path = trailingslashit( $dir_path ); + + foreach ( $items as $needle => $item ) { + unlink( $dir_path . $item ); + } + + return rmdir( $dir_path ); + } ); + + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + $this->assertNull( beans_flush_compiler( 'beans' ) ); + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); + $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); + $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/beans' ) ); + $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/beans/' ) ); + } + + /** + * Overwrites the virtual filesystem for this test. + */ + private function overwrite_virtual_filesystem() { + $this->mock_filesystem = vfsStream::setup( + 'compiled', + 0755, + [ + 'beans' => [ + 'compiler' => [ + 'beans' => [ + '1234567-9876543.css' => $this->get_compiled_css(), + 'abcd3fg-hijklmn.js' => $this->get_compiled_js(), + ], + ], + ], + ] + ); + } + + /** + * Get the compiled JavaScript. + * + * @since 1.5.0 + * + * @return string + */ + protected function get_compiled_js() { + return <<at( $this->mock_filesystem->getChild( $root_dir ) ); + } } From 5f471fa43ae6610ef2120ef2362e9919cb6c1e5f Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 19:26:27 -0500 Subject: [PATCH 723/800] Added beans_scandir() utility function. Throughout the codebase, we are scanning the filesystem with scandir() and then removing the 2 dot files. That's redundant. This commit: 1. Adds the new function. 2. Removes all the WET code and uses the new function. 3. Adds tests. --- lib/api/compiler/class-beans-compiler.php | 3 +- lib/api/compiler/functions.php | 3 +- lib/api/uikit/class-beans-uikit.php | 9 +-- lib/api/utilities/functions.php | 29 +++++++-- .../includes/class-compiler-test-case.php | 3 +- .../unit/api/utilities/beansScandir.php | 60 +++++++++++++++++++ 6 files changed, 89 insertions(+), 18 deletions(-) create mode 100644 tests/phpunit/unit/api/utilities/beansScandir.php diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index d6eadb22..f13fca07 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -732,8 +732,7 @@ private function get_new_hash( $hash, array $fragments_filemtime ) { * @return void */ private function remove_modified_files( $hash, $filemtime_hash ) { - $items = @scandir( $this->dir ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. - unset( $items[0], $items[1] ); + $items = beans_scandir( $this->dir ); if ( empty( $items ) ) { return; diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 3e1db9ca..2f8273a0 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -208,8 +208,7 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { // Remove only the specified file format. if ( $file_format ) { - $items = scandir( $dir ); - unset( $items[0], $items[1] ); + $items = beans_scandir( $dir ); foreach ( $items as $item ) { if ( false !== stripos( $item, '.' . $file_format ) ) { diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index d3ce4efa..dd695bf5 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -286,14 +286,7 @@ public function get_all_components( $type ) { * @return array */ private function get_all_files( $directory ) { - $files = scandir( $directory ); - - // Get rid of dot files when on Linux environment. - if ( '.' === $files[0] ) { - unset( $files[0], $files[1] ); - } - - return $files; + return beans_scandir( $directory ); } /** diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 91cbabd3..e8ee724d 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -77,10 +77,7 @@ function beans_remove_dir( $dir_path ) { return false; } - $items = scandir( $dir_path ); - unset( $items[0], $items[1] ); - - foreach ( $items as $needle => $item ) { + foreach ( beans_scandir( $dir_path ) as $needle => $item ) { $path = $dir_path . '/' . $item; if ( is_dir( $path ) ) { @@ -93,6 +90,30 @@ function beans_remove_dir( $dir_path ) { return @rmdir( $dir_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } +/** + * List files and directories inside of the specified path. + * + * @since 1.5.0 + * + * @param string $dir_path Path to the directory to scan. + * + * @return array|bool Returns false upon error. + */ +function beans_scandir( $dir_path ) { + $items = @scandir( $dir_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + + if ( ! $items ) { + return false; + } + + // Get rid of dot files when present. + if ( '.' === $items[0] ) { + unset( $items[0], $items[1] ); + } + + return $items; +} + /** * Convert internal path to a url. * diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index 11b431de..a0f202b2 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -257,8 +257,7 @@ protected function get_cached_contents( $filename, $id ) { * @return string */ protected function get_compiled_filename( $path ) { - $files = scandir( $path ); - unset( $files[0], $files[1] ); + $files = beans_scandir( $path ); if ( empty( $files ) ) { return ''; diff --git a/tests/phpunit/unit/api/utilities/beansScandir.php b/tests/phpunit/unit/api/utilities/beansScandir.php new file mode 100644 index 00000000..9b213a5f --- /dev/null +++ b/tests/phpunit/unit/api/utilities/beansScandir.php @@ -0,0 +1,60 @@ +assertFalse( beans_scandir( 'directory-does-not-exist' ) ); + } + + /** + * Test beans_scandir() should return all files in given directory. + */ + public function test_should_return_all_files_in_given_directory() { + $files = beans_scandir( __DIR__ ); + $this->assertContains( 'beansArrayUnique.php', $files ); + $this->assertContains( 'beansGet.php', $files ); + $this->assertContains( 'beansIsUri.php', $files ); + $this->assertContains( 'beansIsUrl.php', $files ); + $this->assertContains( 'beansJoinArrays.php', $files ); + $this->assertContains( 'beansScandir.php', $files ); + } + + /** + * Test beans_scandir() should not contain dot files. + */ + public function test_should_not_contain_dot_files() { + $files = beans_scandir( __DIR__ ); + $this->assertNotContains( '.', $files ); + $this->assertNotContains( '..', $files ); + } +} From 9fc21eb511f67ce964515693e7e598d055e2e58b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 19:51:18 -0500 Subject: [PATCH 724/800] Added beans_str_ends_with(). Often the code, we need to check if a string ends with some substring, such as ending with an extension. The code can be confusing to understanding. This commit adds a new utility function that accepts a string to check and one or more substring(s) to check. It uses mb_ for different languages. --- lib/api/compiler/functions.php | 21 ++- lib/api/utilities/functions.php | 26 ++++ .../unit/api/utilities/beansStrEndsWith.php | 125 ++++++++++++++++++ 3 files changed, 161 insertions(+), 11 deletions(-) create mode 100644 tests/phpunit/unit/api/utilities/beansStrEndsWith.php diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 2f8273a0..f5523cd5 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -206,21 +206,20 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { return; } - // Remove only the specified file format. - if ( $file_format ) { - $items = beans_scandir( $dir ); - - foreach ( $items as $item ) { - if ( false !== stripos( $item, '.' . $file_format ) ) { - @unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. - } - } + // Remove all file formats. + if ( ! $file_format ) { + beans_remove_dir( $dir ); return; } - // Remove all file formats. - beans_remove_dir( $dir ); + // Remove only the specified file format. + foreach ( beans_scandir( $dir ) as $item ) { + + if ( beans_str_ends_with( $item, ".{$file_format}" ) ) { + @unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + } + } } /** diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index e8ee724d..965bd4f6 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -114,6 +114,32 @@ function beans_scandir( $dir_path ) { return $items; } +/** + * Check if the given string ends with the given substring. + * + * When passing an array of needles, the first needle match returns `true`. Therefore, only one word in the array + * needs to match. + * + * @since 1.5.0 + * + * @param string $haystack The given string to check. + * @param string|array $needles The substring(s) to check for at the end of the given string. + * + * @return bool + */ +function beans_str_ends_with( $haystack, $needles ) { + + foreach ( (array) $needles as $needle ) { + $substring = mb_substr( $haystack, - mb_strlen( $needle ) ); + + if ( $substring === (string) $needle ) { + return true; + } + } + + return false; +} + /** * Convert internal path to a url. * diff --git a/tests/phpunit/unit/api/utilities/beansStrEndsWith.php b/tests/phpunit/unit/api/utilities/beansStrEndsWith.php new file mode 100644 index 00000000..02281379 --- /dev/null +++ b/tests/phpunit/unit/api/utilities/beansStrEndsWith.php @@ -0,0 +1,125 @@ +assertFalse( beans_str_ends_with( 'Foo', 'O' ) ); + $this->assertFalse( beans_str_ends_with( 'Checking the Case?', 'case?' ) ); + } + + /** + * Test beans_str_ends_with() should return true when the case is correct. + */ + public function test_should_return_true_when_case_is_correct() { + $this->assertTrue( beans_str_ends_with( 'Foo', 'o' ) ); + $this->assertTrue( beans_str_ends_with( 'Checking the Case?', 'Case?' ) ); + } + + /** + * Test beans_str_ends_with() should correctly identify ending string pattern. + */ + public function test_should_correctly_identify_ending_string_pattern() { + $this->assertTrue( beans_str_ends_with( 'This is a string test.', '.' ) ); + $this->assertFalse( beans_str_ends_with( 'This is a string test.', 'test' ) ); + $this->assertTrue( beans_str_ends_with( 'This is a string test.', 'test.' ) ); + $this->assertFalse( beans_str_ends_with( 'Really dig the Beans framework! ', 'framework!' ) ); + $this->assertTrue( beans_str_ends_with( 'Really dig the Beans framework! ', 'framework! ' ) ); + $this->assertTrue( beans_str_ends_with( 'The WordPress Community Rocks!', 'Rocks!' ) ); + $this->assertFalse( beans_str_ends_with( 'The WordPress Community Rocks!', 'rocks!' ) ); + $this->assertTrue( beans_str_ends_with( 'This is a string test ', ' ' ) ); + $this->assertFalse( beans_str_ends_with( 'This is a string test', ' ' ) ); + $this->assertTrue( beans_str_ends_with( 'SomeClass::someMethod', 'd' ) ); + $this->assertFalse( beans_str_ends_with( 'Fulcrum\Extender\Str\StrChecker::endsWith', '/' ) ); + } + + /** + * Test beans_str_ends_with() should correctly identify when different data type is given. + */ + public function test_should_correctly_identify_when_different_data_type_given() { + $this->assertTrue( beans_str_ends_with( 104, '04' ) ); + $this->assertFalse( beans_str_ends_with( 1247.86, '5' ) ); + $this->assertTrue( beans_str_ends_with( 1247.86, '.86' ) ); + + foreach ( [ 85.3002, 97.002 ] as $number ) { + $this->assertTrue( beans_str_ends_with( $number, '002' ) ); + $this->assertFalse( beans_str_ends_with( $number, '.0' ) ); + } + + $this->assertFalse( beans_str_ends_with( false, 'ls' ) ); + $this->assertTrue( beans_str_ends_with( true, '1' ) ); + $this->assertFalse( beans_str_ends_with( false, '0' ) ); + $this->assertTrue( beans_str_ends_with( false, '' ) ); + } + + /** + * Test beans_str_ends_with() should correctly identify when given an array of needles. + */ + public function test_should_correctly_identify_when_given_an_array_of_needles() { + $this->assertTrue( beans_str_ends_with( 'This is a string test', [ 'Test', 'test' ] ) ); + $this->assertFalse( beans_str_ends_with( 'This is a string test', [ 'string', 'are' ] ) ); + $this->assertTrue( beans_str_ends_with( 'This is a string test', [ 'tests', 'test!', 'Test', 'test' ] ) ); + $this->assertFalse( beans_str_ends_with( 'This is a string test', [ 'tests', 'Tests', 'tests!', 'Tests' ] ) ); + $this->assertTrue( beans_str_ends_with( 'Hello from Tonya', [ 'From', 'Tonya' ] ) ); + $this->assertFalse( beans_str_ends_with( 'Hello from Tonya', [ 'hello', 'From' ] ) ); + $this->assertFalse( beans_str_ends_with( + 'The WordPress Community Rocks!', + [ 'wordpress', 'wordPress', 'WordPress', 'WORDPRESS' ] + ) ); + $this->assertFalse( beans_str_ends_with( + 'The WordPress Community Rocks!', + [ 'rocks!', 'community', 'WordPress', 'the' ] + ) ); + $this->assertTrue( beans_str_ends_with( + 'The WordPress Community Rocks!', + [ 'community rocks!', 'unity Rocks!' ] + ) ); + } + + /** + * Test beans_str_ends_with() should correctly identify when non-Latin given. + */ + public function test_should_correctly_identify_when_non_latin_given() { + $string = 'Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός'; + + $this->assertFalse( beans_str_ends_with( $string, ' ' ) ); + $this->assertFalse( beans_str_ends_with( $string, ' ' ) ); + $this->assertTrue( beans_str_ends_with( $string, 'ς' ) ); + $this->assertFalse( beans_str_ends_with( $string, 'Δρασκελίζει' ) ); + $this->assertTrue( beans_str_ends_with( $string, 'ρού κυνός' ) ); + $this->assertTrue( beans_str_ends_with( $string, 'δρασκελίζει υπέρ νωθρού κυνός' ) ); + $this->assertFalse( beans_str_ends_with( $string, [ 'tάχιστη', 'υπέρ' ] ) ); + $this->assertFalse( beans_str_ends_with( $string, [ 'Υπέρ', 'ψημένη' ] ) ); + $this->assertTrue( beans_str_ends_with( $string, [ 'tάχιστη', 'υπέρ', 'κυνός' ] ) ); + $this->assertTrue( beans_str_ends_with( $string, [ 'Υπέρ', 'ψημένη', 'ρού κυνός' ] ) ); + } +} From 1d8fcdd9bb991a727950b6f151b0d01cba2d68f4 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 20:17:41 -0500 Subject: [PATCH 725/800] Added beans_str_starts_with(). Like the beans_str_ends_with() function, this function makes our code more readable without comments. We are communicating that the conditional is checking to find the given string pattern at the start. An example is in the UIkit beans_uikit_register_theme(). We check to see with the path starts with http://. If yes, then it needs to be converted to a path instead of a URI. Adding this function gives developers a handy string utility. --- lib/api/uikit/functions.php | 2 +- lib/api/utilities/functions.php | 37 ++++- .../api/uikit/beansUikitRegisterTheme.php | 10 ++ .../unit/api/utilities/beansStrEndsWith.php | 4 +- .../unit/api/utilities/beansStrStartsWith.php | 144 ++++++++++++++++++ 5 files changed, 192 insertions(+), 5 deletions(-) create mode 100644 tests/phpunit/unit/api/utilities/beansStrStartsWith.php diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index e59f7c8d..f5d62d35 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -110,7 +110,7 @@ function beans_uikit_register_theme( $id, $path ) { return false; } - if ( false !== stripos( $path, 'http' ) ) { + if ( beans_str_starts_with( $path, 'http' ) ) { $path = beans_url_to_path( $path ); } diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 965bd4f6..c15e4a49 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -115,7 +115,7 @@ function beans_scandir( $dir_path ) { } /** - * Check if the given string ends with the given substring. + * Check if the given string ends with the given substring(s). * * When passing an array of needles, the first needle match returns `true`. Therefore, only one word in the array * needs to match. @@ -128,9 +128,42 @@ function beans_scandir( $dir_path ) { * @return bool */ function beans_str_ends_with( $haystack, $needles ) { + $haystack = (string) $haystack; foreach ( (array) $needles as $needle ) { - $substring = mb_substr( $haystack, - mb_strlen( $needle ) ); + $substring = mb_substr( $haystack, -mb_strlen( $needle ) ); + + if ( $substring === (string) $needle ) { + return true; + } + } + + return false; +} + +/** + * Checks if the given string ends with the given substring(s). + * + * When passing an array of needles, the first needle match returns `true`. Therefore, only one word in the array + * needs to match. + * + * @since 1.5.0 + * + * @param string $haystack The given string to check. + * @param string|array $needles The substring(s) to check for at the end of the given string. + * + * @return bool + */ +function beans_str_starts_with( $haystack, $needles ) { + $haystack = (string) $haystack; + + foreach ( (array) $needles as $needle ) { + + if ( '' === $needle ) { + continue; + } + + $substring = mb_substr( $haystack, 0, mb_strlen( $needle ) ); if ( $substring === (string) $needle ) { return true; diff --git a/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php b/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php index 3d87b22d..24f70c5e 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php +++ b/tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php @@ -28,6 +28,7 @@ class Tests_BeansUikitRegisterTheme extends UIkit_Test_Case { * Test beans_uikit_register_theme() should return true when theme is already registered. */ public function test_should_return_true_when_theme_is_already_registered() { + Monkey\Functions\expect( 'beans_str_starts_with' )->never(); Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\expect( 'trailingslashit' )->never(); @@ -47,6 +48,7 @@ public function test_should_return_true_when_theme_is_already_registered() { * Test beans_uikit_register_theme() should return false when the theme is not registered and no path is given. */ public function test_should_return_false_when_theme_not_registered_and_no_path_given() { + Monkey\Functions\expect( 'beans_str_starts_with' )->never(); Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\expect( 'trailingslashit' )->never(); @@ -62,6 +64,10 @@ public function test_should_return_false_when_theme_not_registered_and_no_path_g public function test_should_register_the_theme_when_given_path() { global $_beans_uikit_registered_items; $path = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); + Monkey\Functions\expect( 'beans_str_starts_with' ) + ->once() + ->with( $path, 'http' ) + ->andReturn( false ); Monkey\Functions\expect( 'beans_url_to_path' )->never(); Monkey\Functions\when( 'trailingslashit' )->returnArg(); @@ -78,6 +84,10 @@ public function test_should_register_the_theme_when_given_url() { $path = vfsStream::url( 'virtual-wp-content/themes/beans-child/assets/less/theme' ); $url = 'http://example.com/virtual-wp-content/themes/beans-child/assets/less/theme'; + Monkey\Functions\expect( 'beans_str_starts_with' ) + ->once() + ->with( $url, 'http' ) + ->andReturn( true ); Monkey\Functions\expect( 'beans_url_to_path' ) ->once() ->with( $url ) diff --git a/tests/phpunit/unit/api/utilities/beansStrEndsWith.php b/tests/phpunit/unit/api/utilities/beansStrEndsWith.php index 02281379..35519274 100644 --- a/tests/phpunit/unit/api/utilities/beansStrEndsWith.php +++ b/tests/phpunit/unit/api/utilities/beansStrEndsWith.php @@ -12,13 +12,13 @@ use Beans\Framework\Tests\Unit\Test_Case; /** - * Class Tests_BeansEndsWith + * Class Tests_BeansStrEndsWith * * @package Beans\Framework\Tests\Unit\API\Utilities * @group api * @group api-utilities */ -class Tests_BeansEndsWith extends Test_Case { +class Tests_BeansStrEndsWith extends Test_Case { /** * Prepares the test environment before each test. diff --git a/tests/phpunit/unit/api/utilities/beansStrStartsWith.php b/tests/phpunit/unit/api/utilities/beansStrStartsWith.php new file mode 100644 index 00000000..20164357 --- /dev/null +++ b/tests/phpunit/unit/api/utilities/beansStrStartsWith.php @@ -0,0 +1,144 @@ +assertFalse( beans_str_starts_with( 'Foo', 'f' ) ); + $this->assertFalse( beans_str_starts_with( 'Checking the Case?', 'check' ) ); + $this->assertFalse( beans_str_starts_with( 'WordPress Community Rocks!', [ + 'wordpress', + 'wordPress', + 'WORDPRESS', + ] ) ); + } + + /** + * Test beans_str_starts_with() should return true when the case is correct. + */ + public function test_should_return_true_when_case_is_correct() { + $this->assertTrue( beans_str_starts_with( 'Foo', 'F' ) ); + $this->assertTrue( beans_str_starts_with( 'Checking the Case?', 'Checking' ) ); + $this->assertTrue( beans_str_starts_with( 'WordPress Community Rocks!', [ + 'wordpress', + 'WordPress', + 'WORDPRESS', + ] ) ); + } + + /** + * Test beans_str_starts_with() should correctly identify starting string pattern. + */ + public function test_should_correctly_identify_starting_string_pattern() { + $this->assertTrue( beans_str_starts_with( 'This is a string test.', 'This is' ) ); + $this->assertFalse( beans_str_starts_with( 'This is a string test.', 'this is' ) ); + $this->assertTrue( beans_str_starts_with( 'This is a string test.', 'This is a ' ) ); + $this->assertFalse( beans_str_starts_with( 'Really dig the Beans framework! ', 'dig' ) ); + $this->assertTrue( beans_str_starts_with( 'Really dig the Beans framework! ', 'Really ' ) ); + $this->assertTrue( beans_str_starts_with( 'The WordPress Community Rocks!', 'The W' ) ); + $this->assertFalse( beans_str_starts_with( 'The WordPress Community Rocks!', ' The ' ) ); + $this->assertTrue( beans_str_starts_with( ' This is a string test ', ' ' ) ); + $this->assertFalse( beans_str_starts_with( '. This is a string test', '.This' ) ); + $this->assertTrue( beans_str_starts_with( 'SomeClass::someMethod', 'SomeClass::someMethod' ) ); + $this->assertFalse( beans_str_starts_with( 'Fulcrum\Extender\Str\StrChecker::startsWith', 'startsWith' ) ); + } + + /** + * Test beans_str_starts_with() should correctly identify when different data type is given. + */ + public function test_should_correctly_identify_when_different_data_type_given() { + $this->assertTrue( beans_str_starts_with( 104, '1' ) ); + $this->assertFalse( beans_str_starts_with( 1247.86, '1248' ) ); + $this->assertTrue( beans_str_starts_with( 1247.86, '1247.' ) ); + $this->assertTrue( beans_str_starts_with( 85.3002, '85.' ) ); + $this->assertFalse( beans_str_starts_with( -85.3002, '85.' ) ); + $this->assertTrue( beans_str_starts_with( 0, '0' ) ); + $this->assertTrue( beans_str_starts_with( 0.213, '0.2' ) ); + + $this->assertFalse( beans_str_starts_with( false, 'ls' ) ); + $this->assertTrue( beans_str_starts_with( true, '1' ) ); + $this->assertFalse( beans_str_starts_with( false, '0' ) ); + } + + /** + * Test beans_str_starts_with() should correctly identify when given an array of needles. + */ + public function test_should_correctly_identify_when_given_an_array_of_needles() { + $this->assertTrue( beans_str_starts_with( + 'This is a string test', + [ 'this', ' this', ' This', 'This' ] + ) ); + $this->assertFalse( beans_str_starts_with( 'This is a string test', [ 'These', 'are' ] ) ); + $this->assertTrue( beans_str_starts_with( '.... This is a string test', [ + '... This', + 'this', + '. This', + '.... This', + ] ) ); + $this->assertFalse( beans_str_starts_with( '... this is a string test', [ + 'this', + ' this', + '.. this', + '...this', + ] ) ); + $this->assertTrue( beans_str_starts_with( 'Hello from Tonya', [ 'Hello', 'Tonya' ] ) ); + $this->assertFalse( beans_str_starts_with( 'Hello from Tonya', [ 'hello', 'From' ] ) ); + $this->assertTrue( beans_str_starts_with( + 'WordPress Community Rocks!', + [ 'wordpress', 'wordPress', 'WordPress', 'WORDPRESS' ] + ) ); + $this->assertFalse( beans_str_starts_with( + 'The WordPress Community Rocks!', + [ 'the', 'WordPress', 'Community', 'Rocks!' ] + ) ); + $this->assertTrue( beans_str_starts_with( + 'The WordPress Community Rocks!', + [ 'The WordPress c', 'The WordPress' ] + ) ); + } + + /** + * Test beans_str_starts_with() should correctly identify when non-Latin given. + */ + public function test_should_correctly_identify_when_non_latin_given() { + $string = 'Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός'; + + $this->assertTrue( beans_str_starts_with( $string, 'Τάχιστη' ) ); + $this->assertFalse( beans_str_starts_with( $string, 'Δρασκελίζει' ) ); + $this->assertTrue( beans_str_starts_with( $string, 'Τάχιστη αλώπηξ βαφής ψημένη γη,' ) ); + $this->assertTrue( beans_str_starts_with( $string, 'Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκε' ) ); + $this->assertFalse( beans_str_starts_with( $string, [ 'tάχιστη', 'υπέρ' ] ) ); + $this->assertFalse( beans_str_starts_with( $string, [ 'Υπέρ', 'ψημένη' ] ) ); + $this->assertTrue( beans_str_starts_with( $string, [ 'tάχιστη', 'Τάχιστη', 'κυνός' ] ) ); + $this->assertTrue( beans_str_starts_with( $string, [ 'Υπέρ', 'ψημένη', 'Τάχιστη ' ] ) ); + } +} From 9fcb3ad12b1f554c0e2ac58f884b7b4307848b29 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Mon, 18 Jun 2018 20:53:54 -0500 Subject: [PATCH 726/800] Cleaned up Compiler tests. Removed unnecessary code and mocks from the integration suite. --- .../api/compiler/beans-compiler/cacheFile.php | 154 +++++------------- .../beans-compiler/combineFragments.php | 3 +- .../compiler/beans-compiler/formatContent.php | 3 +- .../compiler/beans-compiler/runCompiler.php | 96 +---------- .../api/compiler/beansCompileCssFragments.php | 17 -- .../compiler/beansCompileLessFragments.php | 17 -- .../beans-compiler/combineFragments.php | 3 +- .../{fileystem.php => filesystem.php} | 0 .../compiler/beans-compiler/formatContent.php | 3 +- .../compiler/beans-compiler/runCompiler.php | 3 +- 10 files changed, 59 insertions(+), 240 deletions(-) rename tests/phpunit/unit/api/compiler/beans-compiler/{fileystem.php => filesystem.php} (100%) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php index 574c3a37..d7841302 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php @@ -25,175 +25,111 @@ */ class Tests_BeansCompiler_CacheFile extends Compiler_Test_Case { - /** - * Test _Beans_Compiler::cache_file() should not create the file. - */ - public function test_should_not_create_the_file() { - $compiler = new _Beans_Compiler( array( - 'id' => 'test-script', - 'type' => 'script', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), - 'dependencies' => array( 'jquery' ), - 'in_footer' => true, - 'minify_js' => true, - ) ); - - // Set up the tests. - $this->set_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler ); - - // Run the tests. - $this->assertFalse( $compiler->cache_file() ); - $this->assertFileNotExists( $compiler->get_filename() ); - } - /** * Test _Beans_Compiler::cache_file() should create the compiled jQuery file. */ public function test_should_create_compiled_jquery_file() { - $compiler = new _Beans_Compiler( array( + $config = [ 'id' => 'test-jquery', 'type' => 'script', 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), 'dependencies' => array( 'jquery' ), 'in_footer' => true, 'minify_js' => true, - ) ); - - // Set up the tests. - $this->set_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler, true ); + ]; + $compiler = $this->initialize_compiler( $config ); // Run the tests. $this->assertTrue( $compiler->cache_file() ); - $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_file_contents( $compiler ) ); + $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); + + // Clean Up. + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); } /** * Test _Beans_Compiler::cache_file() should create the compiled JavaScript file. */ public function test_should_create_compiled_javascript_file() { - $compiler = new _Beans_Compiler( array( + $config = [ 'id' => 'test-js', 'type' => 'script', 'fragments' => array( vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ), 'in_footer' => true, 'minify_js' => true, - ) ); - - // Set up the tests. - $this->set_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler, true ); + ]; + $compiler = $this->initialize_compiler( $config ); // Run the tests. $this->assertTrue( $compiler->cache_file() ); - $this->assertSame( $this->get_compiled_js(), $this->get_cached_file_contents( $compiler ) ); + $this->assertSame( $this->get_compiled_js(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); + + // Clean Up. + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); } /** * Test _Beans_Compiler::cache_file() should create the compiled CSS file. */ public function test_should_create_compiled_css_file() { - $compiler = new _Beans_Compiler( array( + $config = [ 'id' => 'test-css', 'type' => 'style', 'fragments' => array( vfsStream::url( 'compiled/fixtures/style.css' ) ), - ) ); - - // Set up the tests. - $this->set_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler, true ); + ]; + $compiler = $this->initialize_compiler( $config ); // Run the tests. $this->assertTrue( $compiler->cache_file() ); - $this->assertSame( $this->get_compiled_css(), $this->get_cached_file_contents( $compiler ) ); + $this->assertSame( $this->get_compiled_css(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); + + // Clean Up. + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); } /** * Test _Beans_Compiler::cache_file() should create the compiled LESS file. */ public function test_should_create_compiled_less_file() { - $compiler = new _Beans_Compiler( array( + $config = [ 'id' => 'test-css', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), - ) ); - - // Set up the tests. - $this->set_dev_mode( false ); - $this->mock_filesystem_for_fragments( $compiler ); - $this->add_virtual_directory( $compiler->config['id'] ); - $this->set_current_fragment( $compiler, $compiler->config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - $this->mock_creating_file( $compiler, true ); + ], + ]; + $compiler = $this->initialize_compiler( $config ); // Run the tests. $this->assertTrue( $compiler->cache_file() ); - $this->assertSame( $this->get_compiled_less(), $this->get_cached_file_contents( $compiler ) ); - } + $this->assertSame( $this->get_compiled_less(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); - /** - * Mock creating the file. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the compiler. - * @param bool $should_create Optional. When true, mock creating the file. Default is false. - * - * @return void - */ - private function mock_creating_file( $compiler, $should_create = false ) { - $GLOBALS['wp_filesystem']->shouldReceive( 'put_contents' ) - ->once() - ->andReturn( $should_create ); - - if ( ! $should_create ) { - return; - } - - vfsStream::newFile( $compiler->filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $compiler->config['id'] ) ) - ->setContent( $compiler->compiled_content ); + // Clean Up. + remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); } /** - * Get the file's content. + * Initialize the Compiler for the test. * - * @since 1.5.0 + * @since 1.0.0 * - * @param _Beans_Compiler $compiler Instance of the compiler. + * @param array $config Array of runtime configuration parameters. * - * @return string + * @return _Beans_Compiler + * @throws \ReflectionException Throws an error. */ - private function get_cached_file_contents( $compiler ) { - return $this->mock_filesystem - ->getChild( 'beans/compiler/' . $compiler->config['id'] ) - ->getChild( $compiler->filename ) - ->getcontent(); + protected function initialize_compiler( array $config ) { + $compiler = new _Beans_Compiler( $config ); + + add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + $compiler->filesystem(); + $this->add_virtual_directory( $config['id'] ); + $this->set_current_fragment( $compiler, $config['fragments'][0] ); + $compiler->set_filename(); + $compiler->combine_fragments(); + + return $compiler; } } diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php index ee96e3aa..bcf7e9b0 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php @@ -60,8 +60,7 @@ public function setUp() { $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); $this->css = $fixtures->getChild( 'style.css' )->getContent(); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) - ->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); } diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php index 4b28f8c0..9b9fc9af 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -50,8 +50,7 @@ public function setUp() { parent::setUp(); $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) - ->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); } diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php index ee97ff3d..3daf2cda 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -59,23 +59,10 @@ class Tests_BeansCompiler_RunCompiler extends Compiler_Test_Case { public function setUp() { parent::setUp(); - // Set up the global fragments container. - global $_beans_compiler_added_fragments; - $_beans_compiler_added_fragments = array( - 'css' => array(), - 'less' => array(), - 'js' => array(), - ); - $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); $this->css = $fixtures->getChild( 'style.css' )->getContent(); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) - ->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); - $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); - - // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. - Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); } /** @@ -105,9 +92,6 @@ public function test_should_enqueue_existing_cached_file_when_no_modifications() ->setContent( $this->get_compiled_jquery() ); $this->assertFileExists( $original_file ); - // Set up the mocks. - $this->set_up_mocks( $compiler, $config, $original_file ); - // Run the compiler. $compiler->run_compiler(); $actual_filename = $compiler->get_filename(); @@ -155,7 +139,6 @@ public function test_should_recompile_when_fragments_change() { * Next step is to modify the fragment, which will change its modification time. Let's add an opening * comment to the fragment's content and then set up the modified file for our tests. */ - $compiled_content = $this->get_compiled_jquery() . "console.log('Beans rocks!');"; $this->mock_filesystem->getChild( 'fixtures' ) ->getChild( 'jquery.test.js' ) ->write( $this->jquery . "\n console.log( 'Beans rocks!' ); \n" ); @@ -174,9 +157,6 @@ public function test_should_recompile_when_fragments_change() { $this->assertSame( $modified_hashes[0], $original_hashes[0] ); $this->assertNotEquals( $modified_hashes[1], $original_hashes[1] ); - // Set up the mocks. - $this->set_up_mocks( $compiler, $config, $modified_file, $compiled_content ); - // Run the compiler. $compiler->run_compiler(); $actual_filename = $compiler->get_filename(); @@ -211,20 +191,18 @@ public function test_should_compile_save_and_enqueue_jquery() { ); $compiler = new _Beans_Compiler( $config ); - // Set up the mocks. + // Set up the virtual directory. $this->add_virtual_directory( $config['id'] ); $expected_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) ); - $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_jquery() ); - // Run the compiler. Test. $compiler->run_compiler(); $actual_filename = $compiler->get_filename(); $this->assertFileExists( $actual_filename ); $this->assertSame( $expected_file, $actual_filename ); - $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_file_contents( $compiler ) ); + $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); } /** @@ -245,19 +223,18 @@ public function test_should_compile_save_and_enqueue_js() { ); $compiler = new _Beans_Compiler( $config ); - // Set up the mocks. + // Set up the virtual directory. $this->add_virtual_directory( $config['id'] ); $expected_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) ); - $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_js() ); // Run the compiler. Test. $compiler->run_compiler(); $actual_filename = $compiler->get_filename(); $this->assertFileExists( $actual_filename ); $this->assertSame( $expected_file, $actual_filename ); - $this->assertSame( $this->get_compiled_js(), $this->get_cached_file_contents( $compiler ) ); + $this->assertSame( $this->get_compiled_js(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); } /** @@ -278,19 +255,18 @@ public function test_should_compile_save_and_enqueue_css() { ); $compiler = new _Beans_Compiler( $config ); - // Set up the mocks. + // Set up the virtual directory. $this->add_virtual_directory( $config['id'] ); $expected_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) ); - $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_css() ); // Run the compiler. Test. $compiler->run_compiler(); $actual_filename = $compiler->get_filename(); $this->assertFileExists( $actual_filename ); $this->assertSame( $expected_file, $actual_filename ); - $this->assertSame( $this->get_compiled_css(), $this->get_cached_file_contents( $compiler ) ); + $this->assertSame( $this->get_compiled_css(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); } /** @@ -313,72 +289,18 @@ public function test_should_compile_save_and_enqueue_less() { ); $compiler = new _Beans_Compiler( $config ); - // Set up the mocks. + // Set up the virtual directory. $this->add_virtual_directory( $config['id'] ); $expected_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config ) ); - $this->set_up_mocks( $compiler, $config, $expected_file, $this->get_compiled_less() ); // Run the compiler. Test. $compiler->run_compiler(); $actual_filename = $compiler->get_filename(); $this->assertFileExists( $actual_filename ); $this->assertSame( $expected_file, $actual_filename ); - $this->assertSame( $this->get_compiled_less(), $this->get_cached_file_contents( $compiler ) ); - } - - /** - * Set up the mocks for this test. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the compiler. - * @param array $config The compiler's configuration. - * @param string $file The absolute path to the compiled file. - * @param string $content Optional. The expected compiled content. - * @param bool $in_dev_mode Optional. When true, turns on dev mode. Default is false. - * - * @return void - */ - private function set_up_mocks( $compiler, $config, $file, $content = '', $in_dev_mode = false ) { - $this->set_dev_mode( $in_dev_mode ); - - if ( empty( $content ) ) { - return; - } - - // Set the WP Filesystem. - $this->mock_filesystem_for_fragments( $compiler, 1, 'WP_Filesystem_Direct' ); - $GLOBALS['wp_filesystem']->shouldReceive( 'put_contents' ) - ->once() - ->with( $file, $content, FS_CHMOD_FILE ) - ->andReturnUsing( function( $file, $content ) use ( $compiler, $config ) { - $pathinfo = pathinfo( $file ); - - // Add the new file into the virtual filesystem. - vfsStream::newFile( $pathinfo['basename'] ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) - ->setContent( $content ); - - return true; - } ); - } - - /** - * Get the file's content. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the compiler. - * - * @return string - */ - private function get_cached_file_contents( $compiler ) { - return $this->mock_filesystem - ->getChild( 'beans/compiler/' . $compiler->config['id'] ) - ->getChild( $compiler->filename ) - ->getContent(); + $this->assertSame( $this->get_compiled_less(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); } /** diff --git a/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php b/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php index 5f649b30..3b71aa01 100644 --- a/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php +++ b/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php @@ -23,23 +23,6 @@ */ class Tests_BeansCompileCssFragments extends Compiler_Test_Case { - /** - * The CSS content. - * - * @var string - */ - protected $css; - - /** - * Set up the test fixture. - */ - public function setUp() { - parent::setUp(); - - $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); - $this->css = $fixtures->getChild( 'style.css' )->getContent(); - } - /** * Test beans_compile_css_fragments() should compile the CSS fragments, saving it to the virtual filesystem and * enqueuing it in WordPress. diff --git a/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php b/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php index 4ed264d6..95127a3e 100644 --- a/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php +++ b/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php @@ -23,23 +23,6 @@ */ class Tests_BeansCompileLessFragments extends Compiler_Test_Case { - /** - * The Less content. - * - * @var string - */ - protected $less; - - /** - * Set up the test fixture. - */ - public function setUp() { - parent::setUp(); - - $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); - } - /** * Test beans_compile_less_fragments() should compile the Less fragments, saving it to the virtual filesystem and * enqueuing it in WordPress. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php index dabe1717..fa74b7e5 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -60,8 +60,7 @@ protected function setUp() { $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); $this->css = $fixtures->getChild( 'style.css' )->getContent(); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) - ->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/unit/api/compiler/beans-compiler/filesystem.php similarity index 100% rename from tests/phpunit/unit/api/compiler/beans-compiler/fileystem.php rename to tests/phpunit/unit/api/compiler/beans-compiler/filesystem.php diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php index a095c50a..4918fe8c 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -51,8 +51,7 @@ protected function setUp() { parent::setUp(); $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) - ->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index d42ab1a5..494f1e7f 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -60,8 +60,7 @@ protected function setUp() { $fixtures = $this->mock_filesystem->getChild( 'fixtures' ); $this->css = $fixtures->getChild( 'style.css' )->getContent(); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' ) - ->getContent(); + $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); } From 34518bcadd19987cdeb8826ceb86c0e1773bf76e Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 19 Jun 2018 09:12:58 -0500 Subject: [PATCH 727/800] Upgraded UIkit to 2.27.5. --- lib/api/uikit/src/fonts/FontAwesome.otf | Bin 123112 -> 134808 bytes .../uikit/src/fonts/fontawesome-webfont.ttf | Bin 150952 -> 165548 bytes .../uikit/src/fonts/fontawesome-webfont.woff | Bin 89076 -> 98024 bytes .../uikit/src/fonts/fontawesome-webfont.woff2 | Bin 70700 -> 77160 bytes .../uikit/src/js/components/accordion.min.js | 4 +- .../src/js/components/autocomplete.min.js | 4 +- .../uikit/src/js/components/datepicker.min.js | 4 +- .../src/js/components/form-password.min.js | 4 +- .../src/js/components/form-select.min.js | 4 +- .../src/js/components/grid-parallax.min.js | 4 +- lib/api/uikit/src/js/components/grid.min.js | 4 +- .../uikit/src/js/components/htmleditor.min.js | 4 +- .../uikit/src/js/components/lightbox.min.js | 4 +- .../uikit/src/js/components/nestable.min.js | 4 +- lib/api/uikit/src/js/components/notify.min.js | 4 +- .../uikit/src/js/components/pagination.min.js | 4 +- .../uikit/src/js/components/parallax.min.js | 4 +- lib/api/uikit/src/js/components/search.min.js | 4 +- lib/api/uikit/src/js/components/slider.min.js | 4 +- .../uikit/src/js/components/slideset.min.js | 4 +- .../src/js/components/slideshow-fx.min.js | 4 +- .../uikit/src/js/components/slideshow.min.js | 4 +- .../uikit/src/js/components/sortable.min.js | 4 +- lib/api/uikit/src/js/components/sticky.min.js | 4 +- .../uikit/src/js/components/timepicker.min.js | 4 +- .../uikit/src/js/components/tooltip.min.js | 4 +- lib/api/uikit/src/js/components/upload.min.js | 4 +- lib/api/uikit/src/js/core/alert.min.js | 4 +- lib/api/uikit/src/js/core/button.min.js | 4 +- lib/api/uikit/src/js/core/core.min.js | 4 +- lib/api/uikit/src/js/core/cover.min.js | 4 +- lib/api/uikit/src/js/core/dropdown.min.js | 4 +- lib/api/uikit/src/js/core/grid.min.js | 4 +- lib/api/uikit/src/js/core/modal.min.js | 4 +- lib/api/uikit/src/js/core/nav.min.js | 4 +- lib/api/uikit/src/js/core/offcanvas.min.js | 4 +- lib/api/uikit/src/js/core/scrollspy.min.js | 4 +- .../uikit/src/js/core/smooth-scroll.min.js | 4 +- lib/api/uikit/src/js/core/switcher.min.js | 4 +- lib/api/uikit/src/js/core/tab.min.js | 4 +- lib/api/uikit/src/js/core/toggle.min.js | 4 +- lib/api/uikit/src/js/core/touch.min.js | 4 +- lib/api/uikit/src/js/core/utility.min.js | 4 +- .../uikit/src/less/components/accordion.less | 0 .../uikit/src/less/components/datepicker.less | 0 lib/api/uikit/src/less/components/dotnav.less | 0 .../src/less/components/form-advanced.less | 0 .../uikit/src/less/components/form-file.less | 0 .../src/less/components/form-password.less | 0 .../src/less/components/form-select.less | 0 .../uikit/src/less/components/htmleditor.less | 0 lib/api/uikit/src/less/components/notify.less | 4 +- .../src/less/components/placeholder.less | 0 .../uikit/src/less/components/progress.less | 0 .../uikit/src/less/components/slidenav.less | 0 .../uikit/src/less/components/tooltip.less | 2 +- lib/api/uikit/src/less/components/upload.less | 0 lib/api/uikit/src/less/core/alert.less | 0 lib/api/uikit/src/less/core/animation.less | 0 lib/api/uikit/src/less/core/article.less | 0 lib/api/uikit/src/less/core/badge.less | 0 lib/api/uikit/src/less/core/breadcrumb.less | 0 lib/api/uikit/src/less/core/button.less | 0 lib/api/uikit/src/less/core/close.less | 0 lib/api/uikit/src/less/core/column.less | 0 lib/api/uikit/src/less/core/comment.less | 0 lib/api/uikit/src/less/core/cover.less | 0 .../uikit/src/less/core/description-list.less | 0 lib/api/uikit/src/less/core/dropdown.less | 3 + lib/api/uikit/src/less/core/flex.less | 0 lib/api/uikit/src/less/core/icon.less | 59 ++++++++++++++++++ lib/api/uikit/src/less/core/list.less | 0 lib/api/uikit/src/less/core/nav.less | 0 lib/api/uikit/src/less/core/navbar.less | 0 lib/api/uikit/src/less/core/pagination.less | 0 lib/api/uikit/src/less/core/subnav.less | 0 lib/api/uikit/src/less/core/switcher.less | 0 lib/api/uikit/src/less/core/tab.less | 0 lib/api/uikit/src/less/core/table.less | 0 lib/api/uikit/src/less/core/thumbnail.less | 0 lib/api/uikit/src/less/core/thumbnav.less | 0 lib/api/uikit/src/less/core/variables.less | 0 .../src/themes/almost-flat/accordion.less | 0 .../uikit/src/themes/almost-flat/alert.less | 0 .../uikit/src/themes/almost-flat/article.less | 0 .../src/themes/almost-flat/autocomplete.less | 0 .../uikit/src/themes/almost-flat/badge.less | 0 .../uikit/src/themes/almost-flat/block.less | 0 .../src/themes/almost-flat/breadcrumb.less | 0 .../uikit/src/themes/almost-flat/close.less | 0 .../uikit/src/themes/almost-flat/column.less | 0 .../uikit/src/themes/almost-flat/comment.less | 0 .../src/themes/almost-flat/customizer.json | 0 .../src/themes/almost-flat/datepicker.less | 0 .../themes/almost-flat/description-list.less | 0 .../uikit/src/themes/almost-flat/dotnav.less | 0 .../src/themes/almost-flat/dropdown.less | 0 .../src/themes/almost-flat/form-advanced.less | 0 .../src/themes/almost-flat/form-password.less | 0 .../uikit/src/themes/almost-flat/form.less | 0 .../src/themes/almost-flat/htmleditor.less | 0 .../uikit/src/themes/almost-flat/icon.less | 0 .../uikit/src/themes/almost-flat/list.less | 0 .../uikit/src/themes/almost-flat/modal.less | 0 lib/api/uikit/src/themes/almost-flat/nav.less | 0 .../uikit/src/themes/almost-flat/navbar.less | 0 .../src/themes/almost-flat/nestable.less | 0 .../uikit/src/themes/almost-flat/notify.less | 0 .../src/themes/almost-flat/offcanvas.less | 0 .../uikit/src/themes/almost-flat/overlay.less | 0 .../src/themes/almost-flat/pagination.less | 0 .../uikit/src/themes/almost-flat/panel.less | 0 .../src/themes/almost-flat/placeholder.less | 0 .../src/themes/almost-flat/progress.less | 0 .../uikit/src/themes/almost-flat/search.less | 0 .../src/themes/almost-flat/slidenav.less | 0 .../src/themes/almost-flat/sortable.less | 0 .../uikit/src/themes/almost-flat/sticky.less | 0 .../uikit/src/themes/almost-flat/subnav.less | 0 lib/api/uikit/src/themes/almost-flat/tab.less | 0 .../uikit/src/themes/almost-flat/table.less | 0 .../uikit/src/themes/almost-flat/text.less | 0 .../src/themes/almost-flat/thumbnail.less | 0 .../src/themes/almost-flat/thumbnav.less | 0 .../uikit/src/themes/almost-flat/tooltip.less | 0 .../uikit/src/themes/almost-flat/uikit.less | 0 .../uikit/src/themes/almost-flat/utility.less | 0 .../uikit/src/themes/default/accordion.less | 0 lib/api/uikit/src/themes/default/alert.less | 0 lib/api/uikit/src/themes/default/article.less | 0 .../src/themes/default/autocomplete.less | 0 lib/api/uikit/src/themes/default/badge.less | 0 lib/api/uikit/src/themes/default/block.less | 0 .../uikit/src/themes/default/breadcrumb.less | 0 lib/api/uikit/src/themes/default/button.less | 0 lib/api/uikit/src/themes/default/close.less | 0 lib/api/uikit/src/themes/default/column.less | 0 lib/api/uikit/src/themes/default/comment.less | 0 .../uikit/src/themes/default/customizer.json | 0 .../uikit/src/themes/default/datepicker.less | 0 .../src/themes/default/description-list.less | 0 lib/api/uikit/src/themes/default/dotnav.less | 0 .../uikit/src/themes/default/dropdown.less | 0 .../src/themes/default/form-advanced.less | 0 .../src/themes/default/form-password.less | 0 lib/api/uikit/src/themes/default/form.less | 0 .../uikit/src/themes/default/htmleditor.less | 0 lib/api/uikit/src/themes/default/icon.less | 0 lib/api/uikit/src/themes/default/list.less | 0 lib/api/uikit/src/themes/default/modal.less | 0 lib/api/uikit/src/themes/default/nav.less | 0 lib/api/uikit/src/themes/default/navbar.less | 0 .../uikit/src/themes/default/nestable.less | 0 lib/api/uikit/src/themes/default/notify.less | 0 .../uikit/src/themes/default/offcanvas.less | 0 lib/api/uikit/src/themes/default/overlay.less | 0 .../uikit/src/themes/default/pagination.less | 0 lib/api/uikit/src/themes/default/panel.less | 0 .../uikit/src/themes/default/placeholder.less | 0 .../uikit/src/themes/default/progress.less | 0 lib/api/uikit/src/themes/default/search.less | 0 .../uikit/src/themes/default/slidenav.less | 0 .../uikit/src/themes/default/sortable.less | 0 lib/api/uikit/src/themes/default/sticky.less | 0 lib/api/uikit/src/themes/default/subnav.less | 0 lib/api/uikit/src/themes/default/tab.less | 0 lib/api/uikit/src/themes/default/table.less | 0 lib/api/uikit/src/themes/default/text.less | 0 .../uikit/src/themes/default/thumbnail.less | 0 .../uikit/src/themes/default/thumbnav.less | 0 lib/api/uikit/src/themes/default/tooltip.less | 0 lib/api/uikit/src/themes/default/uikit.less | 0 lib/api/uikit/src/themes/default/utility.less | 0 .../uikit/src/themes/gradient/accordion.less | 0 lib/api/uikit/src/themes/gradient/alert.less | 0 .../uikit/src/themes/gradient/article.less | 0 .../src/themes/gradient/autocomplete.less | 0 lib/api/uikit/src/themes/gradient/badge.less | 0 lib/api/uikit/src/themes/gradient/block.less | 0 .../uikit/src/themes/gradient/breadcrumb.less | 0 lib/api/uikit/src/themes/gradient/button.less | 0 lib/api/uikit/src/themes/gradient/close.less | 0 lib/api/uikit/src/themes/gradient/column.less | 0 .../uikit/src/themes/gradient/comment.less | 0 .../uikit/src/themes/gradient/customizer.json | 0 .../uikit/src/themes/gradient/datepicker.less | 0 .../src/themes/gradient/description-list.less | 0 lib/api/uikit/src/themes/gradient/dotnav.less | 0 .../uikit/src/themes/gradient/dropdown.less | 0 .../src/themes/gradient/form-advanced.less | 0 .../src/themes/gradient/form-password.less | 0 lib/api/uikit/src/themes/gradient/form.less | 0 .../uikit/src/themes/gradient/htmleditor.less | 0 lib/api/uikit/src/themes/gradient/icon.less | 0 lib/api/uikit/src/themes/gradient/list.less | 0 lib/api/uikit/src/themes/gradient/modal.less | 0 lib/api/uikit/src/themes/gradient/nav.less | 0 lib/api/uikit/src/themes/gradient/navbar.less | 0 .../uikit/src/themes/gradient/nestable.less | 0 lib/api/uikit/src/themes/gradient/notify.less | 0 .../uikit/src/themes/gradient/offcanvas.less | 0 .../uikit/src/themes/gradient/overlay.less | 0 .../uikit/src/themes/gradient/pagination.less | 0 lib/api/uikit/src/themes/gradient/panel.less | 0 .../src/themes/gradient/placeholder.less | 0 .../uikit/src/themes/gradient/progress.less | 0 lib/api/uikit/src/themes/gradient/search.less | 0 .../uikit/src/themes/gradient/slidenav.less | 0 .../uikit/src/themes/gradient/sortable.less | 0 lib/api/uikit/src/themes/gradient/sticky.less | 0 lib/api/uikit/src/themes/gradient/subnav.less | 0 lib/api/uikit/src/themes/gradient/tab.less | 0 lib/api/uikit/src/themes/gradient/table.less | 0 lib/api/uikit/src/themes/gradient/text.less | 0 .../uikit/src/themes/gradient/thumbnail.less | 0 .../uikit/src/themes/gradient/thumbnav.less | 0 .../uikit/src/themes/gradient/tooltip.less | 0 lib/api/uikit/src/themes/gradient/uikit.less | 0 .../uikit/src/themes/gradient/utility.less | 0 219 files changed, 143 insertions(+), 81 deletions(-) mode change 100644 => 100755 lib/api/uikit/src/less/components/accordion.less mode change 100644 => 100755 lib/api/uikit/src/less/components/datepicker.less mode change 100644 => 100755 lib/api/uikit/src/less/components/dotnav.less mode change 100644 => 100755 lib/api/uikit/src/less/components/form-advanced.less mode change 100644 => 100755 lib/api/uikit/src/less/components/form-file.less mode change 100644 => 100755 lib/api/uikit/src/less/components/form-password.less mode change 100644 => 100755 lib/api/uikit/src/less/components/form-select.less mode change 100644 => 100755 lib/api/uikit/src/less/components/htmleditor.less mode change 100644 => 100755 lib/api/uikit/src/less/components/notify.less mode change 100644 => 100755 lib/api/uikit/src/less/components/placeholder.less mode change 100644 => 100755 lib/api/uikit/src/less/components/progress.less mode change 100644 => 100755 lib/api/uikit/src/less/components/slidenav.less mode change 100644 => 100755 lib/api/uikit/src/less/components/tooltip.less mode change 100644 => 100755 lib/api/uikit/src/less/components/upload.less mode change 100644 => 100755 lib/api/uikit/src/less/core/alert.less mode change 100644 => 100755 lib/api/uikit/src/less/core/animation.less mode change 100644 => 100755 lib/api/uikit/src/less/core/article.less mode change 100644 => 100755 lib/api/uikit/src/less/core/badge.less mode change 100644 => 100755 lib/api/uikit/src/less/core/breadcrumb.less mode change 100644 => 100755 lib/api/uikit/src/less/core/button.less mode change 100644 => 100755 lib/api/uikit/src/less/core/close.less mode change 100644 => 100755 lib/api/uikit/src/less/core/column.less mode change 100644 => 100755 lib/api/uikit/src/less/core/comment.less mode change 100644 => 100755 lib/api/uikit/src/less/core/cover.less mode change 100644 => 100755 lib/api/uikit/src/less/core/description-list.less mode change 100644 => 100755 lib/api/uikit/src/less/core/dropdown.less mode change 100644 => 100755 lib/api/uikit/src/less/core/flex.less mode change 100644 => 100755 lib/api/uikit/src/less/core/list.less mode change 100644 => 100755 lib/api/uikit/src/less/core/nav.less mode change 100644 => 100755 lib/api/uikit/src/less/core/navbar.less mode change 100644 => 100755 lib/api/uikit/src/less/core/pagination.less mode change 100644 => 100755 lib/api/uikit/src/less/core/subnav.less mode change 100644 => 100755 lib/api/uikit/src/less/core/switcher.less mode change 100644 => 100755 lib/api/uikit/src/less/core/tab.less mode change 100644 => 100755 lib/api/uikit/src/less/core/table.less mode change 100644 => 100755 lib/api/uikit/src/less/core/thumbnail.less mode change 100644 => 100755 lib/api/uikit/src/less/core/thumbnav.less mode change 100644 => 100755 lib/api/uikit/src/less/core/variables.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/accordion.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/alert.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/article.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/autocomplete.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/badge.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/block.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/breadcrumb.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/close.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/column.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/comment.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/customizer.json mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/datepicker.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/description-list.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/dotnav.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/dropdown.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/form-advanced.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/form-password.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/form.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/htmleditor.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/icon.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/list.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/modal.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/nav.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/navbar.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/nestable.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/notify.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/offcanvas.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/overlay.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/pagination.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/panel.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/placeholder.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/progress.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/search.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/slidenav.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/sortable.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/sticky.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/subnav.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/tab.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/table.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/text.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/thumbnail.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/thumbnav.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/tooltip.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/uikit.less mode change 100644 => 100755 lib/api/uikit/src/themes/almost-flat/utility.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/accordion.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/alert.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/article.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/autocomplete.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/badge.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/block.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/breadcrumb.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/button.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/close.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/column.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/comment.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/customizer.json mode change 100644 => 100755 lib/api/uikit/src/themes/default/datepicker.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/description-list.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/dotnav.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/dropdown.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/form-advanced.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/form-password.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/form.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/htmleditor.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/icon.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/list.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/modal.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/nav.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/navbar.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/nestable.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/notify.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/offcanvas.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/overlay.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/pagination.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/panel.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/placeholder.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/progress.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/search.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/slidenav.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/sortable.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/sticky.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/subnav.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/tab.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/table.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/text.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/thumbnail.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/thumbnav.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/tooltip.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/uikit.less mode change 100644 => 100755 lib/api/uikit/src/themes/default/utility.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/accordion.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/alert.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/article.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/autocomplete.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/badge.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/block.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/breadcrumb.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/button.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/close.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/column.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/comment.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/customizer.json mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/datepicker.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/description-list.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/dotnav.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/dropdown.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/form-advanced.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/form-password.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/form.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/htmleditor.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/icon.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/list.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/modal.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/nav.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/navbar.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/nestable.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/notify.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/offcanvas.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/overlay.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/pagination.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/panel.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/placeholder.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/progress.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/search.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/slidenav.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/sortable.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/sticky.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/subnav.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/tab.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/table.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/text.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/thumbnail.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/thumbnav.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/tooltip.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/uikit.less mode change 100644 => 100755 lib/api/uikit/src/themes/gradient/utility.less diff --git a/lib/api/uikit/src/fonts/FontAwesome.otf b/lib/api/uikit/src/fonts/FontAwesome.otf index f7f9eaefe09f9cc83cde43919808fa44b89c6142..401ec0f36e4f73b8efa40bd6f604fe80d286db70 100755 GIT binary patch delta 54491 zcmZ@=2V7Lgx}O1d7w0GlyNi^aT~w^tqSzZMYLvvFZj8Mb>}_pW7O;y2Ije{j6{AsO zgIHor^d`A6lJ2If(U@-Py_z|@XCd!DyPE5}@Ao{ir%j)4zViRRIX_%6?bs9Pe#Ys1 zhA@&#!bx(kK7Eoq&i|%8A>=rr{!6{HdJH0*G$vG^foH9r8Qikp>{N#iD(cK(LEf5qc{yKFp&4rdj(&%%95_Dt8}{;74Y;@(9F`)TI5 z#ZBgfUBSCBHWmqtv&PMw)U9?(ecWdg5>ac;?D;M<4DX{BZ#`1i^gi`}5a$12>jzD0 zw>}qbYyDNs2~OzkTCrhg%WKeB!zd*tHYOn^Ii^ueigQtv8MH!)rGFmTi%jz>iHD!cq$_Ukz5vnO8R8vN%ri@Tc z8KIgoLN#TCYRU-Jlo6__cc`Y`p_+P!y3{*VQSVSiy-`s|RNp&PQ}6a;+I0+7(>qj6 z?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wh|x-@=qbXesHe7dRf3E{G7~_VOaP_Wj5~L3+qTmzAo&p&g~0}rF_Je~1&oC4@uo`=vWhdnTIud6 zrQnXjPi-ZSJ~0=S>UolC=Wv3f2b<0b9A;0j9pMeV4k`$trV^$cK?_Cyg#bpua8_q_ z0fFLL)_TFofa=3S07eT4V_t9vTpT}ufD7y8{dgI3%eCVPV9D5QeI-7b&pP$ZW zmR9hB4Nonskqm-E579XW+2?s7Ln_3h=j1Y8L;FsfH6z26Apj!I3!8KZCEBvlhzV8P z2Hf`|Ob~cRJ}zL$!PL)bG4$aDS9khEdE)3UQ1HLv#89T`=k9n6C^mi$4fR94=_~MN z<{|AaR@t+o9YRk)pVim@*@fknb(TbPqIG5Z(!Fa@j5WF0l92wgB2zZ+0Oi3B^nAC- z6u|X`s!#wj67m5BBsdY|yj|F^U_MeO2)V}GJ=nyR2+;PTgz9|+ZpmSA-PmwPK8m1h ziYXx>b}SMkq-te1f5LPeRLU3||t|ppV}lISAB}+YAB( zE`+b(0(+_e|0&0mSG=vsm{zD@B@Aq*@=*QrAFtA~pMUP8Fu=fbaIIj%9s()Nhgh2WG}{_5c6? diff --git a/lib/api/uikit/src/fonts/fontawesome-webfont.ttf b/lib/api/uikit/src/fonts/fontawesome-webfont.ttf index cec09e000a83b41b2bd3a4df5512569883c1e431..35acda2fa1196aad98c2adf4378a7611dd713aa3 100755 GIT binary patch delta 20606 zcmc({d02x~XNyyrrbSIFF5W*H9tfFi|2w@2jAqc408392- zL_y*Lh$AYFsG~CCKDdlBjv}L|jN5?XHiOD2&Zv;f?{jZDh&u0m=e_sGFUh&JpL442 zsj5?_&du)IlJ;Duj}s#z6Lpb5&5e!YN6vp{$m7JX-h|xrAq|5Y`AHIy?m*f%dR%dM zUHGy(A~p%>mYEA?bm)KIKTc%aO~k)$o3W(h>{(#qSIM45I-`BjbpBjYc@oMs3Ur~oFHV%BqB23RjQo*=4= zZ5Rg|WYvx~jsn0DB4-!i43TRSk-Ln@V|L@6B*)S-Ya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5ekr-o;PoE1d|{21ibFjXRP? zKmE$7+vH$UVU-b5+EUW=@iNt$-_CB-*&<=LW4M0Iq;kn;lqIpCTqT#XO7xaK{MRf< zo7TanB3CcRvF14@*b7>&{S6DvV*-JU;lCjlTS3Q@7>wUtKBjGh=PE$Hbhau$5>k zNY`QO$6^4g_{mk9Uh(P!kDV!jpq%ao15NL=1&t?a=>ZP^3T(Lk7Ppc2b7h0zX?5=9 zje-9>d$(G+?kudHMOOYXpHANrBCG%9#q_trwAC_Q$3Vh1jjC0eg=QS|N zwd}TR7A4lq?UeOLkyojTB&&+u#>gi>1NH~W_kY9)QI_QIfR;TSNzLf3wSAcTOi2Dq z8F*=;YC>wvtYt#?^L6OIbkeyjMvfkyN%u9s9^KkBbBk^PkC_1vgYMY@53!K@la@rw z_fs+yO`B>NQvZ8>sAG?jByk`|(8b+iJ2)NdKhi0{EJF(^s>Erxi9S>QXIrZf_u78j zy_8niQBCP+Nar6zXEUR9Pi{)v0Bp?ozf_PR9kqrm2~SCt9LZEwd1%Hv9Trkt30VxC zu@DQXg7X_;)T{F9XQlu3LVV4ilt6xF{Kc=u9(;JtOYz^rghi0q_XU02JB>uvkN;Ou zCSmfQtD9)NyYtF~PEKQn#F#Ped3{{SgBg)xTZ$9iDl<6^Ar10u zLAS_n8;bwUM5VzRLx;-XA=jkS52;6xdy({&`5Vza?qooj*w6)NkZiXLoqTIV*+zAK>%_zIx6A=6lQ!Wm; diff --git a/lib/api/uikit/src/fonts/fontawesome-webfont.woff2 b/lib/api/uikit/src/fonts/fontawesome-webfont.woff2 index 65aeb01eb7845db93347990f40a5a9652c0338c0..4d13fc60404b91e398a37200c4a77b645cfd9586 100755 GIT binary patch literal 77160 zcmV(81_!itTT%&fM`8Do zgetlXfhX-f>pHa>CezJ5a+CKJB5E?t-D3Q@I zv;Az_{%F*wqQWVk+*x^)@=9sx>ldws&U_`?fwx|)6i0%hGq@6No|Wjj+Lhc2#LbXI zik@&>S#lthOy5xS4viawbfqcF5t#22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w7J*UKnCAvf=#N^bu@tMN~O!U7!*N++tWN&Oq(=U>9_@OuOIqWNi|0T zkp4vt?n1*dfJkmVs`-K|Jc)XPPCfXTN#@r`jrSX7Oga4ijz9jM@}xPBkC9&-{*^-Q zwb8P3gp(=Z=fVyCK86eT{Vm9aN2Ip9+0{YYO8BhdWO=l%(-pFR;^BhaAg(`Y-kW8M0x=Jc0cfG5-=V f_|nI5dZ)@_sr^O6RIv5*c{5}5xqrA3` diff --git a/lib/api/uikit/src/js/components/accordion.min.js b/lib/api/uikit/src/js/components/accordion.min.js index d953a084..42e57f96 100755 --- a/lib/api/uikit/src/js/components/accordion.min.js +++ b/lib/api/uikit/src/js/components/accordion.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-accordion",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";function i(i){var e=t.$(i),o="auto";if(e.is(":visible"))o=e.outerHeight();else{var a={position:e.css("position"),visibility:e.css("visibility"),display:e.css("display")};o=e.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),e.css(a)}return o}return t.component("accordion",{defaults:{showfirst:!0,collapse:!0,animate:!0,easing:"swing",duration:300,toggle:".uk-accordion-title",containers:".uk-accordion-content",clsactive:"uk-active"},boot:function(){t.ready(function(i){setTimeout(function(){t.$("[data-uk-accordion]",i).each(function(){var i=t.$(this);i.data("accordion")||t.accordion(i,t.Utils.options(i.attr("data-uk-accordion")))})},0)})},init:function(){var i=this;this.element.on("click.uk.accordion",this.options.toggle,function(e){e.preventDefault(),i.toggleItem(t.$(this).data("wrapper"),i.options.animate,i.options.collapse)}),this.update(!0),t.domObserve(this.element,function(){i.element.children(i.options.containers).length&&i.update()})},toggleItem:function(e,o,a){var n=this;e.data("toggle").toggleClass(this.options.clsactive),e.data("content").toggleClass(this.options.clsactive);var s=e.data("toggle").hasClass(this.options.clsactive);a&&(this.toggle.not(e.data("toggle")).removeClass(this.options.clsactive),this.content.not(e.data("content")).removeClass(this.options.clsactive).parent().stop().css("overflow","hidden").animate({height:0},{easing:this.options.easing,duration:o?this.options.duration:0}).attr("aria-expanded","false")),e.stop().css("overflow","hidden"),o?e.animate({height:s?i(e.data("content")):0},{easing:this.options.easing,duration:this.options.duration,complete:function(){s&&(e.css({overflow:"",height:"auto"}),t.Utils.checkDisplay(e.data("content"))),n.trigger("display.uk.check")}}):(e.height(s?"auto":0),s&&(e.css({overflow:""}),t.Utils.checkDisplay(e.data("content"))),this.trigger("display.uk.check")),e.attr("aria-expanded",s),this.element.trigger("toggle.uk.accordion",[s,e.data("toggle"),e.data("content")])},update:function(i){var e,o,a,n=this;this.toggle=this.find(this.options.toggle),this.content=this.find(this.options.containers),this.content.each(function(i){e=t.$(this),e.parent().data("wrapper")?o=e.parent():(o=t.$(this).wrap('
        ').parent(),o.attr("aria-expanded","false")),a=n.toggle.eq(i),o.data("toggle",a),o.data("content",e),a.data("wrapper",o),e.data("wrapper",o)}),this.element.trigger("update.uk.accordion",[this]),i&&this.options.showfirst&&this.toggleItem(this.toggle.eq(0).data("wrapper"),!1,!1)}}),t.accordion}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-accordion",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";function i(i){var e=t.$(i),o="auto";if(e.is(":visible"))o=e.outerHeight();else{var a={position:e.css("position"),visibility:e.css("visibility"),display:e.css("display")};o=e.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),e.css(a)}return o}return t.component("accordion",{defaults:{showfirst:!0,collapse:!0,animate:!0,easing:"swing",duration:300,toggle:".uk-accordion-title",containers:".uk-accordion-content",clsactive:"uk-active"},boot:function(){t.ready(function(i){setTimeout(function(){t.$("[data-uk-accordion]",i).each(function(){var i=t.$(this);i.data("accordion")||t.accordion(i,t.Utils.options(i.attr("data-uk-accordion")))})},0)})},init:function(){var i=this;this.element.on("click.uk.accordion",this.options.toggle,function(e){e.preventDefault(),i.toggleItem(t.$(this).data("wrapper"),i.options.animate,i.options.collapse)}),this.update(!0),t.domObserve(this.element,function(){i.element.children(i.options.containers).length&&i.update()})},toggleItem:function(e,o,a){var n=this;e.data("toggle").toggleClass(this.options.clsactive),e.data("content").toggleClass(this.options.clsactive);var s=e.data("toggle").hasClass(this.options.clsactive);a&&(this.toggle.not(e.data("toggle")).removeClass(this.options.clsactive),this.content.not(e.data("content")).removeClass(this.options.clsactive).parent().stop().css("overflow","hidden").animate({height:0},{easing:this.options.easing,duration:o?this.options.duration:0}).attr("aria-expanded","false")),e.stop().css("overflow","hidden"),o?e.animate({height:s?i(e.data("content")):0},{easing:this.options.easing,duration:this.options.duration,complete:function(){s&&(e.css({overflow:"",height:"auto"}),t.Utils.checkDisplay(e.data("content"))),n.trigger("display.uk.check")}}):(e.height(s?"auto":0),s&&(e.css({overflow:""}),t.Utils.checkDisplay(e.data("content"))),this.trigger("display.uk.check")),e.attr("aria-expanded",s),this.element.trigger("toggle.uk.accordion",[s,e.data("toggle"),e.data("content")])},update:function(i){var e,o,a,n=this;this.toggle=this.find(this.options.toggle),this.content=this.find(this.options.containers),this.content.each(function(i){e=t.$(this),e.parent().data("wrapper")?o=e.parent():(o=t.$(this).wrap('
        ').parent(),o.attr("aria-expanded","false")),a=n.toggle.eq(i),o.data("toggle",a),o.data("content",e),a.data("wrapper",o),e.data("wrapper",o)}),this.element.trigger("update.uk.accordion",[this]),i&&this.options.showfirst&&this.toggleItem(this.toggle.eq(0).data("wrapper"),!1,!1)}}),t.accordion}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/autocomplete.min.js b/lib/api/uikit/src/js/components/autocomplete.min.js index f89ff1f2..d35e7a0b 100755 --- a/lib/api/uikit/src/js/components/autocomplete.min.js +++ b/lib/api/uikit/src/js/components/autocomplete.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-autocomplete",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e;return t.component("autocomplete",{defaults:{minLength:3,param:"search",method:"post",delay:300,loadingClass:"uk-loading",flipDropdown:!1,skipClass:"uk-skip",hoverClass:"uk-active",source:null,renderer:null,template:'
        '},visible:!1,value:null,selected:null,boot:function(){t.$html.on("focus.autocomplete.uikit","[data-uk-autocomplete]",function(){var e=t.$(this);e.data("autocomplete")||t.autocomplete(e,t.Utils.options(e.attr("data-uk-autocomplete")))}),t.$html.on("click.autocomplete.uikit",function(t){e&&t.target!=e.input[0]&&e.hide()})},init:function(){var e=this,i=!1,s=t.Utils.debounce(function(){return i?i=!1:(e.handle(),void 0)},this.options.delay);this.dropdown=this.find(".uk-dropdown"),this.template=this.find('script[type="text/autocomplete"]').html(),this.template=t.Utils.template(this.template||this.options.template),this.input=this.find("input:first").attr("autocomplete","off"),this.dropdown.length||(this.dropdown=t.$('
        ').appendTo(this.element)),this.options.flipDropdown&&this.dropdown.addClass("uk-dropdown-flip"),this.dropdown.attr("aria-expanded","false"),this.input.on({keydown:function(t){if(t&&t.which&&!t.shiftKey&&e.visible)switch(t.which){case 13:i=!0,e.selected&&(t.preventDefault(),e.select());break;case 38:t.preventDefault(),e.pick("prev",!0);break;case 40:t.preventDefault(),e.pick("next",!0);break;case 27:case 9:e.hide()}},keyup:s}),this.dropdown.on("click",".uk-autocomplete-results > *",function(){e.select()}),this.dropdown.on("mouseover",".uk-autocomplete-results > *",function(){e.pick(t.$(this))}),this.triggercomplete=s},handle:function(){var t=this,e=this.value;return this.value=this.input.val(),this.value.lengtha-1?o.length-1:a-1)}else n=o["next"==e?"first":"last"]();n=t.$(n)}}else n=e;if(n&&n.length&&(this.selected=n,o.removeClass(this.options.hoverClass),this.selected.addClass(this.options.hoverClass),i)){var l=n.position().top,h=s.dropdown.scrollTop(),r=s.dropdown.height();(l>r||0>l)&&s.dropdown.scrollTop(h+l)}},select:function(){if(this.selected){var t=this.selected.data();this.trigger("selectitem.uk.autocomplete",[t,this]),t.value&&this.input.val(t.value).trigger("change"),this.hide()}},show:function(){return this.visible?void 0:(this.visible=!0,this.element.addClass("uk-open"),e&&e!==this&&e.hide(),e=this,this.dropdown.attr("aria-expanded","true"),this)},hide:function(){return this.visible?(this.visible=!1,this.element.removeClass("uk-open"),e===this&&(e=!1),this.dropdown.attr("aria-expanded","false"),this):void 0},request:function(){var e=this,i=function(t){t&&e.render(t),e.element.removeClass(e.options.loadingClass)};if(this.element.addClass(this.options.loadingClass),this.options.source){var s=this.options.source;switch(typeof this.options.source){case"function":this.options.source.apply(this,[i]);break;case"object":if(s.length){var o=[];s.forEach(function(t){t.value&&-1!=t.value.toLowerCase().indexOf(e.value.toLowerCase())&&o.push(t)}),i(o)}break;case"string":var n={};n[this.options.param]=this.value,t.$.ajax({url:this.options.source,data:n,type:this.options.method,dataType:"json"}).done(function(t){i(t||[])});break;default:i(null)}}else this.element.removeClass(e.options.loadingClass)},render:function(t){return this.dropdown.empty(),this.selected=!1,this.options.renderer?this.options.renderer.apply(this,[t]):t&&t.length&&(this.dropdown.append(this.template({items:t})),this.show(),this.trigger("show.uk.autocomplete")),this}}),t.autocomplete}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-autocomplete",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";var e;return t.component("autocomplete",{defaults:{minLength:3,param:"search",method:"post",delay:300,loadingClass:"uk-loading",flipDropdown:!1,skipClass:"uk-skip",hoverClass:"uk-active",source:null,renderer:null,template:''},visible:!1,value:null,selected:null,boot:function(){t.$html.on("focus.autocomplete.uikit","[data-uk-autocomplete]",function(){var e=t.$(this);e.data("autocomplete")||t.autocomplete(e,t.Utils.options(e.attr("data-uk-autocomplete")))}),t.$html.on("click.autocomplete.uikit",function(t){e&&t.target!=e.input[0]&&e.hide()})},init:function(){var e=this,i=!1,s=t.Utils.debounce(function(){return i?i=!1:(e.handle(),void 0)},this.options.delay);this.dropdown=this.find(".uk-dropdown"),this.template=this.find('script[type="text/autocomplete"]').html(),this.template=t.Utils.template(this.template||this.options.template),this.input=this.find("input:first").attr("autocomplete","off"),this.dropdown.length||(this.dropdown=t.$('
        ').appendTo(this.element)),this.options.flipDropdown&&this.dropdown.addClass("uk-dropdown-flip"),this.dropdown.attr("aria-expanded","false"),this.input.on({keydown:function(t){if(t&&t.which&&!t.shiftKey&&e.visible)switch(t.which){case 13:i=!0,e.selected&&(t.preventDefault(),e.select());break;case 38:t.preventDefault(),e.pick("prev",!0);break;case 40:t.preventDefault(),e.pick("next",!0);break;case 27:case 9:e.hide()}},keyup:s}),this.dropdown.on("click",".uk-autocomplete-results > *",function(){e.select()}),this.dropdown.on("mouseover",".uk-autocomplete-results > *",function(){e.pick(t.$(this))}),this.triggercomplete=s},handle:function(){var t=this,e=this.value;return this.value=this.input.val(),this.value.lengtha-1?o.length-1:a-1)}else n=o["next"==e?"first":"last"]();n=t.$(n)}}else n=e;if(n&&n.length&&(this.selected=n,o.removeClass(this.options.hoverClass),this.selected.addClass(this.options.hoverClass),i)){var l=n.position().top,h=s.dropdown.scrollTop(),r=s.dropdown.height();(l>r||0>l)&&s.dropdown.scrollTop(h+l)}},select:function(){if(this.selected){var t=this.selected.data();this.trigger("selectitem.uk.autocomplete",[t,this]),t.value&&this.input.val(t.value).trigger("change"),this.hide()}},show:function(){return this.visible?void 0:(this.visible=!0,this.element.addClass("uk-open"),e&&e!==this&&e.hide(),e=this,this.dropdown.attr("aria-expanded","true"),this)},hide:function(){return this.visible?(this.visible=!1,this.element.removeClass("uk-open"),e===this&&(e=!1),this.dropdown.attr("aria-expanded","false"),this):void 0},request:function(){var e=this,i=function(t){t&&e.render(t),e.element.removeClass(e.options.loadingClass)};if(this.element.addClass(this.options.loadingClass),this.options.source){var s=this.options.source;switch(typeof this.options.source){case"function":this.options.source.apply(this,[i]);break;case"object":if(s.length){var o=[];s.forEach(function(t){t.value&&-1!=t.value.toLowerCase().indexOf(e.value.toLowerCase())&&o.push(t)}),i(o)}break;case"string":var n={};n[this.options.param]=this.value,t.$.ajax({url:this.options.source,data:n,type:this.options.method,dataType:"json"}).done(function(t){i(t||[])});break;default:i(null)}}else this.element.removeClass(e.options.loadingClass)},render:function(t){return this.dropdown.empty(),this.selected=!1,this.options.renderer?this.options.renderer.apply(this,[t]):t&&t.length&&(this.dropdown.append(this.template({items:t})),this.show(),this.trigger("show.uk.autocomplete")),this}}),t.autocomplete}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/datepicker.min.js b/lib/api/uikit/src/js/components/datepicker.min.js index c84307b6..9df0b8a5 100755 --- a/lib/api/uikit/src/js/components/datepicker.min.js +++ b/lib/api/uikit/src/js/components/datepicker.min.js @@ -1,3 +1,3 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-datepicker",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e,n,a=!1;return t.component("datepicker",{defaults:{mobile:!1,weekstart:1,i18n:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},format:"YYYY-MM-DD",offsettop:5,maxDate:!1,minDate:!1,pos:"auto",template:function(e,n){var a,s="";if(s+='
        ',s+='',s+='',t.formSelect){var i,r,o,u,c=(new Date).getFullYear(),d=[];for(a=0;a'+n.i18n.months[a]+""):d.push('");for(i=''+n.i18n.months[e.month]+'",d=[],o=e.minDate?e.minDate.year():c-50,u=e.maxDate?e.maxDate.year():c+20,a=o;u>=a;a++)a==e.year?d.push('"):d.push('");r=''+e.year+'",s+='
        '+i+" "+r+"
        "}else s+='
        '+n.i18n.months[e.month]+" "+e.year+"
        ";for(s+="
        ",s+='',s+="",a=0;a"+e.weekdays[a]+"");for(s+="",s+="",a=0;a";for(var l=0;l'+h.day.format("D")+""}s+=""}return s+="",s+="
        "}},boot:function(){t.$win.on("resize orientationchange",function(){a&&a.hide()}),t.$html.on("focus.datepicker.uikit","[data-uk-datepicker]",function(e){var n=t.$(this);n.data("datepicker")||(e.preventDefault(),t.datepicker(n,t.Utils.options(n.attr("data-uk-datepicker"))),n.trigger("focus"))}),t.$html.on("click focus","*",function(n){var s=t.$(n.target);!a||s[0]==e[0]||s.data("datepicker")||s.parents(".uk-datepicker:first").length||a.hide()})},init:function(){if(!t.support.touch||"date"!=this.element.attr("type")||this.options.mobile){var s=this;this.current=this.element.val()?n(this.element.val(),this.options.format):n(),this.on("click focus",function(){a!==s&&s.pick(this.value?this.value:s.options.minDate?s.options.minDate:"")}).on("change",function(){s.element.val()&&!n(s.element.val(),s.options.format).isValid()&&s.element.val(n().format(s.options.format))}),e||(e=t.$('
        '),e.on("click",".uk-datepicker-next, .uk-datepicker-previous, [data-date]",function(e){e.stopPropagation(),e.preventDefault();var s=t.$(this);return s.hasClass("uk-datepicker-date-disabled")?!1:(s.is("[data-date]")?(a.current=n(s.data("date")),a.element.val(a.current.isValid()?a.current.format(a.options.format):null).trigger("change"),a.hide()):a.add(s.hasClass("uk-datepicker-next")?1:-1,"months"),void 0)}),e.on("change",".update-picker-month, .update-picker-year",function(){var e=t.$(this);a[e.is(".update-picker-year")?"setYear":"setMonth"](Number(e.val()))}),e.appendTo("body"))}},pick:function(s){var i=this.element.offset(),r={left:i.left,right:""};this.current=isNaN(s)?n(s,this.options.format):n(),this.initdate=this.current.format("YYYY-MM-DD"),this.update(),"right"==t.langdirection&&(r.right=window.innerWidth-(r.left+this.element.outerWidth()),r.left="");var o=i.top-this.element.outerHeight()+this.element.height()-this.options.offsettop-e.outerHeight(),u=i.top+this.element.outerHeight()+this.options.offsettop;r.top=u,"top"==this.options.pos?r.top=o:"auto"==this.options.pos&&window.innerHeight-u-e.outerHeight()<0&&o>=0&&(r.top=o),e.css(r).show(),this.trigger("show.uk.datepicker"),a=this},add:function(t,e){this.current.add(t,e),this.update()},setMonth:function(t){this.current.month(t),this.update()},setYear:function(t){this.current.year(t),this.update()},update:function(){var t=this.getRows(this.current.year(),this.current.month()),n=this.options.template(t,this.options);e.html(n),this.trigger("update.uk.datepicker")},getRows:function(t,e){var a=this.options,s=n().format("YYYY-MM-DD"),i=[31,t%4===0&&t%100!==0||t%400===0?29:28,31,30,31,30,31,31,30,31,30,31][e],r=new Date(t,e,1,12).getDay(),o={month:e,year:t,weekdays:[],days:[],maxDate:!1,minDate:!1},u=[];a.maxDate!==!1&&(o.maxDate=isNaN(a.maxDate)?n(a.maxDate,a.format).startOf("day").hours(12):n().add(a.maxDate,"days").startOf("day").hours(12)),a.minDate!==!1&&(o.minDate=isNaN(a.minDate)?n(a.minDate,a.format).startOf("day").hours(12):n().add(a.minDate-1,"days").startOf("day").hours(12)),o.weekdays=function(){for(var t=0,e=[];7>t;t++){for(var n=t+(a.weekstart||0);n>=7;)n-=7;e.push(a.i18n.weekdays[n])}return e}(),a.weekstart&&a.weekstart>0&&(r-=a.weekstart,0>r&&(r+=7));for(var c=i+r,d=c;d>7;)d-=7;c+=7-d;for(var l,h,f,m,_,p=0,y=0;c>p;p++)l=new Date(t,e,1+(p-r),12),h=o.minDate&&o.minDate>l||o.maxDate&&l>o.maxDate,_=!(r>p||p>=i+r),l=n(l),f=this.initdate==l.format("YYYY-MM-DD"),m=s==l.format("YYYY-MM-DD"),u.push({selected:f,today:m,disabled:h,day:l,inmonth:_}),7===++y&&(o.days.push(u),u=[],y=0);return o},hide:function(){a&&a===this&&(e.hide(),a=!1,this.trigger("hide.uk.datepicker"))}}),n=function(t){function e(t,e,n){switch(arguments.length){case 2:return null!=t?t:e;case 3:return null!=t?t:null!=e?e:n;default:throw new Error("Implement me")}}function n(t,e){return Ye.call(t,e)}function a(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function s(t){De.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function i(t,e){var n=!0;return h(function(){return n&&(s(t),n=!1),e.apply(this,arguments)},e)}function r(t,e){mn[t]||(s(e),mn[t]=!0)}function o(t,e){return function(n){return _(t.call(this,n),e)}}function u(t,e){return function(n){return this.localeData().ordinal(t.call(this,n),e)}}function c(){}function d(t,e){e!==!1&&F(t),f(this,t),this._d=new Date(+t._d)}function l(t){var e=v(t),n=e.year||0,a=e.quarter||0,s=e.month||0,i=e.week||0,r=e.day||0,o=e.hour||0,u=e.minute||0,c=e.second||0,d=e.millisecond||0;this._milliseconds=+d+1e3*c+6e4*u+36e5*o,this._days=+r+7*i,this._months=+s+3*a+12*n,this._data={},this._locale=De.localeData(),this._bubble()}function h(t,e){for(var a in e)n(e,a)&&(t[a]=e[a]);return n(e,"toString")&&(t.toString=e.toString),n(e,"valueOf")&&(t.valueOf=e.valueOf),t}function f(t,e){var n,a,s;if("undefined"!=typeof e._isAMomentObject&&(t._isAMomentObject=e._isAMomentObject),"undefined"!=typeof e._i&&(t._i=e._i),"undefined"!=typeof e._f&&(t._f=e._f),"undefined"!=typeof e._l&&(t._l=e._l),"undefined"!=typeof e._strict&&(t._strict=e._strict),"undefined"!=typeof e._tzm&&(t._tzm=e._tzm),"undefined"!=typeof e._isUTC&&(t._isUTC=e._isUTC),"undefined"!=typeof e._offset&&(t._offset=e._offset),"undefined"!=typeof e._pf&&(t._pf=e._pf),"undefined"!=typeof e._locale&&(t._locale=e._locale),Fe.length>0)for(n in Fe)a=Fe[n],s=e[a],"undefined"!=typeof s&&(t[a]=s);return t}function m(t){return 0>t?Math.ceil(t):Math.floor(t)}function _(t,e,n){for(var a=""+Math.abs(t),s=t>=0;a.lengtha;a++)(n&&t[a]!==e[a]||!n&&S(t[a])!==S(e[a]))&&r++;return r+i}function w(t){if(t){var e=t.toLowerCase().replace(/(.)s$/,"$1");t=on[t]||un[e]||e}return t}function v(t){var e,a,s={};for(a in t)n(t,a)&&(e=w(a),e&&(s[e]=t[a]));return s}function b(e){var n,a;if(0===e.indexOf("week"))n=7,a="day";else{if(0!==e.indexOf("month"))return;n=12,a="month"}De[e]=function(s,i){var r,o,u=De._locale[e],c=[];if("number"==typeof s&&(i=s,s=t),o=function(t){var e=De().utc().set(a,t);return u.call(De._locale,e,s||"")},null!=i)return o(i);for(r=0;n>r;r++)c.push(o(r));return c}}function S(t){var e=+t,n=0;return 0!==e&&isFinite(e)&&(n=e>=0?Math.floor(e):Math.ceil(e)),n}function T(t,e){return new Date(Date.UTC(t,e+1,0)).getUTCDate()}function O(t,e,n){return oe(De([t,11,31+e-n]),e,n).week}function W(t){return U(t)?366:365}function U(t){return t%4===0&&t%100!==0||t%400===0}function F(t){var e;t._a&&-2===t._pf.overflow&&(e=t._a[ve]<0||t._a[ve]>11?ve:t._a[be]<1||t._a[be]>T(t._a[we],t._a[ve])?be:t._a[Se]<0||t._a[Se]>23?Se:t._a[Te]<0||t._a[Te]>59?Te:t._a[Oe]<0||t._a[Oe]>59?Oe:t._a[We]<0||t._a[We]>999?We:-1,t._pf._overflowDayOfYear&&(we>e||e>be)&&(e=be),t._pf.overflow=e)}function G(t){return null==t._isValid&&(t._isValid=!isNaN(t._d.getTime())&&t._pf.overflow<0&&!t._pf.empty&&!t._pf.invalidMonth&&!t._pf.nullInput&&!t._pf.invalidFormat&&!t._pf.userInvalidated,t._strict&&(t._isValid=t._isValid&&0===t._pf.charsLeftOver&&0===t._pf.unusedTokens.length)),t._isValid}function C(t){return t?t.toLowerCase().replace("_","-"):t}function z(t){for(var e,n,a,s,i=0;i0;){if(a=x(s.slice(0,e).join("-")))return a;if(n&&n.length>=e&&Y(s,n,!0)>=e-1)break;e--}i++}return null}function x(t){var e=null;if(!Ue[t]&&Ge)try{e=De.locale(),require("./locale/"+t),De.locale(e)}catch(n){}return Ue[t]}function I(t,e){return e._isUTC?De(t).zone(e._offset||0):De(t).local()}function H(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function L(t){var e,n,a=t.match(Ie);for(e=0,n=a.length;n>e;e++)a[e]=fn[a[e]]?fn[a[e]]:H(a[e]);return function(s){var i="";for(e=0;n>e;e++)i+=a[e]instanceof Function?a[e].call(s,t):a[e];return i}}function P(t,e){return t.isValid()?(e=A(e,t.localeData()),cn[e]||(cn[e]=L(e)),cn[e](t)):t.localeData().invalidDate()}function A(t,e){function n(t){return e.longDateFormat(t)||t}var a=5;for(He.lastIndex=0;a>=0&&He.test(t);)t=t.replace(He,n),He.lastIndex=0,a-=1;return t}function N(t,e){var n,a=e._strict;switch(t){case"Q":return qe;case"DDDD":return Re;case"YYYY":case"GGGG":case"gggg":return a?Xe:Ae;case"Y":case"G":case"g":return Ke;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return a?Be:Ne;case"S":if(a)return qe;case"SS":if(a)return Qe;case"SSS":if(a)return Re;case"DDD":return Pe;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return je;case"a":case"A":return e._locale._meridiemParse;case"X":return Ve;case"Z":case"ZZ":return Ee;case"T":return $e;case"SSSS":return Ze;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return a?Qe:Le;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Le;case"Do":return Je;default:return n=new RegExp(R(Q(t.replace("\\","")),"i"))}}function Z(t){t=t||"";var e=t.match(Ee)||[],n=e[e.length-1]||[],a=(n+"").match(sn)||["-",0,0],s=+(60*a[1])+S(a[2]);return"+"===a[0]?-s:s}function j(t,e,n){var a,s=n._a;switch(t){case"Q":null!=e&&(s[ve]=3*(S(e)-1));break;case"M":case"MM":null!=e&&(s[ve]=S(e)-1);break;case"MMM":case"MMMM":a=n._locale.monthsParse(e),null!=a?s[ve]=a:n._pf.invalidMonth=e;break;case"D":case"DD":null!=e&&(s[be]=S(e));break;case"Do":null!=e&&(s[be]=S(parseInt(e,10)));break;case"DDD":case"DDDD":null!=e&&(n._dayOfYear=S(e));break;case"YY":s[we]=De.parseTwoDigitYear(e);break;case"YYYY":case"YYYYY":case"YYYYYY":s[we]=S(e);break;case"a":case"A":n._isPm=n._locale.isPM(e);break;case"H":case"HH":case"h":case"hh":s[Se]=S(e);break;case"m":case"mm":s[Te]=S(e);break;case"s":case"ss":s[Oe]=S(e);break;case"S":case"SS":case"SSS":case"SSSS":s[We]=S(1e3*("0."+e));break;case"X":n._d=new Date(1e3*parseFloat(e));break;case"Z":case"ZZ":n._useUTC=!0,n._tzm=Z(e);break;case"dd":case"ddd":case"dddd":a=n._locale.weekdaysParse(e),null!=a?(n._w=n._w||{},n._w.d=a):n._pf.invalidWeekday=e;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":t=t.substr(0,1);case"gggg":case"GGGG":case"GGGGG":t=t.substr(0,2),e&&(n._w=n._w||{},n._w[t]=S(e));break;case"gg":case"GG":n._w=n._w||{},n._w[t]=De.parseTwoDigitYear(e)}}function E(t){var n,a,s,i,r,o,u;n=t._w,null!=n.GG||null!=n.W||null!=n.E?(r=1,o=4,a=e(n.GG,t._a[we],oe(De(),1,4).year),s=e(n.W,1),i=e(n.E,1)):(r=t._locale._week.dow,o=t._locale._week.doy,a=e(n.gg,t._a[we],oe(De(),r,o).year),s=e(n.w,1),null!=n.d?(i=n.d,r>i&&++s):i=null!=n.e?n.e+r:r),u=ue(a,s,i,o,r),t._a[we]=u.year,t._dayOfYear=u.dayOfYear}function $(t){var n,a,s,i,r=[];if(!t._d){for(s=J(t),t._w&&null==t._a[be]&&null==t._a[ve]&&E(t),t._dayOfYear&&(i=e(t._a[we],s[we]),t._dayOfYear>W(i)&&(t._pf._overflowDayOfYear=!0),a=ae(i,0,t._dayOfYear),t._a[ve]=a.getUTCMonth(),t._a[be]=a.getUTCDate()),n=0;3>n&&null==t._a[n];++n)t._a[n]=r[n]=s[n];for(;7>n;n++)t._a[n]=r[n]=null==t._a[n]?2===n?1:0:t._a[n];t._d=(t._useUTC?ae:ne).apply(null,r),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()+t._tzm)}}function V(t){var e;t._d||(e=v(t._i),t._a=[e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond],$(t))}function J(t){var e=new Date;return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function q(t){if(t._f===De.ISO_8601)return B(t),void 0;t._a=[],t._pf.empty=!0;var e,n,a,s,i,r=""+t._i,o=r.length,u=0;for(a=A(t._f,t._locale).match(Ie)||[],e=0;e0&&t._pf.unusedInput.push(i),r=r.slice(r.indexOf(n)+n.length),u+=n.length),fn[s]?(n?t._pf.empty=!1:t._pf.unusedTokens.push(s),j(s,n,t)):t._strict&&!n&&t._pf.unusedTokens.push(s);t._pf.charsLeftOver=o-u,r.length>0&&t._pf.unusedInput.push(r),t._isPm&&t._a[Se]<12&&(t._a[Se]+=12),t._isPm===!1&&12===t._a[Se]&&(t._a[Se]=0),$(t),F(t)}function Q(t){return t.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,a,s){return e||n||a||s})}function R(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function X(t){var e,n,s,i,r;if(0===t._f.length)return t._pf.invalidFormat=!0,t._d=new Date(0/0),void 0;for(i=0;ir)&&(s=r,n=e));h(t,n||e)}function B(t){var e,n,a=t._i,s=tn.exec(a);if(s){for(t._pf.iso=!0,e=0,n=nn.length;n>e;e++)if(nn[e][1].exec(a)){t._f=nn[e][0]+(s[6]||" ");break}for(e=0,n=an.length;n>e;e++)if(an[e][1].exec(a)){t._f+=an[e][0];break}a.match(Ee)&&(t._f+="Z"),q(t)}else t._isValid=!1}function K(t){B(t),t._isValid===!1&&(delete t._isValid,De.createFromInputFallback(t))}function te(t,e){var n,a=[];for(n=0;nt&&o.setFullYear(t),o}function ae(t){var e=new Date(Date.UTC.apply(null,arguments));return 1970>t&&e.setUTCFullYear(t),e}function se(t,e){if("string"==typeof t)if(isNaN(t)){if(t=e.weekdaysParse(t),"number"!=typeof t)return null}else t=parseInt(t,10);return t}function ie(t,e,n,a,s){return s.relativeTime(e||1,!!n,t,a)}function re(t,e,n){var a=De.duration(t).abs(),s=Me(a.as("s")),i=Me(a.as("m")),r=Me(a.as("h")),o=Me(a.as("d")),u=Me(a.as("M")),c=Me(a.as("y")),d=s0,d[4]=n,ie.apply({},d)}function oe(t,e,n){var a,s=n-e,i=n-t.day();return i>s&&(i-=7),s-7>i&&(i+=7),a=De(t).add(i,"d"),{week:Math.ceil(a.dayOfYear()/7),year:a.year()}}function ue(t,e,n,a,s){var i,r,o=ae(t,0,1).getUTCDay();return o=0===o?7:o,n=null!=n?n:s,i=s-o+(o>a?7:0)-(s>o?7:0),r=7*(e-1)+(n-s)+i+1,{year:r>0?t:t-1,dayOfYear:r>0?r:W(t-1)+r}}function ce(e){var n=e._i,a=e._f;return e._locale=e._locale||De.localeData(e._l),null===n||a===t&&""===n?De.invalid({nullInput:!0}):("string"==typeof n&&(e._i=n=e._locale.preparse(n)),De.isMoment(n)?new d(n,!0):(a?k(a)?X(e):q(e):ee(e),new d(e)))}function de(t,e){var n,a;if(1===e.length&&k(e[0])&&(e=e[0]),!e.length)return De();for(n=e[0],a=1;a=0?"+":"-";return e+_(Math.abs(t),6)},gg:function(){return _(this.weekYear()%100,2)},gggg:function(){return _(this.weekYear(),4)},ggggg:function(){return _(this.weekYear(),5)},GG:function(){return _(this.isoWeekYear()%100,2)},GGGG:function(){return _(this.isoWeekYear(),4)},GGGGG:function(){return _(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return S(this.milliseconds()/100)},SS:function(){return _(S(this.milliseconds()/10),2)},SSS:function(){return _(this.milliseconds(),3)},SSSS:function(){return _(this.milliseconds(),3)},Z:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+":"+_(S(t)%60,2)},ZZ:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+_(S(t)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},mn={},_n=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];ln.length;)ge=ln.pop(),fn[ge+"o"]=u(fn[ge],ge);for(;hn.length;)ge=hn.pop(),fn[ge+ge]=o(fn[ge],2);fn.DDDD=o(fn.DDD,3),h(c.prototype,{set:function(t){var e,n;for(n in t)e=t[n],"function"==typeof e?this[n]=e:this["_"+n]=e},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(t){return this._months[t.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(t){return this._monthsShort[t.month()]},monthsParse:function(t){var e,n,a;for(this._monthsParse||(this._monthsParse=[]),e=0;12>e;e++)if(this._monthsParse[e]||(n=De.utc([2e3,e]),a="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[e]=new RegExp(a.replace(".",""),"i")),this._monthsParse[e].test(t))return e},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(t){return this._weekdays[t.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(t){return this._weekdaysShort[t.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(t){return this._weekdaysMin[t.day()]},weekdaysParse:function(t){var e,n,a;for(this._weekdaysParse||(this._weekdaysParse=[]),e=0;7>e;e++)if(this._weekdaysParse[e]||(n=De([2e3,1]).day(e),a="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[e]=new RegExp(a.replace(".",""),"i")),this._weekdaysParse[e].test(t))return e},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},longDateFormat:function(t){var e=this._longDateFormat[t];return!e&&this._longDateFormat[t.toUpperCase()]&&(e=this._longDateFormat[t.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t]=e),e},isPM:function(t){return"p"===(t+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(t,e,n){return t>11?n?"pm":"PM":n?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(t,e){var n=this._calendar[t];return"function"==typeof n?n.apply(e):n},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(t,e,n,a){var s=this._relativeTime[n];return"function"==typeof s?s(t,e,n,a):s.replace(/%d/i,t)},pastFuture:function(t,e){var n=this._relativeTime[t>0?"future":"past"];return"function"==typeof n?n(e):n.replace(/%s/i,e)},ordinal:function(t){return this._ordinal.replace("%d",t)},_ordinal:"%d",preparse:function(t){return t},postformat:function(t){return t},week:function(t){return oe(t,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),De=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._i=e,r._f=n,r._l=s,r._strict=i,r._isUTC=!1,r._pf=a(),ce(r)},De.suppressDeprecationWarnings=!1,De.createFromInputFallback=i("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(t){t._d=new Date(t._i)}),De.min=function(){var t=[].slice.call(arguments,0);return de("isBefore",t)},De.max=function(){var t=[].slice.call(arguments,0);return de("isAfter",t)},De.utc=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._useUTC=!0,r._isUTC=!0,r._l=s,r._i=e,r._f=n,r._strict=i,r._pf=a(),ce(r).utc()},De.unix=function(t){return De(1e3*t)},De.duration=function(t,e){var a,s,i,r,o=t,u=null;return De.isDuration(t)?o={ms:t._milliseconds,d:t._days,M:t._months}:"number"==typeof t?(o={},e?o[e]=t:o.milliseconds=t):(u=ze.exec(t))?(a="-"===u[1]?-1:1,o={y:0,d:S(u[be])*a,h:S(u[Se])*a,m:S(u[Te])*a,s:S(u[Oe])*a,ms:S(u[We])*a}):(u=xe.exec(t))?(a="-"===u[1]?-1:1,i=function(t){var e=t&&parseFloat(t.replace(",","."));return(isNaN(e)?0:e)*a},o={y:i(u[2]),M:i(u[3]),d:i(u[4]),h:i(u[5]),m:i(u[6]),s:i(u[7]),w:i(u[8])}):"object"==typeof o&&("from"in o||"to"in o)&&(r=y(De(o.from),De(o.to)),o={},o.ms=r.milliseconds,o.M=r.months),s=new l(o),De.isDuration(t)&&n(t,"_locale")&&(s._locale=t._locale),s},De.version=ke,De.defaultFormat=en,De.ISO_8601=function(){},De.momentProperties=Fe,De.updateOffset=function(){},De.relativeTimeThreshold=function(e,n){return dn[e]===t?!1:n===t?dn[e]:(dn[e]=n,!0)},De.lang=i("moment.lang is deprecated. Use moment.locale instead.",function(t,e){return De.locale(t,e)}),De.locale=function(t,e){var n;return t&&(n="undefined"!=typeof e?De.defineLocale(t,e):De.localeData(t),n&&(De.duration._locale=De._locale=n)),De._locale._abbr},De.defineLocale=function(t,e){return null!==e?(e.abbr=t,Ue[t]||(Ue[t]=new c),Ue[t].set(e),De.locale(t),Ue[t]):(delete Ue[t],null)},De.langData=i("moment.langData is deprecated. Use moment.localeData instead.",function(t){return De.localeData(t)}),De.localeData=function(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return De._locale;if(!k(t)){if(e=x(t))return e;t=[t]}return z(t)},De.isMoment=function(t){return t instanceof d||null!=t&&n(t,"_isAMomentObject")},De.isDuration=function(t){return t instanceof l};for(ge=_n.length-1;ge>=0;--ge)b(_n[ge]);De.normalizeUnits=function(t){return w(t)},De.invalid=function(t){var e=De.utc(0/0);return null!=t?h(e._pf,t):e._pf.userInvalidated=!0,e},De.parseZone=function(){return De.apply(null,arguments).parseZone()},De.parseTwoDigitYear=function(t){return S(t)+(S(t)>68?1900:2e3)},h(De.fn=d.prototype,{clone:function(){return De(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var t=De(this).utc();return 00:!1},parsingFlags:function(){return h({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(t){return this.zone(0,t)},local:function(t){return this._isUTC&&(this.zone(0,t),this._isUTC=!1,t&&this.add(this._dateTzOffset(),"m")),this},format:function(t){var e=P(this,t||De.defaultFormat);return this.localeData().postformat(e)},add:D(1,"add"),subtract:D(-1,"subtract"),diff:function(t,e,n){var a,s,i,r=I(t,this),o=6e4*(this.zone()-r.zone());return e=w(e),"year"===e||"month"===e?(a=432e5*(this.daysInMonth()+r.daysInMonth()),s=12*(this.year()-r.year())+(this.month()-r.month()),i=this-De(this).startOf("month")-(r-De(r).startOf("month")),i-=6e4*(this.zone()-De(this).startOf("month").zone()-(r.zone()-De(r).startOf("month").zone())),s+=i/a,"year"===e&&(s/=12)):(a=this-r,s="second"===e?a/1e3:"minute"===e?a/6e4:"hour"===e?a/36e5:"day"===e?(a-o)/864e5:"week"===e?(a-o)/6048e5:a),n?s:m(s)},from:function(t,e){return De.duration({to:this,from:t}).locale(this.locale()).humanize(!e)},fromNow:function(t){return this.from(De(),t)},calendar:function(t){var e=t||De(),n=I(e,this).startOf("day"),a=this.diff(n,"days",!0),s=-6>a?"sameElse":-1>a?"lastWeek":0>a?"lastDay":1>a?"sameDay":2>a?"nextDay":7>a?"nextWeek":"sameElse";return this.format(this.localeData().calendar(s,this))},isLeapYear:function(){return U(this.year())},isDST:function(){return this.zone()+t):+this.clone().startOf(e)>+De(t).startOf(e)},isBefore:function(t,e){return e=w("undefined"!=typeof e?e:"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+t>+this):+this.clone().startOf(e)<+De(t).startOf(e)},isSame:function(t,e){return e=w(e||"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+this===+t):+this.clone().startOf(e)===+I(t,this).startOf(e)},min:i("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),this>t?this:t}),max:i("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),t>this?this:t}),zone:function(t,e){var n,a=this._offset||0;return null==t?this._isUTC?a:this._dateTzOffset():("string"==typeof t&&(t=Z(t)),Math.abs(t)<16&&(t=60*t),!this._isUTC&&e&&(n=this._dateTzOffset()),this._offset=t,this._isUTC=!0,null!=n&&this.subtract(n,"m"),a!==t&&(!e||this._changeInProgress?g(this,De.duration(a-t,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,De.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":"" +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-datepicker",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";var e,n,a=!1;return t.component("datepicker",{defaults:{mobile:!1,weekstart:1,i18n:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},format:"YYYY-MM-DD",offsettop:5,maxDate:!1,minDate:!1,pos:"auto",container:"body",template:function(e,n){var a,s="";if(s+='
        ',s+='',s+='',t.formSelect){var i,r,o,u,c=(new Date).getFullYear(),d=[];for(a=0;a'+n.i18n.months[a]+""):d.push('");for(i=''+n.i18n.months[e.month]+'",d=[],o=e.minDate?e.minDate.year():c-50,u=e.maxDate?e.maxDate.year():c+20,a=o;u>=a;a++)a==e.year?d.push('"):d.push('");r=''+e.year+'",s+='
        '+i+" "+r+"
        "}else s+='
        '+n.i18n.months[e.month]+" "+e.year+"
        ";for(s+="
        ",s+='',s+="",a=0;a"+e.weekdays[a]+"");for(s+="",s+="",a=0;a";for(var l=0;l'+h.day.format("D")+""}s+=""}return s+="",s+="
        "}},boot:function(){t.$win.on("resize orientationchange",function(){a&&a.hide()}),t.$html.on("focus.datepicker.uikit","[data-uk-datepicker]",function(e){var n=t.$(this);n.data("datepicker")||(e.preventDefault(),t.datepicker(n,t.Utils.options(n.attr("data-uk-datepicker"))),n.trigger("focus"))}),t.$html.on("click focus","*",function(n){var s=t.$(n.target);!a||s[0]==e[0]||s.data("datepicker")||s.parents(".uk-datepicker:first").length||a.hide()})},init:function(){if(!t.support.touch||"date"!=this.element.attr("type")||this.options.mobile){var s=this;this.current=this.element.val()?n(this.element.val(),this.options.format):n(),this.on("click focus",function(){a!==s&&s.pick(this.value?this.value:"")}).on("change",function(){s.element.val()&&!n(s.element.val(),s.options.format).isValid()&&s.element.val(n().format(s.options.format))}),e||(e=t.$('
        '),e.on("click",".uk-datepicker-next, .uk-datepicker-previous, [data-date]",function(e){e.stopPropagation(),e.preventDefault();var s=t.$(this);return s.hasClass("uk-datepicker-date-disabled")?!1:(s.is("[data-date]")?(a.current=n(s.data("date")),a.element.val(a.current.isValid()?a.current.format(a.options.format):null).trigger("change"),a.hide()):a.add(s.hasClass("uk-datepicker-next")?1:-1,"months"),void 0)}),e.on("change",".update-picker-month, .update-picker-year",function(){var e=t.$(this);a[e.is(".update-picker-year")?"setYear":"setMonth"](Number(e.val()))}),e.appendTo(this.options.container))}},pick:function(s){var i=this.element.offset(),r={left:i.left,right:""};this.current=isNaN(s)?n(s,this.options.format):n(),this.initdate=this.current.format("YYYY-MM-DD"),this.update(),"right"==t.langdirection&&(r.right=window.innerWidth-(r.left+this.element.outerWidth()),r.left="");var o=i.top-this.element.outerHeight()+this.element.height()-this.options.offsettop-e.outerHeight(),u=i.top+this.element.outerHeight()+this.options.offsettop;r.top=u,"top"==this.options.pos?r.top=o:"auto"==this.options.pos&&window.innerHeight-u-e.outerHeight()<0&&o>=0&&(r.top=o),e.css(r).show(),this.trigger("show.uk.datepicker"),a=this},add:function(t,e){this.current.add(t,e),this.update()},setMonth:function(t){this.current.month(t),this.update()},setYear:function(t){this.current.year(t),this.update()},update:function(){var t=this.getRows(this.current.year(),this.current.month()),n=this.options.template(t,this.options);e.html(n),this.trigger("update.uk.datepicker")},getRows:function(t,e){var a=this.options,s=n().format("YYYY-MM-DD"),i=[31,t%4===0&&t%100!==0||t%400===0?29:28,31,30,31,30,31,31,30,31,30,31][e],r=new Date(t,e,1,12).getDay(),o={month:e,year:t,weekdays:[],days:[],maxDate:!1,minDate:!1},u=[];a.maxDate!==!1&&(o.maxDate=isNaN(a.maxDate)?n(a.maxDate,a.format).startOf("day").hours(12):n().add(a.maxDate,"days").startOf("day").hours(12)),a.minDate!==!1&&(o.minDate=isNaN(a.minDate)?n(a.minDate,a.format).startOf("day").hours(12):n().add(a.minDate-1,"days").startOf("day").hours(12)),o.weekdays=function(){for(var t=0,e=[];7>t;t++){for(var n=t+(a.weekstart||0);n>=7;)n-=7;e.push(a.i18n.weekdays[n])}return e}(),a.weekstart&&a.weekstart>0&&(r-=a.weekstart,0>r&&(r+=7));for(var c=i+r,d=c;d>7;)d-=7;c+=7-d;for(var l,h,f,m,_,p=0,y=0;c>p;p++)l=new Date(t,e,1+(p-r),12),h=o.minDate&&o.minDate>l||o.maxDate&&l>o.maxDate,_=!(r>p||p>=i+r),l=n(l),f=this.initdate==l.format("YYYY-MM-DD"),m=s==l.format("YYYY-MM-DD"),u.push({selected:f,today:m,disabled:h,day:l,inmonth:_}),7===++y&&(o.days.push(u),u=[],y=0);return o},hide:function(){a&&a===this&&(e.hide(),a=!1,this.trigger("hide.uk.datepicker"))}}),n=function(t){function e(t,e,n){switch(arguments.length){case 2:return null!=t?t:e;case 3:return null!=t?t:null!=e?e:n;default:throw new Error("Implement me")}}function n(t,e){return Ye.call(t,e)}function a(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function s(t){De.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function i(t,e){var n=!0;return h(function(){return n&&(s(t),n=!1),e.apply(this,arguments)},e)}function r(t,e){mn[t]||(s(e),mn[t]=!0)}function o(t,e){return function(n){return _(t.call(this,n),e)}}function u(t,e){return function(n){return this.localeData().ordinal(t.call(this,n),e)}}function c(){}function d(t,e){e!==!1&&F(t),f(this,t),this._d=new Date(+t._d)}function l(t){var e=v(t),n=e.year||0,a=e.quarter||0,s=e.month||0,i=e.week||0,r=e.day||0,o=e.hour||0,u=e.minute||0,c=e.second||0,d=e.millisecond||0;this._milliseconds=+d+1e3*c+6e4*u+36e5*o,this._days=+r+7*i,this._months=+s+3*a+12*n,this._data={},this._locale=De.localeData(),this._bubble()}function h(t,e){for(var a in e)n(e,a)&&(t[a]=e[a]);return n(e,"toString")&&(t.toString=e.toString),n(e,"valueOf")&&(t.valueOf=e.valueOf),t}function f(t,e){var n,a,s;if("undefined"!=typeof e._isAMomentObject&&(t._isAMomentObject=e._isAMomentObject),"undefined"!=typeof e._i&&(t._i=e._i),"undefined"!=typeof e._f&&(t._f=e._f),"undefined"!=typeof e._l&&(t._l=e._l),"undefined"!=typeof e._strict&&(t._strict=e._strict),"undefined"!=typeof e._tzm&&(t._tzm=e._tzm),"undefined"!=typeof e._isUTC&&(t._isUTC=e._isUTC),"undefined"!=typeof e._offset&&(t._offset=e._offset),"undefined"!=typeof e._pf&&(t._pf=e._pf),"undefined"!=typeof e._locale&&(t._locale=e._locale),Fe.length>0)for(n in Fe)a=Fe[n],s=e[a],"undefined"!=typeof s&&(t[a]=s);return t}function m(t){return 0>t?Math.ceil(t):Math.floor(t)}function _(t,e,n){for(var a=""+Math.abs(t),s=t>=0;a.lengtha;a++)(n&&t[a]!==e[a]||!n&&S(t[a])!==S(e[a]))&&r++;return r+i}function w(t){if(t){var e=t.toLowerCase().replace(/(.)s$/,"$1");t=on[t]||un[e]||e}return t}function v(t){var e,a,s={};for(a in t)n(t,a)&&(e=w(a),e&&(s[e]=t[a]));return s}function b(e){var n,a;if(0===e.indexOf("week"))n=7,a="day";else{if(0!==e.indexOf("month"))return;n=12,a="month"}De[e]=function(s,i){var r,o,u=De._locale[e],c=[];if("number"==typeof s&&(i=s,s=t),o=function(t){var e=De().utc().set(a,t);return u.call(De._locale,e,s||"")},null!=i)return o(i);for(r=0;n>r;r++)c.push(o(r));return c}}function S(t){var e=+t,n=0;return 0!==e&&isFinite(e)&&(n=e>=0?Math.floor(e):Math.ceil(e)),n}function T(t,e){return new Date(Date.UTC(t,e+1,0)).getUTCDate()}function O(t,e,n){return oe(De([t,11,31+e-n]),e,n).week}function W(t){return U(t)?366:365}function U(t){return t%4===0&&t%100!==0||t%400===0}function F(t){var e;t._a&&-2===t._pf.overflow&&(e=t._a[ve]<0||t._a[ve]>11?ve:t._a[be]<1||t._a[be]>T(t._a[we],t._a[ve])?be:t._a[Se]<0||t._a[Se]>23?Se:t._a[Te]<0||t._a[Te]>59?Te:t._a[Oe]<0||t._a[Oe]>59?Oe:t._a[We]<0||t._a[We]>999?We:-1,t._pf._overflowDayOfYear&&(we>e||e>be)&&(e=be),t._pf.overflow=e)}function G(t){return null==t._isValid&&(t._isValid=!isNaN(t._d.getTime())&&t._pf.overflow<0&&!t._pf.empty&&!t._pf.invalidMonth&&!t._pf.nullInput&&!t._pf.invalidFormat&&!t._pf.userInvalidated,t._strict&&(t._isValid=t._isValid&&0===t._pf.charsLeftOver&&0===t._pf.unusedTokens.length)),t._isValid}function C(t){return t?t.toLowerCase().replace("_","-"):t}function z(t){for(var e,n,a,s,i=0;i0;){if(a=x(s.slice(0,e).join("-")))return a;if(n&&n.length>=e&&Y(s,n,!0)>=e-1)break;e--}i++}return null}function x(t){var e=null;if(!Ue[t]&&Ge)try{e=De.locale(),require("./locale/"+t),De.locale(e)}catch(n){}return Ue[t]}function I(t,e){return e._isUTC?De(t).zone(e._offset||0):De(t).local()}function H(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function L(t){var e,n,a=t.match(Ie);for(e=0,n=a.length;n>e;e++)a[e]=fn[a[e]]?fn[a[e]]:H(a[e]);return function(s){var i="";for(e=0;n>e;e++)i+=a[e]instanceof Function?a[e].call(s,t):a[e];return i}}function P(t,e){return t.isValid()?(e=A(e,t.localeData()),cn[e]||(cn[e]=L(e)),cn[e](t)):t.localeData().invalidDate()}function A(t,e){function n(t){return e.longDateFormat(t)||t}var a=5;for(He.lastIndex=0;a>=0&&He.test(t);)t=t.replace(He,n),He.lastIndex=0,a-=1;return t}function N(t,e){var n,a=e._strict;switch(t){case"Q":return qe;case"DDDD":return Re;case"YYYY":case"GGGG":case"gggg":return a?Xe:Ae;case"Y":case"G":case"g":return Ke;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return a?Be:Ne;case"S":if(a)return qe;case"SS":if(a)return Qe;case"SSS":if(a)return Re;case"DDD":return Pe;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return je;case"a":case"A":return e._locale._meridiemParse;case"X":return Ve;case"Z":case"ZZ":return Ee;case"T":return $e;case"SSSS":return Ze;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return a?Qe:Le;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Le;case"Do":return Je;default:return n=new RegExp(R(Q(t.replace("\\","")),"i"))}}function Z(t){t=t||"";var e=t.match(Ee)||[],n=e[e.length-1]||[],a=(n+"").match(sn)||["-",0,0],s=+(60*a[1])+S(a[2]);return"+"===a[0]?-s:s}function j(t,e,n){var a,s=n._a;switch(t){case"Q":null!=e&&(s[ve]=3*(S(e)-1));break;case"M":case"MM":null!=e&&(s[ve]=S(e)-1);break;case"MMM":case"MMMM":a=n._locale.monthsParse(e),null!=a?s[ve]=a:n._pf.invalidMonth=e;break;case"D":case"DD":null!=e&&(s[be]=S(e));break;case"Do":null!=e&&(s[be]=S(parseInt(e,10)));break;case"DDD":case"DDDD":null!=e&&(n._dayOfYear=S(e));break;case"YY":s[we]=De.parseTwoDigitYear(e);break;case"YYYY":case"YYYYY":case"YYYYYY":s[we]=S(e);break;case"a":case"A":n._isPm=n._locale.isPM(e);break;case"H":case"HH":case"h":case"hh":s[Se]=S(e);break;case"m":case"mm":s[Te]=S(e);break;case"s":case"ss":s[Oe]=S(e);break;case"S":case"SS":case"SSS":case"SSSS":s[We]=S(1e3*("0."+e));break;case"X":n._d=new Date(1e3*parseFloat(e));break;case"Z":case"ZZ":n._useUTC=!0,n._tzm=Z(e);break;case"dd":case"ddd":case"dddd":a=n._locale.weekdaysParse(e),null!=a?(n._w=n._w||{},n._w.d=a):n._pf.invalidWeekday=e;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":t=t.substr(0,1);case"gggg":case"GGGG":case"GGGGG":t=t.substr(0,2),e&&(n._w=n._w||{},n._w[t]=S(e));break;case"gg":case"GG":n._w=n._w||{},n._w[t]=De.parseTwoDigitYear(e)}}function E(t){var n,a,s,i,r,o,u;n=t._w,null!=n.GG||null!=n.W||null!=n.E?(r=1,o=4,a=e(n.GG,t._a[we],oe(De(),1,4).year),s=e(n.W,1),i=e(n.E,1)):(r=t._locale._week.dow,o=t._locale._week.doy,a=e(n.gg,t._a[we],oe(De(),r,o).year),s=e(n.w,1),null!=n.d?(i=n.d,r>i&&++s):i=null!=n.e?n.e+r:r),u=ue(a,s,i,o,r),t._a[we]=u.year,t._dayOfYear=u.dayOfYear}function $(t){var n,a,s,i,r=[];if(!t._d){for(s=J(t),t._w&&null==t._a[be]&&null==t._a[ve]&&E(t),t._dayOfYear&&(i=e(t._a[we],s[we]),t._dayOfYear>W(i)&&(t._pf._overflowDayOfYear=!0),a=ae(i,0,t._dayOfYear),t._a[ve]=a.getUTCMonth(),t._a[be]=a.getUTCDate()),n=0;3>n&&null==t._a[n];++n)t._a[n]=r[n]=s[n];for(;7>n;n++)t._a[n]=r[n]=null==t._a[n]?2===n?1:0:t._a[n];t._d=(t._useUTC?ae:ne).apply(null,r),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()+t._tzm)}}function V(t){var e;t._d||(e=v(t._i),t._a=[e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond],$(t))}function J(t){var e=new Date;return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function q(t){if(t._f===De.ISO_8601)return B(t),void 0;t._a=[],t._pf.empty=!0;var e,n,a,s,i,r=""+t._i,o=r.length,u=0;for(a=A(t._f,t._locale).match(Ie)||[],e=0;e0&&t._pf.unusedInput.push(i),r=r.slice(r.indexOf(n)+n.length),u+=n.length),fn[s]?(n?t._pf.empty=!1:t._pf.unusedTokens.push(s),j(s,n,t)):t._strict&&!n&&t._pf.unusedTokens.push(s);t._pf.charsLeftOver=o-u,r.length>0&&t._pf.unusedInput.push(r),t._isPm&&t._a[Se]<12&&(t._a[Se]+=12),t._isPm===!1&&12===t._a[Se]&&(t._a[Se]=0),$(t),F(t)}function Q(t){return t.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,a,s){return e||n||a||s})}function R(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function X(t){var e,n,s,i,r;if(0===t._f.length)return t._pf.invalidFormat=!0,t._d=new Date(0/0),void 0;for(i=0;ir)&&(s=r,n=e));h(t,n||e)}function B(t){var e,n,a=t._i,s=tn.exec(a);if(s){for(t._pf.iso=!0,e=0,n=nn.length;n>e;e++)if(nn[e][1].exec(a)){t._f=nn[e][0]+(s[6]||" ");break}for(e=0,n=an.length;n>e;e++)if(an[e][1].exec(a)){t._f+=an[e][0];break}a.match(Ee)&&(t._f+="Z"),q(t)}else t._isValid=!1}function K(t){B(t),t._isValid===!1&&(delete t._isValid,De.createFromInputFallback(t))}function te(t,e){var n,a=[];for(n=0;nt&&o.setFullYear(t),o}function ae(t){var e=new Date(Date.UTC.apply(null,arguments));return 1970>t&&e.setUTCFullYear(t),e}function se(t,e){if("string"==typeof t)if(isNaN(t)){if(t=e.weekdaysParse(t),"number"!=typeof t)return null}else t=parseInt(t,10);return t}function ie(t,e,n,a,s){return s.relativeTime(e||1,!!n,t,a)}function re(t,e,n){var a=De.duration(t).abs(),s=Me(a.as("s")),i=Me(a.as("m")),r=Me(a.as("h")),o=Me(a.as("d")),u=Me(a.as("M")),c=Me(a.as("y")),d=s0,d[4]=n,ie.apply({},d)}function oe(t,e,n){var a,s=n-e,i=n-t.day();return i>s&&(i-=7),s-7>i&&(i+=7),a=De(t).add(i,"d"),{week:Math.ceil(a.dayOfYear()/7),year:a.year()}}function ue(t,e,n,a,s){var i,r,o=ae(t,0,1).getUTCDay();return o=0===o?7:o,n=null!=n?n:s,i=s-o+(o>a?7:0)-(s>o?7:0),r=7*(e-1)+(n-s)+i+1,{year:r>0?t:t-1,dayOfYear:r>0?r:W(t-1)+r}}function ce(e){var n=e._i,a=e._f;return e._locale=e._locale||De.localeData(e._l),null===n||a===t&&""===n?De.invalid({nullInput:!0}):("string"==typeof n&&(e._i=n=e._locale.preparse(n)),De.isMoment(n)?new d(n,!0):(a?k(a)?X(e):q(e):ee(e),new d(e)))}function de(t,e){var n,a;if(1===e.length&&k(e[0])&&(e=e[0]),!e.length)return De();for(n=e[0],a=1;a=0?"+":"-";return e+_(Math.abs(t),6)},gg:function(){return _(this.weekYear()%100,2)},gggg:function(){return _(this.weekYear(),4)},ggggg:function(){return _(this.weekYear(),5)},GG:function(){return _(this.isoWeekYear()%100,2)},GGGG:function(){return _(this.isoWeekYear(),4)},GGGGG:function(){return _(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return S(this.milliseconds()/100)},SS:function(){return _(S(this.milliseconds()/10),2)},SSS:function(){return _(this.milliseconds(),3)},SSSS:function(){return _(this.milliseconds(),3)},Z:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+":"+_(S(t)%60,2)},ZZ:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+_(S(t)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},mn={},_n=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];ln.length;)ge=ln.pop(),fn[ge+"o"]=u(fn[ge],ge);for(;hn.length;)ge=hn.pop(),fn[ge+ge]=o(fn[ge],2);fn.DDDD=o(fn.DDD,3),h(c.prototype,{set:function(t){var e,n;for(n in t)e=t[n],"function"==typeof e?this[n]=e:this["_"+n]=e},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(t){return this._months[t.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(t){return this._monthsShort[t.month()]},monthsParse:function(t){var e,n,a;for(this._monthsParse||(this._monthsParse=[]),e=0;12>e;e++)if(this._monthsParse[e]||(n=De.utc([2e3,e]),a="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[e]=new RegExp(a.replace(".",""),"i")),this._monthsParse[e].test(t))return e},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(t){return this._weekdays[t.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(t){return this._weekdaysShort[t.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(t){return this._weekdaysMin[t.day()]},weekdaysParse:function(t){var e,n,a;for(this._weekdaysParse||(this._weekdaysParse=[]),e=0;7>e;e++)if(this._weekdaysParse[e]||(n=De([2e3,1]).day(e),a="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[e]=new RegExp(a.replace(".",""),"i")),this._weekdaysParse[e].test(t))return e},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},longDateFormat:function(t){var e=this._longDateFormat[t];return!e&&this._longDateFormat[t.toUpperCase()]&&(e=this._longDateFormat[t.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t]=e),e},isPM:function(t){return"p"===(t+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(t,e,n){return t>11?n?"pm":"PM":n?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(t,e){var n=this._calendar[t];return"function"==typeof n?n.apply(e):n},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(t,e,n,a){var s=this._relativeTime[n];return"function"==typeof s?s(t,e,n,a):s.replace(/%d/i,t)},pastFuture:function(t,e){var n=this._relativeTime[t>0?"future":"past"];return"function"==typeof n?n(e):n.replace(/%s/i,e)},ordinal:function(t){return this._ordinal.replace("%d",t)},_ordinal:"%d",preparse:function(t){return t},postformat:function(t){return t},week:function(t){return oe(t,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),De=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._i=e,r._f=n,r._l=s,r._strict=i,r._isUTC=!1,r._pf=a(),ce(r)},De.suppressDeprecationWarnings=!1,De.createFromInputFallback=i("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(t){t._d=new Date(t._i)}),De.min=function(){var t=[].slice.call(arguments,0);return de("isBefore",t)},De.max=function(){var t=[].slice.call(arguments,0);return de("isAfter",t)},De.utc=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._useUTC=!0,r._isUTC=!0,r._l=s,r._i=e,r._f=n,r._strict=i,r._pf=a(),ce(r).utc()},De.unix=function(t){return De(1e3*t)},De.duration=function(t,e){var a,s,i,r,o=t,u=null;return De.isDuration(t)?o={ms:t._milliseconds,d:t._days,M:t._months}:"number"==typeof t?(o={},e?o[e]=t:o.milliseconds=t):(u=ze.exec(t))?(a="-"===u[1]?-1:1,o={y:0,d:S(u[be])*a,h:S(u[Se])*a,m:S(u[Te])*a,s:S(u[Oe])*a,ms:S(u[We])*a}):(u=xe.exec(t))?(a="-"===u[1]?-1:1,i=function(t){var e=t&&parseFloat(t.replace(",","."));return(isNaN(e)?0:e)*a},o={y:i(u[2]),M:i(u[3]),d:i(u[4]),h:i(u[5]),m:i(u[6]),s:i(u[7]),w:i(u[8])}):"object"==typeof o&&("from"in o||"to"in o)&&(r=y(De(o.from),De(o.to)),o={},o.ms=r.milliseconds,o.M=r.months),s=new l(o),De.isDuration(t)&&n(t,"_locale")&&(s._locale=t._locale),s},De.version=ke,De.defaultFormat=en,De.ISO_8601=function(){},De.momentProperties=Fe,De.updateOffset=function(){},De.relativeTimeThreshold=function(e,n){return dn[e]===t?!1:n===t?dn[e]:(dn[e]=n,!0)},De.lang=i("moment.lang is deprecated. Use moment.locale instead.",function(t,e){return De.locale(t,e)}),De.locale=function(t,e){var n;return t&&(n="undefined"!=typeof e?De.defineLocale(t,e):De.localeData(t),n&&(De.duration._locale=De._locale=n)),De._locale._abbr},De.defineLocale=function(t,e){return null!==e?(e.abbr=t,Ue[t]||(Ue[t]=new c),Ue[t].set(e),De.locale(t),Ue[t]):(delete Ue[t],null)},De.langData=i("moment.langData is deprecated. Use moment.localeData instead.",function(t){return De.localeData(t)}),De.localeData=function(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return De._locale;if(!k(t)){if(e=x(t))return e;t=[t]}return z(t)},De.isMoment=function(t){return t instanceof d||null!=t&&n(t,"_isAMomentObject")},De.isDuration=function(t){return t instanceof l};for(ge=_n.length-1;ge>=0;--ge)b(_n[ge]);De.normalizeUnits=function(t){return w(t)},De.invalid=function(t){var e=De.utc(0/0);return null!=t?h(e._pf,t):e._pf.userInvalidated=!0,e},De.parseZone=function(){return De.apply(null,arguments).parseZone()},De.parseTwoDigitYear=function(t){return S(t)+(S(t)>68?1900:2e3)},h(De.fn=d.prototype,{clone:function(){return De(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var t=De(this).utc();return 00:!1},parsingFlags:function(){return h({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(t){return this.zone(0,t)},local:function(t){return this._isUTC&&(this.zone(0,t),this._isUTC=!1,t&&this.add(this._dateTzOffset(),"m")),this},format:function(t){var e=P(this,t||De.defaultFormat);return this.localeData().postformat(e)},add:D(1,"add"),subtract:D(-1,"subtract"),diff:function(t,e,n){var a,s,i,r=I(t,this),o=6e4*(this.zone()-r.zone());return e=w(e),"year"===e||"month"===e?(a=432e5*(this.daysInMonth()+r.daysInMonth()),s=12*(this.year()-r.year())+(this.month()-r.month()),i=this-De(this).startOf("month")-(r-De(r).startOf("month")),i-=6e4*(this.zone()-De(this).startOf("month").zone()-(r.zone()-De(r).startOf("month").zone())),s+=i/a,"year"===e&&(s/=12)):(a=this-r,s="second"===e?a/1e3:"minute"===e?a/6e4:"hour"===e?a/36e5:"day"===e?(a-o)/864e5:"week"===e?(a-o)/6048e5:a),n?s:m(s)},from:function(t,e){return De.duration({to:this,from:t}).locale(this.locale()).humanize(!e)},fromNow:function(t){return this.from(De(),t)},calendar:function(t){var e=t||De(),n=I(e,this).startOf("day"),a=this.diff(n,"days",!0),s=-6>a?"sameElse":-1>a?"lastWeek":0>a?"lastDay":1>a?"sameDay":2>a?"nextDay":7>a?"nextWeek":"sameElse";return this.format(this.localeData().calendar(s,this))},isLeapYear:function(){return U(this.year())},isDST:function(){return this.zone()+t):+this.clone().startOf(e)>+De(t).startOf(e)},isBefore:function(t,e){return e=w("undefined"!=typeof e?e:"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+t>+this):+this.clone().startOf(e)<+De(t).startOf(e)},isSame:function(t,e){return e=w(e||"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+this===+t):+this.clone().startOf(e)===+I(t,this).startOf(e)},min:i("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),this>t?this:t}),max:i("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),t>this?this:t}),zone:function(t,e){var n,a=this._offset||0;return null==t?this._isUTC?a:this._dateTzOffset():("string"==typeof t&&(t=Z(t)),Math.abs(t)<16&&(t=60*t),!this._isUTC&&e&&(n=this._dateTzOffset()),this._offset=t,this._isUTC=!0,null!=n&&this.subtract(n,"m"),a!==t&&(!e||this._changeInProgress?g(this,De.duration(a-t,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,De.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":"" },zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(t){return t=t?De(t).zone():0,(this.zone()-t)%60===0},daysInMonth:function(){return T(this.year(),this.month())},dayOfYear:function(t){var e=Me((De(this).startOf("day")-De(this).startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")},quarter:function(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)},weekYear:function(t){var e=oe(this,this.localeData()._week.dow,this.localeData()._week.doy).year;return null==t?e:this.add(t-e,"y")},isoWeekYear:function(t){var e=oe(this,1,4).year;return null==t?e:this.add(t-e,"y")},week:function(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")},isoWeek:function(t){var e=oe(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")},weekday:function(t){var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")},isoWeekday:function(t){return null==t?this.day()||7:this.day(this.day()%7?t:t-7)},isoWeeksInYear:function(){return O(this.year(),1,4)},weeksInYear:function(){var t=this.localeData()._week;return O(this.year(),t.dow,t.doy)},get:function(t){return t=w(t),this[t]()},set:function(t,e){return t=w(t),"function"==typeof this[t]&&this[t](e),this},locale:function(e){var n;return e===t?this._locale._abbr:(n=De.localeData(e),null!=n&&(this._locale=n),this)},lang:i("moment().lang() is deprecated. Use moment().localeData() instead.",function(e){return e===t?this.localeData():this.locale(e)}),localeData:function(){return this._locale},_dateTzOffset:function(){return 15*Math.round(this._d.getTimezoneOffset()/15)}}),De.fn.millisecond=De.fn.milliseconds=me("Milliseconds",!1),De.fn.second=De.fn.seconds=me("Seconds",!1),De.fn.minute=De.fn.minutes=me("Minutes",!1),De.fn.hour=De.fn.hours=me("Hours",!0),De.fn.date=me("Date",!0),De.fn.dates=i("dates accessor is deprecated. Use date instead.",me("Date",!0)),De.fn.year=me("FullYear",!0),De.fn.years=i("years accessor is deprecated. Use year instead.",me("FullYear",!0)),De.fn.days=De.fn.day,De.fn.months=De.fn.month,De.fn.weeks=De.fn.week,De.fn.isoWeeks=De.fn.isoWeek,De.fn.quarters=De.fn.quarter,De.fn.toJSON=De.fn.toISOString,h(De.duration.fn=l.prototype,{_bubble:function(){var t,e,n,a=this._milliseconds,s=this._days,i=this._months,r=this._data,o=0;r.milliseconds=a%1e3,t=m(a/1e3),r.seconds=t%60,e=m(t/60),r.minutes=e%60,n=m(e/60),r.hours=n%24,s+=m(n/24),o=m(_e(s)),s-=m(pe(o)),i+=m(s/30),s%=30,o+=m(i/12),i%=12,r.days=s,r.months=i,r.years=o},abs:function(){return this._milliseconds=Math.abs(this._milliseconds),this._days=Math.abs(this._days),this._months=Math.abs(this._months),this._data.milliseconds=Math.abs(this._data.milliseconds),this._data.seconds=Math.abs(this._data.seconds),this._data.minutes=Math.abs(this._data.minutes),this._data.hours=Math.abs(this._data.hours),this._data.months=Math.abs(this._data.months),this._data.years=Math.abs(this._data.years),this},weeks:function(){return m(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*S(this._months/12)},humanize:function(t){var e=re(this,!t,this.localeData());return t&&(e=this.localeData().pastFuture(+this,e)),this.localeData().postformat(e)},add:function(t,e){var n=De.duration(t,e);return this._milliseconds+=n._milliseconds,this._days+=n._days,this._months+=n._months,this._bubble(),this},subtract:function(t,e){var n=De.duration(t,e);return this._milliseconds-=n._milliseconds,this._days-=n._days,this._months-=n._months,this._bubble(),this},get:function(t){return t=w(t),this[t.toLowerCase()+"s"]()},as:function(t){var e,n;if(t=w(t),"month"===t||"year"===t)return e=this._days+this._milliseconds/864e5,n=this._months+12*_e(e),"month"===t?n:n/12;switch(e=this._days+pe(this._months/12),t){case"week":return e/7+this._milliseconds/6048e5;case"day":return e+this._milliseconds/864e5;case"hour":return 24*e+this._milliseconds/36e5;case"minute":return 24*e*60+this._milliseconds/6e4;case"second":return 24*e*60*60+this._milliseconds/1e3;case"millisecond":return Math.floor(24*e*60*60*1e3)+this._milliseconds;default:throw new Error("Unknown unit "+t)}},lang:De.fn.lang,locale:De.fn.locale,toIsoString:i("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",function(){return this.toISOString()}),toISOString:function(){var t=Math.abs(this.years()),e=Math.abs(this.months()),n=Math.abs(this.days()),a=Math.abs(this.hours()),s=Math.abs(this.minutes()),i=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(t?t+"Y":"")+(e?e+"M":"")+(n?n+"D":"")+(a||s||i?"T":"")+(a?a+"H":"")+(s?s+"M":"")+(i?i+"S":""):"P0D"},localeData:function(){return this._locale}}),De.duration.fn.toString=De.duration.fn.toISOString;for(ge in rn)n(rn,ge)&&ye(ge.toLowerCase());return De.duration.fn.asMilliseconds=function(){return this.as("ms")},De.duration.fn.asSeconds=function(){return this.as("s")},De.duration.fn.asMinutes=function(){return this.as("m")},De.duration.fn.asHours=function(){return this.as("h")},De.duration.fn.asDays=function(){return this.as("d")},De.duration.fn.asWeeks=function(){return this.as("weeks")},De.duration.fn.asMonths=function(){return this.as("M")},De.duration.fn.asYears=function(){return this.as("y")},De.locale("en",{ordinal:function(t){var e=t%10,n=1===S(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th";return t+n}}),De}.call(this),t.Utils.moment=n,t.datepicker}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/form-password.min.js b/lib/api/uikit/src/js/components/form-password.min.js index c5f5f8a1..8201cb76 100755 --- a/lib/api/uikit/src/js/components/form-password.min.js +++ b/lib/api/uikit/src/js/components/form-password.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-form-password",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";return t.component("formPassword",{defaults:{lblShow:"Show",lblHide:"Hide"},boot:function(){t.$html.on("click.formpassword.uikit","[data-uk-form-password]",function(i){var e=t.$(this);e.data("formPassword")||(i.preventDefault(),t.formPassword(e,t.Utils.options(e.attr("data-uk-form-password"))),e.trigger("click"))})},init:function(){var t=this;this.on("click",function(i){if(i.preventDefault(),t.input.length){var e=t.input.attr("type");t.input.attr("type","text"==e?"password":"text"),t.element.html(t.options["text"==e?"lblShow":"lblHide"])}}),this.input=this.element.next("input").length?this.element.next("input"):this.element.prev("input"),this.element.html(this.options[this.input.is("[type='password']")?"lblShow":"lblHide"]),this.element.data("formPassword",this)}}),t.formPassword}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-form-password",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";return t.component("formPassword",{defaults:{lblShow:"Show",lblHide:"Hide"},boot:function(){t.$html.on("click.formpassword.uikit","[data-uk-form-password]",function(i){var e=t.$(this);e.data("formPassword")||(i.preventDefault(),t.formPassword(e,t.Utils.options(e.attr("data-uk-form-password"))),e.trigger("click"))})},init:function(){var t=this;this.on("click",function(i){if(i.preventDefault(),t.input.length){var e=t.input.attr("type");t.input.attr("type","text"==e?"password":"text"),t.element.html(t.options["text"==e?"lblShow":"lblHide"])}}),this.input=this.element.next("input").length?this.element.next("input"):this.element.prev("input"),this.element.html(this.options[this.input.is('[type="password"]')?"lblShow":"lblHide"]),this.element.data("formPassword",this)}}),t.formPassword}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/form-select.min.js b/lib/api/uikit/src/js/components/form-select.min.js index 1f6e3df5..fe1a750f 100755 --- a/lib/api/uikit/src/js/components/form-select.min.js +++ b/lib/api/uikit/src/js/components/form-select.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-form-select",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";return t.component("formSelect",{defaults:{target:">span:first",activeClass:"uk-active"},boot:function(){t.ready(function(e){t.$("[data-uk-form-select]",e).each(function(){var e=t.$(this);e.data("formSelect")||t.formSelect(e,t.Utils.options(e.attr("data-uk-form-select")))})})},init:function(){var t=this;this.target=this.find(this.options.target),this.select=this.find("select"),this.select.on({change:function(){var e=t.select[0],n=function(){try{"input"===t.options.target?t.target.val(e.options[e.selectedIndex].text):t.target.text(e.options[e.selectedIndex].text)}catch(s){}return t.element[t.select.val()?"addClass":"removeClass"](t.options.activeClass),n};return n()}(),focus:function(){t.target.addClass("uk-focus")},blur:function(){t.target.removeClass("uk-focus")},mouseenter:function(){t.target.addClass("uk-hover")},mouseleave:function(){t.target.removeClass("uk-hover")}}),this.element.data("formSelect",this)}}),t.formSelect}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-form-select",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";return t.component("formSelect",{defaults:{target:">span:first",activeClass:"uk-active"},boot:function(){t.ready(function(e){t.$("[data-uk-form-select]",e).each(function(){var e=t.$(this);e.data("formSelect")||t.formSelect(e,t.Utils.options(e.attr("data-uk-form-select")))})})},init:function(){var t=this;this.target=this.find(this.options.target),this.select=this.find("select"),this.select.on({change:function(){var e=t.select[0],n=function(){try{"input"===t.options.target?t.target.val(e.options[e.selectedIndex].text):t.target.text(e.options[e.selectedIndex].text)}catch(s){}return t.element[t.select.val()?"addClass":"removeClass"](t.options.activeClass),n};return n()}(),focus:function(){t.target.addClass("uk-focus")},blur:function(){t.target.removeClass("uk-focus")},mouseenter:function(){t.target.addClass("uk-hover")},mouseleave:function(){t.target.removeClass("uk-hover")}}),this.element.data("formSelect",this)}}),t.formSelect}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/grid-parallax.min.js b/lib/api/uikit/src/js/components/grid-parallax.min.js index 5e08db77..0bc309f5 100755 --- a/lib/api/uikit/src/js/components/grid-parallax.min.js +++ b/lib/api/uikit/src/js/components/grid-parallax.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var n;window.UIkit&&(n=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-grid-parallax",["uikit"],function(){return n||t(UIkit)})}(function(t){function n(t){for(var n=t.children(),i=n.filter(":visible:first"),e=i[0].offsetTop+i.outerHeight(),o=0;o=e);o++);return o||1}function i(t){var n,i,e,o=t.offset().top,r=t.outerHeight(),s=UIkit.$win.scrollTop(),a=window.innerHeight;return o>s+a?e=0:s>o+r?e=1:(a>o+r?e=(a>s?s:s-a)/(o+r):(n=s+a-o,i=Math.round(n/((a+r)/100)),e=i/100),a>o&&(e=e*s/(o+r-a))),e>1?1:e}var e=[],o=function(){requestAnimationFrame(function(){for(var t=0;t1&&i.element.css("margin-bottom",i.options.translate+parseInt(i.element.css("margin-bottom")))};return t.$(function(){e()}),t.Utils.debounce(e,50)}())},initItems:function(){var n=this.options.smooth;return this.items=(this.options.target?this.element.find(this.options.target):this.element.children()).each(function(){t.$(this).css({transition:"transform "+n+"ms linear",transform:""})}),this},process:function(){var e=i(this.element),o=n(this.element),r=this.items,s=[o-1];if(1==o||!e)return r.css("transform",""),void 0;for(;s.length=e);o++);return o||1}function i(n){var i,e,o,r=n.offset().top,s=n.outerHeight(),a=t.$win.scrollTop(),l=window.innerHeight;return r>a+l?o=0:a>r+s?o=1:(l>r+s?o=(l>a?a:a-l)/(r+s):(i=a+l-r,e=Math.round(i/((l+s)/100)),o=e/100),l>r&&(o=o*a/(r+s-l))),o>1?1:o}var e=[],o=function(){requestAnimationFrame(function(){for(var t=0;t1&&i.element.css("margin-bottom",i.options.translate+parseInt(i.element.css("margin-bottom")))};return t.$(function(){e()}),t.Utils.debounce(e,50)}())},initItems:function(){var n=this.options.smooth;return this.items=(this.options.target?this.element.find(this.options.target):this.element.children()).each(function(){t.$(this).css({transition:"transform "+n+"ms linear",transform:""})}),this},process:function(){var e=i(this.element),o=n(this.element),r=this.items,s=[o-1];if(1==o||!e)return r.css("transform",""),void 0;for(;s.lengthe;e++)if(i=h[e]+t,"string"==typeof u[i])return i}}function i(t){var i=parseFloat(t),e=-1===t.indexOf("%")&&!isNaN(i);return e&&i}function e(){}function n(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},i=0,e=c.length;e>i;i++){var n=c[i];t[n]=0}return t}function r(){if(!f){f=!0;var e=window.getComputedStyle;if(s=function(){var t=e?function(t){return e(t,null)}:function(t){return t.currentStyle};return function(i){var e=t(i);return e||l("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),e}}(),a=t("boxSizing")){var n=document.createElement("div");n.style.width="200px",n.style.padding="1px 2px 3px 4px",n.style.borderStyle="solid",n.style.borderWidth="1px 2px 3px 4px",n.style[a]="border-box";var r=document.body||document.documentElement;r.appendChild(n);var o=s(n);d=200===i(o.width),r.removeChild(n)}}}function o(t){if(r(),"string"==typeof t&&(t=document.querySelector(t)),t&&"object"==typeof t&&t.nodeType){var e=s(t);if("none"===e.display)return n();var o={};o.width=t.offsetWidth,o.height=t.offsetHeight;for(var h=o.isBorderBox=!(!a||!e[a]||"border-box"!==e[a]),u=0,l=c.length;l>u;u++){var f=c[u],p=e[f],g=parseFloat(p);o[f]=isNaN(g)?0:g}var m=o.paddingLeft+o.paddingRight,v=o.paddingTop+o.paddingBottom,b=o.marginLeft+o.marginRight,y=o.marginTop+o.marginBottom,k=o.borderLeftWidth+o.borderRightWidth,w=o.borderTopWidth+o.borderBottomWidth,x=h&&d,W=i(e.width);W!==!1&&(o.width=W+(x?0:m+k));var $=i(e.height);return $!==!1&&(o.height=$+(x?0:v+w)),o.innerWidth=o.width-(m+k),o.innerHeight=o.height-(v+w),o.outerWidth=o.width+b,o.outerHeight=o.height+y,o}}var s,a,d,h="Webkit Moz ms Ms O".split(" "),u=document.documentElement.style,l="undefined"==typeof console?e:function(t){console.error(t)},c=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],f=!1;return o}function e(t){return i()(t)}t.component("grid",{defaults:{colwidth:"auto",animation:!0,duration:300,gutter:0,controls:!1,filter:!1,origin:t.langdirection},boot:function(){t.ready(function(i){t.$("[data-uk-grid]",i).each(function(){var i=t.$(this);i.data("grid")||t.grid(i,t.Utils.options(i.attr("data-uk-grid")))})})},init:function(){var i=this,e=String(this.options.gutter).trim().split(" ");this.gutterv=parseInt(e[0],10),this.gutterh=parseInt(e[1]||e[0],10),this.element.css({position:"relative"}),this.controls=null,this.origin=this.options.origin,this.options.controls&&(this.controls=t.$(this.options.controls),this.controls.on("click","[data-uk-filter]",function(e){e.preventDefault(),i.filter(t.$(this).attr("data-uk-filter"))}),this.controls.on("click","[data-uk-sort]",function(e){e.preventDefault();var n=t.$(this).attr("data-uk-sort").split(":");i.sort(n[0],n[1])})),t.$win.on("load resize orientationchange",t.Utils.debounce(function(){i.currentfilter?i.filter(i.currentfilter):this.update()}.bind(this),100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.update()}),t.domObserve(this.element,function(){i.update()}),this.options.filter!==!1?this.filter(this.options.filter):this.update()},_prepareElements:function(){var t,i=this.element.children(":not([data-grid-prepared])");i.length&&(t={position:"absolute","box-sizing":"border-box",width:"auto"==this.options.colwidth?"":this.options.colwidth},this.options.gutter&&(t["padding-"+this.origin]=this.gutterh,t["padding-bottom"]=this.gutterv,this.element.css("margin-"+this.origin,-1*this.gutterh)),i.attr("data-grid-prepared","true").css(t))},update:function(i){var n=this;this._prepareElements(),i=i||this.element.children(":visible");var r,o,s,a,d,h,u,l,c,f=i,p=this.element.width()+2*this.gutterh+2,g=0,m=0,v=[];this.trigger("beforeupdate.uk.grid",[f]),f.each(function(){for(c=e(this),r=t.$(this),o=c.outerWidth,s=c.outerHeight,g=0,m=0,h=0,l=v.length;l>h;h++)a=v[h],g<=a.aX&&(g=a.aX),g+o>p&&(g=0),m<=a.aY&&(m=a.aY);d={ele:r,top:m,width:o,height:s,aY:m+s,aX:g+o},d[n.origin]=g,v.push(d)});var b,y,k=0;for(h=0,l=v.length;l>h;h++){for(a=v[h],m=0,u=0;h>u;u++)b=v[u],a[this.origin]-1&&(o=!0)})),r[o?"visible":"hidden"].push(e)}),r.hidden=t.$(r.hidden).map(function(){return this[0]}),r.visible=t.$(r.visible).map(function(){return this[0]}),r.hidden.attr("aria-hidden","true").filter(":visible").fadeOut(this.options.duration),r.visible.attr("aria-hidden","false").filter(":hidden").css("opacity",0).show(),e.update(r.visible),this.controls&&this.controls.length&&this.controls.find("[data-uk-filter]").removeClass("uk-active").filter('[data-uk-filter="'+i+'"]').addClass("uk-active")},sort:function(i,e){e=e||1,"string"==typeof e&&(e="desc"==e.toLowerCase()?-1:1);var n=this.element.children();n.sort(function(n,r){return n=t.$(n),r=t.$(r),(r.data(i)||"")<(n.data(i)||"")?e:-1*e}).appendTo(this.element),this.update(n.filter(":visible")),this.controls&&this.controls.length&&this.controls.find("[data-uk-sort]").removeClass("uk-active").filter('[data-uk-sort="'+i+":"+(-1==e?"desc":"asc")+'"]').addClass("uk-active")}})}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-grid",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";t.component("grid",{defaults:{colwidth:"auto",animation:!0,duration:300,gutter:0,controls:!1,filter:!1,origin:t.langdirection},boot:function(){t.ready(function(i){t.$("[data-uk-grid]",i).each(function(){var i=t.$(this);i.data("grid")||t.grid(i,t.Utils.options(i.attr("data-uk-grid")))})})},init:function(){var i=this,e=String(this.options.gutter).trim().split(" ");this.gutterv=parseInt(e[0],10),this.gutterh=parseInt(e[1]||e[0],10),this.element.css({position:"relative"}),this.controls=null,this.origin=this.options.origin,this.options.controls&&(this.controls=t.$(this.options.controls),this.controls.on("click","[data-uk-filter]",function(e){e.preventDefault(),i.filter(t.$(this).attr("data-uk-filter"))}),this.controls.on("click","[data-uk-sort]",function(e){e.preventDefault();var n=t.$(this).attr("data-uk-sort").split(":");i.sort(n[0],n[1])})),t.$win.on("load resize orientationchange",t.Utils.debounce(function(){i.currentfilter?i.filter(i.currentfilter):this.update()}.bind(this),100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.update()}),t.domObserve(this.element,function(){i.update()}),this.options.filter!==!1?this.filter(this.options.filter):this.update()},_prepareElements:function(){var t,i=this.element.children().not("[data-grid-prepared]");i.length&&(t={position:"absolute",boxSizing:"border-box",width:"auto"==this.options.colwidth?"":this.options.colwidth},this.options.gutter&&(t["padding-"+this.origin]=this.gutterh,t["padding-bottom"]=this.gutterv,this.element.css("margin-"+this.origin,-1*this.gutterh)),i.attr("data-grid-prepared","true").css(t))},update:function(i){var e=this;this._prepareElements(),i=i||this.element.children(":visible");var n,o,s,r,a,h,d,l,u,c=i,f=this.element.width()+2*this.gutterh+2,p=0,g=0,m=[];this.trigger("beforeupdate.uk.grid",[c]),c.each(function(){for(n=t.$(this),u=this.getBoundingClientRect(),o=u.width,s=u.height,p=0,g=0,h=0,l=m.length;l>h;h++)r=m[h],p<=r.aX&&(p=r.aX),p+o>f&&(p=0),g<=r.aY&&(g=r.aY);a={ele:n,top:g,width:o,height:s,aY:g+s,aX:p+o},a[e.origin]=p,m.push(a)});var v,k,b=0;for(h=0,l=m.length;l>h;h++){for(r=m[h],g=0,d=0;h>d;d++)v=m[d],r[this.origin]-1&&(s=!0)})),o[s?"visible":"hidden"].push(e)}),o.hidden=t.$(o.hidden).map(function(){return this[0]}),o.visible=t.$(o.visible).map(function(){return this[0]}),o.hidden.attr("aria-hidden","true").filter(":visible").fadeOut(this.options.duration),o.visible.attr("aria-hidden","false").filter(":hidden").css("opacity",0).show(),e.update(o.visible),this.controls&&this.controls.length&&this.controls.find("[data-uk-filter]").removeClass("uk-active").filter('[data-uk-filter="'+i+'"]').addClass("uk-active")},sort:function(i,e){e=e||1,"string"==typeof e&&(e="desc"==e.toLowerCase()?-1:1);var n=this.element.children();n.sort(function(n,o){return n=t.$(n),o=t.$(o),(o.data(i)||"")<(n.data(i)||"")?e:-1*e}).appendTo(this.element),this.update(n.filter(":visible")),this.controls&&this.controls.length&&this.controls.find("[data-uk-sort]").removeClass("uk-active").filter('[data-uk-sort="'+i+":"+(-1==e?"desc":"asc")+'"]').addClass("uk-active")}})}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/htmleditor.min.js b/lib/api/uikit/src/js/components/htmleditor.min.js index 38105854..14d99ebb 100755 --- a/lib/api/uikit/src/js/components/htmleditor.min.js +++ b/lib/api/uikit/src/js/components/htmleditor.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-htmleditor",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e=[];return t.component("htmleditor",{defaults:{iframe:!1,mode:"split",markdown:!1,autocomplete:!0,enablescripts:!1,height:500,maxsplitsize:1e3,codemirror:{mode:"htmlmixed",lineWrapping:!0,dragDrop:!1,autoCloseTags:!0,matchTags:!0,autoCloseBrackets:!0,matchBrackets:!0,indentUnit:4,indentWithTabs:!1,tabSize:4,hintOptions:{completionSingle:!1}},toolbar:["bold","italic","strike","link","image","blockquote","listUl","listOl"],lblPreview:"Preview",lblCodeview:"HTML",lblMarkedview:"Markdown"},boot:function(){t.ready(function(e){t.$("textarea[data-uk-htmleditor]",e).each(function(){var e=t.$(this);e.data("htmleditor")||t.htmleditor(e,t.Utils.options(e.attr("data-uk-htmleditor")))})})},init:function(){var i=this,o=t.components.htmleditor.template;this.CodeMirror=this.options.CodeMirror||CodeMirror,this.buttons={},o=o.replace(/\{:lblPreview}/g,this.options.lblPreview),o=o.replace(/\{:lblCodeview}/g,this.options.lblCodeview),this.htmleditor=t.$(o),this.content=this.htmleditor.find(".uk-htmleditor-content"),this.toolbar=this.htmleditor.find(".uk-htmleditor-toolbar"),this.preview=this.htmleditor.find(".uk-htmleditor-preview").children().eq(0),this.code=this.htmleditor.find(".uk-htmleditor-code"),this.element.before(this.htmleditor).appendTo(this.code),this.editor=this.CodeMirror.fromTextArea(this.element[0],this.options.codemirror),this.editor.htmleditor=this,this.editor.on("change",t.Utils.debounce(function(){i.render()},150)),this.editor.on("change",function(){i.editor.save(),i.element.trigger("input")}),this.code.find(".CodeMirror").css("height",this.options.height),this.options.iframe?(this.iframe=t.$(''),this.preview.append(this.iframe),this.iframe[0].contentWindow.document.open(),this.iframe[0].contentWindow.document.close(),this.preview.container=t.$(this.iframe[0].contentWindow.document).find("body"),"string"==typeof this.options.iframe&&this.preview.container.parent().append('')):this.preview.container=this.preview,t.$win.on("resize load",t.Utils.debounce(function(){i.fit()},200));var n=this.iframe?this.preview.container:i.preview.parent(),r=this.code.find(".CodeMirror-sizer"),l=this.code.find(".CodeMirror-scroll").on("scroll",t.Utils.debounce(function(){if("tab"!=i.htmleditor.attr("data-mode")){var t=r.height()-l.height(),e=n[0].scrollHeight-(i.iframe?i.iframe.height():n.height()),o=e/t,s=l.scrollTop()*o;n.scrollTop(s)}},10));this.htmleditor.on("click",".uk-htmleditor-button-code, .uk-htmleditor-button-preview",function(e){e.preventDefault(),"tab"==i.htmleditor.attr("data-mode")&&(i.htmleditor.find(".uk-htmleditor-button-code, .uk-htmleditor-button-preview").removeClass("uk-active").filter(this).addClass("uk-active"),i.activetab=t.$(this).hasClass("uk-htmleditor-button-code")?"code":"preview",i.htmleditor.attr("data-active-tab",i.activetab),i.editor.refresh())}),this.htmleditor.on("click","a[data-htmleditor-button]",function(){i.code.is(":visible")&&i.trigger("action."+t.$(this).data("htmleditor-button"),[i.editor])}),this.preview.parent().css("height",this.code.height()),this.options.autocomplete&&this.CodeMirror.showHint&&this.CodeMirror.hint&&this.CodeMirror.hint.html&&this.editor.on("inputRead",t.Utils.debounce(function(){var t=i.editor.getDoc(),e=t.getCursor(),o=i.CodeMirror.innerMode(i.editor.getMode(),i.editor.getTokenAt(e).state).mode.name;if("xml"==o){var n=i.editor.getCursor(),r=i.editor.getTokenAt(n);("<"==r.string.charAt(0)||"attribute"==r.type)&&i.CodeMirror.showHint(i.editor,i.CodeMirror.hint.html,{completeSingle:!1})}},100)),this.debouncedRedraw=t.Utils.debounce(function(){i.redraw()},5),this.on("init.uk.component",function(){i.debouncedRedraw()}),this.element.attr("data-uk-check-display",1).on("display.uk.check",function(){this.htmleditor.is(":visible")&&this.fit()}.bind(this)),e.push(this)},addButton:function(t,e){this.buttons[t]=e},addButtons:function(e){t.$.extend(this.buttons,e)},replaceInPreview:function(t,e){function i(t){var e=o.getValue().substring(0,t).split("\n");return{line:e.length-1,ch:e[e.length-1].length}}var o=this.editor,n=[],r=o.getValue(),l=-1,s=0;return this.currentvalue=this.currentvalue.replace(t,function(){l=r.indexOf(arguments[0],++l);var t={matches:arguments,from:i(l),to:i(l+arguments[0].length),replace:function(e){o.replaceRange(e,t.from,t.to)},inRange:function(e){return e.line===t.from.line&&e.line===t.to.line?e.ch>=t.from.ch&&e.ch=t.from.ch||e.line>t.from.line&&e.line'+t.buttons[i].label+"")}}),this.toolbar.html(e.join("\n"))}},fit:function(){var t=this.options.mode;"split"==t&&this.htmleditor.width())<[^<]*)*<\/(script|style)>/gim,"")),this.currentvalue?(this.trigger("render",[this]),this.trigger("renderLate",[this]),this.preview.container.html(this.currentvalue),void 0):(this.element.val(""),this.preview.container.html(""),void 0)},addShortcut:function(e,i){var o={};return t.$.isArray(e)||(e=[e]),e.forEach(function(t){o[t]=i}),this.editor.addKeyMap(o),o},addShortcutAction:function(t,e){var i=this;this.addShortcut(e,function(){i.element.trigger("action."+t,[i.editor])})},replaceSelection:function(t){var e=this.editor.getSelection();if(!e.length){for(var i=this.editor.getCursor(),o=this.editor.getLine(i.line),n=i.ch,r=n;r','
        ','
          ','
          ','","
          ","
          ",'
          ','
          ','
          ',"
          ","
          "].join(""),t.plugin("htmleditor","base",{init:function(e){function i(t,i,o){e.on("action."+t,function(){"html"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}e.addButtons({fullscreen:{title:"Fullscreen",label:''},bold:{title:"Bold",label:''},italic:{title:"Italic",label:''},strike:{title:"Strikethrough",label:''},blockquote:{title:"Blockquote",label:''},link:{title:"Link",label:''},image:{title:"Image",label:''},listUl:{title:"Unordered List",label:''},listOl:{title:"Ordered List",label:''}}),i("bold","$1"),i("italic","$1"),i("strike","$1"),i("blockquote","

          $1

          ","replaceLine"),i("link",'$1'),i("image",'$1');var o=function(t){if("html"==e.getCursorMode()){t=t||"ul";for(var i=e.editor,o=i.getDoc(),n=o.getCursor(!0),r=o.getCursor(!1),l=CodeMirror.innerMode(i.getMode(),i.getTokenAt(i.getCursor()).state),s=l&&l.state&&l.state.context&&-1!=["ul","ol"].indexOf(l.state.context.tagName),a=n.line;a"+i.getLine(a)+"",{line:a,ch:0},{line:a,ch:i.getLine(a).length});s?i.setCursor({line:r.line,ch:i.getLine(r.line).length}):(i.replaceRange("<"+t+">\n"+i.getLine(n.line),{line:n.line,ch:0},{line:n.line,ch:i.getLine(n.line).length}),i.replaceRange(i.getLine(r.line+1)+"\n",{line:r.line+1,ch:0},{line:r.line+1,ch:i.getLine(r.line+1).length}),i.setCursor({line:r.line+1,ch:i.getLine(r.line+1).length})),i.focus()}};e.on("action.listUl",function(){o("ul")}),e.on("action.listOl",function(){o("ol")}),e.htmleditor.on("click",'a[data-htmleditor-button="fullscreen"]',function(){e.htmleditor.toggleClass("uk-htmleditor-fullscreen");var i=e.editor.getWrapperElement();if(e.htmleditor.hasClass("uk-htmleditor-fullscreen")){var o=!1,n=e.htmleditor.parents().each(function(){"fixed"!=t.$(this).css("position")||t.$(this).is("html")||(o=t.$(this))});if(e.htmleditor.data("fixedParents",!1),o){var r=[];o=o.parent().find(n).each(function(){"none"!=t.$(this).css("transform")&&r.push(t.$(this).data("transform-reset",{transform:this.style.transform,"-webkit-transform":this.style.webkitTransform,"-webkit-transition":this.style.webkitTransition,transition:this.style.transition}).css({transform:"none","-webkit-transform":"none","-webkit-transition":"none",transition:"none"}))}),e.htmleditor.data("fixedParents",r)}e.editor.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:i.style.width,height:i.style.height},i.style.width="",i.style.height=e.content.height()+"px",document.documentElement.style.overflow="hidden"}else{document.documentElement.style.overflow="";var l=e.editor.state.fullScreenRestore;i.style.width=l.width,i.style.height=l.height,window.scrollTo(l.scrollLeft,l.scrollTop),e.htmleditor.data("fixedParents")&&e.htmleditor.data("fixedParents").forEach(function(t){t.css(t.data("transform-reset"))})}setTimeout(function(){e.fit(),t.$win.trigger("resize")},50)}),e.addShortcut(["Ctrl-S","Cmd-S"],function(){e.element.trigger("htmleditor-save",[e])}),e.addShortcutAction("bold",["Ctrl-B","Cmd-B"])}}),t.plugin("htmleditor","markdown",{init:function(e){function i(){e.editor.setOption("mode","gfm"),e.htmleditor.find(".uk-htmleditor-button-code a").html(e.options.lblMarkedview)}function o(t,i,o){e.on("action."+t,function(){"markdown"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}var n=e.options.mdparser||window.marked||null;n&&(e.options.markdown&&i(),o("bold","**$1**"),o("italic","*$1*"),o("strike","~~$1~~"),o("blockquote","> $1","replaceLine"),o("link","[$1](http://)"),o("image","![$1](http://)"),e.on("action.listUl",function(){if("markdown"==e.getCursorMode()){for(var t=e.editor,i=t.getDoc().getCursor(!0),o=t.getDoc().getCursor(!1),n=i.line;n0){var r,l=t.getLine(i.line-1);(r=l.match(/^(\d+)\./))&&(n=Number(r[1])+1)}for(var s=i.line;s'),this.preview.append(this.iframe),this.iframe[0].contentWindow.document.open(),this.iframe[0].contentWindow.document.close(),this.preview.container=t.$(this.iframe[0].contentWindow.document).find("body"),"string"==typeof this.options.iframe&&this.preview.container.parent().append('')):this.preview.container=this.preview,t.$win.on("resize load",t.Utils.debounce(function(){i.fit()},200));var n=this.iframe?this.preview.container:i.preview.parent(),r=this.code.find(".CodeMirror-sizer"),l=this.code.find(".CodeMirror-scroll").on("scroll",t.Utils.debounce(function(){if("tab"!=i.htmleditor.attr("data-mode")){var t=r.height()-l.height(),e=n[0].scrollHeight-(i.iframe?i.iframe.height():n.height()),o=e/t,s=l.scrollTop()*o;n.scrollTop(s)}},10));this.htmleditor.on("click",".uk-htmleditor-button-code, .uk-htmleditor-button-preview",function(e){e.preventDefault(),"tab"==i.htmleditor.attr("data-mode")&&(i.htmleditor.find(".uk-htmleditor-button-code, .uk-htmleditor-button-preview").removeClass("uk-active").filter(this).addClass("uk-active"),i.activetab=t.$(this).hasClass("uk-htmleditor-button-code")?"code":"preview",i.htmleditor.attr("data-active-tab",i.activetab),i.editor.refresh())}),this.htmleditor.on("click","a[data-htmleditor-button]",function(){i.code.is(":visible")&&i.trigger("action."+t.$(this).data("htmleditor-button"),[i.editor])}),this.preview.parent().css("height",this.code.height()),this.options.autocomplete&&this.CodeMirror.showHint&&this.CodeMirror.hint&&this.CodeMirror.hint.html&&this.editor.on("inputRead",t.Utils.debounce(function(){var t=i.editor.getDoc(),e=t.getCursor(),o=i.CodeMirror.innerMode(i.editor.getMode(),i.editor.getTokenAt(e).state).mode.name;if("xml"==o){var n=i.editor.getCursor(),r=i.editor.getTokenAt(n);("<"==r.string.charAt(0)||"attribute"==r.type)&&i.CodeMirror.showHint(i.editor,i.CodeMirror.hint.html,{completeSingle:!1})}},100)),this.debouncedRedraw=t.Utils.debounce(function(){i.redraw()},5),this.on("init.uk.component",function(){i.debouncedRedraw()}),this.element.attr("data-uk-check-display",1).on("display.uk.check",function(){this.htmleditor.is(":visible")&&this.fit()}.bind(this)),e.push(this)},addButton:function(t,e){this.buttons[t]=e},addButtons:function(e){t.$.extend(this.buttons,e)},replaceInPreview:function(t,e){function i(t){var e=o.getValue().substring(0,t).split("\n");return{line:e.length-1,ch:e[e.length-1].length}}var o=this.editor,n=[],r=o.getValue(),l=-1,s=0;return this.currentvalue=this.currentvalue.replace(t,function(){l=r.indexOf(arguments[0],++l);var t={matches:arguments,from:i(l),to:i(l+arguments[0].length),replace:function(e){o.replaceRange(e,t.from,t.to)},inRange:function(e){return e.line===t.from.line&&e.line===t.to.line?e.ch>=t.from.ch&&e.ch=t.from.ch||e.line>t.from.line&&e.line'+t.buttons[i].label+"")}}),this.toolbar.html(e.join("\n"))}},fit:function(){var t=this.options.mode;"split"==t&&this.htmleditor.width())<[^<]*)*<\/(script|style)>/gim,"")),this.currentvalue?(this.trigger("render",[this]),this.trigger("renderLate",[this]),this.preview.container.html(this.currentvalue),void 0):(this.element.val(""),this.preview.container.html(""),void 0)},addShortcut:function(e,i){var o={};return t.$.isArray(e)||(e=[e]),e.forEach(function(t){o[t]=i}),this.editor.addKeyMap(o),o},addShortcutAction:function(t,e){var i=this;this.addShortcut(e,function(){i.element.trigger("action."+t,[i.editor])})},replaceSelection:function(t){var e=this.editor.getSelection();if(!e.length){for(var i=this.editor.getCursor(),o=this.editor.getLine(i.line),n=i.ch,r=n;r','
          ','
            ','
            ','","
            ","
            ",'
            ','
            ','
            ',"
            ","
            "].join(""),t.plugin("htmleditor","base",{init:function(e){function i(t,i,o){e.on("action."+t,function(){"html"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}e.addButtons({fullscreen:{title:"Fullscreen",label:''},bold:{title:"Bold",label:''},italic:{title:"Italic",label:''},strike:{title:"Strikethrough",label:''},blockquote:{title:"Blockquote",label:''},link:{title:"Link",label:''},image:{title:"Image",label:''},listUl:{title:"Unordered List",label:''},listOl:{title:"Ordered List",label:''}}),i("bold","$1"),i("italic","$1"),i("strike","$1"),i("blockquote","

            $1

            ","replaceLine"),i("link",'$1'),i("image",'$1');var o=function(t){if("html"==e.getCursorMode()){t=t||"ul";for(var i=e.editor,o=i.getDoc(),n=o.getCursor(!0),r=o.getCursor(!1),l=CodeMirror.innerMode(i.getMode(),i.getTokenAt(i.getCursor()).state),s=l&&l.state&&l.state.context&&-1!=["ul","ol"].indexOf(l.state.context.tagName),a=n.line;a"+i.getLine(a)+"",{line:a,ch:0},{line:a,ch:i.getLine(a).length});s?i.setCursor({line:r.line,ch:i.getLine(r.line).length}):(i.replaceRange("<"+t+">\n"+i.getLine(n.line),{line:n.line,ch:0},{line:n.line,ch:i.getLine(n.line).length}),i.replaceRange(i.getLine(r.line+1)+"\n",{line:r.line+1,ch:0},{line:r.line+1,ch:i.getLine(r.line+1).length}),i.setCursor({line:r.line+1,ch:i.getLine(r.line+1).length})),i.focus()}};e.on("action.listUl",function(){o("ul")}),e.on("action.listOl",function(){o("ol")}),e.htmleditor.on("click",'a[data-htmleditor-button="fullscreen"]',function(){e.htmleditor.toggleClass("uk-htmleditor-fullscreen");var i=e.editor.getWrapperElement();if(e.htmleditor.hasClass("uk-htmleditor-fullscreen")){var o=!1,n=e.htmleditor.parents().each(function(){"fixed"!=t.$(this).css("position")||t.$(this).is("html")||(o=t.$(this))});if(e.htmleditor.data("fixedParents",!1),o){var r=[];o=o.parent().find(n).each(function(){"none"!=t.$(this).css("transform")&&r.push(t.$(this).data("transform-reset",{transform:this.style.transform,"-webkit-transform":this.style.webkitTransform,"-webkit-transition":this.style.webkitTransition,transition:this.style.transition}).css({transform:"none","-webkit-transform":"none","-webkit-transition":"none",transition:"none"}))}),e.htmleditor.data("fixedParents",r)}e.editor.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:i.style.width,height:i.style.height},i.style.width="",i.style.height=e.content.height()+"px",document.documentElement.style.overflow="hidden"}else{document.documentElement.style.overflow="";var l=e.editor.state.fullScreenRestore;i.style.width=l.width,i.style.height=l.height,window.scrollTo(l.scrollLeft,l.scrollTop),e.htmleditor.data("fixedParents")&&e.htmleditor.data("fixedParents").forEach(function(t){t.css(t.data("transform-reset"))})}setTimeout(function(){e.fit(),t.$win.trigger("resize")},50)}),e.addShortcut(["Ctrl-S","Cmd-S"],function(){e.element.trigger("htmleditor-save",[e])}),e.addShortcutAction("bold",["Ctrl-B","Cmd-B"])}}),t.plugin("htmleditor","markdown",{init:function(e){function i(){e.editor.setOption("mode","gfm"),e.htmleditor.find(".uk-htmleditor-button-code a").html(e.options.lblMarkedview)}function o(t,i,o){e.on("action."+t,function(){"markdown"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}var n=e.options.mdparser||window.marked||null;n&&(e.options.markdown&&i(),o("bold","**$1**"),o("italic","*$1*"),o("strike","~~$1~~"),o("blockquote","> $1","replaceLine"),o("link","[$1](http://)"),o("image","![$1](http://)"),e.on("action.listUl",function(){if("markdown"==e.getCursorMode()){for(var t=e.editor,i=t.getDoc().getCursor(!0),o=t.getDoc().getCursor(!1),n=i.line;n0){var r,l=t.getLine(i.line-1);(r=l.match(/^(\d+)\./))&&(n=Number(r[1])+1)}for(var s=i.line;s','
            ','','
            ','
            ',"
            ","
            "].join("")).appendTo("body"),e.dialog=e.find(".uk-modal-dialog:first"),e.content=e.find(".uk-lightbox-content:first"),e.loader=e.find(".uk-modal-spinner:first"),e.closer=e.find(".uk-close.uk-close-alt"),e.modal=i.modal(e,{modal:!1}),e.on("swipeRight swipeLeft",function(i){e.lightbox["swipeLeft"==i.type?"next":"previous"]()}).on("click","[data-lightbox-previous], [data-lightbox-next]",function(t){t.preventDefault(),e.lightbox[i.$(this).is("[data-lightbox-next]")?"next":"previous"]()}),e.on("hide.uk.modal",function(){e.content.html("")});var o={w:window.innerWidth,h:window.innerHeight};return i.$win.on("load resize orientationchange",i.Utils.debounce(function(){o.w!==window.innerWidth&&e.is(":visible")&&!i.Utils.isFullscreen()&&e.lightbox.fitSize(),o={w:window.innerWidth,h:window.innerHeight}},100)),e.lightbox=t,e}var e,o={};return i.component("lightbox",{defaults:{allowfullscreen:!0,duration:400,group:!1,keyboard:!0},index:0,items:!1,boot:function(){i.$html.on("click","[data-uk-lightbox]",function(t){t.preventDefault();var e=i.$(this);e.data("lightbox")||i.lightbox(e,i.Utils.options(e.attr("data-uk-lightbox"))),e.data("lightbox").show(e)}),i.$doc.on("keyup",function(i){if(e&&e.is(":visible")&&e.lightbox.options.keyboard)switch(i.preventDefault(),i.keyCode){case 37:e.lightbox.previous();break;case 39:e.lightbox.next()}})},init:function(){var t=[];if(this.index=0,this.siblings=[],this.element&&this.element.length){var e=this.options.group?i.$(['[data-uk-lightbox*="'+this.options.group+'"]',"[data-uk-lightbox*='"+this.options.group+"']"].join(",")):this.element;e.each(function(){var e=i.$(this);t.push({source:e.attr("href"),title:e.attr("data-title")||e.attr("title"),type:e.attr("data-lightbox-type")||"auto",link:e})}),this.index=e.index(this.element),this.siblings=t}else this.options.group&&this.options.group.length&&(this.siblings=this.options.group);this.trigger("lightbox-init",[this])},show:function(e){this.modal=t(this),this.modal.dialog.stop(),this.modal.content.stop();var o,n,s=this,h=i.$.Deferred();e=e||0,"object"==typeof e&&this.siblings.forEach(function(i,t){e[0]===i.link[0]&&(e=t)}),0>e?e=this.siblings.length-e:this.siblings[e]||(e=0),n=this.siblings[e],o={lightbox:s,source:n.source,type:n.type,index:e,promise:h,title:n.title,item:n,meta:{content:"",width:null,height:null}},this.index=e,this.modal.content.empty(),this.modal.is(":visible")||(this.modal.content.css({width:"",height:""}).empty(),this.modal.modal.show()),this.modal.loader.removeClass("uk-hidden"),h.promise().done(function(){s.data=o,s.fitSize(o)}).fail(function(){o.meta.content='
            Loading resource failed!
            ',o.meta.width=400,o.meta.height=300,s.data=o,s.fitSize(o)}),s.trigger("showitem.uk.lightbox",[o])},fitSize:function(){var t=this,e=this.data,o=this.modal.dialog.outerWidth()-this.modal.dialog.width(),n=parseInt(this.modal.dialog.css("margin-top"),10),s=parseInt(this.modal.dialog.css("margin-bottom"),10),h=n+s,a=e.meta.content,l=t.options.duration;this.siblings.length>1&&(a=[a,'',''].join(""));var d,r,u=i.$("
             
            ").css({opacity:0,position:"absolute",top:0,left:0,width:"100%","max-width":t.modal.dialog.css("max-width"),padding:t.modal.dialog.css("padding"),margin:t.modal.dialog.css("margin")}),c=e.meta.width,g=e.meta.height;u.appendTo("body").width(),d=u.width(),r=window.innerHeight-h,u.remove(),this.modal.dialog.find(".uk-modal-caption").remove(),e.title&&(this.modal.dialog.append('
            '+e.title+"
            "),r-=this.modal.dialog.find(".uk-modal-caption").outerHeight()),dr&&(g=Math.floor(r),c=Math.ceil(e.meta.width*(r/e.meta.height))),this.modal.content.css("opacity",0).width(c).html(a),"iframe"==e.type&&this.modal.content.find("iframe:first").height(g);var m=g+o,p=Math.floor(window.innerHeight/2-m/2)-h;0>p&&(p=0),this.modal.closer.addClass("uk-hidden"),t.modal.data("mwidth")==c&&t.modal.data("mheight")==g&&(l=0),this.modal.dialog.animate({width:c+o,height:g+o,top:p},l,"swing",function(){t.modal.loader.addClass("uk-hidden"),t.modal.content.css({width:""}).animate({opacity:1},function(){t.modal.closer.removeClass("uk-hidden")}),t.modal.data({mwidth:c,mheight:g})})},next:function(){this.show(this.siblings[this.index+1]?this.index+1:0)},previous:function(){this.show(this.siblings[this.index-1]?this.index-1:this.siblings.length-1)}}),i.plugin("lightbox","image",{init:function(i){i.on("showitem.uk.lightbox",function(i,t){if("image"==t.type||t.source&&t.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)){var e=function(i,e,o){t.meta={content:'',width:e,height:o},t.type="image",t.promise.resolve()};if(o[t.source])e(t.source,o[t.source].width,o[t.source].height);else{var n=new Image;n.onerror=function(){t.promise.reject("Loading image failed")},n.onload=function(){o[t.source]={width:n.width,height:n.height},e(t.source,o[t.source].width,o[t.source].height)},n.src=t.source}}})}}),i.plugin("lightbox","youtube",{init:function(i){var t=/(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,n=/youtu\.be\/(.*)/;i.on("showitem.uk.lightbox",function(i,s){var h,a,l=function(i,t,o){s.meta={content:'",width:t,height:o},s.type="iframe",s.promise.resolve()};if((a=s.source.match(t))&&(h=a[2]),(a=s.source.match(n))&&(h=a[1]),h){if(o[h])l(h,o[h].width,o[h].height);else{var d=new Image,r=!1;d.onerror=function(){o[h]={width:640,height:320},l(h,o[h].width,o[h].height)},d.onload=function(){120==d.width&&90==d.height?r?(o[h]={width:640,height:320},l(h,o[h].width,o[h].height)):(r=!0,d.src="//img.youtube.com/vi/"+h+"/0.jpg"):(o[h]={width:d.width,height:d.height},l(h,d.width,d.height))},d.src="//img.youtube.com/vi/"+h+"/maxresdefault.jpg"}i.stopImmediatePropagation()}})}}),i.plugin("lightbox","vimeo",{init:function(t){var n,s=/(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/;t.on("showitem.uk.lightbox",function(t,h){var a,l=function(i,t,o){h.meta={content:'",width:t,height:o},h.type="iframe",h.promise.resolve()};(n=h.source.match(s))&&(a=n[2],o[a]?l(a,o[a].width,o[a].height):i.$.ajax({type:"GET",url:"//vimeo.com/api/oembed.json?url="+encodeURI(h.source),jsonp:"callback",dataType:"jsonp",success:function(i){o[a]={width:i.width,height:i.height},l(a,o[a].width,o[a].height)}}),t.stopImmediatePropagation())})}}),i.plugin("lightbox","video",{init:function(t){t.on("showitem.uk.lightbox",function(t,e){var n=function(i,t,o){e.meta={content:'',width:t,height:o},e.type="video",e.promise.resolve()};if("video"==e.type||e.source.match(/\.(mp4|webm|ogv)$/i))if(o[e.source])n(e.source,o[e.source].width,o[e.source].height);else var s=i.$('').attr("src",e.source).appendTo("body"),h=setInterval(function(){s[0].videoWidth&&(clearInterval(h),o[e.source]={width:s[0].videoWidth,height:s[0].videoHeight},n(e.source,o[e.source].width,o[e.source].height),s.remove())},20)})}}),UIkit.plugin("lightbox","iframe",{init:function(i){i.on("showitem.uk.lightbox",function(t,o){var n=function(i,t,n){o.meta={content:'",width:t,height:n},o.type="iframe",o.promise.resolve()};("iframe"===o.type||o.source.match(/\.(html|php)$/))&&n(o.source,i.options.width||800,i.options.height||600)})}}),i.lightbox.create=function(t,e){if(t){var o,n=[];return t.forEach(function(t){n.push(i.$.extend({source:"",title:"",type:"auto",link:!1},"string"==typeof t?{source:t}:t))}),o=i.lightbox(i.$.extend({},e,{group:n}))}},i.lightbox}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){var t;window.UIkit2&&(t=i(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-lightbox",["uikit"],function(){return t||i(UIkit2)})}(function(i){"use strict";function t(t){if(e)return e.lightbox=t,e;e=i.$(['
            ','
            ','','
            ','
            ',"
            ","
            "].join("")).appendTo("body"),e.dialog=e.find(".uk-modal-dialog:first"),e.content=e.find(".uk-lightbox-content:first"),e.loader=e.find(".uk-modal-spinner:first"),e.closer=e.find(".uk-close.uk-close-alt"),e.modal=i.modal(e,{modal:!1}),e.on("swipeRight swipeLeft",function(i){e.lightbox["swipeLeft"==i.type?"next":"previous"]()}).on("click","[data-lightbox-previous], [data-lightbox-next]",function(t){t.preventDefault(),e.lightbox[i.$(this).is("[data-lightbox-next]")?"next":"previous"]()}),e.on("hide.uk.modal",function(){e.content.html("")});var o={w:window.innerWidth,h:window.innerHeight};return i.$win.on("load resize orientationchange",i.Utils.debounce(function(){o.w!==window.innerWidth&&e.is(":visible")&&!i.Utils.isFullscreen()&&e.lightbox.fitSize(),o={w:window.innerWidth,h:window.innerHeight}},100)),e.lightbox=t,e}var e,o={};return i.component("lightbox",{defaults:{allowfullscreen:!0,duration:400,group:!1,keyboard:!0},index:0,items:!1,boot:function(){i.$html.on("click","[data-uk-lightbox]",function(t){t.preventDefault();var e=i.$(this);e.data("lightbox")||i.lightbox(e,i.Utils.options(e.attr("data-uk-lightbox"))),e.data("lightbox").show(e)}),i.$doc.on("keyup",function(i){if(e&&e.is(":visible")&&e.lightbox.options.keyboard)switch(i.preventDefault(),i.keyCode){case 37:e.lightbox.previous();break;case 39:e.lightbox.next()}})},init:function(){var t=[];if(this.index=0,this.siblings=[],this.element&&this.element.length){var e=this.options.group?i.$('[data-uk-lightbox*="'+this.options.group+'"]'):this.element;e.each(function(){var e=i.$(this);t.push({source:e.attr("href"),title:e.attr("data-title")||e.attr("title"),type:e.attr("data-lightbox-type")||"auto",link:e})}),this.index=e.index(this.element),this.siblings=t}else this.options.group&&this.options.group.length&&(this.siblings=this.options.group);this.trigger("lightbox-init",[this])},show:function(e){this.modal=t(this),this.modal.dialog.stop(),this.modal.content.stop();var o,n,s=this,h=i.$.Deferred();e=e||0,"object"==typeof e&&this.siblings.forEach(function(i,t){e[0]===i.link[0]&&(e=t)}),0>e?e=this.siblings.length-e:this.siblings[e]||(e=0),n=this.siblings[e],o={lightbox:s,source:n.source,type:n.type,index:e,promise:h,title:n.title,item:n,meta:{content:"",width:null,height:null}},this.index=e,this.modal.content.empty(),this.modal.is(":visible")||(this.modal.content.css({width:"",height:""}).empty(),this.modal.modal.show()),this.modal.loader.removeClass("uk-hidden"),h.promise().done(function(){s.data=o,s.fitSize(o)}).fail(function(){o.meta.content='
            Loading resource failed!
            ',o.meta.width=400,o.meta.height=300,s.data=o,s.fitSize(o)}),s.trigger("showitem.uk.lightbox",[o])},fitSize:function(){var t=this,e=this.data,o=this.modal.dialog.outerWidth()-this.modal.dialog.width(),n=parseInt(this.modal.dialog.css("margin-top"),10),s=parseInt(this.modal.dialog.css("margin-bottom"),10),h=n+s,a=e.meta.content,l=t.options.duration;this.siblings.length>1&&(a=[a,'',''].join(""));var d,r,u=i.$("
             
            ").css({opacity:0,position:"absolute",top:0,left:0,width:"100%",maxWidth:t.modal.dialog.css("max-width"),padding:t.modal.dialog.css("padding"),margin:t.modal.dialog.css("margin")}),c=e.meta.width,g=e.meta.height;u.appendTo("body").width(),d=u.width(),r=window.innerHeight-h,u.remove(),this.modal.dialog.find(".uk-modal-caption").remove(),e.title&&(this.modal.dialog.append('
            '+e.title+"
            "),r-=this.modal.dialog.find(".uk-modal-caption").outerHeight()),dr&&(g=Math.floor(r),c=Math.ceil(e.meta.width*(r/e.meta.height))),this.modal.content.css("opacity",0).width(c).html(a),"iframe"==e.type&&this.modal.content.find("iframe:first").height(g);var m=g+o,p=Math.floor(window.innerHeight/2-m/2)-h;0>p&&(p=0),this.modal.closer.addClass("uk-hidden"),t.modal.data("mwidth")==c&&t.modal.data("mheight")==g&&(l=0),this.modal.dialog.animate({width:c+o,height:g+o,top:p},l,"swing",function(){t.modal.loader.addClass("uk-hidden"),t.modal.content.css({width:""}).animate({opacity:1},function(){t.modal.closer.removeClass("uk-hidden")}),t.modal.data({mwidth:c,mheight:g})})},next:function(){this.show(this.siblings[this.index+1]?this.index+1:0)},previous:function(){this.show(this.siblings[this.index-1]?this.index-1:this.siblings.length-1)}}),i.plugin("lightbox","image",{init:function(i){i.on("showitem.uk.lightbox",function(i,t){if("image"==t.type||t.source&&t.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)){var e=function(i,e,o){t.meta={content:'',width:e,height:o},t.type="image",t.promise.resolve()};if(o[t.source])e(t.source,o[t.source].width,o[t.source].height);else{var n=new Image;n.onerror=function(){t.promise.reject("Loading image failed")},n.onload=function(){o[t.source]={width:n.width,height:n.height},e(t.source,o[t.source].width,o[t.source].height)},n.src=t.source}}})}}),i.plugin("lightbox","youtube",{init:function(i){var t=/(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,n=/youtu\.be\/(.*)/;i.on("showitem.uk.lightbox",function(i,s){var h,a,l=function(i,t,o){s.meta={content:'",width:t,height:o},s.type="iframe",s.promise.resolve()};if((a=s.source.match(t))&&(h=a[2]),(a=s.source.match(n))&&(h=a[1]),h){if(o[h])l(h,o[h].width,o[h].height);else{var d=new Image,r=!1;d.onerror=function(){o[h]={width:640,height:320},l(h,o[h].width,o[h].height)},d.onload=function(){120==d.width&&90==d.height?r?(o[h]={width:640,height:320},l(h,o[h].width,o[h].height)):(r=!0,d.src="//img.youtube.com/vi/"+h+"/0.jpg"):(o[h]={width:d.width,height:d.height},l(h,d.width,d.height))},d.src="//img.youtube.com/vi/"+h+"/maxresdefault.jpg"}i.stopImmediatePropagation()}})}}),i.plugin("lightbox","vimeo",{init:function(t){var n,s=/(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/;t.on("showitem.uk.lightbox",function(t,h){var a,l=function(i,t,o){h.meta={content:'",width:t,height:o},h.type="iframe",h.promise.resolve()};(n=h.source.match(s))&&(a=n[2],o[a]?l(a,o[a].width,o[a].height):i.$.ajax({type:"GET",url:"//vimeo.com/api/oembed.json?url="+encodeURI(h.source),jsonp:"callback",dataType:"jsonp",success:function(i){o[a]={width:i.width,height:i.height},l(a,o[a].width,o[a].height)}}),t.stopImmediatePropagation())})}}),i.plugin("lightbox","video",{init:function(t){t.on("showitem.uk.lightbox",function(t,e){var n=function(i,t,o){e.meta={content:'',width:t,height:o},e.type="video",e.promise.resolve()};if("video"==e.type||e.source.match(/\.(mp4|webm|ogv)$/i))if(o[e.source])n(e.source,o[e.source].width,o[e.source].height);else var s=i.$('').attr("src",e.source).appendTo("body"),h=setInterval(function(){s[0].videoWidth&&(clearInterval(h),o[e.source]={width:s[0].videoWidth,height:s[0].videoHeight},n(e.source,o[e.source].width,o[e.source].height),s.remove())},20)})}}),i.plugin("lightbox","iframe",{init:function(i){i.on("showitem.uk.lightbox",function(t,o){var n=function(i,t,n){o.meta={content:'",width:t,height:n},o.type="iframe",o.promise.resolve()};("iframe"===o.type||o.source.match(/\.(html|php)$/))&&n(o.source,i.options.width||800,i.options.height||600)})}}),i.lightbox.create=function(t,e){if(t){var o,n=[];return t.forEach(function(t){n.push(i.$.extend({source:"",title:"",type:"auto",link:!1},"string"==typeof t?{source:t}:t))}),o=i.lightbox(i.$.extend({},e,{group:n}))}},i.lightbox}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/nestable.min.js b/lib/api/uikit/src/js/components/nestable.min.js index f6151412..b22bf131 100755 --- a/lib/api/uikit/src/js/components/nestable.min.js +++ b/lib/api/uikit/src/js/components/nestable.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var s;window.UIkit&&(s=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-nestable",["uikit"],function(){return s||t(UIkit)})}(function(t){"use strict";var s,e="ontouchstart"in window,i=t.$html,l=[],a=t.$win,n=e?"touchstart":"mousedown",o=e?"touchmove":"mousemove",h=e?"touchend":"mouseup",r=e?"touchcancel":"mouseup";return t.component("nestable",{defaults:{listBaseClass:"uk-nestable",listClass:"uk-nestable-list",listItemClass:"uk-nestable-item",dragClass:"uk-nestable-dragged",movingClass:"uk-nestable-moving",noChildrenClass:"uk-nestable-nochildren",emptyClass:"uk-nestable-empty",handleClass:"",collapsedClass:"uk-collapsed",placeholderClass:"uk-nestable-placeholder",noDragClass:"uk-nestable-nodrag",group:!1,maxDepth:10,threshold:20,idlethreshold:10},boot:function(){t.$html.on("mousemove touchmove",function(){if(s){var e=s.offset().top;ewindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(s.height()/2))}}),t.ready(function(s){t.$("[data-uk-nestable]",s).each(function(){var s=t.$(this);s.data("nestable")||t.nestable(s,t.Utils.options(s.attr("data-uk-nestable")))})})},init:function(){var i=this;Object.keys(this.options).forEach(function(t){-1!=String(t).indexOf("Class")&&(i.options["_"+t]="."+i.options[t])}),this.find(this.options._listItemClass).find(">ul").addClass(this.options.listClass),this.checkEmptyList(),this.reset(),this.element.data("nestable-group",this.options.group||t.Utils.uid("nestable-group")),this.find(this.options._listItemClass).each(function(){i.setParent(t.$(this))}),this.on("click","[data-nestable-action]",function(s){if(!i.dragEl&&(e||0===s.button)){s.preventDefault();var l=t.$(s.currentTarget),a=l.data("nestableAction"),n=l.closest(i.options._listItemClass);"collapse"===a&&i.collapseItem(n),"expand"===a&&i.expandItem(n),"toggle"===a&&i.toggleItem(n)}});var l=function(s){var l=t.$(s.target),a=l.is("a[href]")?l:l.parents("a[href]");s.target!==i.element[0]&&(l.is(i.options._noDragClass)||l.closest(i.options._noDragClass).length||l.is("[data-nestable-action]")||l.closest("[data-nestable-action]").length||(i.options.handleClass&&!l.hasClass(i.options.handleClass)&&i.options.handleClass&&(l=l.closest(i.options._handleClass)),!l.length||i.dragEl||!e&&0!==s.button||e&&1!==s.touches.length||(s.originalEvent&&s.originalEvent.touches&&(s=evt.originalEvent.touches[0]),i.delayMove=function(t){a=!1,t.preventDefault(),i.dragStart(s),i.trigger("start.uk.nestable",[i]),i.delayMove=!1},i.delayMove.x=parseInt(s.pageX,10),i.delayMove.y=parseInt(s.pageY,10),i.delayMove.threshold=i.options.idlethreshold,a.length&&"touchend"==h&&i.one(h,function(){a&&a.attr("href").trim()&&(location.href=a.attr("href"))}),s.preventDefault())))},d=function(t){t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i.delayMove&&(Math.abs(t.pageX-i.delayMove.x)>i.delayMove.threshold||Math.abs(t.pageY-i.delayMove.y)>i.delayMove.threshold)&&(window.getSelection().toString()?i.delayMove=!1:i.delayMove(t)),i.dragEl&&(t.preventDefault(),i.dragMove(t),i.trigger("move.uk.nestable",[i]))},p=function(t){i.dragEl&&(t.preventDefault(),i.dragStop(e?t.touches[0]:t)),s=!1,i.delayMove=!1};e?(this.element[0].addEventListener(n,l,!1),window.addEventListener(o,d,!1),window.addEventListener(h,p,!1),window.addEventListener(r,p,!1)):(this.on(n,l),a.on(o,d),a.on(h,p))},serialize:function(){var s,e=0,i=this,l=function(s,e){var a=[],n=s.children(i.options._listItemClass);return n.each(function(){for(var s,n,o,h=t.$(this),r={},d=h.children(i.options._listClass),p=0;p").addClass(this.options.listClass+" "+this.options.dragClass).append(n.clone()),this.dragEl.css("width",n.width()),this.placeEl.addClass(this.options.placeholderClass),s=this.dragEl,this.tmpDragOnSiblings=[n[0].previousSibling,n[0].nextSibling],t.$body.append(this.dragEl),this.dragEl.css({left:o.left,top:o.top});var h,r,d=this.dragEl.find(this.options._listItemClass);for(h=0;hthis.dragDepth&&(this.dragDepth=r);i.addClass(this.options.movingClass)},dragStop:function(){var s=t.$(this.placeEl),e=this.placeEl.parents(this.options._listBaseClass+":first");this.placeEl.removeClass(this.options.placeholderClass),this.dragEl.remove(),this.element[0]!==e[0]?(e.trigger("change.uk.nestable",[e.data("nestable"),s,"added"]),this.element.trigger("change.uk.nestable",[this,s,"removed"])):this.element.trigger("change.uk.nestable",[this,s,"moved"]),this.trigger("stop.uk.nestable",[this,s]),this.reset(),i.removeClass(this.options.movingClass)},dragMove:function(s){var e,i,a,n,o,h=this.options,r=this.mouse,d=this.dragRootEl?this.dragRootEl.data("nestable").options.maxDepth:h.maxDepth;this.dragEl.css({left:s.pageX-r.offsetX,top:s.pageY-r.offsetY}),r.lastX=r.nowX,r.lastY=r.nowY,r.nowX=s.pageX,r.nowY=s.pageY,r.distX=r.nowX-r.lastX,r.distY=r.nowY-r.lastY,r.lastDirX=r.dirX,r.lastDirY=r.dirY,r.dirX=0===r.distX?0:r.distX>0?1:-1,r.dirY=0===r.distY?0:r.distY>0?1:-1;var p=Math.abs(r.distX)>Math.abs(r.distY)?1:0;if(!r.moving)return r.dirAx=p,r.moving=!0,void 0;if(r.dirAx!==p?(r.distAxX=0,r.distAxY=0):(r.distAxX+=Math.abs(r.distX),0!==r.dirX&&r.dirX!==r.lastDirX&&(r.distAxX=0),r.distAxY+=Math.abs(r.distY),0!==r.dirY&&r.dirY!==r.lastDirY&&(r.distAxY=0)),r.dirAx=p,r.dirAx&&r.distAxX>=h.threshold&&(r.distAxX=0,a=this.placeEl.prev("li"),r.distX>0&&a.length&&!a.hasClass(h.collapsedClass)&&!a.hasClass(h.noChildrenClass)&&(e=a.find(h._listClass).last(),o=this.placeEl.parents(h._listClass+","+h._listBaseClass).length,o+this.dragDepth<=d&&(e.length?(e=a.children(h._listClass).last(),e.append(this.placeEl)):(e=t.$("
              ").addClass(h.listClass),e.append(this.placeEl),a.append(e),this.setParent(a)))),r.distX<0&&(n=this.placeEl.next(h._listItemClass),!n.length))){var c=this.placeEl.closest([h._listBaseClass,h._listClass].join(",")),g=c.closest(h._listItemClass);g.length&&(g.after(this.placeEl),c.children().length||this.unsetParent(g))}var u=!1,f=s.pageX-(window.pageXOffset||document.scrollLeft||0),m=s.pageY-(window.pageYOffset||document.documentElement.scrollTop);if(this.pointEl=t.$(document.elementFromPoint(f,m)),h.handleClass&&this.pointEl.hasClass(h.handleClass))this.pointEl=this.pointEl.closest(h._listItemClass);else{var C=this.pointEl.closest(h._listItemClass);C.length&&(this.pointEl=C)}if(!this.placeEl.find(this.pointEl).length){if(this.pointEl.data("nestable")&&!this.pointEl.children().length)u=!0,this.checkEmptyList(this.pointEl);else if(!this.pointEl.length||!this.pointEl.hasClass(h.listItemClass))return;var v=this.element,E=this.pointEl.closest(this.options._listBaseClass),b=v[0]!=E[0];if(!r.dirAx||b||u){if(b&&h.group!==E.data("nestable-group"))return;if(l.push(v),o=this.dragDepth-1+this.pointEl.parents(h._listClass+","+h._listBaseClass).length,o>d)return;var X=s.pageYwindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(s.height()/2))}}),t.ready(function(s){t.$("[data-uk-nestable]",s).each(function(){var s=t.$(this);s.data("nestable")||t.nestable(s,t.Utils.options(s.attr("data-uk-nestable")))})})},init:function(){var i=this;Object.keys(this.options).forEach(function(t){-1!=String(t).indexOf("Class")&&(i.options["_"+t]="."+i.options[t])}),this.find(this.options._listItemClass).find(">ul").addClass(this.options.listClass),this.checkEmptyList(),this.reset(),this.element.data("nestable-group",this.options.group||t.Utils.uid("nestable-group")),this.find(this.options._listItemClass).each(function(){i.setParent(t.$(this))}),this.on("click","[data-nestable-action]",function(s){if(!i.dragEl&&(e||0===s.button)){s.preventDefault();var l=t.$(s.currentTarget),a=l.data("nestableAction"),n=l.closest(i.options._listItemClass);"collapse"===a&&i.collapseItem(n),"expand"===a&&i.expandItem(n),"toggle"===a&&i.toggleItem(n)}});var l=function(s){var l=t.$(s.target),a=l.is("a[href]")?l:l.parents("a[href]");s.target!==i.element[0]&&(l.is(i.options._noDragClass)||l.closest(i.options._noDragClass).length||l.is("[data-nestable-action]")||l.closest("[data-nestable-action]").length||(i.options.handleClass&&!l.hasClass(i.options.handleClass)&&i.options.handleClass&&(l=l.closest(i.options._handleClass)),!l.length||i.dragEl||!e&&0!==s.button||e&&s.touches&&1!==s.touches.length||(s.originalEvent&&s.originalEvent.touches&&(s=evt.originalEvent.touches[0]),i.delayMove=function(t){a=!1,t.preventDefault(),i.dragStart(s),i.trigger("start.uk.nestable",[i]),i.delayMove=!1},i.delayMove.x=parseInt(s.pageX,10),i.delayMove.y=parseInt(s.pageY,10),i.delayMove.threshold=i.options.idlethreshold,a.length&&"touchend"==h&&i.one(h,function(){a&&a.attr("href").trim()&&(location.href=a.attr("href"))}),s.preventDefault())))},d=function(t){t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i.delayMove&&(Math.abs(t.pageX-i.delayMove.x)>i.delayMove.threshold||Math.abs(t.pageY-i.delayMove.y)>i.delayMove.threshold)&&(window.getSelection().toString()?i.delayMove=!1:i.delayMove(t)),i.dragEl&&(t.preventDefault(),i.dragMove(t),i.trigger("move.uk.nestable",[i]))},p=function(t){i.dragEl&&(t.preventDefault(),i.dragStop(e&&t.touches?t.touches[0]:t)),s=!1,i.delayMove=!1};e?(this.element[0].addEventListener(n,l,!1),window.addEventListener(o,d,!1),window.addEventListener(h,p,!1),window.addEventListener(r,p,!1)):(this.on(n,l),a.on(o,d),a.on(h,p))},serialize:function(){var s,e=0,i=this,l=function(s,e){var a=[],n=s.children(i.options._listItemClass);return n.each(function(){for(var s,n,o,h=t.$(this),r={},d=h.children(i.options._listClass),p=0;p
            ").addClass(this.options.listClass+" "+this.options.dragClass).append(n.clone()),this.dragEl.css("width",n.width()),this.placeEl.addClass(this.options.placeholderClass),s=this.dragEl,this.tmpDragOnSiblings=[n[0].previousSibling,n[0].nextSibling],t.$body.append(this.dragEl),this.dragEl.css({left:o.left,top:o.top});var h,r,d=this.dragEl.find(this.options._listItemClass);for(h=0;hthis.dragDepth&&(this.dragDepth=r);i.addClass(this.options.movingClass)},dragStop:function(){var s=t.$(this.placeEl),e=this.placeEl.parents(this.options._listBaseClass+":first");this.placeEl.removeClass(this.options.placeholderClass),this.dragEl.remove(),this.element[0]!==e[0]?(e.trigger("change.uk.nestable",[e.data("nestable"),s,"added"]),this.element.trigger("change.uk.nestable",[this,s,"removed"])):this.element.trigger("change.uk.nestable",[this,s,"moved"]),this.trigger("stop.uk.nestable",[this,s]),this.reset(),i.removeClass(this.options.movingClass)},dragMove:function(s){var e,i,a,n,o,h=this.options,r=this.mouse,d=this.dragRootEl?this.dragRootEl.data("nestable").options.maxDepth:h.maxDepth;this.dragEl.css({left:s.pageX-r.offsetX,top:s.pageY-r.offsetY}),r.lastX=r.nowX,r.lastY=r.nowY,r.nowX=s.pageX,r.nowY=s.pageY,r.distX=r.nowX-r.lastX,r.distY=r.nowY-r.lastY,r.lastDirX=r.dirX,r.lastDirY=r.dirY,r.dirX=0===r.distX?0:r.distX>0?1:-1,r.dirY=0===r.distY?0:r.distY>0?1:-1;var p=Math.abs(r.distX)>Math.abs(r.distY)?1:0;if(!r.moving)return r.dirAx=p,r.moving=!0,void 0;if(r.dirAx!==p?(r.distAxX=0,r.distAxY=0):(r.distAxX+=Math.abs(r.distX),0!==r.dirX&&r.dirX!==r.lastDirX&&(r.distAxX=0),r.distAxY+=Math.abs(r.distY),0!==r.dirY&&r.dirY!==r.lastDirY&&(r.distAxY=0)),r.dirAx=p,r.dirAx&&r.distAxX>=h.threshold&&(r.distAxX=0,a=this.placeEl.prev("li"),r.distX>0&&a.length&&!a.hasClass(h.collapsedClass)&&!a.hasClass(h.noChildrenClass)&&(e=a.find(h._listClass).last(),o=this.placeEl.parents(h._listClass+","+h._listBaseClass).length,o+this.dragDepth<=d&&(e.length?(e=a.children(h._listClass).last(),e.append(this.placeEl)):(e=t.$("
              ").addClass(h.listClass),e.append(this.placeEl),a.append(e),this.setParent(a)))),r.distX<0&&(n=this.placeEl.next(h._listItemClass),!n.length))){var c=this.placeEl.closest([h._listBaseClass,h._listClass].join(",")),u=c.closest(h._listItemClass);u.length&&(u.after(this.placeEl),c.children().length||this.unsetParent(u))}var g=!1,f=s.pageX-(window.pageXOffset||document.scrollLeft||0),m=s.pageY-(window.pageYOffset||document.documentElement.scrollTop);if(this.pointEl=t.$(document.elementFromPoint(f,m)),h.handleClass&&this.pointEl.hasClass(h.handleClass))this.pointEl=this.pointEl.closest(h._listItemClass);else{var v=this.pointEl.closest(h._listItemClass);v.length&&(this.pointEl=v)}if(!this.placeEl.find(this.pointEl).length){if(this.pointEl.data("nestable")&&!this.pointEl.children().length)g=!0,this.checkEmptyList(this.pointEl);else if(!this.pointEl.length||!this.pointEl.hasClass(h.listItemClass))return;var C=this.element,E=this.pointEl.closest(this.options._listBaseClass),w=C[0]!=E[0];if(!r.dirAx||w||g){if(w&&h.group!==E.data("nestable-group"))return;if(l.push(C),o=this.dragDepth-1+this.pointEl.parents(h._listClass+","+h._listBaseClass).length,o>d)return;var b=s.pageY','',"
              ","
            "].join("")).data("notifyMessage",this),this.content(this.options.message),this.options.status&&(this.element.addClass("uk-notify-message-"+this.options.status),this.currentstatus=this.options.status),this.group=this.options.group,i[this.uuid]=this,e[this.options.pos]||(e[this.options.pos]=t.$('
            ').appendTo("body").on("click",".uk-notify-message",function(){var e=t.$(this).data("notifyMessage");e.element.trigger("manualclose.uk.notify",[e]),e.close()}))};return t.$.extend(n.prototype,{uuid:!1,element:!1,timout:!1,currentstatus:"",group:!1,show:function(){if(!this.element.is(":visible")){var t=this;e[this.options.pos].show().prepend(this.element);var i=parseInt(this.element.css("margin-bottom"),10);return this.element.css({opacity:0,"margin-top":-1*this.element.outerHeight(),"margin-bottom":0}).animate({opacity:1,"margin-top":0,"margin-bottom":i},function(){if(t.options.timeout){var e=function(){t.close()};t.timeout=setTimeout(e,t.options.timeout),t.element.hover(function(){clearTimeout(t.timeout)},function(){t.timeout=setTimeout(e,t.options.timeout)})}}),this}},close:function(t){var s=this,o=function(){s.element.remove(),e[s.options.pos].children().length||e[s.options.pos].hide(),s.options.onClose.apply(s,[]),s.element.trigger("close.uk.notify",[s]),delete i[s.uuid]};this.timeout&&clearTimeout(this.timeout),t?o():this.element.animate({opacity:0,"margin-top":-1*this.element.outerHeight(),"margin-bottom":0},function(){o()})},content:function(t){var e=this.element.find(">div");return t?(e.html(t),this):e.html()},status:function(t){return t?(this.element.removeClass("uk-notify-message-"+this.currentstatus).addClass("uk-notify-message-"+t),this.currentstatus=t,this):this.currentstatus}}),n.defaults={message:"",status:"",timeout:5e3,group:null,pos:"top-center",onClose:function(){}},t.notify=s,t.notify.message=n,t.notify.closeAll=o,s}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-notify",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";var e={},i={},s=function(e){return"string"==t.$.type(e)&&(e={message:e}),arguments[1]&&(e=t.$.extend(e,"string"==t.$.type(arguments[1])?{status:arguments[1]}:arguments[1])),new n(e).show()},o=function(t,e){var s;if(t)for(s in i)t===i[s].group&&i[s].close(e);else for(s in i)i[s].close(e)},n=function(s){this.options=t.$.extend({},n.defaults,s),this.uuid=t.Utils.uid("notifymsg"),this.element=t.$(['
            ','',"
            ","
            "].join("")).data("notifyMessage",this),this.content(this.options.message),this.options.status&&(this.element.addClass("uk-notify-message-"+this.options.status),this.currentstatus=this.options.status),this.group=this.options.group,i[this.uuid]=this,e[this.options.pos]||(e[this.options.pos]=t.$('
            ').appendTo("body").on("click",".uk-notify-message",function(){var e=t.$(this).data("notifyMessage");e.element.trigger("manualclose.uk.notify",[e]),e.close()}))};return t.$.extend(n.prototype,{uuid:!1,element:!1,timout:!1,currentstatus:"",group:!1,show:function(){if(!this.element.is(":visible")){var t=this;e[this.options.pos].show().prepend(this.element);var i=parseInt(this.element.css("margin-bottom"),10);return this.element.css({opacity:0,marginTop:-1*this.element.outerHeight(),marginBottom:0}).animate({opacity:1,marginTop:0,marginBottom:i},function(){if(t.options.timeout){var e=function(){t.close()};t.timeout=setTimeout(e,t.options.timeout),t.element.hover(function(){clearTimeout(t.timeout)},function(){t.timeout=setTimeout(e,t.options.timeout)})}}),this}},close:function(t){var s=this,o=function(){s.element.remove(),e[s.options.pos].children().length||e[s.options.pos].hide(),s.options.onClose.apply(s,[]),s.element.trigger("close.uk.notify",[s]),delete i[s.uuid]};this.timeout&&clearTimeout(this.timeout),t?o():this.element.animate({opacity:0,marginTop:-1*this.element.outerHeight(),marginBottom:0},function(){o()})},content:function(t){var e=this.element.find(">div");return t?(e.html(t),this):e.html()},status:function(t){return t?(this.element.removeClass("uk-notify-message-"+this.currentstatus).addClass("uk-notify-message-"+t),this.currentstatus=t,this):this.currentstatus}}),n.defaults={message:"",status:"",timeout:5e3,group:null,pos:"top-center",onClose:function(){}},t.notify=s,t.notify.message=n,t.notify.closeAll=o,s}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/pagination.min.js b/lib/api/uikit/src/js/components/pagination.min.js index 9a0c5778..10ad7139 100755 --- a/lib/api/uikit/src/js/components/pagination.min.js +++ b/lib/api/uikit/src/js/components/pagination.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-pagination",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";return t.component("pagination",{defaults:{items:1,itemsOnPage:1,pages:0,displayedPages:7,edges:1,currentPage:0,lblPrev:!1,lblNext:!1,onSelectPage:function(){}},boot:function(){t.ready(function(e){t.$("[data-uk-pagination]",e).each(function(){var e=t.$(this);e.data("pagination")||t.pagination(e,t.Utils.options(e.attr("data-uk-pagination")))})})},init:function(){var e=this;this.pages=this.options.pages?this.options.pages:Math.ceil(this.options.items/this.options.itemsOnPage)?Math.ceil(this.options.items/this.options.itemsOnPage):1,this.currentPage=this.options.currentPage,this.halfDisplayed=this.options.displayedPages/2,this.on("click","a[data-page]",function(i){i.preventDefault(),e.selectPage(t.$(this).data("page"))}),this._render()},_getInterval:function(){return{start:Math.ceil(this.currentPage>this.halfDisplayed?Math.max(Math.min(this.currentPage-this.halfDisplayed,this.pages-this.options.displayedPages),0):0),end:Math.ceil(this.currentPage>this.halfDisplayed?Math.min(this.currentPage+this.halfDisplayed,this.pages):Math.min(this.options.displayedPages,this.pages))}},render:function(t){this.pages=t?t:this.pages,this._render()},selectPage:function(t,e){this.currentPage=t,this.render(e),this.options.onSelectPage.apply(this,[t]),this.trigger("select.uk.pagination",[t,this])},_render:function(){var t,e=this.options,i=this._getInterval();if(this.element.empty(),e.lblPrev&&this._append(this.currentPage-1,{text:e.lblPrev}),i.start>0&&e.edges>0){var s=Math.min(e.edges,i.start);for(t=0;s>t;t++)this._append(t);e.edges..."):i.start-e.edges==1&&this._append(e.edges)}for(t=i.start;t0){this.pages-e.edges>i.end&&this.pages-e.edges-i.end!=1?this.element.append("
          • ...
          • "):this.pages-e.edges-i.end==1&&this._append(i.end++);var a=Math.max(this.pages-e.edges,i.end);for(t=a;te?0:e'+a.text+"":'
          • '+a.text+"
          • ",this.element.append(s)}}),t.pagination}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-pagination",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";return t.component("pagination",{defaults:{items:1,itemsOnPage:1,pages:0,displayedPages:7,edges:1,currentPage:0,lblPrev:!1,lblNext:!1,onSelectPage:function(){}},boot:function(){t.ready(function(e){t.$("[data-uk-pagination]",e).each(function(){var e=t.$(this);e.data("pagination")||t.pagination(e,t.Utils.options(e.attr("data-uk-pagination")))})})},init:function(){var e=this;this.pages=this.options.pages?this.options.pages:Math.ceil(this.options.items/this.options.itemsOnPage)?Math.ceil(this.options.items/this.options.itemsOnPage):1,this.currentPage=this.options.currentPage,this.halfDisplayed=this.options.displayedPages/2,this.on("click","a[data-page]",function(i){i.preventDefault(),e.selectPage(t.$(this).data("page"))}),this._render()},_getInterval:function(){return{start:Math.ceil(this.currentPage>this.halfDisplayed?Math.max(Math.min(this.currentPage-this.halfDisplayed,this.pages-this.options.displayedPages),0):0),end:Math.ceil(this.currentPage>this.halfDisplayed?Math.min(this.currentPage+this.halfDisplayed,this.pages):Math.min(this.options.displayedPages,this.pages))}},render:function(t){this.pages=t?t:this.pages,this._render()},selectPage:function(t,e){this.currentPage=t,this.render(e),this.options.onSelectPage.apply(this,[t]),this.trigger("select.uk.pagination",[t,this])},_render:function(){var t,e=this.options,i=this._getInterval();if(this.element.empty(),e.lblPrev&&this._append(this.currentPage-1,{text:e.lblPrev}),i.start>0&&e.edges>0){var s=Math.min(e.edges,i.start);for(t=0;s>t;t++)this._append(t);e.edges..."):i.start-e.edges==1&&this._append(e.edges)}for(t=i.start;t0){this.pages-e.edges>i.end&&this.pages-e.edges-i.end!=1?this.element.append("
          • ...
          • "):this.pages-e.edges-i.end==1&&this._append(i.end++);var a=Math.max(this.pages-e.edges,i.end);for(t=a;te?0:e'+a.text+"":'
          • '+a.text+"
          • ",this.element.append(s)}}),t.pagination}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/parallax.min.js b/lib/api/uikit/src/js/components/parallax.min.js index 36180dce..a3cc3fa9 100755 --- a/lib/api/uikit/src/js/components/parallax.min.js +++ b/lib/api/uikit/src/js/components/parallax.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(e){var t;window.UIkit&&(t=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-parallax",["uikit"],function(){return t||e(UIkit)})}(function(e){"use strict";function t(t,a,r){var i,n,s,o,c,l,p,f=new Image;return n=t.element.css({"background-size":"cover","background-repeat":"no-repeat"}),i=n.css("background-image").replace(/^url\(/g,"").replace(/\)$/g,"").replace(/("|')/g,""),o=function(){var e=n.innerWidth(),i=n.innerHeight(),o="bg"==a?r.diff:r.diff/100*i;return i+=o,e+=Math.ceil(o*c),e-oe/c?(l=Math.ceil(i*c),p=i,i>window.innerHeight&&(l=1.2*l,p=1.2*p)):(l=e,p=Math.ceil(e/c)),n.css({"background-size":l+"px "+p+"px"}).data("bgsize",{w:l,h:p}),void 0)},f.onerror=function(){},f.onload=function(){s={w:f.width,h:f.height},c=f.width/f.height,e.$win.on("load resize orientationchange",e.Utils.debounce(function(){o()},50)),o()},f.src=i,!0}function a(e,t,a){return e=i(e),t=i(t),a=a||0,r(e,t,a)}function r(e,t,a){var r="rgba("+parseInt(e[0]+a*(t[0]-e[0]),10)+","+parseInt(e[1]+a*(t[1]-e[1]),10)+","+parseInt(e[2]+a*(t[2]-e[2]),10)+","+(e&&t?parseFloat(e[3]+a*(t[3]-e[3])):1);return r+=")"}function i(e){var t,a;return a=(t=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(e))?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),1]:(t=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(e))?[17*parseInt(t[1],16),17*parseInt(t[2],16),17*parseInt(t[3],16),1]:(t=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(e))?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3]),1]:(t=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(e))?[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10),parseFloat(t[4])]:p[e]||[255,255,255,0]}var n=[],s=!1,o=0,c=window.innerHeight,l=function(){o=e.$win.scrollTop(),window.requestAnimationFrame(function(){for(var e=0;e0&&"none"!==e}(),e.$doc.on("scrolling.uk.document",l),e.$win.on("load resize orientationchange",e.Utils.debounce(function(){c=window.innerHeight,l()},50)),e.ready(function(t){e.$("[data-uk-parallax]",t).each(function(){var t=e.$(this);t.data("parallax")||e.parallax(t,e.Utils.options(t.attr("data-uk-parallax")))})})},init:function(){this.base=this.options.target?e.$(this.options.target):this.element,this.props={},this.velocity=this.options.velocity||1;var t=["target","velocity","viewport","plugins","media"];Object.keys(this.options).forEach(function(e){if(-1===t.indexOf(e)){var a,r,i,n,s=String(this.options[e]).split(",");e.match(/color/i)?(a=s[1]?s[0]:this._getStartValue(e),r=s[1]?s[1]:s[0],a||(a="rgba(255,255,255,0)")):(a=parseFloat(s[1]?s[0]:this._getStartValue(e)),r=parseFloat(s[1]?s[1]:s[0]),n=r>a?r-a:a-r,i=r>a?1:-1),this.props[e]={start:a,end:r,dir:i,diff:n}}}.bind(this)),n.push(this)},process:function(){if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidtho+c?a=0:o>r+i?a=1:c>r+i?a=(c>o?o:o-c)/(r+i):(e=o+c-r,t=Math.round(e/((c+i)/100)),a=t/100),a},update:function(e){var r,i,n={transform:"",filter:""},o=e*(1-(this.velocity-this.velocity*e));0>o&&(o=0),o>1&&(o=1),(void 0===this._percent||this._percent!=o)&&(Object.keys(this.props).forEach(function(c){switch(r=this.props[c],0===e?i=r.start:1===e?i=r.end:void 0!==r.diff&&(i=r.start+r.diff*o*r.dir),"bg"!=c&&"bgp"!=c||this._bgcover||(this._bgcover=t(this,c,r)),c){case"x":n.transform+=s?" translate3d("+i+"px, 0, 0)":" translateX("+i+"px)";break;case"xp":n.transform+=s?" translate3d("+i+"%, 0, 0)":" translateX("+i+"%)";break;case"y":n.transform+=s?" translate3d(0, "+i+"px, 0)":" translateY("+i+"px)";break;case"yp":n.transform+=s?" translate3d(0, "+i+"%, 0)":" translateY("+i+"%)";break;case"rotate":n.transform+=" rotate("+i+"deg)";break;case"scale":n.transform+=" scale("+i+")";break;case"bg":n["background-position"]="50% "+i+"px";break;case"bgp":n["background-position"]="50% "+i+"%";break;case"color":case"background-color":case"border-color":n[c]=a(r.start,r.end,o);break;case"blur":n.filter+=" blur("+i+"px)";break;case"hue":n.filter+=" hue-rotate("+i+"deg)";break;case"grayscale":n.filter+=" grayscale("+i+"%)";break;case"invert":n.filter+=" invert("+i+"%)";break;case"fopacity":n.filter+=" opacity("+i+"%)";break;case"saturate":n.filter+=" saturate("+i+"%)";break;case"sepia":n.filter+=" sepia("+i+"%)";break;default:n[c]=i}}.bind(this)),n.filter&&(n["-webkit-filter"]=n.filter),this.element.css(n),this._percent=o)},_getStartValue:function(e){var t=0;switch(e){case"scale":t=1;break;default:t=this.element.css(e)}return t||0}});var p={black:[0,0,0,1],blue:[0,0,255,1],brown:[165,42,42,1],cyan:[0,255,255,1],fuchsia:[255,0,255,1],gold:[255,215,0,1],green:[0,128,0,1],indigo:[75,0,130,1],khaki:[240,230,140,1],lime:[0,255,0,1],magenta:[255,0,255,1],maroon:[128,0,0,1],navy:[0,0,128,1],olive:[128,128,0,1],orange:[255,165,0,1],pink:[255,192,203,1],purple:[128,0,128,1],violet:[128,0,128,1],red:[255,0,0,1],silver:[192,192,192,1],white:[255,255,255,1],yellow:[255,255,0,1],transparent:[255,255,255,0]};return e.parallax}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){var t;window.UIkit2&&(t=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-parallax",["uikit"],function(){return t||e(UIkit2)})}(function(e){"use strict";function t(t,a,r){var i,n,s,o,c,l,p,f=new Image;return n=t.element.css({backgroundSize:"cover",backgroundRepeat:"no-repeat"}),i=n.css("background-image").replace(/^url\(/g,"").replace(/\)$/g,"").replace(/("|')/g,""),o=function(){var e=n.innerWidth(),i=n.innerHeight(),o="bg"==a?r.diff:r.diff/100*i;return i+=o,e+=Math.ceil(o*c),e-oe/c?(l=Math.ceil(i*c),p=i,i>window.innerHeight&&(l=1.2*l,p=1.2*p)):(l=e,p=Math.ceil(e/c)),n.css({backgroundSize:l+"px "+p+"px"}).data("bgsize",{w:l,h:p}),void 0)},f.onerror=function(){},f.onload=function(){s={w:f.width,h:f.height},c=f.width/f.height,e.$win.on("load resize orientationchange",e.Utils.debounce(function(){o()},50)),o()},f.src=i,!0}function a(e,t,a){return e=i(e),t=i(t),a=a||0,r(e,t,a)}function r(e,t,a){var r="rgba("+parseInt(e[0]+a*(t[0]-e[0]),10)+","+parseInt(e[1]+a*(t[1]-e[1]),10)+","+parseInt(e[2]+a*(t[2]-e[2]),10)+","+(e&&t?parseFloat(e[3]+a*(t[3]-e[3])):1);return r+=")"}function i(e){var t,a;return a=(t=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(e))?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),1]:(t=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(e))?[17*parseInt(t[1],16),17*parseInt(t[2],16),17*parseInt(t[3],16),1]:(t=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(e))?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3]),1]:(t=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(e))?[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10),parseFloat(t[4])]:p[e]||[255,255,255,0]}var n=[],s=!1,o=0,c=window.innerHeight,l=function(){o=e.$win.scrollTop(),window.requestAnimationFrame(function(){for(var e=0;e0&&"none"!==e}(),e.$doc.on("scrolling.uk.document",l),e.$win.on("load resize orientationchange",e.Utils.debounce(function(){c=window.innerHeight,l()},50)),e.ready(function(t){e.$("[data-uk-parallax]",t).each(function(){var t=e.$(this);t.data("parallax")||e.parallax(t,e.Utils.options(t.attr("data-uk-parallax")))})})},init:function(){this.base=this.options.target?e.$(this.options.target):this.element,this.props={},this.velocity=this.options.velocity||1;var t=["target","velocity","viewport","plugins","media"];Object.keys(this.options).forEach(function(e){if(-1===t.indexOf(e)){var a,r,i,n,s=String(this.options[e]).split(",");e.match(/color/i)?(a=s[1]?s[0]:this._getStartValue(e),r=s[1]?s[1]:s[0],a||(a="rgba(255,255,255,0)")):(a=parseFloat(s[1]?s[0]:this._getStartValue(e)),r=parseFloat(s[1]?s[1]:s[0]),n=r>a?r-a:a-r,i=r>a?1:-1),this.props[e]={start:a,end:r,dir:i,diff:n}}}.bind(this)),n.push(this)},process:function(){if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidtho+c?a=0:o>r+i?a=1:c>r+i?a=(c>o?o:o-c)/(r+i):(e=o+c-r,t=Math.round(e/((c+i)/100)),a=t/100),a},update:function(e){var r,i,n={transform:"",filter:""},o=e*(1-(this.velocity-this.velocity*e));0>o&&(o=0),o>1&&(o=1),(void 0===this._percent||this._percent!=o)&&(Object.keys(this.props).forEach(function(c){switch(r=this.props[c],0===e?i=r.start:1===e?i=r.end:void 0!==r.diff&&(i=r.start+r.diff*o*r.dir),"bg"!=c&&"bgp"!=c||this._bgcover||(this._bgcover=t(this,c,r)),c){case"x":n.transform+=s?" translate3d("+i+"px, 0, 0)":" translateX("+i+"px)";break;case"xp":n.transform+=s?" translate3d("+i+"%, 0, 0)":" translateX("+i+"%)";break;case"y":n.transform+=s?" translate3d(0, "+i+"px, 0)":" translateY("+i+"px)";break;case"yp":n.transform+=s?" translate3d(0, "+i+"%, 0)":" translateY("+i+"%)";break;case"rotate":n.transform+=" rotate("+i+"deg)";break;case"scale":n.transform+=" scale("+i+")";break;case"bg":n["background-position"]="50% "+i+"px";break;case"bgp":n["background-position"]="50% "+i+"%";break;case"color":case"background-color":case"border-color":n[c]=a(r.start,r.end,o);break;case"blur":n.filter+=" blur("+i+"px)";break;case"hue":n.filter+=" hue-rotate("+i+"deg)";break;case"grayscale":n.filter+=" grayscale("+i+"%)";break;case"invert":n.filter+=" invert("+i+"%)";break;case"fopacity":n.filter+=" opacity("+i+"%)";break;case"saturate":n.filter+=" saturate("+i+"%)";break;case"sepia":n.filter+=" sepia("+i+"%)";break;default:n[c]=i}}.bind(this)),n.filter&&(n["-webkit-filter"]=n.filter),this.element.css(n),this._percent=o)},_getStartValue:function(e){var t=0;switch(e){case"scale":t=1;break;default:t=this.element.css(e)}return t||0}});var p={black:[0,0,0,1],blue:[0,0,255,1],brown:[165,42,42,1],cyan:[0,255,255,1],fuchsia:[255,0,255,1],gold:[255,215,0,1],green:[0,128,0,1],indigo:[75,0,130,1],khaki:[240,230,140,1],lime:[0,255,0,1],magenta:[255,0,255,1],maroon:[128,0,0,1],navy:[0,0,128,1],olive:[128,128,0,1],orange:[255,165,0,1],pink:[255,192,203,1],purple:[128,0,128,1],violet:[128,0,128,1],red:[255,0,0,1],silver:[192,192,192,1],white:[255,255,255,1],yellow:[255,255,0,1],transparent:[255,255,255,0]};return e.parallax}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/search.min.js b/lib/api/uikit/src/js/components/search.min.js index 700f8502..b6e7e7a8 100755 --- a/lib/api/uikit/src/js/components/search.min.js +++ b/lib/api/uikit/src/js/components/search.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(e){var s;window.UIkit&&(s=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-search",["uikit"],function(){return s||e(UIkit)})}(function(e){"use strict";e.component("search",{defaults:{msgResultsHeader:"Search Results",msgMoreResults:"More Results",msgNoResults:"No results found",template:'',renderer:function(e){var s=this.options;this.dropdown.append(this.template({items:e.results||[],msgResultsHeader:s.msgResultsHeader,msgMoreResults:s.msgMoreResults,msgNoResults:s.msgNoResults})),this.show()}},boot:function(){e.$html.on("focus.search.uikit","[data-uk-search]",function(){var s=e.$(this);s.data("search")||e.search(s,e.Utils.options(s.attr("data-uk-search")))})},init:function(){var s=this;this.autocomplete=e.autocomplete(this.element,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-search"),this.autocomplete.input.on("keyup",function(){s.element[s.autocomplete.input.val()?"addClass":"removeClass"]("uk-active")}).closest("form").on("reset",function(){s.value="",s.element.removeClass("uk-active")}),this.on("selectitem.uk.autocomplete",function(e,t){t.url?location.href=t.url:t.moreresults&&s.autocomplete.input.closest("form").submit()}),this.element.data("search",this)}})}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){var s;window.UIkit2&&(s=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-search",["uikit"],function(){return s||e(UIkit2)})}(function(e){"use strict";e.component("search",{defaults:{msgResultsHeader:"Search Results",msgMoreResults:"More Results",msgNoResults:"No results found",template:'',renderer:function(e){var s=this.options;this.dropdown.append(this.template({items:e.results||[],msgResultsHeader:s.msgResultsHeader,msgMoreResults:s.msgMoreResults,msgNoResults:s.msgNoResults})),this.show()}},boot:function(){e.$html.on("focus.search.uikit","[data-uk-search]",function(){var s=e.$(this);s.data("search")||e.search(s,e.Utils.options(s.attr("data-uk-search")))})},init:function(){var s=this;this.autocomplete=e.autocomplete(this.element,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-search"),this.autocomplete.input.on("keyup",function(){s.element[s.autocomplete.input.val()?"addClass":"removeClass"]("uk-active")}).closest("form").on("reset",function(){s.value="",s.element.removeClass("uk-active")}),this.on("selectitem.uk.autocomplete",function(e,t){t.url?location.href=t.url:t.moreresults&&s.autocomplete.input.closest("form").submit()}),this.element.data("search",this)}})}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/slider.min.js b/lib/api/uikit/src/js/components/slider.min.js index 9f6ca6a8..d9435396 100755 --- a/lib/api/uikit/src/js/components/slider.min.js +++ b/lib/api/uikit/src/js/components/slider.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-slider",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e,i,s,n,a={};return t.component("slider",{defaults:{center:!1,threshold:10,infinite:!0,autoplay:!1,autoplayInterval:7e3,pauseOnHover:!0,activecls:"uk-active"},boot:function(){t.ready(function(e){setTimeout(function(){t.$("[data-uk-slider]",e).each(function(){var e=t.$(this);e.data("slider")||t.slider(e,t.Utils.options(e.attr("data-uk-slider")))})},0)})},init:function(){var o=this;this.container=this.element.find(".uk-slider"),this.focus=0,t.$win.on("resize load",t.Utils.debounce(function(){o.update(!0)},100)),this.on("click.uk.slider","[data-uk-slider-item]",function(e){e.preventDefault();var i=t.$(this).attr("data-uk-slider-item");if(o.focus!=i)switch(o.stop(),i){case"next":case"previous":o["next"==i?"next":"previous"]();break;default:o.updateFocus(parseInt(i,10))}}),this.container.on({"touchstart mousedown":function(h){h.originalEvent&&h.originalEvent.touches&&(h=h.originalEvent.touches[0]),h.button&&2==h.button||!o.active||(o.stop(),s=t.$(h.target).is("a")?t.$(h.target):t.$(h.target).parents("a:first"),n=!1,s.length&&s.one("click",function(t){n&&t.preventDefault()}),i=function(t){n=!0,e=o,a={touchx:parseInt(t.pageX,10),dir:1,focus:o.focus,base:o.options.center?"center":"area"},t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),e.element.data({"pointer-start":{x:parseInt(t.pageX,10),y:parseInt(t.pageY,10)},"pointer-pos-start":o.pos}),o.container.addClass("uk-drag"),i=!1},i.x=parseInt(h.pageX,10),i.threshold=o.options.threshold)},mouseenter:function(){o.options.pauseOnHover&&(o.hovering=!0)},mouseleave:function(){o.hovering=!1}}),this.update(!0),this.on("display.uk.check",function(){o.element.is(":visible")&&o.update(!0)}),this.element.find("a,img").attr("draggable","false"),this.options.autoplay&&this.start(),t.domObserve(this.element,function(){o.element.children(":not([data-slide])").length&&o.update(!0)})},update:function(e){var i,s,n,a,o=this,h=0,r=0;return this.items=this.container.children().filter(":visible"),this.vp=this.element[0].getBoundingClientRect().width,this.container.css({"min-width":"","min-height":""}),this.items.each(function(e){i=t.$(this).attr("data-slide",e),a=i.css({left:"",width:""})[0].getBoundingClientRect(),s=a.width,n=i.width(),r=Math.max(r,a.height),i.css({left:h,width:s}).data({idx:e,left:h,width:s,cwidth:n,area:h+s,center:h-(o.vp/2-n/2)}),h+=s}),this.container.css({"min-width":h,"min-height":r}),this.options.infinite&&(h<=2*this.vp||this.items.length<5)&&!this.itemsResized?(this.container.children().each(function(t){o.container.append(o.items.eq(t).clone(!0).attr("id",""))}).each(function(t){o.container.append(o.items.eq(t).clone(!0).attr("id",""))}),this.itemsResized=!0,this.update()):(this.cw=h,this.pos=0,this.active=h>=this.vp,this.container.css({"-ms-transform":"","-webkit-transform":"",transform:""}),e&&this.updateFocus(this.focus),void 0)},updatePos:function(t){this.pos=t,this.container.css({"-ms-transform":"translateX("+t+"px)","-webkit-transform":"translateX("+t+"px)",transform:"translateX("+t+"px)"})},updateFocus:function(e,i){if(this.active){i=i||(e>this.focus?1:-1);var s,n,a=this.items.eq(e);if(this.options.infinite&&this.infinite(e,i),this.options.center)this.updatePos(-1*a.data("center")),this.items.filter("."+this.options.activecls).removeClass(this.options.activecls),a.addClass(this.options.activecls);else if(this.options.infinite)this.updatePos(-1*a.data("left"));else{for(s=0,n=e;nthis.vp)this.updatePos(-1*a.data("left"));else if(1==i){for(s=0,n=this.items.length-1;n>=0;n--){if(s+=this.items.eq(n).data("width"),s==this.vp){e=n;break}if(s>this.vp){e=nthis.vp?this.updatePos(-1*(this.container.width()-this.vp)):this.updatePos(-1*this.items.eq(e).data("left"))}}var o=this.items.eq(e).data("left");this.items.removeClass("uk-slide-before uk-slide-after").each(function(i){i!==e&&t.$(this).addClass(t.$(this).data("left")this.vp));i++)a=a+1==this.items.length?0:a+1;o.length&&o.forEach(function(t){var e=n.data("area");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}else{for(i=this.items.length-1;i>-1&&(h+=this.items.eq(a).data("width"),a!=t&&o.push(this.items.eq(a)),!(h>this.vp));i--)a=a-1==-1?this.items.length-1:a-1;o.length&&o.forEach(function(t){var e=n.data("left")-t.data("width");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}}}),t.$doc.on("mousemove.uk.slider touchmove.uk.slider",function(t){if(t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i&&Math.abs(t.pageX-i.x)>i.threshold&&(window.getSelection().toString()?e=i=!1:i(t)),e){var s,n,o,h,r,c,d,u,f,l;if(t.clientX||t.clientY?s=t.clientX:(t.pageX||t.pageY)&&(s=t.pageX-document.body.scrollLeft-document.documentElement.scrollLeft),r=a.focus,n=s-e.element.data("pointer-start").x,o=e.element.data("pointer-pos-start")+n,h=s>e.element.data("pointer-start").x?-1:1,c=e.items.eq(a.focus),1==h)for(d=c.data("left")+Math.abs(n),u=0,f=a.focus;ud){r=f;break}f=f+1==e.items.length?0:f+1}else for(d=c.data("left")-Math.abs(n),u=0,f=a.focus;ua.diff){o=n;break}n=n+1==e.items.length?0:n+1}e.options.infinite||o||(o=e.items.length)}else{for(s=0,n=a.focus;s=this.vp,this.container.css({"-ms-transform":"","-webkit-transform":"",transform:""}),e&&this.updateFocus(this.focus),void 0)},updatePos:function(t){this.pos=t,this.container.css({"-ms-transform":"translateX("+t+"px)","-webkit-transform":"translateX("+t+"px)",transform:"translateX("+t+"px)"})},updateFocus:function(e,i){if(this.active){i=i||(e>this.focus?1:-1);var s,n,a=this.items.eq(e);if(this.options.infinite&&this.infinite(e,i),this.options.center)this.updatePos(-1*a.data("center")),this.items.filter("."+this.options.activecls).removeClass(this.options.activecls),a.addClass(this.options.activecls);else if(this.options.infinite)this.updatePos(-1*a.data("left"));else{for(s=0,n=e;nthis.vp)this.updatePos(-1*a.data("left"));else if(1==i){for(s=0,n=this.items.length-1;n>=0;n--){if(s+=this.items.eq(n).data("width"),s==this.vp){e=n;break}if(s>this.vp){e=nthis.vp?this.updatePos(-1*(this.container.width()-this.vp)):this.updatePos(-1*this.items.eq(e).data("left"))}}var o=this.items.eq(e).data("left");this.items.removeClass("uk-slide-before uk-slide-after").each(function(i){i!==e&&t.$(this).addClass(t.$(this).data("left")this.vp));i++)a=a+1==this.items.length?0:a+1;o.length&&o.forEach(function(t){var e=n.data("area");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}else{for(i=this.items.length-1;i>-1&&(h+=this.items.eq(a).data("width"),a!=t&&o.push(this.items.eq(a)),!(h>this.vp));i--)a=a-1==-1?this.items.length-1:a-1;o.length&&o.forEach(function(t){var e=n.data("left")-t.data("width");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}}}),t.$doc.on("mousemove.uk.slider touchmove.uk.slider",function(t){if(t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i&&Math.abs(t.pageX-i.x)>i.threshold&&(window.getSelection().toString()?e=i=!1:i(t)),e){var s,n,o,h,r,c,d,u,f,l;if(t.clientX||t.clientY?s=t.clientX:(t.pageX||t.pageY)&&(s=t.pageX-document.body.scrollLeft-document.documentElement.scrollLeft),r=a.focus,n=s-e.element.data("pointer-start").x,o=e.element.data("pointer-pos-start")+n,h=s>e.element.data("pointer-start").x?-1:1,c=e.items.eq(a.focus),1==h)for(d=c.data("left")+Math.abs(n),u=0,f=a.focus;ud){r=f;break}f=f+1==e.items.length?0:f+1}else for(d=c.data("left")-Math.abs(n),u=0,f=a.focus;ua.diff){o=n;break}n=n+1==e.items.length?0:n+1}e.options.infinite||o||(o=e.items.length)}else{for(s=0,n=a.focus;si)return null;for(;a>n;)e=n%i,e?o[s][e]=t[n]:o[++s]=[t[n]],n++;for(n=0,a=o.length;a>n;)o[n]=jQuery(o[n]),n++;return o}var n;t.component("slideset",{defaults:{"default":1,animation:"fade",duration:200,filter:"",delay:!1,controls:!1,autoplay:!1,autoplayInterval:7e3,pauseOnHover:!0},sets:[],boot:function(){t.ready(function(i){t.$("[data-uk-slideset]",i).each(function(){var i=t.$(this);i.data("slideset")||t.slideset(i,t.Utils.options(i.attr("data-uk-slideset")))})})},init:function(){var i=this;this.activeSet=!1,this.list=this.element.find(".uk-slideset"),this.nav=this.element.find(".uk-slideset-nav"),this.controls=this.options.controls?t.$(this.options.controls):this.element,t.$win.on("resize load",t.Utils.debounce(function(){i.update()},100)),i.list.addClass("uk-grid-width-1-"+i.options.default),["xlarge","large","medium","small"].forEach(function(t){i.options[t]&&i.list.addClass("uk-grid-width-"+t+"-1-"+i.options[t])}),this.on("click.uk.slideset","[data-uk-slideset-item]",function(e){if(e.preventDefault(),!i.animating){var n=t.$(this).attr("data-uk-slideset-item");if(i.activeSet!==n)switch(n){case"next":case"previous":i["next"==n?"next":"previous"]();break;default:i.show(parseInt(n,10))}}}),this.controls.on("click.uk.slideset","[data-uk-filter]",function(e){var n=t.$(this);n.parent().hasClass("uk-slideset")||(e.preventDefault(),i.animating||i.currentFilter==n.attr("data-uk-filter")||(i.updateFilter(n.attr("data-uk-filter")),i._hide().then(function(){i.update(!0,!0)})))}),this.on("swipeRight swipeLeft",function(t){i["swipeLeft"==t.type?"next":"previous"]()}),this.updateFilter(this.options.filter),this.update(),this.element.on({mouseenter:function(){i.options.pauseOnHover&&(i.hovering=!0)},mouseleave:function(){i.hovering=!1}}),this.options.autoplay&&this.start(),t.domObserve(this.list,function(){i.list.children(":visible:not(.uk-active)").length&&i.update(!1,!0)})},update:function(t,i){var n,s=this.visible;if(this.visible=this.getVisibleOnCurrenBreakpoint(),s!=this.visible||i){for(this.children=this.list.children().hide(),this.items=this.getItems(),this.sets=e(this.items,this.visible),n=0;n');this.nav[1==this.nav.children().length?"addClass":"removeClass"]("uk-invisible")}this.activeSet=!1,this.show(0,!t)}},updateFilter:function(i){var e,n=this;this.currentFilter=i,this.controls.find("[data-uk-filter]").each(function(){e=t.$(this),e.parent().hasClass("uk-slideset")||(e.attr("data-uk-filter")==n.currentFilter?e.addClass("uk-active"):e.removeClass("uk-active"))})},getVisibleOnCurrenBreakpoint:function(){var i=null,e=t.$('
            ').appendTo("body"),n=e.children().eq(0),s=this.options;return["xlarge","large","medium","small"].forEach(function(t){s[t]&&!i&&(e.attr("class","uk-grid-width-"+t+"-1-2").width(),50==n.width()&&(i=t))}),e.remove(),this.options[i]||this.options["default"]},getItems:function(){var i,e=[];return this.currentFilter?(i=this.currentFilter||[],"string"==typeof i&&(i=i.split(/,/).map(function(t){return t.trim()})),this.children.each(function(){var n=t.$(this),s=n.attr("data-uk-filter"),a=i.length?!1:!0;s&&(s=s.split(/,/).map(function(t){return t.trim()}),i.forEach(function(t){s.indexOf(t)>-1&&(a=!0)})),a&&e.push(n[0])}),e=t.$(e)):e=this.list.children(),e},show:function(i,e,s){var a=this;if(this.activeSet!==i&&!this.animating){s=s||(ii)return null;for(;a>n;)e=n%i,e?o[s][e]=t[n]:o[++s]=[t[n]],n++;for(n=0,a=o.length;a>n;)o[n]=jQuery(o[n]),n++;return o}var n;t.component("slideset",{defaults:{"default":1,animation:"fade",duration:200,filter:"",delay:!1,controls:!1,autoplay:!1,autoplayInterval:7e3,pauseOnHover:!0},sets:[],boot:function(){t.ready(function(i){t.$("[data-uk-slideset]",i).each(function(){var i=t.$(this);i.data("slideset")||t.slideset(i,t.Utils.options(i.attr("data-uk-slideset")))})})},init:function(){var i=this;this.activeSet=!1,this.list=this.element.find(".uk-slideset"),this.nav=this.element.find(".uk-slideset-nav"),this.controls=this.options.controls?t.$(this.options.controls):this.element,t.$win.on("resize load",t.Utils.debounce(function(){i.update()},100)),i.list.addClass("uk-grid-width-1-"+i.options.default),["xlarge","large","medium","small"].forEach(function(t){i.options[t]&&i.list.addClass("uk-grid-width-"+t+"-1-"+i.options[t])}),this.on("click.uk.slideset","[data-uk-slideset-item]",function(e){if(e.preventDefault(),!i.animating){var n=t.$(this).attr("data-uk-slideset-item");if(i.activeSet!==n)switch(n){case"next":case"previous":i["next"==n?"next":"previous"]();break;default:i.show(parseInt(n,10))}}}),this.controls.on("click.uk.slideset","[data-uk-filter]",function(e){var n=t.$(this);n.parent().hasClass("uk-slideset")||(e.preventDefault(),i.animating||i.currentFilter==n.attr("data-uk-filter")||(i.updateFilter(n.attr("data-uk-filter")),i._hide().then(function(){i.update(!0,!0)})))}),this.on("swipeRight swipeLeft",function(t){i["swipeLeft"==t.type?"next":"previous"]()}),this.updateFilter(this.options.filter),this.update(),this.element.on({mouseenter:function(){i.options.pauseOnHover&&(i.hovering=!0)},mouseleave:function(){i.hovering=!1}}),this.options.autoplay&&this.start(),t.domObserve(this.list,function(){i.list.children(":visible:not(.uk-active)").length&&i.update(!1,!0)})},update:function(t,i){var n,s=this.visible;if(this.visible=this.getVisibleOnCurrenBreakpoint(),s!=this.visible||i){for(this.children=this.list.children().hide(),this.items=this.getItems(),this.sets=e(this.items,this.visible),n=0;n');this.nav[1==this.nav.children().length?"addClass":"removeClass"]("uk-invisible")}this.activeSet=!1,this.show(0,!t)}},updateFilter:function(i){var e,n=this;this.currentFilter=i,this.controls.find("[data-uk-filter]").each(function(){e=t.$(this),e.parent().hasClass("uk-slideset")||(e.attr("data-uk-filter")==n.currentFilter?e.addClass("uk-active"):e.removeClass("uk-active"))})},getVisibleOnCurrenBreakpoint:function(){var i=null,e=t.$('
            ').appendTo("body"),n=e.children().eq(0),s=this.options;return["xlarge","large","medium","small"].forEach(function(t){s[t]&&!i&&(e.attr("class","uk-grid-width-"+t+"-1-2").width(),50==n.width()&&(i=t))}),e.remove(),this.options[i]||this.options["default"]},getItems:function(){var i,e=[];return this.currentFilter?(i=this.currentFilter||[],"string"==typeof i&&(i=i.split(/,/).map(function(t){return t.trim()})),this.children.each(function(){var n=t.$(this),s=n.attr("data-uk-filter"),a=i.length?!1:!0;s&&(s=s.split(/,/).map(function(t){return t.trim()}),i.forEach(function(t){s.indexOf(t)>-1&&(a=!0)})),a&&e.push(n[0])}),e=t.$(e)):e=this.list.children(),e},show:function(i,e,s){var a=this;if(this.activeSet!==i&&!this.animating){s=s||(i").css({top:0,left:0,width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),p=h.width(),l=h.height(),u="slice-up"==o?l:"0",f=0;f
            ').css({position:"absolute",top:0,left:0,width:p,height:l,"background-image":d,clip:m,opacity:0,transition:"all "+this.options.duration+"ms ease-in-out "+60*f+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+60*f+"ms"}).data("clip",v),h.append(r)}return this.container.append(h),h.children().last().on(i.support.transition.end,function(){setTimeout(h.remove.bind(h),0),a.resolve()}),h.width(),h.children().each(function(){var t=i.$(this);t.css({clip:t.data("clip"),opacity:1})}),a.promise()},"slice-up":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up"])},"slice-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-down"])},"slice-up-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up-down"])},fold:function(e,s){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var n,o=i.$.Deferred(),r=Math.ceil(this.element.width()/this.options.slices),a=s.data("cover").css("background-image"),c=i.$("
          • ").css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),d=s.width(),h=s.height(),p=0;p
            ').css({position:"absolute",top:0,left:0,width:d,height:h,"background-image":a,"transform-origin":r*p+"px 0 0",clip:"rect(0px, "+r*(p+1)+"px, "+h+"px, "+r*p+"px)",opacity:0,transform:"scaleX(0.000001)",transition:"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms"}),c.prepend(n);return this.container.append(c),c.width(),c.children().first().on(i.support.transition.end,function(){setTimeout(c.remove.bind(c),0),o.resolve()}).end().css({transform:"scaleX(1)",opacity:1}),o.promise()},puzzle:function(s,n){if(!n.data("cover"))return t.fade.apply(this,arguments);for(var o,r,a,c=i.$.Deferred(),d=this,h=Math.round(this.options.slices/2),p=Math.round(n.width()/h),l=Math.round(n.height()/p),u=Math.round(n.height()/l)+1,f=n.data("cover").css("background-image"),m=i.$("
          • ").css({width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),x=this.container.width(),v=this.container.height(),g=0;l>g;g++)for(var w=0;h>w;w++)a=w==h-1?p+2:p,r=[u*g+"px",a*(w+1)+"px",u*(g+1)+"px",p*w+"px"],o=i.$('
            ').css({position:"absolute",top:0,left:0,opacity:0,width:x,height:v,"background-image":f,clip:"rect("+r.join(",")+")","-webkit-transform":"translateZ(0)",transform:"translateZ(0)"}),m.append(o);this.container.append(m);var b=e(m.children());return b.each(function(t){i.$(this).css({transition:"all "+d.options.duration+"ms ease-in-out "+(50+25*t)+"ms","-webkit-transition":"all "+d.options.duration+"ms ease-in-out "+(50+25*t)+"ms"})}).last().on(i.support.transition.end,function(){setTimeout(m.remove.bind(m),0),c.resolve()}),m.width(),b.css({opacity:1}),c.promise()},boxes:function(e,s,n,o){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var r,a,c,d,h=i.$.Deferred(),p=Math.round(this.options.slices/2),l=Math.round(s.width()/p),u=Math.round(s.height()/l),f=Math.round(s.height()/u)+1,m=s.data("cover").css("background-image"),x=i.$("
          • ").css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),v=s.width(),g=s.height(),w=0;u>w;w++)for(d=0;p>d;d++)c=d==p-1?l+2:l,a=[f*w+"px",c*(d+1)+"px",f*(w+1)+"px",l*d+"px"],r=i.$('
            ').css({position:"absolute",top:0,left:0,opacity:1,width:v,height:g,"background-image":m,"transform-origin":a[3]+" "+a[0]+" 0",clip:"rect("+a.join(",")+")","-webkit-transform":"scale(0.0000000000000001)",transform:"scale(0.0000000000000001)"}),x.append(r);this.container.append(x);var b,k=0,y=0,$=0,I=[[]],M=x.children();for("boxes-reverse"==o&&(M=[].reverse.apply(M)),M.each(function(){I[k][y]=i.$(this),y++,y==p&&(k++,y=0,I[k]=[])}),d=0,b=0;p*u>d;d++){b=d;for(var z=0;u>z;z++)b>=0&&p>b&&I[z][b].css({transition:"all "+this.options.duration+"ms linear "+(50+$)+"ms","-webkit-transition":"all "+this.options.duration+"ms linear "+(50+$)+"ms"}),b--;$+=100}return M.last().on(i.support.transition.end,function(){setTimeout(x.remove.bind(x),0),h.resolve()}),x.width(),M.css({"-webkit-transform":"scale(1)",transform:"scale(1)"}),h.promise()},"boxes-reverse":function(i,e,s){return t.boxes.apply(this,[i,e,s,"boxes-reverse"])},"random-fx":function(){var i=["slice-up","fold","puzzle","slice-down","boxes","slice-up-down","boxes-reverse"];return this.fxIndex=(void 0===this.fxIndex?-1:this.fxIndex)+1,i[this.fxIndex]||(this.fxIndex=0),t[i[this.fxIndex]].apply(this,arguments)}});var e=function(i){for(var t,e,s=i.length;s;t=parseInt(Math.random()*s),e=i[--s],i[s]=i[t],i[t]=e);return i};return i.slideshow.animations}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){var t;window.UIkit2&&(t=i(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-slideshow-fx",["uikit"],function(){return t||i(UIkit2)})}(function(i){"use strict";var t=i.slideshow.animations;i.$.extend(i.slideshow.animations,{slice:function(e,s,n,o){if(!e.data("cover"))return t.fade.apply(this,arguments);for(var r,a=i.$.Deferred(),c=Math.ceil(this.element.width()/this.options.slices),h=s.data("cover").css("background-image"),d=i.$('
          • ').css({top:0,left:0,width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),p=d.width(),l=d.height(),u="slice-up"==o?l:"0",f=0;f
            ').css({position:"absolute",top:0,left:0,width:p,height:l,"background-image":h,clip:m,opacity:0,transition:"all "+this.options.duration+"ms ease-in-out "+60*f+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+60*f+"ms"}).data("clip",x),d.append(r)}return this.container.append(d),d.children().last().on(i.support.transition.end,function(){setTimeout(function(){d.remove(),a.resolve()},0)}),d.width(),d.children().each(function(){r=i.$(this),r.css({clip:r.data("clip"),opacity:1})}),a.promise()},"slice-up":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up"])},"slice-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-down"])},"slice-up-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up-down"])},fold:function(e,s){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var n,o=i.$.Deferred(),r=Math.ceil(this.element.width()/this.options.slices),a=s.data("cover").css("background-image"),c=i.$('
          • ').css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),h=s.width(),d=s.height(),p=0;p
            ').css({position:"absolute",top:0,left:0,width:h,height:d,"background-image":a,"transform-origin":r*p+"px 0 0",clip:"rect(0px, "+r*(p+1)+"px, "+d+"px, "+r*p+"px)",opacity:0,transform:"scaleX(0.000001)",transition:"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms"}),c.prepend(n);return this.container.append(c),c.width(),c.children().first().on(i.support.transition.end,function(){setTimeout(function(){c.remove(),o.resolve()},0)}).end().css({transform:"scaleX(1)",opacity:1}),o.promise()},puzzle:function(s,n){if(!n.data("cover"))return t.fade.apply(this,arguments);for(var o,r,a,c=i.$.Deferred(),h=this,d=Math.round(this.options.slices/2),p=Math.round(n.width()/d),l=Math.round(n.height()/p),u=Math.round(n.height()/l)+1,f=n.data("cover").css("background-image"),m=i.$('
          • ').css({width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),g=this.container.width(),x=this.container.height(),w=0;l>w;w++)for(var v=0;d>v;v++)a=v==d-1?p+2:p,r=[u*w+"px",a*(v+1)+"px",u*(w+1)+"px",p*v+"px"],o=i.$('
            ').css({position:"absolute",top:0,left:0,opacity:0,width:g,height:x,"background-image":f,clip:"rect("+r.join(",")+")","-webkit-transform":"translateZ(0)",transform:"translateZ(0)"}),m.append(o);this.container.append(m);var k=e(m.children());return k.each(function(t){i.$(this).css({transition:"all "+h.options.duration+"ms ease-in-out "+(50+25*t)+"ms","-webkit-transition":"all "+h.options.duration+"ms ease-in-out "+(50+25*t)+"ms"})}).last().on(i.support.transition.end,function(){setTimeout(function(){m.remove(),c.resolve()},0)}),m.width(),k.css({opacity:1}),c.promise()},boxes:function(e,s,n,o){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var r,a,c,h,d=i.$.Deferred(),p=Math.round(this.options.slices/2),l=Math.round(s.width()/p),u=Math.round(s.height()/l),f=Math.round(s.height()/u)+1,m=s.data("cover").css("background-image"),g=i.$('
          • ').css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),x=s.width(),w=s.height(),v=0;u>v;v++)for(h=0;p>h;h++)c=h==p-1?l+2:l,a=[f*v+"px",c*(h+1)+"px",f*(v+1)+"px",l*h+"px"],r=i.$('
            ').css({position:"absolute",top:0,left:0,opacity:1,width:x,height:w,"background-image":m,"transform-origin":a[3]+" "+a[0]+" 0",clip:"rect("+a.join(",")+")","-webkit-transform":"scale(0.0000000000000001)",transform:"scale(0.0000000000000001)"}),g.append(r);this.container.append(g);var k,b=0,y=0,$=0,I=[[]],M=g.children();for("boxes-reverse"==o&&(M=[].reverse.apply(M)),M.each(function(){I[b][y]=i.$(this),y++,y==p&&(b++,y=0,I[b]=[])}),h=0,k=0;p*u>h;h++){k=h;for(var z=0;u>z;z++)k>=0&&p>k&&I[z][k].css({transition:"all "+this.options.duration+"ms linear "+(50+$)+"ms","-webkit-transition":"all "+this.options.duration+"ms linear "+(50+$)+"ms"}),k--;$+=100}return M.last().on(i.support.transition.end,function(){setTimeout(function(){g.remove(),d.resolve()},0)}),g.width(),M.css({"-webkit-transform":"scale(1)",transform:"scale(1)"}),d.promise()},"boxes-reverse":function(i,e,s){return t.boxes.apply(this,[i,e,s,"boxes-reverse"])},"random-fx":function(){var i=["slice-up","fold","puzzle","slice-down","boxes","slice-up-down","boxes-reverse"];return this.fxIndex=(void 0===this.fxIndex?-1:this.fxIndex)+1,i[this.fxIndex]||(this.fxIndex=0),t[i[this.fxIndex]].apply(this,arguments)}});var e=function(i){for(var t,e,s=i.length;s;t=parseInt(Math.random()*s),e=i[--s],i[s]=i[t],i[t]=e);return i};return i.slideshow.animations}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/slideshow.min.js b/lib/api/uikit/src/js/components/slideshow.min.js index 09d22955..8fe8ced4 100755 --- a/lib/api/uikit/src/js/components/slideshow.min.js +++ b/lib/api/uikit/src/js/components/slideshow.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(i){var t;window.UIkit&&(t=i(UIkit)),"function"==typeof define&&define.amd&&define("uikit-slideshow",["uikit"],function(){return t||i(UIkit)})}(function(i){"use strict";var t,s=0;i.component("slideshow",{defaults:{animation:"fade",duration:500,height:"auto",start:0,autoplay:!1,autoplayInterval:7e3,videoautoplay:!0,videomute:!0,slices:15,pauseOnHover:!0,kenburns:!1,kenburnsanimations:["uk-animation-middle-left","uk-animation-top-right","uk-animation-bottom-left","uk-animation-top-center","","uk-animation-bottom-right"]},current:!1,interval:null,hovering:!1,boot:function(){i.ready(function(t){i.$("[data-uk-slideshow]",t).each(function(){var t=i.$(this);t.data("slideshow")||i.slideshow(t,i.Utils.options(t.attr("data-uk-slideshow")))})})},init:function(){var t=this;this.container=this.element.hasClass("uk-slideshow")?this.element:i.$(this.find(".uk-slideshow:first")),this.current=this.options.start,this.animating=!1,this.fixFullscreen=navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&this.container.hasClass("uk-slideshow-fullscreen"),this.options.kenburns&&(this.kbanimduration=this.options.kenburns===!0?"15s":this.options.kenburns,String(this.kbanimduration).match(/(ms|s)$/)||(this.kbanimduration+="ms"),"string"==typeof this.options.kenburnsanimations&&(this.options.kenburnsanimations=this.options.kenburnsanimations.split(","))),this.update(),this.on("click.uk.slideshow","[data-uk-slideshow-item]",function(s){s.preventDefault();var e=i.$(this).attr("data-uk-slideshow-item");if(t.current!=e){switch(e){case"next":case"previous":t["next"==e?"next":"previous"]();break;default:t.show(parseInt(e,10))}t.stop()}}),i.$win.on("resize load",i.Utils.debounce(function(){t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight))},100)),setTimeout(function(){t.resize()},80),this.options.autoplay&&this.start(),this.options.videoautoplay&&this.slides.eq(this.current).data("media")&&this.playmedia(this.slides.eq(this.current).data("media")),this.options.kenburns&&this.applyKenBurns(this.slides.eq(this.current)),this.container.on({mouseenter:function(){t.options.pauseOnHover&&(t.hovering=!0)},mouseleave:function(){t.hovering=!1}}),this.on("swipeRight swipeLeft",function(i){t["swipeLeft"==i.type?"next":"previous"]()}),this.on("display.uk.check",function(){t.element.is(":visible")&&(t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight)))}),i.domObserve(this.element,function(){t.container.children(":not([data-slide])").length&&t.update(!0)})},update:function(t){var e,a=this,n=0;this.slides=this.container.children(),this.slidesCount=this.slides.length,this.slides.eq(this.current).length||(this.current=0),this.slides.each(function(t){var o=i.$(this);if(!o.data("processed")){var r=o.children("img,video,iframe").eq(0),d="html";if(o.data("media",r),o.data("sizer",r),r.length){var u;switch(d=r[0].nodeName.toLowerCase(),r[0].nodeName){case"IMG":var h=i.$('
            ').css({"background-image":"url("+r.attr("src")+")"});r.attr("width")&&r.attr("height")&&(u=i.$("").attr({width:r.attr("width"),height:r.attr("height")}),r.replaceWith(u),r=u,u=void 0),r.css({width:"100%",height:"auto",opacity:0}),o.prepend(h).data("cover",h);break;case"IFRAME":var c=r[0].src,l="sw-"+ ++s;r.attr("src","").on("load",function(){if((t!==a.current||t==a.current&&!a.options.videoautoplay)&&a.pausemedia(r),a.options.videomute){a.mutemedia(r);var i=setInterval(function(t){return function(){a.mutemedia(r),++t>=4&&clearInterval(i)}}(0),250)}}).data("slideshow",a).attr("data-player-id",l).attr("src",[c,c.indexOf("?")>-1?"&":"?","enablejsapi=1&api=1&player_id="+l].join("")).addClass("uk-position-absolute"),i.support.touch||r.css("pointer-events","none"),u=!0,i.cover&&(i.cover(r),r.attr("data-uk-cover","{}"));break;case"VIDEO":r.addClass("uk-cover-object uk-position-absolute"),u=!0,a.options.videomute&&a.mutemedia(r)}if(u){e=i.$("").attr({width:r[0].width,height:r[0].height});var p=i.$('').attr("src",e[0].toDataURL());o.prepend(p),o.data("sizer",p)}}else o.data("sizer",o);a.hasKenBurns(o)&&o.data("cover").css({"-webkit-animation-duration":a.kbanimduration,"animation-duration":a.kbanimduration}),o.data("processed",++n),o.attr("data-slide",d)}}),n&&(this.triggers=this.find("[data-uk-slideshow-item]"),this.slides.attr("aria-hidden","true").removeClass("uk-active").eq(this.current).addClass("uk-active").attr("aria-hidden","false"),this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass("uk-active")),t&&n&&this.resize()},resize:function(){if(!this.container.hasClass("uk-slideshow-fullscreen")){var t=this.options.height;"auto"===this.options.height&&(t=0,this.slides.css("height","").each(function(){t=Math.max(t,i.$(this).height())})),this.container.css("height",t),this.slides.css("height",t)}},show:function(s,e){if(!this.animating&&this.current!=s){this.animating=!0;var a=this,n=this.slides.eq(this.current),o=this.slides.eq(s),r=e?e:this.current-1&&"ready"==e.event&&e.player_id&&(s=i.$('[data-player-id="'+e.player_id+'"]'),s.length&&s.data("slideshow").mutemedia(s))},!1)}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){var t;window.UIkit2&&(t=i(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-slideshow",["uikit"],function(){return t||i(UIkit2)})}(function(i){"use strict";var t,s=0;i.component("slideshow",{defaults:{animation:"fade",duration:500,height:"auto",start:0,autoplay:!1,autoplayInterval:7e3,videoautoplay:!0,videomute:!0,slices:15,pauseOnHover:!0,kenburns:!1,kenburnsanimations:["uk-animation-middle-left","uk-animation-top-right","uk-animation-bottom-left","uk-animation-top-center","","uk-animation-bottom-right"]},current:!1,interval:null,hovering:!1,boot:function(){i.ready(function(t){i.$("[data-uk-slideshow]",t).each(function(){var t=i.$(this);t.data("slideshow")||i.slideshow(t,i.Utils.options(t.attr("data-uk-slideshow")))})})},init:function(){var t=this;this.container=this.element.hasClass("uk-slideshow")?this.element:i.$(this.find(".uk-slideshow:first")),this.current=this.options.start,this.animating=!1,this.fixFullscreen=navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&this.container.hasClass("uk-slideshow-fullscreen"),this.options.kenburns&&(this.kbanimduration=this.options.kenburns===!0?"15s":this.options.kenburns,String(this.kbanimduration).match(/(ms|s)$/)||(this.kbanimduration+="ms"),"string"==typeof this.options.kenburnsanimations&&(this.options.kenburnsanimations=this.options.kenburnsanimations.split(","))),this.update(),this.on("click.uk.slideshow","[data-uk-slideshow-item]",function(s){s.preventDefault();var e=i.$(this).attr("data-uk-slideshow-item");if(t.current!=e){switch(e){case"next":case"previous":t["next"==e?"next":"previous"]();break;default:t.show(parseInt(e,10))}t.stop()}}),i.$win.on("resize load",i.Utils.debounce(function(){t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight))},100)),setTimeout(function(){t.resize()},80),this.options.autoplay&&this.start(),this.options.videoautoplay&&this.slides.eq(this.current).data("media")&&this.playmedia(this.slides.eq(this.current).data("media")),this.options.kenburns&&this.applyKenBurns(this.slides.eq(this.current)),this.container.on({mouseenter:function(){t.options.pauseOnHover&&(t.hovering=!0)},mouseleave:function(){t.hovering=!1}}),this.on("swipeRight swipeLeft",function(i){t["swipeLeft"==i.type?"next":"previous"]()}),this.on("display.uk.check",function(){t.element.is(":visible")&&(t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight)))}),i.domObserve(this.element,function(){t.container.children(":not([data-slideshow-slide])").not(".uk-slideshow-ghost").length&&t.update(!0)})},update:function(t){var e,a=this,n=0;this.slides=this.container.children(),this.slidesCount=this.slides.length,this.slides.eq(this.current).length||(this.current=0),this.slides.each(function(t){var o=i.$(this);if(!o.data("processed")){var r=o.children("img,video,iframe").eq(0),d="html";if(o.data("media",r),o.data("sizer",r),r.length){var u;switch(d=r[0].nodeName.toLowerCase(),r[0].nodeName){case"IMG":var h=i.$('
            ').css({"background-image":"url("+r.attr("src")+")"});r.attr("width")&&r.attr("height")&&(u=i.$("").attr({width:r.attr("width"),height:r.attr("height")}),r.replaceWith(u),r=u,u=void 0),r.css({width:"100%",height:"auto",opacity:0}),o.prepend(h).data("cover",h);break;case"IFRAME":var c=r[0].src,l="sw-"+ ++s;r.attr("src","").on("load",function(){if((t!==a.current||t==a.current&&!a.options.videoautoplay)&&a.pausemedia(r),a.options.videomute){a.mutemedia(r);var i=setInterval(function(t){return function(){a.mutemedia(r),++t>=4&&clearInterval(i)}}(0),250)}}).data("slideshow",a).attr("data-player-id",l).attr("src",[c,c.indexOf("?")>-1?"&":"?","enablejsapi=1&api=1&player_id="+l].join("")).addClass("uk-position-absolute"),i.support.touch||r.css("pointer-events","none"),u=!0,i.cover&&(i.cover(r),r.attr("data-uk-cover","{}"));break;case"VIDEO":r.addClass("uk-cover-object uk-position-absolute"),u=!0,a.options.videomute&&a.mutemedia(r)}if(u){e=i.$("").attr({width:r[0].width,height:r[0].height});var p=i.$('').attr("src",e[0].toDataURL());o.prepend(p),o.data("sizer",p)}}else o.data("sizer",o);a.hasKenBurns(o)&&o.data("cover").css({"-webkit-animation-duration":a.kbanimduration,"animation-duration":a.kbanimduration}),o.data("processed",++n),o.attr("data-slideshow-slide",d)}}),n&&(this.triggers=this.find("[data-uk-slideshow-item]"),this.slides.attr("aria-hidden","true").removeClass("uk-active").eq(this.current).addClass("uk-active").attr("aria-hidden","false"),this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass("uk-active")),t&&n&&this.resize()},resize:function(){if(!this.container.hasClass("uk-slideshow-fullscreen")){var t=this.options.height;"auto"===this.options.height&&(t=0,this.slides.css("height","").each(function(){t=Math.max(t,i.$(this).height())})),this.container.css("height",t),this.slides.css("height",t)}},show:function(s,e){if(!this.animating&&this.current!=s){this.animating=!0;var a=this,n=this.slides.eq(this.current),o=this.slides.eq(s),r=e?e:this.current-1&&"ready"==e.event&&e.player_id&&(s=i.$('[data-player-id="'+e.player_id+'"]'),s.length&&s.data("slideshow").mutemedia(s))},!1)}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/sortable.min.js b/lib/api/uikit/src/js/components/sortable.min.js index cd66f57c..e083d2d8 100755 --- a/lib/api/uikit/src/js/components/sortable.min.js +++ b/lib/api/uikit/src/js/components/sortable.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-sortable",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";function e(e){e=t.$(e);do{if(e.data("sortable"))return e;e=t.$(e).parent()}while(e.length);return e}function o(t,e){var o=t.parentNode;if(e.parentNode!=o)return!1;for(var n=t.previousSibling;n&&9!==n.nodeType;){if(n===e)return!0;n=n.previousSibling}return!1}function n(t,e){var o=e;if(o==t)return null;for(;o;){if(o.parentNode===t)return o;if(o=o.parentNode,!o||!o.ownerDocument||11===o.nodeType)break}return null}function s(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}var a,r,i,l,d,h,u,p,c,g,f,m="ontouchstart"in window||"MSGesture"in window||window.DocumentTouch&&document instanceof DocumentTouch,v=m?"MSGesture"in window?"pointerdown":"touchstart":"mousedown",b=m?"MSGesture"in window?"pointermove":"touchmove":"mousemove",C=m?"MSGesture"in window?"pointerup":"touchend":"mouseup";return t.component("sortable",{defaults:{animation:150,threshold:10,childClass:"uk-sortable-item",placeholderClass:"uk-sortable-placeholder",overClass:"uk-sortable-over",draggingClass:"uk-sortable-dragged",dragMovingClass:"uk-sortable-moving",baseClass:"uk-sortable",noDragClass:"uk-sortable-nodrag",emptyClass:"uk-sortable-empty",dragCustomClass:"",handleClass:!1,group:!1,stop:function(){},start:function(){},change:function(){}},boot:function(){t.ready(function(e){t.$("[data-uk-sortable]",e).each(function(){var e=t.$(this);e.data("sortable")||t.sortable(e,t.Utils.options(e.attr("data-uk-sortable")))})}),t.$html.on(b,function(e){if(u){var o=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0]:e;(Math.abs(o.pageX-u.pos.x)>u.threshold||Math.abs(o.pageY-u.pos.y)>u.threshold)&&u.apply(o)}if(a){d||(d=!0,a.show(),a.$current.addClass(a.$sortable.options.placeholderClass),a.$sortable.element.children().addClass(a.$sortable.options.childClass),t.$html.addClass(a.$sortable.options.dragMovingClass));var n=a.data("mouse-offset"),s=e.originalEvent.touches&&e.originalEvent.touches[0]||e.originalEvent,r=parseInt(s.pageX,10)+n.left,i=parseInt(s.pageY,10)+n.top;if(a.css({left:r,top:i}),i+a.height()/3>document.body.offsetHeight)return;iwindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(a.height()/3))}}),t.$html.on(C,function(t){if(u=h=!1,!r||!a)return r=a=null,void 0;var o=e(r),n=a.$sortable,s={type:t.type};o[0]&&n.dragDrop(s,n.element),n.dragEnd(s,n.element)})},init:function(){function e(){m&&f.touches&&f.touches.length?h.addEventListener(b,y,!1):(h.addEventListener("mouseover",$,!1),h.addEventListener("mouseout",w,!1))}function o(){m&&f.touches&&f.touches.length?h.removeEventListener(b,y,!1):(h.removeEventListener("mouseover",$,!1),h.removeEventListener("mouseout",w,!1))}function a(t){r&&d.dragMove(t,d)}function l(e){return function(o){var s,a,r;f=o,o&&(s=o.touches&&o.touches[0]||o,a=s.target||o.target,m&&document.elementFromPoint&&(a=document.elementFromPoint(s.pageX-document.body.scrollLeft,s.pageY-document.body.scrollTop)),g=t.$(a)),t.$(a).hasClass("."+d.options.childClass)?e.apply(a,[o]):a!==h&&(r=n(h,a),r&&e.apply(r,[o]))}}var d=this,h=this.element[0];p=[],this.checkEmptyList(),this.element.data("sortable-group",this.options.group?this.options.group:t.Utils.uid("sortable-group"));var u=l(function(e){if(!e.data||!e.data.sortable){var o=t.$(e.target),n=o.is("a[href]")?o:o.parents("a[href]");if(!o.is(":input")){if(d.options.handleClass){var s=o.hasClass(d.options.handleClass)?o:o.closest("."+d.options.handleClass,d.element);if(!s.length)return}return e.preventDefault(),n.length&&n.one("click",function(t){t.preventDefault()}).one(C,function(){c||(n.trigger("click"),m&&n.attr("href").trim()&&(location.href=n.attr("href")))}),e.data=e.data||{},e.data.sortable=h,d.dragStart(e,this)}}}),$=l(t.Utils.debounce(function(t){return d.dragEnter(t,this)}),40),w=l(function(){var e=d.dragenterData(this);d.dragenterData(this,e-1),d.dragenterData(this)||(t.$(this).removeClass(d.options.overClass),d.dragenterData(this,!1))}),y=l(function(t){return r&&r!==this&&i!==this?(d.element.children().removeClass(d.options.overClass),i=this,d.moveElementNextTo(r,this),s(t)):!0});this.addDragHandlers=e,this.removeDragHandlers=o,window.addEventListener(b,a,!1),h.addEventListener(v,u,!1)},dragStart:function(e,o){c=!1,d=!1,l=!1;var n=this,s=t.$(e.target);if(!(!m&&2==e.button||s.is("."+n.options.noDragClass)||s.closest("."+n.options.noDragClass).length||s.is(":input"))){r=o,a&&a.remove();var i=t.$(r),h=i.offset(),p=e.touches&&e.touches[0]||e;u={pos:{x:p.pageX,y:p.pageY},threshold:n.options.handleClass?1:n.options.threshold,apply:function(){a=t.$('
            ').css({display:"none",top:h.top,left:h.left,width:i.width(),height:i.height(),padding:i.css("padding")}).data({"mouse-offset":{left:h.left-parseInt(p.pageX,10),top:h.top-parseInt(p.pageY,10)},origin:n.element,index:i.index()}).append(i.html()).appendTo("body"),a.$current=i,a.$sortable=n,i.data({"start-list":i.parent(),"start-index":i.index(),"sortable-group":n.options.group}),n.addDragHandlers(),n.options.start(this,r),n.trigger("start.uk.sortable",[n,r,a]),c=!0,u=!1}}}},dragMove:function(e){g=t.$(document.elementFromPoint(e.pageX-(document.body.scrollLeft||document.scrollLeft||0),e.pageY-(document.body.scrollTop||document.documentElement.scrollTop||0)));var o,n=g.closest("."+this.options.baseClass),s=n.data("sortable-group"),a=t.$(r),i=a.parent(),l=a.data("sortable-group");n[0]!==i[0]&&void 0!==l&&s===l&&(n.data("sortable").addDragHandlers(),p.push(n),n.children().addClass(this.options.childClass),n.children().length>0?(o=g.closest("."+this.options.childClass),o.length?o.before(a):n.append(a)):g.append(a),UIkit.$doc.trigger("mouseover")),this.checkEmptyList(),this.checkEmptyList(i)},dragEnter:function(e,o){if(!r||r===o)return!0;var n=this.dragenterData(o);if(this.dragenterData(o,n+1),0===n){var s=t.$(o).parent(),a=t.$(r).data("start-list");if(s[0]!==a[0]){var i=s.data("sortable-group"),l=t.$(r).data("sortable-group");if((i||l)&&i!=l)return!1}t.$(o).addClass(this.options.overClass),this.moveElementNextTo(r,o)}return!1},dragEnd:function(e,o){var n=this;r&&(this.options.stop(o),this.trigger("stop.uk.sortable",[this])),r=null,i=null,p.push(this.element),p.forEach(function(e){t.$(e).children().each(function(){1===this.nodeType&&(t.$(this).removeClass(n.options.overClass).removeClass(n.options.placeholderClass).removeClass(n.options.childClass),n.dragenterData(this,!1))})}),p=[],t.$html.removeClass(this.options.dragMovingClass),this.removeDragHandlers(),a&&(a.remove(),a=null)},dragDrop:function(t){"drop"===t.type&&(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()),this.triggerChangeEvents()},triggerChangeEvents:function(){if(r){var e=t.$(r),o=a.data("origin"),n=e.closest("."+this.options.baseClass),s=[],i=t.$(r);o[0]===n[0]&&a.data("index")!=e.index()?s.push({sortable:this,mode:"moved"}):o[0]!=n[0]&&s.push({sortable:t.$(n).data("sortable"),mode:"added"},{sortable:t.$(o).data("sortable"),mode:"removed"}),s.forEach(function(t){t.sortable&&t.sortable.element.trigger("change.uk.sortable",[t.sortable,i,t.mode])})}},dragenterData:function(e,o){return e=t.$(e),1==arguments.length?parseInt(e.data("child-dragenter"),10)||0:(o?e.data("child-dragenter",Math.max(0,o)):e.removeData("child-dragenter"),void 0)},moveElementNextTo:function(e,n){l=!0;var s=this,a=t.$(e).parent().css("min-height",""),r=o(e,n)?n:n.nextSibling,i=a.children(),d=i.length;return s.options.animation?(a.css("min-height",a.height()),i.stop().each(function(){var e=t.$(this),o=e.position();o.width=e.width(),e.data("offset-before",o)}),n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(s.element.parent()),i=a.children().each(function(){var e=t.$(this);e.data("offset-after",e.position())}).each(function(){var e=t.$(this),o=e.data("offset-before");e.css({position:"absolute",top:o.top,left:o.left,"min-width":o.width})}),i.each(function(){var e=t.$(this),o=(e.data("offset-before"),e.data("offset-after"));e.css("pointer-events","none").width(),setTimeout(function(){e.animate({top:o.top,left:o.left},s.options.animation,function(){e.css({position:"",top:"",left:"","min-width":"","pointer-events":""}).removeClass(s.options.overClass).removeData("child-dragenter"),d--,d||(a.css("min-height",""),t.Utils.checkDisplay(s.element.parent()))})},0)}),void 0):(n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(s.element.parent()),void 0)},serialize:function(){var e,o,n=[];return this.element.children().each(function(s,a){e={};for(var r,i,l=0;lu.threshold||Math.abs(o.pageY-u.pos.y)>u.threshold)&&u.apply(o)}if(s){d||(d=!0,s.show(),s.$current.addClass(s.$sortable.options.placeholderClass),s.$sortable.element.children().addClass(s.$sortable.options.childClass),t.$html.addClass(s.$sortable.options.dragMovingClass));var n=s.data("mouse-offset"),a=e.originalEvent.touches&&e.originalEvent.touches[0]||e.originalEvent,r=parseInt(a.pageX,10)+n.left,i=parseInt(a.pageY,10)+n.top;if(s.css({left:r,top:i}),i+s.height()/3>document.body.offsetHeight)return;iwindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(s.height()/3))}}),t.$html.on(C,function(t){if(u=h=!1,!r||!s)return r=s=null,void 0;var o=e(r),n=s.$sortable,a={type:t.type};o[0]&&n.dragDrop(a,n.element),n.dragEnd(a,n.element)})},init:function(){function e(){m&&g.touches&&g.touches.length?h.addEventListener(b,y,!1):(h.addEventListener("mouseover",$,!1),h.addEventListener("mouseout",w,!1))}function o(){m&&g.touches&&g.touches.length?h.removeEventListener(b,y,!1):(h.removeEventListener("mouseover",$,!1),h.removeEventListener("mouseout",w,!1))}function s(t){r&&d.dragMove(t,d)}function l(e){return function(o){var a,s,r;if(g=o,o){if(a=o.touches&&o.touches[0]||o,s=a.target||o.target,m&&document.elementFromPoint){var i=document.elementFromPoint(a.pageX-document.body.scrollLeft,a.pageY-document.body.scrollTop);i&&(s=i)}f=t.$(s)}t.$(s).hasClass("."+d.options.childClass)?e.apply(s,[o]):s!==h&&(r=n(h,s),r&&e.apply(r,[o]))}}var d=this,h=this.element[0];p=[],this.checkEmptyList(),this.element.data("sortable-group",this.options.group?this.options.group:t.Utils.uid("sortable-group"));var u=l(function(e){if(!e.data||!e.data.sortable){var o=t.$(e.target),n=o.is("a[href]")?o:o.parents("a[href]");if(!o.is(":input")){if(d.options.handleClass){var a=o.hasClass(d.options.handleClass)?o:o.closest("."+d.options.handleClass,d.element);if(!a.length)return}return e.preventDefault(),n.length&&n.one("click",function(t){t.preventDefault()}).one(C,function(){c||(n.trigger("click"),m&&n.attr("href").trim()&&(location.href=n.attr("href")))}),e.data=e.data||{},e.data.sortable=h,d.dragStart(e,this)}}}),$=l(t.Utils.debounce(function(t){return d.dragEnter(t,this)}),40),w=l(function(){var e=d.dragenterData(this);d.dragenterData(this,e-1),d.dragenterData(this)||(t.$(this).removeClass(d.options.overClass),d.dragenterData(this,!1))}),y=l(function(t){return r&&r!==this&&i!==this?(d.element.children().removeClass(d.options.overClass),i=this,d.moveElementNextTo(r,this),a(t)):!0});this.addDragHandlers=e,this.removeDragHandlers=o,window.addEventListener(b,s,!1),h.addEventListener(v,u,!1)},dragStart:function(e,o){c=!1,d=!1,l=!1;var n=this,a=t.$(e.target);if((m||2!=e.button)&&!a.is("."+n.options.noDragClass)){var i=a.closest("."+n.options.noDragClass);if(!(i.length&&this.element.find(i[0]).length||a.is(":input"))){r=o,s&&s.remove();var h=t.$(r),p=h.offset(),f=e.touches&&e.touches[0]||e;u={pos:{x:f.pageX,y:f.pageY},threshold:n.options.handleClass?1:n.options.threshold,apply:function(){s=t.$('
            ').css({display:"none",top:p.top,left:p.left,width:h.width(),height:h.height(),padding:h.css("padding")}).data({"mouse-offset":{left:p.left-parseInt(f.pageX,10),top:p.top-parseInt(f.pageY,10)},origin:n.element,index:h.index()}).append(h.html()).appendTo("body"),s.$current=h,s.$sortable=n,h.data({"start-list":h.parent(),"start-index":h.index(),"sortable-group":n.options.group}),n.addDragHandlers(),n.options.start(this,r),n.trigger("start.uk.sortable",[n,r,s]),c=!0,u=!1}}}}},dragMove:function(e){f=t.$(document.elementFromPoint(e.pageX-(document.body.scrollLeft||document.scrollLeft||0),e.pageY-(document.body.scrollTop||document.documentElement.scrollTop||0)));var o,n=f.closest("."+this.options.baseClass),a=n.data("sortable-group"),s=t.$(r),i=s.parent(),l=s.data("sortable-group");n[0]!==i[0]&&void 0!==l&&a===l&&(n.data("sortable").addDragHandlers(),p.push(n),n.children().addClass(this.options.childClass),n.children().length>0?(o=f.closest("."+this.options.childClass),o.length?o.before(s):n.append(s)):f.append(s),t.$doc.trigger("mouseover")),this.checkEmptyList(),this.checkEmptyList(i)},dragEnter:function(e,o){if(!r||r===o)return!0;var n=this.dragenterData(o);if(this.dragenterData(o,n+1),0===n){var a=t.$(o).parent(),s=t.$(r).data("start-list");if(a[0]!==s[0]){var i=a.data("sortable-group"),l=t.$(r).data("sortable-group");if((i||l)&&i!=l)return!1}t.$(o).addClass(this.options.overClass),this.moveElementNextTo(r,o)}return!1},dragEnd:function(e,o){var n=this;r&&(this.options.stop(o),this.trigger("stop.uk.sortable",[this])),r=null,i=null,p.push(this.element),p.forEach(function(e){t.$(e).children().each(function(){1===this.nodeType&&(t.$(this).removeClass(n.options.overClass).removeClass(n.options.placeholderClass).removeClass(n.options.childClass),n.dragenterData(this,!1))})}),p=[],t.$html.removeClass(this.options.dragMovingClass),this.removeDragHandlers(),s&&(s.remove(),s=null)},dragDrop:function(t){"drop"===t.type&&(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()),this.triggerChangeEvents()},triggerChangeEvents:function(){if(r){var e=t.$(r),o=s.data("origin"),n=e.closest("."+this.options.baseClass),a=[],i=t.$(r);o[0]===n[0]&&s.data("index")!=e.index()?a.push({sortable:this,mode:"moved"}):o[0]!=n[0]&&a.push({sortable:t.$(n).data("sortable"),mode:"added"},{sortable:t.$(o).data("sortable"),mode:"removed"}),a.forEach(function(t){t.sortable&&t.sortable.element.trigger("change.uk.sortable",[t.sortable,i,t.mode])})}},dragenterData:function(e,o){return e=t.$(e),1==arguments.length?parseInt(e.data("child-dragenter"),10)||0:(o?e.data("child-dragenter",Math.max(0,o)):e.removeData("child-dragenter"),void 0)},moveElementNextTo:function(e,n){l=!0;var a=this,s=t.$(e).parent().css("min-height",""),r=o(e,n)?n:n.nextSibling,i=s.children(),d=i.length;return a.options.animation?(s.css("min-height",s.height()),i.stop().each(function(){var e=t.$(this),o=e.position();o.width=e.width(),e.data("offset-before",o)}),n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(a.element.parent()),i=s.children().each(function(){var e=t.$(this);e.data("offset-after",e.position())}).each(function(){var e=t.$(this),o=e.data("offset-before");e.css({position:"absolute",top:o.top,left:o.left,minWidth:o.width})}),i.each(function(){var e=t.$(this),o=(e.data("offset-before"),e.data("offset-after"));e.css("pointer-events","none").width(),setTimeout(function(){e.animate({top:o.top,left:o.left},a.options.animation,function(){e.css({position:"",top:"",left:"",minWidth:"","pointer-events":""}).removeClass(a.options.overClass).removeData("child-dragenter"),d--,d||(s.css("min-height",""),t.Utils.checkDisplay(a.element.parent()))})},0)}),void 0):(n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(a.element.parent()),void 0)},serialize:function(){var e,o,n=[];return this.element.children().each(function(a,s){e={};for(var r,i,l=0;lm?m-p:0,u=0;uo?o+h.top:h.top),h.boundary&&h.boundary.length){var f=h.boundary.offset().top;a=h.boundtoparent?c-(f+h.boundary.outerHeight())+parseInt(h.boundary.css("padding-bottom")):c-f,o=p+r>c-a-(h.top<0?0:h.top)?c-a-(p+r):o}if(h.currentTop!=o){if(h.element.css({position:"fixed",top:o,width:h.getWidthFrom.length?h.getWidthFrom.width():h.element.width()}),!h.init&&(h.element.addClass(h.options.clsinit),location.hash&&p>0&&h.options.target)){var g=t.$(location.hash);g.length&&setTimeout(function(t,i){return function(){i.element.width();var e=t.offset(),s=e.top+t.outerHeight(),n=i.element.offset(),o=i.element.outerHeight(),a=n.top+o;n.top
            ').parent(),this.computeWrapper(),this.wrapper.css({"margin-top":this.element.css("margin-top"),"margin-bottom":this.element.css("margin-bottom"),"margin-left":this.element.css("margin-left"),"margin-right":this.element.css("margin-right")}),this.element.css("margin",0),a&&(a===!0||"!"===a[0]?(a=a===!0?this.wrapper.parent():this.wrapper.closest(a.substr(1)),i=!0):"string"==typeof a&&(a=t.$(a))),this.sticky={self:this,options:this.options,element:this.element,currentTop:null,wrapper:this.wrapper,init:!1,getWidthFrom:t.$(this.options.getWidthFrom||this.wrapper),boundary:a,boundtoparent:i,top:0,calcTop:function(){var i=this.options.top;if(this.options.top&&"string"==typeof this.options.top)if(this.options.top.match(/^(-|)(\d+)vh$/))i=window.innerHeight*parseInt(this.options.top,10)/100;else{var e=t.$(this.options.top).first();e.length&&e.is(":visible")&&(i=-1*(e.offset().top+e.outerHeight()-this.wrapper.offset().top))}this.top=i},reset:function(i){this.calcTop();var e=function(){this.element.css({position:"",top:"",width:"",left:"",margin:"0"}),this.element.removeClass([this.options.animation,"uk-animation-reverse",this.options.clsactive].join(" ")),this.element.addClass(this.options.clsinactive),this.element.trigger("inactive.uk.sticky"),this.currentTop=null,this.animate=!1}.bind(this);!i&&this.options.animation&&t.support.animation&&!t.Utils.isInView(this.wrapper)?(this.animate=!0,this.element.removeClass(this.options.animation).one(t.support.animation.end,function(){e()}).width(),this.element.addClass(this.options.animation+" uk-animation-reverse")):e()},check:function(){if(this.options.disabled)return!1;if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidtha?a-i:0,h=this.wrapper.offset().top,p=h-this.top-r,c=i>=p;return c&&this.options.showup&&(1==o&&(c=!1),-1==o&&!this.element.hasClass(this.options.clsactive)&&t.Utils.isInView(this.wrapper)&&(c=!1)),c}},this.sticky.calcTop(),n.push(this.sticky)},update:function(){i(this.sticky)},enable:function(){this.options.disabled=!1,this.update()},disable:function(t){this.options.disabled=!0,this.sticky.reset(t)},computeWrapper:function(){this.wrapper.css({height:-1==["absolute","fixed"].indexOf(this.element.css("position"))?this.element.outerHeight():"","float":"none"!=this.element.css("float")?this.element.css("float"):""}),"fixed"==this.element.css("position")&&this.element.css({width:this.sticky.getWidthFrom.length?this.sticky.getWidthFrom.width():this.element.width()})}}),t.sticky}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-sticky",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";function i(){var i=arguments.length?arguments:n;if(i.length&&!(e.scrollTop()<0))for(var o,a,r,h,p=e.scrollTop(),c=s.height(),l=e.height(),m=c-l,d=p>m?m-p:0,u=0;uo?o+h.top:h.top),h.boundary&&h.boundary.length){var f=h.boundary.offset().top;a=h.boundtoparent?c-(f+h.boundary.outerHeight())+parseInt(h.boundary.css("padding-bottom")):c-f,o=p+r>c-a-(h.top<0?0:h.top)?c-a-(p+r):o}if(h.currentTop!=o){if(h.element.css({position:"fixed",top:o,width:h.getWidthFrom.length?h.getWidthFrom.width():h.element.width()}),!h.init&&(h.element.addClass(h.options.clsinit),location.hash&&p>0&&h.options.target)){var g=t.$(location.hash);g.length&&setTimeout(function(t,i){return function(){i.element.width();var e=t.offset(),s=e.top+t.outerHeight(),n=i.element.offset(),o=i.element.outerHeight(),a=n.top+o;n.top').parent(),this.computeWrapper(),this.wrapper.css({"margin-top":this.element.css("margin-top"),"margin-bottom":this.element.css("margin-bottom"),"margin-left":this.element.css("margin-left"),"margin-right":this.element.css("margin-right")}),this.element.css("margin",0),a&&(a===!0||"!"===a[0]?(a=a===!0?this.wrapper.parent():this.wrapper.closest(a.substr(1)),i=!0):"string"==typeof a&&(a=t.$(a))),this.sticky={self:this,options:this.options,element:this.element,currentTop:null,wrapper:this.wrapper,init:!1,getWidthFrom:t.$(this.options.getWidthFrom||this.wrapper),boundary:a,boundtoparent:i,top:0,calcTop:function(){var i=this.options.top;if(this.options.top&&"string"==typeof this.options.top)if(this.options.top.match(/^(-|)(\d+)vh$/))i=window.innerHeight*parseInt(this.options.top,10)/100;else{var e=t.$(this.options.top).first();e.length&&e.is(":visible")&&(i=-1*(e.offset().top+e.outerHeight()-this.wrapper.offset().top))}this.top=i},reset:function(i){this.calcTop();var e=function(){this.element.css({position:"",top:"",width:"",left:"",margin:"0"}),this.element.removeClass([this.options.animation,"uk-animation-reverse",this.options.clsactive].join(" ")),this.element.addClass(this.options.clsinactive),this.element.trigger("inactive.uk.sticky"),this.currentTop=null,this.animate=!1}.bind(this);!i&&this.options.animation&&t.support.animation&&!t.Utils.isInView(this.wrapper)?(this.animate=!0,this.element.removeClass(this.options.animation).one(t.support.animation.end,function(){e()}).width(),this.element.addClass(this.options.animation+" uk-animation-reverse")):e()},check:function(){if(this.options.disabled)return!1;if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidtha?a-i:0,h=this.wrapper.offset().top,p=h-this.top-r,c=i>=p;return c&&this.options.showup&&(1==o&&(c=!1),-1==o&&!this.element.hasClass(this.options.clsactive)&&t.Utils.isInView(this.wrapper)&&(c=!1)),c}},this.sticky.calcTop(),n.push(this.sticky)},update:function(){i(this.sticky)},enable:function(){this.options.disabled=!1,this.update()},disable:function(t){this.options.disabled=!0,this.sticky.reset(t)},computeWrapper:function(){this.wrapper.css({height:-1==["absolute","fixed"].indexOf(this.element.css("position"))?this.element.outerHeight():"","float":"none"!=this.element.css("float")?this.element.css("float"):""}),"fixed"==this.element.css("position")&&this.element.css({width:this.sticky.getWidthFrom.length?this.sticky.getWidthFrom.width():this.element.width()})}}),t.sticky}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/timepicker.min.js b/lib/api/uikit/src/js/components/timepicker.min.js index ae8c9f8d..cf8dee4c 100755 --- a/lib/api/uikit/src/js/components/timepicker.min.js +++ b/lib/api/uikit/src/js/components/timepicker.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-timepicker",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";function e(t,e){t=t||0,e=e||24;var i,o,a={"12h":[],"24h":[]};for(i=t,o="";e>i;i++)o=""+i,10>i&&(o="0"+o),a["24h"].push({value:o+":00"}),a["24h"].push({value:o+":30"}),0===i&&(o=12,a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>0&&13>i&&12!==i&&(a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>=12&&(o-=12,0===o&&(o=12),10>o&&(o="0"+String(o)),a["12h"].push({value:o+":00 PM"}),a["12h"].push({value:o+":30 PM"}));return a}t.component("timepicker",{defaults:{format:"24h",delay:0,start:0,end:24},boot:function(){t.$html.on("focus.timepicker.uikit","[data-uk-timepicker]",function(){var e=t.$(this);if(!e.data("timepicker")){var i=t.timepicker(e,t.Utils.options(e.attr("data-uk-timepicker")));setTimeout(function(){i.autocomplete.input.focus()},40)}})},init:function(){var i,o=this,a=e(this.options.start,this.options.end);this.options.minLength=0,this.options.template='',this.options.source=function(t){t(a[o.options.format]||a["12h"])},this.element.is("input")?(this.element.wrap('
            '),i=this.element.parent()):i=this.element.addClass("uk-autocomplete"),this.autocomplete=t.autocomplete(i,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-small uk-dropdown-scrollable"),this.autocomplete.on("show.uk.autocomplete",function(){var t=o.autocomplete.dropdown.find('[data-value="'+o.autocomplete.input.val()+'"]');setTimeout(function(){o.autocomplete.pick(t,!0)},10)}),this.autocomplete.input.on("focus",function(){o.autocomplete.value=Math.random(),o.autocomplete.triggercomplete()}).on("blur",t.Utils.debounce(function(){o.checkTime()},100)),this.element.data("timepicker",this)},checkTime:function(){var t,e,i,o,a="AM",u=this.autocomplete.input.val();"12h"==this.options.format?(t=u.split(" "),e=t[0].split(":"),a=t[1]):e=u.split(":"),i=parseInt(e[0],10),o=parseInt(e[1],10),isNaN(i)&&(i=0),isNaN(o)&&(o=0),"12h"==this.options.format?(i>12?i=12:0>i&&(i=12),"am"===a||"a"===a?a="AM":("pm"===a||"p"===a)&&(a="PM"),"AM"!==a&&"PM"!==a&&(a="AM")):i>=24?i=23:0>i&&(i=0),0>o?o=0:o>=60&&(o=0),this.autocomplete.input.val(this.formatTime(i,o,a)).trigger("change")},formatTime:function(t,e,i){return t=10>t?"0"+t:t,e=10>e?"0"+e:e,t+":"+e+("12h"==this.options.format?" "+i:"")}})}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-timepicker",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";function e(t,e){t=t||0,e=e||24;var i,o,a={"12h":[],"24h":[]};for(i=t,o="";e>i;i++)o=""+i,10>i&&(o="0"+o),a["24h"].push({value:o+":00"}),a["24h"].push({value:o+":30"}),0===i&&(o=12,a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>0&&13>i&&12!==i&&(a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>=12&&(o-=12,0===o&&(o=12),10>o&&(o="0"+String(o)),a["12h"].push({value:o+":00 PM"}),a["12h"].push({value:o+":30 PM"}));return a}t.component("timepicker",{defaults:{format:"24h",delay:0,start:0,end:24},boot:function(){t.$html.on("focus.timepicker.uikit","[data-uk-timepicker]",function(){var e=t.$(this);if(!e.data("timepicker")){var i=t.timepicker(e,t.Utils.options(e.attr("data-uk-timepicker")));setTimeout(function(){i.autocomplete.input.focus()},40)}})},init:function(){var i,o=this,a=e(this.options.start,this.options.end);this.options.minLength=0,this.options.template='',this.options.source=function(t){t(a[o.options.format]||a["12h"])},this.element.is("input")?(this.element.wrap('
            '),i=this.element.parent()):i=this.element.addClass("uk-autocomplete"),this.autocomplete=t.autocomplete(i,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-small uk-dropdown-scrollable"),this.autocomplete.on("show.uk.autocomplete",function(){var t=o.autocomplete.dropdown.find('[data-value="'+o.autocomplete.input.val()+'"]');setTimeout(function(){o.autocomplete.pick(t,!0)},10)}),this.autocomplete.input.on("focus",function(){o.autocomplete.value=Math.random(),o.autocomplete.triggercomplete()}).on("blur",t.Utils.debounce(function(){o.checkTime()},100)),this.element.data("timepicker",this)},checkTime:function(){var t,e,i,o,a="AM",u=this.autocomplete.input.val();"12h"==this.options.format?(t=u.split(" "),e=t[0].split(":"),a=t[1]):e=u.split(":"),i=parseInt(e[0],10),o=parseInt(e[1],10),isNaN(i)&&(i=0),isNaN(o)&&(o=0),"12h"==this.options.format?(i>12?i=12:0>i&&(i=12),"am"===a||"a"===a?a="AM":("pm"===a||"p"===a)&&(a="PM"),"AM"!==a&&"PM"!==a&&(a="AM")):i>=24?i=23:0>i&&(i=0),0>o?o=0:o>=60&&(o=0),this.autocomplete.input.val(this.formatTime(i,o,a)).trigger("change")},formatTime:function(t,e,i){return t=10>t?"0"+t:t,e=10>e?"0"+e:e,t+":"+e+("12h"==this.options.format?" "+i:"")}})}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/tooltip.min.js b/lib/api/uikit/src/js/components/tooltip.min.js index 31eda9ab..a47d6524 100755 --- a/lib/api/uikit/src/js/components/tooltip.min.js +++ b/lib/api/uikit/src/js/components/tooltip.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-tooltip",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";var i,o,e;return t.component("tooltip",{defaults:{offset:5,pos:"top",animation:!1,delay:0,cls:"",activeClass:"uk-active",src:function(t){var i=t.attr("title");return void 0!==i&&t.data("cached-title",i).removeAttr("title"),t.data("cached-title")}},tip:"",boot:function(){t.$html.on("mouseenter.tooltip.uikit focus.tooltip.uikit","[data-uk-tooltip]",function(){var i=t.$(this);i.data("tooltip")||(t.tooltip(i,t.Utils.options(i.attr("data-uk-tooltip"))),i.trigger("mouseenter"))})},init:function(){var o=this;i||(i=t.$('
            ').appendTo("body")),this.on({focus:function(){o.show()},blur:function(){o.hide()},mouseenter:function(){o.show()},mouseleave:function(){o.hide()}})},show:function(){if(this.tip="function"==typeof this.options.src?this.options.src(this.element):this.options.src,o&&clearTimeout(o),e&&clearTimeout(e),"string"==typeof this.tip?this.tip.length:0){i.stop().css({top:-2e3,visibility:"hidden"}).removeClass(this.options.activeClass).show(),i.html('
            '+this.tip+"
            ");var s=this,n=t.$.extend({},this.element.offset(),{width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}),l=i[0].offsetWidth,f=i[0].offsetHeight,p="function"==typeof this.options.offset?this.options.offset.call(this.element):this.options.offset,a="function"==typeof this.options.pos?this.options.pos.call(this.element):this.options.pos,h=a.split("-"),c={display:"none",visibility:"visible",top:n.top+n.height+f,left:n.left};if("fixed"==t.$html.css("position")||"fixed"==t.$body.css("position")){var r=t.$("body").offset(),d=t.$("html").offset(),u={top:d.top+r.top,left:d.left+r.left};n.left-=u.left,n.top-=u.top}"left"!=h[0]&&"right"!=h[0]||"right"!=t.langdirection||(h[0]="left"==h[0]?"right":"left");var m={bottom:{top:n.top+n.height+p,left:n.left+n.width/2-l/2},top:{top:n.top-f-p,left:n.left+n.width/2-l/2},left:{top:n.top+n.height/2-f/2,left:n.left-l-p},right:{top:n.top+n.height/2-f/2,left:n.left+n.width+p}};t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l);var v=this.checkBoundary(c.left,c.top,l,f);if(v){switch(v){case"x":a=2==h.length?h[0]+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left";break;case"y":a=2==h.length?(c.top<0?"bottom":"top")+"-"+h[1]:c.top<0?"bottom":"top";break;case"xy":a=2==h.length?(c.top<0?"bottom":"top")+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left"}h=a.split("-"),t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l)}c.left-=t.$body.position().left,o=setTimeout(function(){i.css(c).attr("class",["uk-tooltip","uk-tooltip-"+a,s.options.cls].join(" ")),s.options.animation?i.css({opacity:0,display:"block"}).addClass(s.options.activeClass).animate({opacity:1},parseInt(s.options.animation,10)||400):i.show().addClass(s.options.activeClass),o=!1,e=setInterval(function(){s.element.is(":visible")||s.hide()},150)},parseInt(this.options.delay,10)||0)}},hide:function(){if(!this.element.is("input")||this.element[0]!==document.activeElement)if(o&&clearTimeout(o),e&&clearTimeout(e),i.stop(),this.options.animation){var t=this;i.fadeOut(parseInt(this.options.animation,10)||400,function(){i.removeClass(t.options.activeClass)})}else i.hide().removeClass(this.options.activeClass)},content:function(){return this.tip},checkBoundary:function(i,o,e,s){var n="";return(0>i||i-t.$win.scrollLeft()+e>window.innerWidth)&&(n+="x"),(0>o||o-t.$win.scrollTop()+s>window.innerHeight)&&(n+="y"),n}}),t.tooltip}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-tooltip",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";var i,o,e;return t.component("tooltip",{defaults:{offset:5,pos:"top",animation:!1,delay:0,cls:"",activeClass:"uk-active",src:function(t){var i=t.attr("title");return void 0!==i&&t.data("cached-title",i).removeAttr("title"),t.data("cached-title")}},tip:"",boot:function(){t.$html.on("mouseenter.tooltip.uikit focus.tooltip.uikit","[data-uk-tooltip]",function(){var i=t.$(this);i.data("tooltip")||(t.tooltip(i,t.Utils.options(i.attr("data-uk-tooltip"))),i.trigger("mouseenter"))})},init:function(){var o=this;i||(i=t.$('
            ').appendTo("body")),this.on({focus:function(){o.show()},blur:function(){o.hide()},mouseenter:function(){o.show()},mouseleave:function(){o.hide()}})},show:function(){if(this.tip="function"==typeof this.options.src?this.options.src(this.element):this.options.src,o&&clearTimeout(o),e&&clearInterval(e),"string"==typeof this.tip?this.tip.length:0){i.stop().css({top:-2e3,visibility:"hidden"}).removeClass(this.options.activeClass).show(),i.html('
            '+this.tip+"
            ");var s=this,n=t.$.extend({},this.element.offset(),{width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}),l=i[0].offsetWidth,f=i[0].offsetHeight,a="function"==typeof this.options.offset?this.options.offset.call(this.element):this.options.offset,p="function"==typeof this.options.pos?this.options.pos.call(this.element):this.options.pos,h=p.split("-"),c={display:"none",visibility:"visible",top:n.top+n.height+f,left:n.left};if("fixed"==t.$html.css("position")||"fixed"==t.$body.css("position")){var r=t.$("body").offset(),d=t.$("html").offset(),u={top:d.top+r.top,left:d.left+r.left};n.left-=u.left,n.top-=u.top}"left"!=h[0]&&"right"!=h[0]||"right"!=t.langdirection||(h[0]="left"==h[0]?"right":"left");var m={bottom:{top:n.top+n.height+a,left:n.left+n.width/2-l/2},top:{top:n.top-f-a,left:n.left+n.width/2-l/2},left:{top:n.top+n.height/2-f/2,left:n.left-l-a},right:{top:n.top+n.height/2-f/2,left:n.left+n.width+a}};t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l);var v=this.checkBoundary(c.left,c.top,l,f);if(v){switch(v){case"x":p=2==h.length?h[0]+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left";break;case"y":p=2==h.length?(c.top<0?"bottom":"top")+"-"+h[1]:c.top<0?"bottom":"top";break;case"xy":p=2==h.length?(c.top<0?"bottom":"top")+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left"}h=p.split("-"),t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l)}c.left-=t.$body.position().left,o=setTimeout(function(){i.css(c).attr("class",["uk-tooltip","uk-tooltip-"+p,s.options.cls].join(" ")),s.options.animation?i.css({opacity:0,display:"block"}).addClass(s.options.activeClass).animate({opacity:1},parseInt(s.options.animation,10)||400):i.show().addClass(s.options.activeClass),o=!1,e=setInterval(function(){s.element.is(":visible")||s.hide()},150)},parseInt(this.options.delay,10)||0)}},hide:function(){if(!this.element.is("input")||this.element[0]!==document.activeElement)if(o&&clearTimeout(o),e&&clearInterval(e),i.stop(),this.options.animation){var t=this;i.fadeOut(parseInt(this.options.animation,10)||400,function(){i.removeClass(t.options.activeClass)})}else i.hide().removeClass(this.options.activeClass)},content:function(){return this.tip},checkBoundary:function(i,o,e,s){var n="";return(0>i||i-t.$win.scrollLeft()+e>window.innerWidth)&&(n+="x"),(0>o||o-t.$win.scrollTop()+s>window.innerHeight)&&(n+="y"),n}}),t.tooltip}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/upload.min.js b/lib/api/uikit/src/js/components/upload.min.js index 2f7f3c61..31fe9d43 100755 --- a/lib/api/uikit/src/js/components/upload.min.js +++ b/lib/api/uikit/src/js/components/upload.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(e){var t;window.UIkit&&(t=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json");for(var s in n.headers)a.setRequestHeader(s,n.headers[s]);a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var s=a.complete;if(a.single){var d=o.length,f=0,p=!0;a.beforeAll(o),a.complete=function(e,t){f+=1,s(e,t),a.filelimit&&f>=a.filelimit&&(p=!1),p&&d>f?r([o[f]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){s(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.originalEvent.dataTransfer.files]),t(n.originalEvent.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,headers:{},before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){var t;window.UIkit2&&(t=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit2)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json");for(var s in n.headers)a.setRequestHeader(s,n.headers[s]);a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var s=a.complete;if(a.single){var d=o.length,f=0,p=!0;a.beforeAll(o),a.complete=function(e,t){f+=1,s(e,t),a.filelimit&&f>=a.filelimit&&(p=!1),p&&d>f?r([o[f]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){s(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.originalEvent.dataTransfer.files]),t(n.originalEvent.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,headers:{},before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/alert.min.js b/lib/api/uikit/src/js/core/alert.min.js index e33d27ff..165c3d8b 100755 --- a/lib/api/uikit/src/js/core/alert.min.js +++ b/lib/api/uikit/src/js/core/alert.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";t.component("alert",{defaults:{fade:!0,duration:200,trigger:".uk-alert-close"},boot:function(){t.$html.on("click.alert.uikit","[data-uk-alert]",function(i){var o=t.$(this);if(!o.data("alert")){var e=t.alert(o,t.Utils.options(o.attr("data-uk-alert")));t.$(i.target).is(e.options.trigger)&&(i.preventDefault(),e.close())}})},init:function(){var t=this;this.on("click",this.options.trigger,function(i){i.preventDefault(),t.close()})},close:function(){var t=this.trigger("close.uk.alert"),i=function(){this.trigger("closed.uk.alert").remove()}.bind(this);this.options.fade?t.css("overflow","hidden").css("max-height",t.height()).animate({height:0,opacity:0,"padding-top":0,"padding-bottom":0,"margin-top":0,"margin-bottom":0},this.options.duration,i):i()}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("alert",{defaults:{fade:!0,duration:200,trigger:".uk-alert-close"},boot:function(){t.$html.on("click.alert.uikit","[data-uk-alert]",function(i){var o=t.$(this);if(!o.data("alert")){var e=t.alert(o,t.Utils.options(o.attr("data-uk-alert")));t.$(i.target).is(e.options.trigger)&&(i.preventDefault(),e.close())}})},init:function(){var t=this;this.on("click",this.options.trigger,function(i){i.preventDefault(),t.close()})},close:function(){var t=this.trigger("close.uk.alert"),i=function(){this.trigger("closed.uk.alert").remove()}.bind(this);this.options.fade?t.css("overflow","hidden").css("max-height",t.height()).animate({height:0,opacity:0,paddingTop:0,paddingBottom:0,marginTop:0,marginBottom:0},this.options.duration,i):i()}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/button.min.js b/lib/api/uikit/src/js/core/button.min.js index c1bd2e09..28e6b514 100755 --- a/lib/api/uikit/src/js/core/button.min.js +++ b/lib/api/uikit/src/js/core/button.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";t.component("buttonRadio",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttonradio.uikit","[data-uk-button-radio]",function(i){var a=t.$(this);if(!a.data("buttonRadio")){var e=t.buttonRadio(a,t.Utils.options(a.attr("data-uk-button-radio"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),i.find(i.options.target).not(e).removeClass(i.options.activeClass).blur(),e.addClass(i.options.activeClass),i.find(i.options.target).not(e).attr("aria-checked","false"),e.attr("aria-checked","true"),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("buttonCheckbox",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttoncheckbox.uikit","[data-uk-button-checkbox]",function(i){var a=t.$(this);if(!a.data("buttonCheckbox")){var e=t.buttonCheckbox(a,t.Utils.options(a.attr("data-uk-button-checkbox"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),e.toggleClass(i.options.activeClass).blur(),e.attr("aria-checked",e.hasClass(i.options.activeClass)),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("button",{defaults:{},boot:function(){t.$html.on("click.button.uikit","[data-uk-button]",function(){var i=t.$(this);if(!i.data("button")){{t.button(i,t.Utils.options(i.attr("data-uk-button")))}i.trigger("click")}})},init:function(){var t=this;this.element.attr("aria-pressed",this.element.hasClass("uk-active")),this.on("click",function(i){t.element.is('a[href="#"]')&&i.preventDefault(),t.toggle(),t.trigger("change.uk.button",[t.element.blur().hasClass("uk-active")])})},toggle:function(){this.element.toggleClass("uk-active"),this.element.attr("aria-pressed",this.element.hasClass("uk-active"))}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("buttonRadio",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttonradio.uikit","[data-uk-button-radio]",function(i){var a=t.$(this);if(!a.data("buttonRadio")){var e=t.buttonRadio(a,t.Utils.options(a.attr("data-uk-button-radio"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),i.find(i.options.target).not(e).removeClass(i.options.activeClass).blur(),e.addClass(i.options.activeClass),i.find(i.options.target).not(e).attr("aria-checked","false"),e.attr("aria-checked","true"),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("buttonCheckbox",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttoncheckbox.uikit","[data-uk-button-checkbox]",function(i){var a=t.$(this);if(!a.data("buttonCheckbox")){var e=t.buttonCheckbox(a,t.Utils.options(a.attr("data-uk-button-checkbox"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),e.toggleClass(i.options.activeClass).blur(),e.attr("aria-checked",e.hasClass(i.options.activeClass)),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("button",{defaults:{},boot:function(){t.$html.on("click.button.uikit","[data-uk-button]",function(){var i=t.$(this);if(!i.data("button")){{t.button(i,t.Utils.options(i.attr("data-uk-button")))}i.trigger("click")}})},init:function(){var t=this;this.element.attr("aria-pressed",this.element.hasClass("uk-active")),this.on("click",function(i){t.element.is('a[href="#"]')&&i.preventDefault(),t.toggle(),t.trigger("change.uk.button",[t.element.blur().hasClass("uk-active")])})},toggle:function(){this.element.toggleClass("uk-active"),this.element.attr("aria-pressed",this.element.hasClass("uk-active"))}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/core.min.js b/lib/api/uikit/src/js/core/core.min.js index 04735e65..0419371a 100755 --- a/lib/api/uikit/src/js/core/core.min.js +++ b/lib/api/uikit/src/js/core/core.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){if("function"==typeof define&&define.amd&&define("uikit",function(){var n=window.UIkit||t(window,window.jQuery,window.document);return n.load=function(t,e,o,i){var r,a=t.split(","),s=[],u=(i.config&&i.config.uikit&&i.config.uikit.base?i.config.uikit.base:"").replace(/\/+$/g,"");if(!u)throw new Error("Please define base path to UIkit in the requirejs config.");for(r=0;r0||t.navigator.pointerEnabled&&t.navigator.maxTouchPoints>0||!1,o.support.mutationobserver=t.MutationObserver||t.WebKitMutationObserver||null,o.Utils={},o.Utils.isFullscreen=function(){return document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.fullscreenElement||!1},o.Utils.str2json=function(t,n){try{return n?JSON.parse(t.replace(/([\$\w]+)\s*:/g,function(t,n){return'"'+n+'":'}).replace(/'([^']+)'/g,function(t,n){return'"'+n+'"'})):new Function("","var json = "+t+"; return JSON.parse(JSON.stringify(json));")()}catch(e){return!1}},o.Utils.debounce=function(t,n,e){var o;return function(){var i=this,r=arguments,a=function(){o=null,e||t.apply(i,r)},s=e&&!o;clearTimeout(o),o=setTimeout(a,n),s&&t.apply(i,r)}},o.Utils.throttle=function(t,n){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},n))}},o.Utils.removeCssRules=function(t){var n,e,o,i,r,a,s,u,c,d;t&&setTimeout(function(){try{for(d=document.styleSheets,i=0,s=d.length;s>i;i++){for(o=d[i],e=[],o.cssRules=o.cssRules,n=r=0,u=o.cssRules.length;u>r;n=++r)o.cssRules[n].type===CSSRule.STYLE_RULE&&t.test(o.cssRules[n].selectorText)&&e.unshift(n);for(a=0,c=e.length;c>a;a++)o.deleteRule(e[a])}}catch(l){}},0)},o.Utils.isInView=function(t,e){var i=n(t);if(!i.is(":visible"))return!1;var r=o.$win.scrollLeft(),a=o.$win.scrollTop(),s=i.offset(),u=s.left,c=s.top;return e=n.extend({topoffset:0,leftoffset:0},e),c+i.height()>=a&&c-e.topoffset<=a+o.$win.height()&&u+i.width()>=r&&u-e.leftoffset<=r+o.$win.width()?!0:!1},o.Utils.checkDisplay=function(t,e){var i=o.$("[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]",t||document);return t&&!i.length&&(i=n(t)),i.trigger("display.uk.check"),e&&("string"!=typeof e&&(e='[class*="uk-animation-"]'),i.find(e).each(function(){var t=o.$(this),n=t.attr("class"),e=n.match(/uk-animation-(.+)/);t.removeClass(e[0]).width(),t.addClass(e[0])})),i},o.Utils.options=function(t){if("string"!=n.type(t))return t;-1!=t.indexOf(":")&&"}"!=t.trim().substr(-1)&&(t="{"+t+"}");var e=t?t.indexOf("{"):-1,i={};if(-1!=e)try{i=o.Utils.str2json(t.substr(e))}catch(r){}return i},o.Utils.animate=function(t,e){var i=n.Deferred();return t=o.$(t),t.css("display","none").addClass(e).one(o.support.animation.end,function(){t.removeClass(e),i.resolve()}),t.css("display",""),i.promise()},o.Utils.uid=function(t){return(t||"id")+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random())},o.Utils.template=function(t,n){for(var e,o,i,r,a=t.replace(/\n/g,"\\n").replace(/\{\{\{\s*(.+?)\s*\}\}\}/g,"{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),s=0,u=[],c=0;s/g, '>');}"].join("\n")),n?r(n):r},o.Utils.focus=function(t,e){t=n(t);var o,i=t.find("[autofocus]:first");return i.length?i.focus():(i=t.find(":input"+(e&&","+e||"")).first(),i.length?i.focus():(t.attr("tabindex")||(o=1e3,t.attr("tabindex",o)),t[0].focus(),o&&t.attr("tabindex",""),t))},o.Utils.events={},o.Utils.events.click=o.support.touch?"tap":"click",t.UIkit=o,o.fn=function(t,e){var i=arguments,r=t.match(/^([a-z\-]+)(?:\.([a-z]+))?/i),a=r[1],s=r[2];return o[a]?this.each(function(){var t=n(this),r=t.data(a);r||t.data(a,r=o[a](this,s?void 0:e)),s&&r[s].apply(r,Array.prototype.slice.call(i,1))}):(n.error("UIkit component ["+a+"] does not exist."),this)},n.UIkit=o,n.fn.uk=o.fn,o.langdirection="rtl"==o.$html.attr("dir")?"right":"left",o.components={},o.component=function(t,e){var i=function(e,r){var a=this;return this.UIkit=o,this.element=e?o.$(e):null,this.options=n.extend(!0,{},this.defaults,r),this.plugins={},this.element&&this.element.data(t,this),this.init(),(this.options.plugins.length?this.options.plugins:Object.keys(i.plugins)).forEach(function(t){i.plugins[t].init&&(i.plugins[t].init(a),a.plugins[t]=!0)}),this.trigger("init.uk.component",[t,this]),this};return i.plugins={},n.extend(!0,i.prototype,{defaults:{plugins:[]},boot:function(){},init:function(){},on:function(t,n,e){return o.$(this.element||this).on(t,n,e)},one:function(t,n,e){return o.$(this.element||this).one(t,n,e)},off:function(t){return o.$(this.element||this).off(t)},trigger:function(t,n){return o.$(this.element||this).trigger(t,n)},find:function(t){return o.$(this.element?this.element:[]).find(t)},proxy:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=function(){return t[n].apply(t,arguments)})})},mixin:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=t[n].bind(e))})},option:function(){return 1==arguments.length?this.options[arguments[0]]||void 0:(2==arguments.length&&(this.options[arguments[0]]=arguments[1]),void 0)}},e),this.components[t]=i,this[t]=function(){var e,i;if(arguments.length)switch(arguments.length){case 1:"string"==typeof arguments[0]||arguments[0].nodeType||arguments[0]instanceof jQuery?e=n(arguments[0]):i=arguments[0];break;case 2:e=n(arguments[0]),i=arguments[1]}return e&&e.data(t)?e.data(t):new o.components[t](e,i)},o.domready&&o.component.boot(t),i},o.plugin=function(t,n,e){this.components[t].plugins[n]=e},o.component.boot=function(t){o.components[t].prototype&&o.components[t].prototype.boot&&!o.components[t].booted&&(o.components[t].prototype.boot.apply(o,[]),o.components[t].booted=!0)},o.component.bootComponents=function(){for(var t in o.components)o.component.boot(t)},o.domObservers=[],o.domready=!1,o.ready=function(t){o.domObservers.push(t),o.domready&&t(document)},o.on=function(t,n,e){return t&&t.indexOf("ready.uk.dom")>-1&&o.domready&&n.apply(o.$doc),o.$doc.on(t,n,e)},o.one=function(t,n,e){return t&&t.indexOf("ready.uk.dom")>-1&&o.domready?(n.apply(o.$doc),o.$doc):o.$doc.one(t,n,e)},o.trigger=function(t,n){return o.$doc.trigger(t,n)},o.domObserve=function(t,n){o.support.mutationobserver&&(n=n||function(){},o.$(t).each(function(){var t=this,e=o.$(t);if(!e.data("observer"))try{var i=new o.support.mutationobserver(o.Utils.debounce(function(){n.apply(t,[e]),e.trigger("changed.uk.dom")},50),{childList:!0,subtree:!0});i.observe(t,{childList:!0,subtree:!0}),e.data("observer",i)}catch(r){}}))},o.init=function(t){t=t||document,o.domObservers.forEach(function(n){n(t)})},o.on("domready.uk.dom",function(){o.init(),o.domready&&o.Utils.checkDisplay()}),document.addEventListener("DOMContentLoaded",function(){var t=function(){o.$body=o.$("body"),o.trigger("beforeready.uk.dom"),o.component.bootComponents();var t=requestAnimationFrame(function(){var n={dir:{x:0,y:0},x:window.pageXOffset,y:window.pageYOffset},e=function(){var i=window.pageXOffset,r=window.pageYOffset;(n.x!=i||n.y!=r)&&(n.dir.x=i!=n.x?i>n.x?1:-1:0,n.dir.y=r!=n.y?r>n.y?1:-1:0,n.x=i,n.y=r,o.$doc.trigger("scrolling.uk.document",[{dir:{x:n.dir.x,y:n.dir.y},x:i,y:r}])),cancelAnimationFrame(t),t=requestAnimationFrame(e)};return o.support.touch&&o.$html.on("touchmove touchend MSPointerMove MSPointerUp pointermove pointerup",e),(n.x||n.y)&&e(),e}());if(o.trigger("domready.uk.dom"),o.support.touch&&navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&o.$win.on("load orientationchange resize",o.Utils.debounce(function(){var t=function(){return n(".uk-height-viewport").css("height",window.innerHeight),t};return t()}(),100)),o.trigger("afterready.uk.dom"),o.domready=!0,o.support.mutationobserver){var e=o.Utils.debounce(function(){requestAnimationFrame(function(){o.init(document.body)})},10);new o.support.mutationobserver(function(t){var n=!1;t.every(function(t){if("childList"!=t.type)return!0;for(var e,o=0;o0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0||!1,n.support.mutationobserver=window.MutationObserver||window.WebKitMutationObserver||null,n.Utils={},n.Utils.isFullscreen=function(){return document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.fullscreenElement||!1},n.Utils.str2json=function(t,n){try{return n?JSON.parse(t.replace(/([\$\w]+)\s*:/g,function(t,n){return'"'+n+'":'}).replace(/'([^']+)'/g,function(t,n){return'"'+n+'"'})):new Function("","var json = "+t+"; return JSON.parse(JSON.stringify(json));")()}catch(e){return!1}},n.Utils.debounce=function(t,n,e){var o;return function(){var i=this,r=arguments,a=function(){o=null,e||t.apply(i,r)},s=e&&!o;clearTimeout(o),o=setTimeout(a,n),s&&t.apply(i,r)}},n.Utils.throttle=function(t,n){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},n))}},n.Utils.removeCssRules=function(t){var n,e,o,i,r,a,s,u,c,d;t&&setTimeout(function(){try{for(d=document.styleSheets,i=0,s=d.length;s>i;i++){for(o=d[i],e=[],o.cssRules=o.cssRules,n=r=0,u=o.cssRules.length;u>r;n=++r)o.cssRules[n].type===CSSRule.STYLE_RULE&&t.test(o.cssRules[n].selectorText)&&e.unshift(n);for(a=0,c=e.length;c>a;a++)o.deleteRule(e[a])}}catch(l){}},0)},n.Utils.isInView=function(e,o){var i=t(e);if(!i.is(":visible"))return!1;var r=n.$win.scrollLeft(),a=n.$win.scrollTop(),s=i.offset(),u=s.left,c=s.top;return o=t.extend({topoffset:0,leftoffset:0},o),c+i.height()>=a&&c-o.topoffset<=a+n.$win.height()&&u+i.width()>=r&&u-o.leftoffset<=r+n.$win.width()?!0:!1},n.Utils.checkDisplay=function(e,o){var i=n.$("[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]",e||document);return e&&!i.length&&(i=t(e)),i.trigger("display.uk.check"),o&&("string"!=typeof o&&(o='[class*="uk-animation-"]'),i.find(o).each(function(){var t=n.$(this),e=t.attr("class"),o=e.match(/uk-animation-(.+)/);t.removeClass(o[0]).width(),t.addClass(o[0])})),i},n.Utils.options=function(e){if("string"!=t.type(e))return e;-1!=e.indexOf(":")&&"}"!=e.trim().substr(-1)&&(e="{"+e+"}");var o=e?e.indexOf("{"):-1,i={};if(-1!=o)try{i=n.Utils.str2json(e.substr(o))}catch(r){}return i},n.Utils.animate=function(e,o){var i=t.Deferred();return e=n.$(e),e.css("display","none").addClass(o).one(n.support.animation.end,function(){e.removeClass(o),i.resolve()}),e.css("display",""),i.promise()},n.Utils.uid=function(t){return(t||"id")+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random())},n.Utils.template=function(t,n){for(var e,o,i,r,a=t.replace(/\n/g,"\\n").replace(/\{\{\{\s*(.+?)\s*\}\}\}/g,"{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),s=0,u=[],c=0;s/g, '>');}"].join("\n")),n?r(n):r},n.Utils.focus=function(n,e){if(n=t(n),!n.length)return n;var o,i=n.find("[autofocus]:first");return i.length?i.focus():(i=n.find(":input"+(e&&","+e||"")).first(),i.length?i.focus():(n.attr("tabindex")||(o=1e3,n.attr("tabindex",o)),n[0].focus(),o&&n.attr("tabindex",""),n))},n.Utils.events={},n.Utils.events.click=n.support.touch?"tap":"click",n.fn=function(e,o){var i=arguments,r=e.match(/^([a-z\-]+)(?:\.([a-z]+))?/i),a=r[1],s=r[2];return n[a]?this.each(function(){var e=t(this),r=e.data(a);r||e.data(a,r=n[a](this,s?void 0:o)),s&&r[s].apply(r,Array.prototype.slice.call(i,1))}):(t.error("UIkit component ["+a+"] does not exist."),this)},t.UIkit=n,t.fn.uk=n.fn,n.langdirection="rtl"==n.$html.attr("dir")?"right":"left",n.components={},n.component=function(e,o,i){if(n.components[e]&&!i)return n.components[e];var r=function(o,i){var a=this;return this.UIkit=n,this.element=o?n.$(o):null,this.options=t.extend(!0,{},this.defaults,i),this.plugins={},this.element&&this.element.data(e,this),this.init(),(this.options.plugins.length?this.options.plugins:Object.keys(r.plugins)).forEach(function(t){r.plugins[t].init&&(r.plugins[t].init(a),a.plugins[t]=!0)}),this.trigger("init.uk.component",[e,this]),this};return r.plugins={},t.extend(!0,r.prototype,{defaults:{plugins:[]},boot:function(){},init:function(){},on:function(t,e,o){return n.$(this.element||this).on(t,e,o)},one:function(t,e,o){return n.$(this.element||this).one(t,e,o)},off:function(t){return n.$(this.element||this).off(t)},trigger:function(t,e){return n.$(this.element||this).trigger(t,e)},find:function(t){return n.$(this.element?this.element:[]).find(t)},proxy:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=function(){return t[n].apply(t,arguments)})})},mixin:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=t[n].bind(e))})},option:function(){return 1==arguments.length?this.options[arguments[0]]||void 0:(2==arguments.length&&(this.options[arguments[0]]=arguments[1]),void 0)}},o),this.components[e]=r,this[e]=function(){var o,i;if(arguments.length)switch(arguments.length){case 1:"string"==typeof arguments[0]||arguments[0].nodeType||arguments[0]instanceof jQuery?o=t(arguments[0]):i=arguments[0];break;case 2:o=t(arguments[0]),i=arguments[1]}return o&&o.data(e)?o.data(e):new n.components[e](o,i)},n.domready&&n.component.boot(e),r},n.plugin=function(t,n,e){this.components[t].plugins[n]=e},n.component.boot=function(t){n.components[t].prototype&&n.components[t].prototype.boot&&!n.components[t].booted&&(n.components[t].prototype.boot.apply(n,[]),n.components[t].booted=!0)},n.component.bootComponents=function(){for(var t in n.components)n.component.boot(t)},n.domObservers=[],n.domready=!1,n.ready=function(t){n.domObservers.push(t),n.domready&&t(document)},n.on=function(t,e,o){return t&&t.indexOf("ready.uk.dom")>-1&&n.domready&&e.apply(n.$doc),n.$doc.on(t,e,o)},n.one=function(t,e,o){return t&&t.indexOf("ready.uk.dom")>-1&&n.domready?(e.apply(n.$doc),n.$doc):n.$doc.one(t,e,o)},n.trigger=function(t,e){return n.$doc.trigger(t,e)},n.domObserve=function(t,e){n.support.mutationobserver&&(e=e||function(){},n.$(t).each(function(){var t=this,o=n.$(t);if(!o.data("observer"))try{var i=new n.support.mutationobserver(n.Utils.debounce(function(){e.apply(t,[o]),o.trigger("changed.uk.dom")},50),{childList:!0,subtree:!0});i.observe(t,{childList:!0,subtree:!0}),o.data("observer",i)}catch(r){}}))},n.init=function(t){t=t||document,n.domObservers.forEach(function(n){n(t)})},n.on("domready.uk.dom",function(){n.init(),n.domready&&n.Utils.checkDisplay()}),document.addEventListener("DOMContentLoaded",function(){var e=function(){n.$body=n.$("body"),n.trigger("beforeready.uk.dom"),n.component.bootComponents();var e=requestAnimationFrame(function(){var t={dir:{x:0,y:0},x:window.pageXOffset,y:window.pageYOffset},o=function(){var i=window.pageXOffset,r=window.pageYOffset;(t.x!=i||t.y!=r)&&(t.dir.x=i!=t.x?i>t.x?1:-1:0,t.dir.y=r!=t.y?r>t.y?1:-1:0,t.x=i,t.y=r,n.$doc.trigger("scrolling.uk.document",[{dir:{x:t.dir.x,y:t.dir.y},x:i,y:r}])),cancelAnimationFrame(e),e=requestAnimationFrame(o)};return n.support.touch&&n.$html.on("touchmove touchend MSPointerMove MSPointerUp pointermove pointerup",o),(t.x||t.y)&&o(),o}());if(n.trigger("domready.uk.dom"),n.support.touch&&navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&n.$win.on("load orientationchange resize",n.Utils.debounce(function(){var n=function(){return t(".uk-height-viewport").css("height",window.innerHeight),n};return n()}(),100)),n.trigger("afterready.uk.dom"),n.domready=!0,n.support.mutationobserver){var o=n.Utils.debounce(function(){requestAnimationFrame(function(){n.init(document.body)})},10);new n.support.mutationobserver(function(t){var n=!1;t.every(function(t){if("childList"!=t.type)return!0;for(var e,o=0;o-1?"&":"?","enablejsapi=1&api=1"].join(""))}},check:function(){this.element.css({width:"",height:""}),this.dimension={w:this.element.width(),h:this.element.height()},this.element.attr("width")&&!isNaN(this.element.attr("width"))&&(this.dimension.w=this.element.attr("width")),this.element.attr("height")&&!isNaN(this.element.attr("height"))&&(this.dimension.h=this.element.attr("height")),this.ratio=this.dimension.w/this.dimension.h;var t,i,e=this.parent.width(),n=this.parent.height();e/this.ratio-1?"&":"?","enablejsapi=1&api=1"].join(""))}},check:function(){this.element.css({width:"",height:""}),this.dimension={w:this.element.width(),h:this.element.height()},this.element.attr("width")&&!isNaN(this.element.attr("width"))&&(this.dimension.w=this.element.attr("width")),this.element.attr("height")&&!isNaN(this.element.attr("height"))&&(this.dimension.h=this.element.attr("height")),this.ratio=this.dimension.w/this.dimension.h;var t,i,e=this.parent.width(),n=this.parent.height();e/this.ratiol&&(s.addClass("uk-dropdown-stack"),this.trigger("stack.uk.dropdown",[this])),s.css(f).css("display","").addClass("uk-dropdown-"+e[0])}},checkBoundary:function(o,e,i,n,r){var s="";return(0>o||o-t.$win.scrollLeft()+i>r)&&(s+="x"),(e-t.$win.scrollTop()<0||e-t.$win.scrollTop()+n>window.innerHeight)&&(s+="y"),s}}),t.component("dropdownOverlay",{defaults:{justify:!1,cls:"",duration:200},boot:function(){t.ready(function(o){t.$("[data-uk-dropdown-overlay]",o).each(function(){var o=t.$(this);o.data("dropdownOverlay")||t.dropdownOverlay(o,t.Utils.options(o.attr("data-uk-dropdown-overlay")))})})},init:function(){var e=this;this.justified=this.options.justify?t.$(this.options.justify):!1,this.overlay=this.element.find("uk-dropdown-overlay"),this.overlay.length||(this.overlay=t.$('
            ').appendTo(this.element)),this.overlay.addClass(this.options.cls),this.on({"beforeshow.uk.dropdown":function(t,i){e.dropdown=i,e.justified&&e.justified.length&&o(e.overlay.css({display:"block","margin-left":"","margin-right":""}),e.justified,e.justified.outerWidth())},"show.uk.dropdown":function(){var o=e.dropdown.dropdown.outerHeight(!0);e.dropdown.element.removeClass("uk-open"),e.overlay.stop().css("display","block").animate({height:o},e.options.duration,function(){e.dropdown.dropdown.css("visibility",""),e.dropdown.element.addClass("uk-open"),t.Utils.checkDisplay(e.dropdown.dropdown,!0)}),e.pointerleave=!1},"hide.uk.dropdown":function(){e.overlay.stop().animate({height:0},e.options.duration)},"pointerenter.uk.dropdown":function(){clearTimeout(e.remainIdle)},"pointerleave.uk.dropdown":function(){e.pointerleave=!0}}),this.overlay.on({mouseenter:function(){e.remainIdle&&(clearTimeout(e.dropdown.remainIdle),clearTimeout(e.remainIdle))},mouseleave:function(){e.pointerleave&&i&&(e.remainIdle=setTimeout(function(){i&&i.hide()},i.options.remaintime))}})}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function o(o,e,i,n){if(o=t.$(o),e=t.$(e),i=i||window.innerWidth,n=n||o.offset(),e.length){var r=e.outerWidth();if(o.css("min-width",r),"right"==t.langdirection){var s=i-(e.offset().left+r),d=i-(o.offset().left+o.outerWidth());o.css("margin-right",s-d)}else o.css("margin-left",e.offset().left-n.left)}}var e,i=!1,n={x:{"bottom-left":"bottom-right","bottom-right":"bottom-left","bottom-center":"bottom-center","top-left":"top-right","top-right":"top-left","top-center":"top-center","left-top":"right-top","left-bottom":"right-bottom","left-center":"right-center","right-top":"left-top","right-bottom":"left-bottom","right-center":"left-center"},y:{"bottom-left":"top-left","bottom-right":"top-right","bottom-center":"top-center","top-left":"bottom-left","top-right":"bottom-right","top-center":"bottom-center","left-top":"left-bottom","left-bottom":"left-top","left-center":"left-center","right-top":"right-bottom","right-bottom":"right-top","right-center":"right-center"},xy:{"bottom-left":"top-right","bottom-right":"top-left","bottom-center":"top-center","top-left":"bottom-right","top-right":"bottom-left","top-center":"bottom-center","left-top":"right-bottom","left-bottom":"right-top","left-center":"right-center","right-top":"left-bottom","right-bottom":"left-top","right-center":"left-center"}};t.component("dropdown",{defaults:{mode:"hover",pos:"bottom-left",offset:0,remaintime:800,justify:!1,boundary:t.$win,delay:0,dropdownSelector:".uk-dropdown,.uk-dropdown-blank",hoverDelayIdle:250,preventflip:!1},remainIdle:!1,boot:function(){var o=t.support.touch?"click":"mouseenter";t.$html.on(o+".dropdown.uikit focus pointerdown","[data-uk-dropdown]",function(e){var i=t.$(this);if(!i.data("dropdown")){var n=t.dropdown(i,t.Utils.options(i.attr("data-uk-dropdown")));("click"==e.type||"mouseenter"==e.type&&"hover"==n.options.mode)&&n.element.trigger(o),n.dropdown.length&&e.preventDefault()}})},init:function(){var o=this;this.dropdown=this.find(this.options.dropdownSelector),this.offsetParent=this.dropdown.parents().filter(function(){return-1!==t.$.inArray(t.$(this).css("position"),["relative","fixed","absolute"])}).slice(0,1),this.offsetParent.length||(this.offsetParent=this.element),this.centered=this.dropdown.hasClass("uk-dropdown-center"),this.justified=this.options.justify?t.$(this.options.justify):!1,this.boundary=t.$(this.options.boundary),this.boundary.length||(this.boundary=t.$win),this.dropdown.hasClass("uk-dropdown-up")&&(this.options.pos="top-left"),this.dropdown.hasClass("uk-dropdown-flip")&&(this.options.pos=this.options.pos.replace("left","right")),this.dropdown.hasClass("uk-dropdown-center")&&(this.options.pos=this.options.pos.replace(/(left|right)/,"center")),this.element.attr("aria-haspopup","true"),this.element.attr("aria-expanded",this.element.hasClass("uk-open")),this.dropdown.attr("aria-hidden","true"),"click"==this.options.mode||t.support.touch?this.on("click.uk.dropdown",function(e){var i=t.$(e.target);i.parents(o.options.dropdownSelector).length||((i.is("a[href='#']")||i.parent().is("a[href='#']")||o.dropdown.length&&!o.dropdown.is(":visible"))&&e.preventDefault(),i.blur()),o.element.hasClass("uk-open")?(!o.dropdown.find(e.target).length||i.is(".uk-dropdown-close")||i.parents(".uk-dropdown-close").length)&&o.hide():o.show()}):this.on("mouseenter",function(){o.trigger("pointerenter.uk.dropdown",[o]),o.remainIdle&&clearTimeout(o.remainIdle),e&&clearTimeout(e),i&&i==o||(e=i&&i!=o?setTimeout(function(){e=setTimeout(o.show.bind(o),o.options.delay)},o.options.hoverDelayIdle):setTimeout(o.show.bind(o),o.options.delay))}).on("mouseleave",function(){e&&clearTimeout(e),o.remainIdle=setTimeout(function(){i&&i==o&&o.hide()},o.options.remaintime),o.trigger("pointerleave.uk.dropdown",[o])}).on("click",function(e){var n=t.$(e.target);return o.remainIdle&&clearTimeout(o.remainIdle),i&&i==o?((!o.dropdown.find(e.target).length||n.is(".uk-dropdown-close")||n.parents(".uk-dropdown-close").length)&&o.hide(),void 0):((n.is("a[href='#']")||n.parent().is("a[href='#']"))&&e.preventDefault(),o.show(),void 0)})},show:function(){t.$html.off("click.outer.dropdown"),i&&i!=this&&i.hide(!0),e&&clearTimeout(e),this.trigger("beforeshow.uk.dropdown",[this]),this.checkDimensions(),this.element.addClass("uk-open"),this.element.attr("aria-expanded","true"),this.dropdown.attr("aria-hidden","false"),this.trigger("show.uk.dropdown",[this]),t.Utils.checkDisplay(this.dropdown,!0),t.Utils.focus(this.dropdown),i=this,this.registerOuterClick()},hide:function(t){this.trigger("beforehide.uk.dropdown",[this,t]),this.element.removeClass("uk-open"),this.remainIdle&&clearTimeout(this.remainIdle),this.remainIdle=!1,this.element.attr("aria-expanded","false"),this.dropdown.attr("aria-hidden","true"),this.trigger("hide.uk.dropdown",[this,t]),i==this&&(i=!1)},registerOuterClick:function(){var o=this;t.$html.off("click.outer.dropdown"),setTimeout(function(){t.$html.on("click.outer.dropdown",function(n){e&&clearTimeout(e);t.$(n.target);i!=o||o.element.find(n.target).length||(o.hide(!0),t.$html.off("click.outer.dropdown"))})},10)},checkDimensions:function(){if(this.dropdown.length){this.dropdown.removeClass("uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack uk-dropdown-autoflip").css({topLeft:"",left:"",marginLeft:"",marginRight:""}),this.justified&&this.justified.length&&this.dropdown.css("min-width","");var e,i=t.$.extend({},this.offsetParent.offset(),{width:this.offsetParent[0].offsetWidth,height:this.offsetParent[0].offsetHeight}),r=this.options.offset,s=this.dropdown,d=(s.show().offset()||{left:0,top:0},s.outerWidth()),h=s.outerHeight(),p=this.boundary.width(),l=(this.boundary[0]!==window&&this.boundary.offset()?this.boundary.offset():{top:0,left:0},this.options.pos),a={"bottom-left":{top:0+i.height+r,left:0},"bottom-right":{top:0+i.height+r,left:0+i.width-d},"bottom-center":{top:0+i.height+r,left:0+i.width/2-d/2},"top-left":{top:0-h-r,left:0},"top-right":{top:0-h-r,left:0+i.width-d},"top-center":{top:0-h-r,left:0+i.width/2-d/2},"left-top":{top:0,left:0-d-r},"left-bottom":{top:0+i.height-h,left:0-d-r},"left-center":{top:0+i.height/2-h/2,left:0-d-r},"right-top":{top:0,left:0+i.width+r},"right-bottom":{top:0+i.height-h,left:0+i.width+r},"right-center":{top:0+i.height/2-h/2,left:0+i.width+r}},f={};if(e=l.split("-"),f=a[l]?a[l]:a["bottom-left"],this.justified&&this.justified.length)o(s.css({left:0}),this.justified,p);else if(this.options.preventflip!==!0){var u;switch(this.checkBoundary(i.left+f.left,i.top+f.top,d,h,p)){case"x":"x"!==this.options.preventflip&&(u=n.x[l]||"right-top");break;case"y":"y"!==this.options.preventflip&&(u=n.y[l]||"top-left");break;case"xy":this.options.preventflip||(u=n.xy[l]||"right-bottom")}u&&(e=u.split("-"),f=a[u]?a[u]:a["bottom-left"],s.addClass("uk-dropdown-autoflip"),this.checkBoundary(i.left+f.left,i.top+f.top,d,h,p)&&(e=l.split("-"),f=a[l]?a[l]:a["bottom-left"]))}d>p&&(s.addClass("uk-dropdown-stack"),this.trigger("stack.uk.dropdown",[this])),s.css(f).css("display","").addClass("uk-dropdown-"+e[0])}},checkBoundary:function(o,e,i,n,r){var s="";return(0>o||o-t.$win.scrollLeft()+i>r)&&(s+="x"),(e-t.$win.scrollTop()<0||e-t.$win.scrollTop()+n>window.innerHeight)&&(s+="y"),s}}),t.component("dropdownOverlay",{defaults:{justify:!1,cls:"",duration:200},boot:function(){t.ready(function(o){t.$("[data-uk-dropdown-overlay]",o).each(function(){var o=t.$(this);o.data("dropdownOverlay")||t.dropdownOverlay(o,t.Utils.options(o.attr("data-uk-dropdown-overlay")))})})},init:function(){var e=this;this.justified=this.options.justify?t.$(this.options.justify):!1,this.overlay=this.element.find("uk-dropdown-overlay"),this.overlay.length||(this.overlay=t.$('
            ').appendTo(this.element)),this.overlay.addClass(this.options.cls),this.on({"beforeshow.uk.dropdown":function(t,i){e.dropdown=i,e.justified&&e.justified.length&&o(e.overlay.css({display:"block",marginLeft:"",marginRight:""}),e.justified,e.justified.outerWidth())},"show.uk.dropdown":function(){var o=e.dropdown.dropdown.outerHeight(!0);e.dropdown.element.removeClass("uk-open"),e.overlay.stop().css("display","block").animate({height:o},e.options.duration,function(){e.dropdown.dropdown.css("visibility",""),e.dropdown.element.addClass("uk-open"),t.Utils.checkDisplay(e.dropdown.dropdown,!0)}),e.pointerleave=!1},"hide.uk.dropdown":function(){e.overlay.stop().animate({height:0},e.options.duration)},"pointerenter.uk.dropdown":function(){clearTimeout(e.remainIdle)},"pointerleave.uk.dropdown":function(){e.pointerleave=!0}}),this.overlay.on({mouseenter:function(){e.remainIdle&&(clearTimeout(e.dropdown.remainIdle),clearTimeout(e.remainIdle))},mouseleave:function(){e.pointerleave&&i&&(e.remainIdle=setTimeout(function(){i&&i.hide()},i.options.remaintime))}})}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/grid.min.js b/lib/api/uikit/src/js/core/grid.min.js index cb967d62..dde71152 100755 --- a/lib/api/uikit/src/js/core/grid.min.js +++ b/lib/api/uikit/src/js/core/grid.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";var i=[];t.component("gridMatchHeight",{defaults:{target:!1,row:!0,ignorestacked:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid-match]",i).each(function(){var i,n=t.$(this);n.data("gridMatchHeight")||(i=t.gridMatchHeight(n,t.Utils.options(n.attr("data-uk-grid-match"))))})})},init:function(){var n=this;this.columns=this.element.children(),this.elements=this.options.target?this.find(this.options.target):this.columns,this.columns.length&&(t.$win.on("load resize orientationchange",function(){var i=function(){n.element.is(":visible")&&n.match()};return t.$(function(){i()}),t.Utils.debounce(i,50)}()),this.options.observe&&t.domObserve(this.element,function(){n.element.is(":visible")&&n.match()}),this.on("display.uk.check",function(){this.element.is(":visible")&&this.match()}.bind(this)),i.push(this))},match:function(){var i=this.columns.filter(":visible:first");if(i.length){var n=Math.ceil(100*parseFloat(i.css("width"))/parseFloat(i.parent().css("width")))>=100;return n&&!this.options.ignorestacked?this.revert():t.Utils.matchHeights(this.elements,this.options),this}},revert:function(){return this.elements.css("min-height",""),this}}),t.component("gridMargin",{defaults:{cls:"uk-grid-margin",rowfirst:"uk-row-first"},boot:function(){t.ready(function(i){t.$("[data-uk-grid-margin]",i).each(function(){var i,n=t.$(this);n.data("gridMargin")||(i=t.gridMargin(n,t.Utils.options(n.attr("data-uk-grid-margin"))))})})},init:function(){t.stackMargin(this.element,this.options)}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var i=[];t.component("gridMatchHeight",{defaults:{target:!1,row:!0,ignorestacked:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid-match]",i).each(function(){var i,n=t.$(this);n.data("gridMatchHeight")||(i=t.gridMatchHeight(n,t.Utils.options(n.attr("data-uk-grid-match"))))})})},init:function(){var n=this;this.columns=this.element.children(),this.elements=this.options.target?this.find(this.options.target):this.columns,this.columns.length&&(t.$win.on("load resize orientationchange",function(){var i=function(){n.element.is(":visible")&&n.match()};return t.$(function(){i()}),t.Utils.debounce(i,50)}()),this.options.observe&&t.domObserve(this.element,function(){n.element.is(":visible")&&n.match()}),this.on("display.uk.check",function(){this.element.is(":visible")&&this.match()}.bind(this)),i.push(this))},match:function(){var i=this.columns.filter(":visible:first");if(i.length){var n=Math.ceil(100*parseFloat(i.css("width"))/parseFloat(i.parent().css("width")))>=100;return n&&!this.options.ignorestacked?this.revert():t.Utils.matchHeights(this.elements,this.options),this}},revert:function(){return this.elements.css("min-height",""),this}}),t.component("gridMargin",{defaults:{cls:"uk-grid-margin",rowfirst:"uk-row-first"},boot:function(){t.ready(function(i){t.$("[data-uk-grid-margin]",i).each(function(){var i,n=t.$(this);n.data("gridMargin")||(i=t.gridMargin(n,t.Utils.options(n.attr("data-uk-grid-margin"))))})})},init:function(){t.stackMargin(this.element,this.options)}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/modal.min.js b/lib/api/uikit/src/js/core/modal.min.js index 25da8e26..ce9e9739 100755 --- a/lib/api/uikit/src/js/core/modal.min.js +++ b/lib/api/uikit/src/js/core/modal.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";function i(i,e){return e?("object"==typeof i?(i=i instanceof jQuery?i:t.$(i),i.parent().length&&(e.persist=i,e.persist.data("modalPersistParent",i.parent()))):i="string"==typeof i||"number"==typeof i?t.$("
            ").html(i):t.$("
            ").html("UIkit.modal Error: Unsupported data type: "+typeof i),i.appendTo(e.element.find(".uk-modal-dialog")),e):void 0}var e,o=!1,n=0,s=t.$html;t.$win.on("resize orientationchange",t.Utils.debounce(function(){t.$(".uk-modal.uk-open").each(function(){return t.$(this).data("modal")&&t.$(this).data("modal").resize()})},150)),t.component("modal",{defaults:{keyboard:!0,bgclose:!0,minScrollHeight:150,center:!1,modal:!0},scrollable:!1,transition:!1,hasTransitioned:!0,init:function(){if(e||(e=t.$("body")),this.element.length){var i=this;this.paddingdir="padding-"+("left"==t.langdirection?"right":"left"),this.dialog=this.find(".uk-modal-dialog"),this.active=!1,this.element.attr("aria-hidden",this.element.hasClass("uk-open")),this.on("click",".uk-modal-close",function(t){t.preventDefault(),i.hide()}).on("click",function(e){var o=t.$(e.target);o[0]==i.element[0]&&i.options.bgclose&&i.hide()}),t.domObserve(this.element,function(){i.resize()})}},toggle:function(){return this[this.isActive()?"hide":"show"]()},show:function(){if(this.element.length){var i=this;if(!this.isActive())return this.options.modal&&o&&o.hide(!0),this.element.removeClass("uk-open").show(),this.resize(!0),this.options.modal&&(o=this),this.active=!0,n++,t.support.transition?(this.hasTransitioned=!1,this.element.one(t.support.transition.end,function(){i.hasTransitioned=!0,t.Utils.focus(i.dialog,"a[href]")}).addClass("uk-open")):(this.element.addClass("uk-open"),t.Utils.focus(this.dialog,"a[href]")),s.addClass("uk-modal-page").height(),this.element.attr("aria-hidden","false"),this.element.trigger("show.uk.modal"),t.Utils.checkDisplay(this.dialog,!0),this}},hide:function(i){if(!i&&t.support.transition&&this.hasTransitioned){var e=this;this.one(t.support.transition.end,function(){e._hide()}).removeClass("uk-open")}else this._hide();return this},resize:function(t){if(this.isActive()||t){var i=e.width();if(this.scrollbarwidth=window.innerWidth-i,e.css(this.paddingdir,this.scrollbarwidth),this.element.css("overflow-y",this.scrollbarwidth?"scroll":"auto"),!this.updateScrollable()&&this.options.center){var o=this.dialog.outerHeight(),n=parseInt(this.dialog.css("margin-top"),10)+parseInt(this.dialog.css("margin-bottom"),10);o+ni?20:i)-e;return t.css({"max-height":n0?n--:n=0,this.element.hide().removeClass("uk-open"),this.element.attr("aria-hidden","true"),n||(s.removeClass("uk-modal-page"),e.css(this.paddingdir,"")),o===this&&(o=!1),this.trigger("hide.uk.modal")},isActive:function(){return this.element.hasClass("uk-open")}}),t.component("modalTrigger",{boot:function(){t.$html.on("click.modal.uikit","[data-uk-modal]",function(i){var e=t.$(this);if(e.is("a")&&i.preventDefault(),!e.data("modalTrigger")){var o=t.modalTrigger(e,t.Utils.options(e.attr("data-uk-modal")));o.show()}}),t.$html.on("keydown.modal.uikit",function(t){o&&27===t.keyCode&&o.options.keyboard&&(t.preventDefault(),o.hide())})},init:function(){var i=this;this.options=t.$.extend({target:i.element.is("a")?i.element.attr("href"):!1},this.options),this.modal=t.modal(this.options.target,this.options),this.on("click",function(t){t.preventDefault(),i.show()}),this.proxy(this.modal,"show hide isActive")}}),t.modal.dialog=function(e,o){var n=t.modal(t.$(t.modal.dialog.template).appendTo("body"),o);return n.on("hide.uk.modal",function(){n.persist&&(n.persist.appendTo(n.persist.data("modalPersistParent")),n.persist=!1),n.element.remove()}),i(e,n),n},t.modal.dialog.template='
            ',t.modal.alert=function(i,e){e=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},e);var o=t.modal.dialog(['
            '+String(i)+"
            ",'"].join(""),e);return o.on("show.uk.modal",function(){setTimeout(function(){o.element.find("button:first").focus()},50)}),o.show()},t.modal.confirm=function(i,e,o){var n=arguments.length>1&&arguments[arguments.length-1]?arguments[arguments.length-1]:{};e=t.$.isFunction(e)?e:function(){},o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},t.$.isFunction(n)?{}:n);var s=t.modal.dialog(['
            '+String(i)+"
            ",'"].join(""),n);return s.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click",function(){t.$(this).is(".js-modal-confirm")?e():o(),s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){s.element.find(".js-modal-confirm").focus()},50)}),s.show()},t.modal.prompt=function(i,e,o,n){o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},n);var s=t.modal.dialog([i?'
            '+String(i)+"
            ":"",'

            ','"].join(""),n),a=s.element.find("input[type='text']").val(e||"").on("keyup",function(t){13==t.keyCode&&s.element.find(".js-modal-ok").trigger("click")});return s.element.find(".js-modal-ok").on("click",function(){o(a.val())!==!1&&s.hide()}),s.show()},t.modal.blockUI=function(i,e){var o=t.modal.dialog(['
            '+String(i||'
            ...
            ')+"
            "].join(""),t.$.extend({bgclose:!1,keyboard:!1,modal:!1},e));return o.content=o.element.find(".uk-modal-content:first"),o.show()},t.modal.labels={Ok:"Ok",Cancel:"Cancel"}}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i,e){return e?("object"==typeof i?(i=i instanceof jQuery?i:t.$(i),i.parent().length&&(e.persist=i,e.persist.data("modalPersistParent",i.parent()))):i="string"==typeof i||"number"==typeof i?t.$("
            ").html(i):t.$("
            ").html("UIkit2.modal Error: Unsupported data type: "+typeof i),i.appendTo(e.element.find(".uk-modal-dialog")),e):void 0}var e,o=!1,n=0,s=t.$html;t.$win.on("resize orientationchange",t.Utils.debounce(function(){t.$(".uk-modal.uk-open").each(function(){return t.$(this).data("modal")&&t.$(this).data("modal").resize()})},150)),t.component("modal",{defaults:{keyboard:!0,bgclose:!0,minScrollHeight:150,center:!1,modal:!0},scrollable:!1,transition:!1,hasTransitioned:!0,init:function(){if(e||(e=t.$("body")),this.element.length){var i=this;this.paddingdir="padding-"+("left"==t.langdirection?"right":"left"),this.dialog=this.find(".uk-modal-dialog"),this.active=!1,this.element.attr("aria-hidden",this.element.hasClass("uk-open")),this.on("click",".uk-modal-close",function(e){e.preventDefault();var o=t.$(e.target).closest(".uk-modal");o[0]===i.element[0]&&i.hide()}).on("click",function(e){var o=t.$(e.target);o[0]==i.element[0]&&i.options.bgclose&&i.hide()}),t.domObserve(this.element,function(){i.resize()})}},toggle:function(){return this[this.isActive()?"hide":"show"]()},show:function(){if(this.element.length){var i=this;if(!this.isActive())return this.options.modal&&o&&o.hide(!0),this.element.removeClass("uk-open").show(),this.resize(!0),this.options.modal&&(o=this),this.active=!0,n++,t.support.transition?(this.hasTransitioned=!1,this.element.one(t.support.transition.end,function(){i.hasTransitioned=!0,t.Utils.focus(i.dialog,"a[href]")}).addClass("uk-open")):(this.element.addClass("uk-open"),t.Utils.focus(this.dialog,"a[href]")),s.addClass("uk-modal-page").height(),this.element.attr("aria-hidden","false"),this.element.trigger("show.uk.modal"),t.Utils.checkDisplay(this.dialog,!0),this}},hide:function(i){if(!i&&t.support.transition&&this.hasTransitioned){var e=this;this.one(t.support.transition.end,function(){e._hide()}).removeClass("uk-open")}else this._hide();return this},resize:function(t){if(this.isActive()||t){var i=e.width();if(this.scrollbarwidth=window.innerWidth-i,e.css(this.paddingdir,this.scrollbarwidth),this.element.css("overflow-y",this.scrollbarwidth?"scroll":"auto"),!this.updateScrollable()&&this.options.center){var o=this.dialog.outerHeight(),n=parseInt(this.dialog.css("margin-top"),10)+parseInt(this.dialog.css("margin-bottom"),10);o+ni?20:i)-e;return t.css({maxHeight:n0?n--:n=0,this.element.hide().removeClass("uk-open"),this.element.attr("aria-hidden","true"),n||(s.removeClass("uk-modal-page"),e.css(this.paddingdir,"")),o===this&&(o=!1),this.trigger("hide.uk.modal")},isActive:function(){return this.element.hasClass("uk-open")}}),t.component("modalTrigger",{boot:function(){t.$html.on("click.modal.uikit","[data-uk-modal]",function(i){var e=t.$(this);if(e.is("a")&&i.preventDefault(),!e.data("modalTrigger")){var o=t.modalTrigger(e,t.Utils.options(e.attr("data-uk-modal")));o.show()}}),t.$html.on("keydown.modal.uikit",function(t){o&&27===t.keyCode&&o.options.keyboard&&(t.preventDefault(),o.hide())})},init:function(){var i=this;this.options=t.$.extend({target:i.element.is("a")?i.element.attr("href"):!1},this.options),this.modal=t.modal(this.options.target,this.options),this.on("click",function(t){t.preventDefault(),i.show()}),this.proxy(this.modal,"show hide isActive")}}),t.modal.dialog=function(e,o){var n=t.modal(t.$(t.modal.dialog.template).appendTo("body"),o);return n.on("hide.uk.modal",function(){n.persist&&(n.persist.appendTo(n.persist.data("modalPersistParent")),n.persist=!1),n.element.remove()}),i(e,n),n},t.modal.dialog.template='
            ',t.modal.alert=function(i,e){e=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},e);var o=t.modal.dialog(['
            '+String(i)+"
            ",'"].join(""),e);return o.on("show.uk.modal",function(){setTimeout(function(){o.element.find("button:first").focus()},50)}),o.show()},t.modal.confirm=function(i,e,o){var n=arguments.length>1&&arguments[arguments.length-1]?arguments[arguments.length-1]:{};e=t.$.isFunction(e)?e:function(){},o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},t.$.isFunction(n)?{}:n);var s=t.modal.dialog(['
            '+String(i)+"
            ",'"].join(""),n);return s.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click",function(){t.$(this).is(".js-modal-confirm")?e():o(),s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){s.element.find(".js-modal-confirm").focus()},50)}),s.show()},t.modal.prompt=function(i,e,o,n){o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},n);var s=t.modal.dialog([i?'
            '+String(i)+"
            ":"",'

            ','"].join(""),n),a=s.element.find("input[type='text']").val(e||"").on("keyup",function(t){13==t.keyCode&&s.element.find(".js-modal-ok").trigger("click")});return s.element.find(".js-modal-ok").on("click",function(){o(a.val())!==!1&&s.hide()}),s.show()},t.modal.blockUI=function(i,e){var o=t.modal.dialog(['
            '+String(i||'
            ...
            ')+"
            "].join(""),t.$.extend({bgclose:!1,keyboard:!1,modal:!1},e));return o.content=o.element.find(".uk-modal-content:first"),o.show()},t.modal.labels={Ok:"Ok",Cancel:"Cancel"}}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/nav.min.js b/lib/api/uikit/src/js/core/nav.min.js index 25e43ab2..88e6fec0 100755 --- a/lib/api/uikit/src/js/core/nav.min.js +++ b/lib/api/uikit/src/js/core/nav.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";function i(i){var s=t.$(i),e="auto";if(s.is(":visible"))e=s.outerHeight();else{var a={position:s.css("position"),visibility:s.css("visibility"),display:s.css("display")};e=s.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),s.css(a)}return e}t.component("nav",{defaults:{toggle:">li.uk-parent > a[href='#']",lists:">li.uk-parent > ul",multiple:!1},boot:function(){t.ready(function(i){t.$("[data-uk-nav]",i).each(function(){var i=t.$(this);if(!i.data("nav")){t.nav(i,t.Utils.options(i.attr("data-uk-nav")))}})})},init:function(){var i=this;this.on("click.uk.nav",this.options.toggle,function(s){s.preventDefault();var e=t.$(this);i.open(e.parent()[0]==i.element[0]?e:e.parent("li"))}),this.update(!0),t.domObserve(this.element,function(){i.element.find(this.options.lists).not("[role]").length&&i.update()})},update:function(){var i=this;this.find(this.options.lists).each(function(){var s=t.$(this).attr("role","menu"),e=s.closest("li"),a=e.hasClass("uk-active");e.data("list-container")||(s.wrap('
            '),e.data("list-container",s.parent()[a?"removeClass":"addClass"]("uk-hidden"))),e.attr("aria-expanded",e.hasClass("uk-open")),a&&i.open(e,!0)})},open:function(s,e){var a=this,n=this.element,o=t.$(s),l=o.data("list-container");this.options.multiple||n.children(".uk-open").not(s).each(function(){var i=t.$(this);i.data("list-container")&&i.data("list-container").stop().animate({height:0},function(){t.$(this).parent().removeClass("uk-open").end().addClass("uk-hidden")})}),o.toggleClass("uk-open"),o.attr("aria-expanded",o.hasClass("uk-open")),l&&(o.hasClass("uk-open")&&l.removeClass("uk-hidden"),e?(l.stop().height(o.hasClass("uk-open")?"auto":0),o.hasClass("uk-open")||l.addClass("uk-hidden"),this.trigger("display.uk.check")):l.stop().animate({height:o.hasClass("uk-open")?i(l.find("ul:first")):0},function(){o.hasClass("uk-open")?l.css("height",""):l.addClass("uk-hidden"),a.trigger("display.uk.check")}))}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i){var s=t.$(i),e="auto";if(s.is(":visible"))e=s.outerHeight();else{var a={position:s.css("position"),visibility:s.css("visibility"),display:s.css("display")};e=s.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),s.css(a)}return e}t.component("nav",{defaults:{toggle:'>li.uk-parent > a[href="#"]',lists:">li.uk-parent > ul",multiple:!1},boot:function(){t.ready(function(i){t.$("[data-uk-nav]",i).each(function(){var i=t.$(this);if(!i.data("nav")){t.nav(i,t.Utils.options(i.attr("data-uk-nav")))}})})},init:function(){var i=this;this.on("click.uk.nav",this.options.toggle,function(s){s.preventDefault();var e=t.$(this);i.open(e.parent()[0]==i.element[0]?e:e.parent("li"))}),this.update(),t.domObserve(this.element,function(){i.element.find(i.options.lists).not("[role]").length&&i.update()})},update:function(){var i=this;this.find(this.options.lists).each(function(){var s=t.$(this).attr("role","menu"),e=s.closest("li"),a=e.hasClass("uk-active");e.data("list-container")||(s.wrap('
            '),e.data("list-container",s.parent()[a?"removeClass":"addClass"]("uk-hidden"))),e.attr("aria-expanded",e.hasClass("uk-open")),a&&i.open(e,!0)})},open:function(s,e){var a=this,n=this.element,o=t.$(s),l=o.data("list-container");this.options.multiple||n.children(".uk-open").not(s).each(function(){var i=t.$(this);i.data("list-container")&&i.data("list-container").stop().animate({height:0},function(){t.$(this).parent().removeClass("uk-open").end().addClass("uk-hidden")})}),o.toggleClass("uk-open"),o.attr("aria-expanded",o.hasClass("uk-open")),l&&(o.hasClass("uk-open")&&l.removeClass("uk-hidden"),e?(l.stop().height(o.hasClass("uk-open")?"auto":0),o.hasClass("uk-open")||l.addClass("uk-hidden"),this.trigger("display.uk.check")):l.stop().animate({height:o.hasClass("uk-open")?i(l.find("ul:first")):0},function(){o.hasClass("uk-open")?l.css("height",""):l.addClass("uk-hidden"),a.trigger("display.uk.check")}))}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/offcanvas.min.js b/lib/api/uikit/src/js/core/offcanvas.min.js index ea104ecd..7ee78a05 100755 --- a/lib/api/uikit/src/js/core/offcanvas.min.js +++ b/lib/api/uikit/src/js/core/offcanvas.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(a){"use strict";var t={x:window.scrollX,y:window.scrollY},n=(a.$win,a.$doc,a.$html),i={show:function(i,o){if(i=a.$(i),i.length){o=a.$.extend({mode:"push"},o);var e=a.$("body"),s=i.find(".uk-offcanvas-bar:first"),r="right"==a.langdirection,f=s.hasClass("uk-offcanvas-bar-flip")?-1:1,c=f*(r?-1:1),h=window.innerWidth-e.width();t={x:window.pageXOffset,y:window.pageYOffset},s.attr("mode",o.mode),i.addClass("uk-active"),e.css({width:window.innerWidth-h,height:window.innerHeight}).addClass("uk-offcanvas-page"),("push"==o.mode||"reveal"==o.mode)&&e.css(r?"margin-right":"margin-left",(r?-1:1)*s.outerWidth()*c),"reveal"==o.mode&&s.css("clip","rect(0, "+s.outerWidth()+"px, 100vh, 0)"),n.css("margin-top",-1*t.y).width(),s.addClass("uk-offcanvas-bar-show"),this._initElement(i),s.trigger("show.uk.offcanvas",[i,s]),i.attr("aria-hidden","false")}},hide:function(i){var o=a.$("body"),e=a.$(".uk-offcanvas.uk-active"),s="right"==a.langdirection,r=e.find(".uk-offcanvas-bar:first"),f=function(){o.removeClass("uk-offcanvas-page").css({width:"",height:"","margin-left":"","margin-right":""}),e.removeClass("uk-active"),r.removeClass("uk-offcanvas-bar-show"),n.css("margin-top",""),window.scrollTo(t.x,t.y),r.trigger("hide.uk.offcanvas",[e,r]),e.attr("aria-hidden","true")};e.length&&("none"==r.attr("mode")&&(i=!0),a.support.transition&&!i?(o.one(a.support.transition.end,function(){f()}).css(s?"margin-right":"margin-left",""),"reveal"==r.attr("mode")&&r.css("clip",""),setTimeout(function(){r.removeClass("uk-offcanvas-bar-show")},0)):f())},_initElement:function(t){t.data("OffcanvasInit")||(t.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas",function(t){var n=a.$(t.target);if(!t.type.match(/swipe/)&&!n.hasClass("uk-offcanvas-close")){if(n.hasClass("uk-offcanvas-bar"))return;if(n.parents(".uk-offcanvas-bar:first").length)return}t.stopImmediatePropagation(),i.hide()}),t.on("click","a[href*='#']",function(){var t=a.$(this),n=t.attr("href");"#"!=n&&(a.$doc.one("hide.uk.offcanvas",function(){var i;try{i=a.$(t[0].hash)}catch(o){i=""}i.length||(i=a.$('[name="'+t[0].hash.replace("#","")+'"]')),i.length&&a.Utils.scrollToElement?a.Utils.scrollToElement(i,a.Utils.options(t.attr("data-uk-smooth-scroll")||"{}")):window.location.href=n}),i.hide())}),t.data("OffcanvasInit",!0))}};a.component("offcanvasTrigger",{boot:function(){n.on("click.offcanvas.uikit","[data-uk-offcanvas]",function(t){t.preventDefault();var n=a.$(this);if(!n.data("offcanvasTrigger")){{a.offcanvasTrigger(n,a.Utils.options(n.attr("data-uk-offcanvas")))}n.trigger("click")}}),n.on("keydown.uk.offcanvas",function(a){27===a.keyCode&&i.hide()})},init:function(){var t=this;this.options=a.$.extend({target:t.element.is("a")?t.element.attr("href"):!1,mode:"push"},this.options),this.on("click",function(a){a.preventDefault(),i.show(t.options.target,t.options)})}}),a.offcanvas=i}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(a){"use strict";var t={x:window.scrollX,y:window.scrollY},n=(a.$win,a.$doc,a.$html),i={show:function(i,e){if(i=a.$(i),i.length){e=a.$.extend({mode:"push"},e);var o=a.$("body"),s=i.find(".uk-offcanvas-bar:first"),r="right"==a.langdirection,f=s.hasClass("uk-offcanvas-bar-flip")?-1:1,c=f*(r?-1:1),h=window.innerWidth-o.width();t={x:window.pageXOffset,y:window.pageYOffset},s.attr("mode",e.mode),i.addClass("uk-active"),o.css({width:window.innerWidth-h,height:window.innerHeight}).addClass("uk-offcanvas-page"),("push"==e.mode||"reveal"==e.mode)&&o.css(r?"margin-right":"margin-left",(r?-1:1)*s.outerWidth()*c),"reveal"==e.mode&&s.css("clip","rect(0, "+s.outerWidth()+"px, 100vh, 0)"),n.css("margin-top",-1*t.y).width(),s.addClass("uk-offcanvas-bar-show"),this._initElement(i),s.trigger("show.uk.offcanvas",[i,s]),i.attr("aria-hidden","false")}},hide:function(i){var e=a.$("body"),o=a.$(".uk-offcanvas.uk-active"),s="right"==a.langdirection,r=o.find(".uk-offcanvas-bar:first"),f=function(){e.removeClass("uk-offcanvas-page").css({width:"",height:"",marginLeft:"",marginRight:""}),o.removeClass("uk-active"),r.removeClass("uk-offcanvas-bar-show"),n.css("margin-top",""),window.scrollTo(t.x,t.y),r.trigger("hide.uk.offcanvas",[o,r]),o.attr("aria-hidden","true")};o.length&&("none"==r.attr("mode")&&(i=!0),a.support.transition&&!i?(e.one(a.support.transition.end,function(){f()}).css(s?"margin-right":"margin-left",""),"reveal"==r.attr("mode")&&r.css("clip",""),setTimeout(function(){r.removeClass("uk-offcanvas-bar-show")},0)):f())},_initElement:function(t){t.data("OffcanvasInit")||(t.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas",function(t){var n=a.$(t.target);if(t.type.match(/swipe/)){if(n.parents(".uk-offcanvas-bar:first").length)return}else if(!n.hasClass("uk-offcanvas-close")){if(n.hasClass("uk-offcanvas-bar"))return;if(n.parents(".uk-offcanvas-bar:first").length)return}t.stopImmediatePropagation(),i.hide()}),t.on("click",'a[href*="#"]',function(){var t=a.$(this),n=t.attr("href");"#"!=n&&(a.$doc.one("hide.uk.offcanvas",function(){var i;try{i=a.$(t[0].hash)}catch(e){i=""}i.length||(i=a.$('[name="'+t[0].hash.replace("#","")+'"]')),i.length&&a.Utils.scrollToElement?a.Utils.scrollToElement(i,a.Utils.options(t.attr("data-uk-smooth-scroll")||"{}")):window.location.href=n}),i.hide())}),t.data("OffcanvasInit",!0))}};a.component("offcanvasTrigger",{boot:function(){n.on("click.offcanvas.uikit","[data-uk-offcanvas]",function(t){t.preventDefault();var n=a.$(this);if(!n.data("offcanvasTrigger")){{a.offcanvasTrigger(n,a.Utils.options(n.attr("data-uk-offcanvas")))}n.trigger("click")}}),n.on("keydown.uk.offcanvas",function(a){27===a.keyCode&&i.hide()})},init:function(){var t=this;this.options=a.$.extend({target:t.element.is("a")?t.element.attr("href"):!1,mode:"push"},this.options),this.on("click",function(a){a.preventDefault(),i.show(t.options.target,t.options)})}}),a.offcanvas=i}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/scrollspy.min.js b/lib/api/uikit/src/js/core/scrollspy.min.js index 39453724..74c7d801 100755 --- a/lib/api/uikit/src/js/core/scrollspy.min.js +++ b/lib/api/uikit/src/js/core/scrollspy.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";var s=t.$win,o=t.$doc,i=[],e=function(){for(var t=0;t=p)return o[t]}();if(!f)return;c.options.closest?(e.blur().closest(r).removeClass(a),l=e.filter("a[href='#"+f.attr("id")+"']").closest(r).addClass(a)):l=e.removeClass(a).filter("a[href='#"+f.attr("id")+"']").addClass(a),c.element.trigger("inview.uk.scrollspynav",[f,l])}};this.options.smoothscroll&&t.smoothScroll&&e.each(function(){t.smoothScroll(this,c.options.smoothscroll)}),p(),this.element.data("scrollspynav",this),this.check=p,l.push(this)}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var s=t.$win,o=t.$doc,i=[],e=function(){for(var t=0;t=p)return o[t]}();if(!f)return;c.options.closest?(e.blur().closest(r).removeClass(a),l=e.filter("a[href='#"+f.attr("id")+"']").closest(r).addClass(a)):l=e.removeClass(a).filter("a[href='#"+f.attr("id")+"']").addClass(a),c.element.trigger("inview.uk.scrollspynav",[f,l])}};this.options.smoothscroll&&t.smoothScroll&&e.each(function(){t.smoothScroll(this,c.options.smoothscroll)}),p(),this.element.data("scrollspynav",this),this.check=p,l.push(this)}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/smooth-scroll.min.js b/lib/api/uikit/src/js/core/smooth-scroll.min.js index 2eb43f56..9a35beca 100755 --- a/lib/api/uikit/src/js/core/smooth-scroll.min.js +++ b/lib/api/uikit/src/js/core/smooth-scroll.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";function o(o,i){i=t.$.extend({duration:1e3,transition:"easeOutExpo",offset:0,complete:function(){}},i);var n=o.offset().top-i.offset,s=t.$doc.height(),e=window.innerHeight;n+e>s&&(n=s-e),t.$("html,body").stop().animate({scrollTop:n},i.duration,i.transition).promise().done(i.complete)}t.component("smoothScroll",{boot:function(){t.$html.on("click.smooth-scroll.uikit","[data-uk-smooth-scroll]",function(){var o=t.$(this);if(!o.data("smoothScroll")){{t.smoothScroll(o,t.Utils.options(o.attr("data-uk-smooth-scroll")))}o.trigger("click")}return!1})},init:function(){var i=this;this.on("click",function(n){n.preventDefault(),o(t.$(this.hash).length?t.$(this.hash):t.$("body"),i.options)})}}),t.Utils.scrollToElement=o,t.$.easing.easeOutExpo||(t.$.easing.easeOutExpo=function(t,o,i,n,s){return o==s?i+n:n*(-Math.pow(2,-10*o/s)+1)+i})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function o(o,i){i=t.$.extend({duration:1e3,transition:"easeOutExpo",offset:0,complete:function(){}},i);var n=o.offset().top-i.offset,s=t.$doc.height(),e=window.innerHeight;n+e>s&&(n=s-e),t.$("html,body").stop().animate({scrollTop:n},i.duration,i.transition).promise().done(i.complete)}t.component("smoothScroll",{boot:function(){t.$html.on("click.smooth-scroll.uikit","[data-uk-smooth-scroll]",function(){var o=t.$(this);if(!o.data("smoothScroll")){{t.smoothScroll(o,t.Utils.options(o.attr("data-uk-smooth-scroll")))}o.trigger("click")}return!1})},init:function(){var i=this;this.on("click",function(n){n.preventDefault(),o(t.$(this.hash).length?t.$(this.hash):t.$("body"),i.options)})}}),t.Utils.scrollToElement=o,t.$.easing.easeOutExpo||(t.$.easing.easeOutExpo=function(t,o,i,n,s){return o==s?i+n:n*(-Math.pow(2,-10*o/s)+1)+i})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/switcher.min.js b/lib/api/uikit/src/js/core/switcher.min.js index 2a041ad2..f7149bbc 100755 --- a/lib/api/uikit/src/js/core/switcher.min.js +++ b/lib/api/uikit/src/js/core/switcher.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";function i(i,n,e){var s,a=t.$.Deferred(),o=i,r=i;return e[0]===n[0]?(a.resolve(),a.promise()):("object"==typeof i&&(o=i[0],r=i[1]||i[0]),t.$body.css("overflow-x","hidden"),s=function(){n&&n.hide().removeClass("uk-active "+r+" uk-animation-reverse"),e.addClass(o).one(t.support.animation.end,function(){setTimeout(function(){e.removeClass(""+o).css({opacity:"",display:""})},0),a.resolve(),t.$body.css("overflow-x",""),n&&n.css({opacity:"",display:""})}.bind(this)).show()},e.css("animation-duration",this.options.duration+"ms"),n&&n.length?(n.css("animation-duration",this.options.duration+"ms"),n.css("display","none").addClass(r+" uk-animation-reverse").one(t.support.animation.end,function(){s()}.bind(this)).css("display","")):(e.addClass("uk-active"),s()),a.promise())}var n;t.component("switcher",{defaults:{connect:!1,toggle:">*",active:0,animation:!1,duration:200,swiping:!0},animating:!1,boot:function(){t.ready(function(i){t.$("[data-uk-switcher]",i).each(function(){var i=t.$(this);if(!i.data("switcher")){t.switcher(i,t.Utils.options(i.attr("data-uk-switcher")))}})})},init:function(){var i=this;this.on("click.uk.switcher",this.options.toggle,function(t){t.preventDefault(),i.show(this)}),this.options.connect&&(this.connect=t.$(this.options.connect),this.connect.length&&(this.connect.on("click.uk.switcher","[data-uk-switcher-item]",function(n){n.preventDefault();var e=t.$(this).attr("data-uk-switcher-item");if(i.index!=e)switch(e){case"next":case"previous":i.show(i.index+("next"==e?1:-1));break;default:i.show(parseInt(e,10))}}),this.options.swiping&&this.connect.on("swipeRight swipeLeft",function(t){t.preventDefault(),window.getSelection().toString()||i.show(i.index+("swipeLeft"==t.type?1:-1))}),this.update()))},update:function(){this.connect.children().removeClass("uk-active").attr("aria-hidden","true");var t=this.find(this.options.toggle),i=t.filter(".uk-active");if(i.length)this.show(i,!1);else{if(this.options.active===!1)return;i=t.eq(this.options.active),this.show(i.length?i:t.eq(0),!1)}t.not(i).attr("aria-expanded","false"),i.attr("aria-expanded","true")},show:function(e,s){if(!this.animating){if(isNaN(e))e=t.$(e);else{var a=this.find(this.options.toggle);e=0>e?a.length-1:e,e=a.eq(a[e]?e:0)}var o=this,a=this.find(this.options.toggle),r=t.$(e),c=n[this.options.animation]||function(t,e){if(!o.options.animation)return n.none.apply(o);var s=o.options.animation.split(",");return 1==s.length&&(s[1]=s[0]),s[0]=s[0].trim(),s[1]=s[1].trim(),i.apply(o,[s,t,e])};s!==!1&&t.support.animation||(c=n.none),r.hasClass("uk-disabled")||(a.attr("aria-expanded","false"),r.attr("aria-expanded","true"),a.filter(".uk-active").removeClass("uk-active"),r.addClass("uk-active"),this.options.connect&&this.connect.length&&(this.index=this.find(this.options.toggle).index(r),-1==this.index&&(this.index=0),this.connect.each(function(){var i=t.$(this),n=t.$(i.children()),e=t.$(n.filter(".uk-active")),s=t.$(n.eq(o.index));o.animating=!0,c.apply(o,[e,s]).then(function(){e.removeClass("uk-active"),s.addClass("uk-active"),e.attr("aria-hidden","true"),s.attr("aria-hidden","false"),t.Utils.checkDisplay(s,!0),o.animating=!1})})),this.trigger("show.uk.switcher",[r]))}}}),n={none:function(){var i=t.$.Deferred();return i.resolve(),i.promise()},fade:function(t,n){return i.apply(this,["uk-animation-fade",t,n])},"slide-bottom":function(t,n){return i.apply(this,["uk-animation-slide-bottom",t,n])},"slide-top":function(t,n){return i.apply(this,["uk-animation-slide-top",t,n])},"slide-vertical":function(t,n){var e=["uk-animation-slide-top","uk-animation-slide-bottom"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},"slide-left":function(t,n){return i.apply(this,["uk-animation-slide-left",t,n])},"slide-right":function(t,n){return i.apply(this,["uk-animation-slide-right",t,n])},"slide-horizontal":function(t,n){var e=["uk-animation-slide-right","uk-animation-slide-left"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},scale:function(t,n){return i.apply(this,["uk-animation-scale-up",t,n])}},t.switcher.animations=n}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i,n,e){var s,a=t.$.Deferred(),o=i,r=i;return e[0]===n[0]?(a.resolve(),a.promise()):("object"==typeof i&&(o=i[0],r=i[1]||i[0]),t.$body.css("overflow-x","hidden"),s=function(){n&&n.hide().removeClass("uk-active "+r+" uk-animation-reverse"),e.addClass(o).one(t.support.animation.end,function(){setTimeout(function(){e.removeClass(""+o).css({opacity:"",display:""})},0),a.resolve(),t.$body.css("overflow-x",""),n&&n.css({opacity:"",display:""})}.bind(this)).show()},e.css("animation-duration",this.options.duration+"ms"),n&&n.length?(n.css("animation-duration",this.options.duration+"ms"),n.css("display","none").addClass(r+" uk-animation-reverse").one(t.support.animation.end,function(){s()}.bind(this)).css("display","")):(e.addClass("uk-active"),s()),a.promise())}var n;t.component("switcher",{defaults:{connect:!1,toggle:">*",active:0,animation:!1,duration:200,swiping:!0},animating:!1,boot:function(){t.ready(function(i){t.$("[data-uk-switcher]",i).each(function(){var i=t.$(this);if(!i.data("switcher")){t.switcher(i,t.Utils.options(i.attr("data-uk-switcher")))}})})},init:function(){var i=this;this.on("click.uk.switcher",this.options.toggle,function(t){t.preventDefault(),i.show(this)}),this.options.connect&&(this.connect=t.$(this.options.connect),this.connect.length&&(this.connect.on("click.uk.switcher","[data-uk-switcher-item]",function(n){n.preventDefault();var e=t.$(this).attr("data-uk-switcher-item");if(i.index!=e)switch(e){case"next":case"previous":i.show(i.index+("next"==e?1:-1));break;default:i.show(parseInt(e,10))}}),this.options.swiping&&this.connect.on("swipeRight swipeLeft",function(t){t.preventDefault(),window.getSelection().toString()||i.show(i.index+("swipeLeft"==t.type?1:-1))}),this.update()))},update:function(){this.connect.children().removeClass("uk-active").attr("aria-hidden","true");var t=this.find(this.options.toggle),i=t.filter(".uk-active");if(i.length)this.show(i,!1);else{if(this.options.active===!1)return;i=t.eq(this.options.active),this.show(i.length?i:t.eq(0),!1)}t.not(i).attr("aria-expanded","false"),i.attr("aria-expanded","true")},show:function(e,s){if(!this.animating){var a=this.find(this.options.toggle);isNaN(e)?e=t.$(e):(e=0>e?a.length-1:e,e=a.eq(a[e]?e:0));var o=this,r=t.$(e),c=n[this.options.animation]||function(t,e){if(!o.options.animation)return n.none.apply(o);var s=o.options.animation.split(",");return 1==s.length&&(s[1]=s[0]),s[0]=s[0].trim(),s[1]=s[1].trim(),i.apply(o,[s,t,e])};s!==!1&&t.support.animation||(c=n.none),r.hasClass("uk-disabled")||(a.attr("aria-expanded","false"),r.attr("aria-expanded","true"),a.filter(".uk-active").removeClass("uk-active"),r.addClass("uk-active"),this.options.connect&&this.connect.length&&(this.index=this.find(this.options.toggle).index(r),-1==this.index&&(this.index=0),this.connect.each(function(){var i=t.$(this),n=t.$(i.children()),e=t.$(n.filter(".uk-active")),s=t.$(n.eq(o.index));o.animating=!0,c.apply(o,[e,s]).then(function(){e.removeClass("uk-active"),s.addClass("uk-active"),e.attr("aria-hidden","true"),s.attr("aria-hidden","false"),t.Utils.checkDisplay(s,!0),o.animating=!1})})),this.trigger("show.uk.switcher",[r]))}}}),n={none:function(){var i=t.$.Deferred();return i.resolve(),i.promise()},fade:function(t,n){return i.apply(this,["uk-animation-fade",t,n])},"slide-bottom":function(t,n){return i.apply(this,["uk-animation-slide-bottom",t,n])},"slide-top":function(t,n){return i.apply(this,["uk-animation-slide-top",t,n])},"slide-vertical":function(t,n){var e=["uk-animation-slide-top","uk-animation-slide-bottom"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},"slide-left":function(t,n){return i.apply(this,["uk-animation-slide-left",t,n])},"slide-right":function(t,n){return i.apply(this,["uk-animation-slide-right",t,n])},"slide-horizontal":function(t,n){var e=["uk-animation-slide-right","uk-animation-slide-left"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},scale:function(t,n){return i.apply(this,["uk-animation-scale-up",t,n])}},t.switcher.animations=n}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/tab.min.js b/lib/api/uikit/src/js/core/tab.min.js index 517cc4db..7650c1bf 100755 --- a/lib/api/uikit/src/js/core/tab.min.js +++ b/lib/api/uikit/src/js/core/tab.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";t.component("tab",{defaults:{target:">li:not(.uk-tab-responsive, .uk-disabled)",connect:!1,active:0,animation:!1,duration:200,swiping:!0},boot:function(){t.ready(function(i){t.$("[data-uk-tab]",i).each(function(){var i=t.$(this);if(!i.data("tab")){t.tab(i,t.Utils.options(i.attr("data-uk-tab")))}})})},init:function(){var i=this;this.current=!1,this.on("click.uk.tab",this.options.target,function(e){if(e.preventDefault(),!i.switcher||!i.switcher.animating){var s=i.find(i.options.target).not(this);s.removeClass("uk-active").blur(),i.trigger("change.uk.tab",[t.$(this).addClass("uk-active"),i.current]),i.current=t.$(this),i.options.connect||(s.attr("aria-expanded","false"),t.$(this).attr("aria-expanded","true"))}}),this.options.connect&&(this.connect=t.$(this.options.connect)),this.responsivetab=t.$('
          • ').append('
              '),this.responsivetab.dropdown=this.responsivetab.find(".uk-dropdown"),this.responsivetab.lst=this.responsivetab.dropdown.find("ul"),this.responsivetab.caption=this.responsivetab.find("a:first"),this.element.hasClass("uk-tab-bottom")&&this.responsivetab.dropdown.addClass("uk-dropdown-up"),this.responsivetab.lst.on("click.uk.tab","a",function(e){e.preventDefault(),e.stopPropagation();var s=t.$(this);i.element.children("li:not(.uk-tab-responsive)").eq(s.data("index")).trigger("click")}),this.on("show.uk.switcher change.uk.tab",function(t,e){i.responsivetab.caption.html(e.text())}),this.element.append(this.responsivetab),this.options.connect&&(this.switcher=t.switcher(this.element,{toggle:">li:not(.uk-tab-responsive)",connect:this.options.connect,active:this.options.active,animation:this.options.animation,duration:this.options.duration,swiping:this.options.swiping})),t.dropdown(this.responsivetab,{mode:"click",preventflip:"y"}),i.trigger("change.uk.tab",[this.element.find(this.options.target).not(".uk-tab-responsive").filter(".uk-active")]),this.check(),t.$win.on("resize orientationchange",t.Utils.debounce(function(){i.element.is(":visible")&&i.check()},100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.check()})},check:function(){var i=this.element.children("li:not(.uk-tab-responsive)").removeClass("uk-hidden");if(!i.length)return this.responsivetab.addClass("uk-hidden"),void 0;var e,s,n,a=i.eq(0).offset().top+Math.ceil(i.eq(0).height()/2),o=!1;if(this.responsivetab.lst.empty(),i.each(function(){t.$(this).offset().top>a&&(o=!0)}),o)for(var r=0;rli:not(.uk-tab-responsive, .uk-disabled)",connect:!1,active:0,animation:!1,duration:200,swiping:!0},boot:function(){t.ready(function(i){t.$("[data-uk-tab]",i).each(function(){var i=t.$(this);if(!i.data("tab")){t.tab(i,t.Utils.options(i.attr("data-uk-tab")))}})})},init:function(){var i=this;this.current=!1,this.on("click.uk.tab",this.options.target,function(e){if(e.preventDefault(),!i.switcher||!i.switcher.animating){var n=i.find(i.options.target).not(this);n.removeClass("uk-active").blur(),i.trigger("change.uk.tab",[t.$(this).addClass("uk-active"),i.current]),i.current=t.$(this),i.options.connect||(n.attr("aria-expanded","false"),t.$(this).attr("aria-expanded","true"))}}),this.options.connect&&(this.connect=t.$(this.options.connect)),this.responsivetab=t.$('
            • ').append('
                '),this.responsivetab.dropdown=this.responsivetab.find(".uk-dropdown"),this.responsivetab.lst=this.responsivetab.dropdown.find("ul"),this.responsivetab.caption=this.responsivetab.find("a:first"),this.element.hasClass("uk-tab-bottom")&&this.responsivetab.dropdown.addClass("uk-dropdown-up"),this.responsivetab.lst.on("click.uk.tab","a",function(e){e.preventDefault(),e.stopPropagation();var n=t.$(this);i.element.children("li:not(.uk-tab-responsive)").eq(n.data("index")).trigger("click")}),this.on("show.uk.switcher change.uk.tab",function(t,e){i.responsivetab.caption.html(e.text())}),this.element.append(this.responsivetab),this.options.connect&&(this.switcher=t.switcher(this.element,{toggle:">li:not(.uk-tab-responsive)",connect:this.options.connect,active:this.options.active,animation:this.options.animation,duration:this.options.duration,swiping:this.options.swiping})),t.dropdown(this.responsivetab,{mode:"click",preventflip:"y"}),i.trigger("change.uk.tab",[this.element.find(this.options.target).not(".uk-tab-responsive").filter(".uk-active")]),this.check(),t.$win.on("resize orientationchange",t.Utils.debounce(function(){i.element.is(":visible")&&i.check()},100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.check()})},check:function(){var i=this.element.children("li:not(.uk-tab-responsive)").removeClass("uk-hidden");if(!i.length)return this.responsivetab.addClass("uk-hidden"),void 0;var e,n,s,a=i.eq(0).offset().top+Math.ceil(i.eq(0).height()/2),o=!1;if(this.responsivetab.lst.empty(),i.each(function(){t.$(this).offset().top>a&&(o=!0)}),o)for(var r=0;r=Math.abs(n-o)?e-t>0?"Left":"Right":n-o>0?"Up":"Down"}function n(){p=null,g.last&&(void 0!==g.el&&g.el.trigger("longTap"),g={})}function o(){p&&clearTimeout(p),p=null}function i(){a&&clearTimeout(a),l&&clearTimeout(l),u&&clearTimeout(u),p&&clearTimeout(p),a=l=u=p=null,g={}}function r(e){return e.pointerType==e.MSPOINTER_TYPE_TOUCH&&e.isPrimary}if(!e.fn.swipeLeft){var a,l,u,p,c,g={},s=750;e(function(){var v,y,w,f=0,d=0;"MSGesture"in window&&(c=new MSGesture,c.target=document.body),e(document).on("MSGestureEnd gestureend",function(e){var t=e.originalEvent.velocityX>1?"Right":e.originalEvent.velocityX<-1?"Left":e.originalEvent.velocityY>1?"Down":e.originalEvent.velocityY<-1?"Up":null;t&&void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t))}).on("touchstart MSPointerDown pointerdown",function(t){("MSPointerDown"!=t.type||r(t.originalEvent))&&(w="MSPointerDown"==t.type||"pointerdown"==t.type?t:t.originalEvent.touches[0],v=Date.now(),y=v-(g.last||v),g.el=e("tagName"in w.target?w.target:w.target.parentNode),a&&clearTimeout(a),g.x1=w.pageX,g.y1=w.pageY,y>0&&250>=y&&(g.isDoubleTap=!0),g.last=v,p=setTimeout(n,s),!c||"MSPointerDown"!=t.type&&"pointerdown"!=t.type&&"touchstart"!=t.type||c.addPointer(t.originalEvent.pointerId))}).on("touchmove MSPointerMove pointermove",function(e){("MSPointerMove"!=e.type||r(e.originalEvent))&&(w="MSPointerMove"==e.type||"pointermove"==e.type?e:e.originalEvent.touches[0],o(),g.x2=w.pageX,g.y2=w.pageY,f+=Math.abs(g.x1-g.x2),d+=Math.abs(g.y1-g.y2))}).on("touchend MSPointerUp pointerup",function(n){("MSPointerUp"!=n.type||r(n.originalEvent))&&(o(),g.x2&&Math.abs(g.x1-g.x2)>30||g.y2&&Math.abs(g.y1-g.y2)>30?u=setTimeout(function(){void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t(g.x1,g.x2,g.y1,g.y2))),g={}},0):"last"in g&&(isNaN(f)||30>f&&30>d?l=setTimeout(function(){var t=e.Event("tap");t.cancelTouch=i,void 0!==g.el&&g.el.trigger(t),g.isDoubleTap?(void 0!==g.el&&g.el.trigger("doubleTap"),g={}):a=setTimeout(function(){a=null,void 0!==g.el&&g.el.trigger("singleTap"),g={}},250)},0):g={},f=d=0))}).on("touchcancel MSPointerCancel pointercancel",i),e(window).on("scroll",i)}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(t){e.fn[t]=function(n){return e(this).on(t,n)}})}}(jQuery); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){function t(e,t,n,o){return Math.abs(e-t)>=Math.abs(n-o)?e-t>0?"Left":"Right":n-o>0?"Up":"Down"}function n(){c=null,g.last&&(void 0!==g.el&&g.el.trigger("longTap"),g={})}function o(){c&&clearTimeout(c),c=null}function i(){a&&clearTimeout(a),l&&clearTimeout(l),u&&clearTimeout(u),c&&clearTimeout(c),a=l=u=c=null,g={}}function r(e){return e.pointerType==e.MSPOINTER_TYPE_TOUCH&&e.isPrimary}if(!e.fn.swipeLeft){var a,l,u,c,p,g={},s=750,v="ontouchstart"in window,w=window.PointerEvent,d=v||window.DocumentTouch&&document instanceof DocumentTouch||navigator.msPointerEnabled&&navigator.msMaxTouchPoints>0||navigator.pointerEnabled&&navigator.maxTouchPoints>0;e(function(){var y,T,f,h=0,M=0;"MSGesture"in window&&(p=new MSGesture,p.target=document.body),e(document).on("MSGestureEnd gestureend",function(e){var t=e.originalEvent.velocityX>1?"Right":e.originalEvent.velocityX<-1?"Left":e.originalEvent.velocityY>1?"Down":e.originalEvent.velocityY<-1?"Up":null;t&&void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t))}).on("touchstart MSPointerDown pointerdown",function(t){("MSPointerDown"!=t.type||r(t.originalEvent))&&(f="MSPointerDown"==t.type||"pointerdown"==t.type?t:t.originalEvent.touches[0],y=Date.now(),T=y-(g.last||y),g.el=e("tagName"in f.target?f.target:f.target.parentNode),a&&clearTimeout(a),g.x1=f.pageX,g.y1=f.pageY,T>0&&250>=T&&(g.isDoubleTap=!0),g.last=y,c=setTimeout(n,s),t.originalEvent&&t.originalEvent.pointerId&&p&&("MSPointerDown"==t.type||"pointerdown"==t.type||"touchstart"==t.type)&&p.addPointer(t.originalEvent.pointerId))}).on("touchmove MSPointerMove pointermove",function(e){("MSPointerMove"!=e.type||r(e.originalEvent))&&(f="MSPointerMove"==e.type||"pointermove"==e.type?e:e.originalEvent.touches[0],o(),g.x2=f.pageX,g.y2=f.pageY,h+=Math.abs(g.x1-g.x2),M+=Math.abs(g.y1-g.y2))}).on("touchend MSPointerUp pointerup",function(n){("MSPointerUp"!=n.type||r(n.originalEvent))&&(o(),g.x2&&Math.abs(g.x1-g.x2)>30||g.y2&&Math.abs(g.y1-g.y2)>30?u=setTimeout(function(){void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t(g.x1,g.x2,g.y1,g.y2))),g={}},0):"last"in g&&(isNaN(h)||30>h&&30>M?l=setTimeout(function(){var t=e.Event("tap");t.cancelTouch=i,void 0!==g.el&&g.el.trigger(t),g.isDoubleTap?(void 0!==g.el&&g.el.trigger("doubleTap"),g={}):a=setTimeout(function(){a=null,void 0!==g.el&&g.el.trigger("singleTap"),g={}},250)},0):g={},h=M=0))}).on("touchcancel MSPointerCancel pointercancel",function(e){("touchcancel"==e.type&&v&&d||!v&&"pointercancel"==e.type&&w)&&i()}),e(window).on("scroll",i)}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(t){e.fn[t]=function(n){return e(this).on(t,n)}})}}(jQuery); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/utility.min.js b/lib/api/uikit/src/js/core/utility.min.js index 5c06efd6..de5581d3 100755 --- a/lib/api/uikit/src/js/core/utility.min.js +++ b/lib/api/uikit/src/js/core/utility.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";var i=[];t.component("stackMargin",{defaults:{cls:"uk-margin-small-top",rowfirst:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-margin]",i).each(function(){var i=t.$(this);i.data("stackMargin")||t.stackMargin(i,t.Utils.options(i.attr("data-uk-margin")))})})},init:function(){var e=this;t.$win.on("resize orientationchange",function(){var i=function(){e.process()};return t.$(function(){i(),t.$win.on("load",i)}),t.Utils.debounce(i,20)}()),this.on("display.uk.check",function(){this.element.is(":visible")&&this.process()}.bind(this)),this.options.observe&&t.domObserve(this.element,function(){e.element.is(":visible")&&e.process()}),i.push(this)},process:function(){var i=this.element.children();if(t.Utils.stackMargin(i,this.options),!this.options.rowfirst||!i.length)return this;var e={},n=!1;return i.removeClass(this.options.rowfirst).each(function(i,s){s=t.$(this),"none"!=this.style.display&&(i=s.offset().left,((e[i]=e[i]||[])&&e[i]).push(this),n=n===!1?i:Math.min(n,i))}),t.$(e[n]).addClass(this.options.rowfirst),this}}),function(){var i=[],e=function(t){if(t.is(":visible")){var i=t.parent().width(),e=t.data("width"),n=i/e,s=Math.floor(n*t.data("height"));t.css({height:e>i?s:t.data("height")})}};t.component("responsiveElement",{defaults:{},boot:function(){t.ready(function(i){t.$("iframe.uk-responsive-width, [data-uk-responsive]",i).each(function(){var i,e=t.$(this);e.data("responsiveElement")||(i=t.responsiveElement(e,{}))})})},init:function(){var t=this.element;t.attr("width")&&t.attr("height")&&(t.data({width:t.attr("width"),height:t.attr("height")}).on("display.uk.check",function(){e(t)}),e(t),i.push(t))}}),t.$win.on("resize load",t.Utils.debounce(function(){i.forEach(function(t){e(t)})},15))}(),t.Utils.stackMargin=function(i,e){e=t.$.extend({cls:"uk-margin-small-top"},e),i=t.$(i).removeClass(e.cls);var n=!1;i.each(function(i,e,s,a){a=t.$(this),"none"!=a.css("display")&&(i=a.offset(),e=a.outerHeight(),s=i.top+e,a.data({ukMarginPos:s,ukMarginTop:i.top}),(n===!1||i.topn.top&&i.data("ukMarginPos")>n.pos&&i.addClass(e.cls)})},t.Utils.matchHeights=function(i,e){i=t.$(i).css("min-height",""),e=t.$.extend({row:!0},e);var n=function(i){if(!(i.length<2)){var e=0;i.each(function(){e=Math.max(e,t.$(this).outerHeight())}).each(function(){var i=t.$(this),n=e-("border-box"==i.css("box-sizing")?0:i.outerHeight()-i.height());i.css("min-height",n+"px")})}};e.row?(i.first().width(),setTimeout(function(){var e=!1,s=[];i.each(function(){var i=t.$(this),a=i.offset().top;a!=e&&s.length&&(n(t.$(s)),s=[],a=i.offset().top),s.push(i),e=a}),s.length&&n(t.$(s))},0)):n(i)},function(i){t.Utils.inlineSvg=function(e,n){t.$(e||'img[src$=".svg"]',n||document).each(function(){var e=t.$(this),n=e.attr("src");if(!i[n]){var s=t.$.Deferred();t.$.get(n,{nc:Math.random()},function(i){s.resolve(t.$(i).find("svg"))}),i[n]=s.promise()}i[n].then(function(i){var n=t.$(i).clone();e.attr("id")&&n.attr("id",e.attr("id")),e.attr("class")&&n.attr("class",e.attr("class")),e.attr("style")&&n.attr("style",e.attr("style")),e.attr("width")&&(n.attr("width",e.attr("width")),e.attr("height")||n.removeAttr("height")),e.attr("height")&&(n.attr("height",e.attr("height")),e.attr("width")||n.removeAttr("width")),e.replaceWith(n)})})},t.ready(function(i){t.Utils.inlineSvg("[data-uk-svg]",i)})}({}),t.Utils.getCssVar=function(t){var i,e=document.documentElement,n=e.appendChild(document.createElement("div"));n.classList.add("var-"+t);try{i=JSON.parse(i=getComputedStyle(n,":before").content.replace(/^["'](.*)["']$/,"$1"))}catch(s){i=void 0}return e.removeChild(n),i}}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var i=[];t.component("stackMargin",{defaults:{cls:"uk-margin-small-top",rowfirst:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-margin]",i).each(function(){var i=t.$(this);i.data("stackMargin")||t.stackMargin(i,t.Utils.options(i.attr("data-uk-margin")))})})},init:function(){var e=this;t.$win.on("resize orientationchange",function(){var i=function(){e.process()};return t.$(function(){i(),t.$win.on("load",i)}),t.Utils.debounce(i,20)}()),this.on("display.uk.check",function(){this.element.is(":visible")&&this.process()}.bind(this)),this.options.observe&&t.domObserve(this.element,function(){e.element.is(":visible")&&e.process()}),i.push(this)},process:function(){var i=this.element.children();if(t.Utils.stackMargin(i,this.options),!this.options.rowfirst||!i.length)return this;var e={},n=!1;return i.removeClass(this.options.rowfirst).each(function(i,s){s=t.$(this),"none"!=this.style.display&&(i=s.offset().left,((e[i]=e[i]||[])&&e[i]).push(this),n=n===!1?i:Math.min(n,i))}),t.$(e[n]).addClass(this.options.rowfirst),this}}),function(){var i=[],e=function(t){if(t.is(":visible")){var i=t.parent().width(),e=t.data("width"),n=i/e,s=Math.floor(n*t.data("height"));t.css({height:e>i?s:t.data("height")})}};t.component("responsiveElement",{defaults:{},boot:function(){t.ready(function(i){t.$("iframe.uk-responsive-width, [data-uk-responsive]",i).each(function(){var i,e=t.$(this);e.data("responsiveElement")||(i=t.responsiveElement(e,{}))})})},init:function(){var t=this.element;t.attr("width")&&t.attr("height")&&(t.data({width:t.attr("width"),height:t.attr("height")}).on("display.uk.check",function(){e(t)}),e(t),i.push(t))}}),t.$win.on("resize load",t.Utils.debounce(function(){i.forEach(function(t){e(t)})},15))}(),t.Utils.stackMargin=function(i,e){e=t.$.extend({cls:"uk-margin-small-top"},e),i=t.$(i).removeClass(e.cls);var n=!1;i.each(function(i,e,s,a){a=t.$(this),"none"!=a.css("display")&&(i=a.offset(),e=a.outerHeight(),s=i.top+e,a.data({ukMarginPos:s,ukMarginTop:i.top}),(n===!1||i.topn.top&&i.data("ukMarginPos")>n.pos&&i.addClass(e.cls)})},t.Utils.matchHeights=function(i,e){i=t.$(i).css("min-height",""),e=t.$.extend({row:!0},e);var n=function(i){if(!(i.length<2)){var e=0;i.each(function(){e=Math.max(e,t.$(this).outerHeight())}).each(function(){var i=t.$(this),n=e-("border-box"==i.css("box-sizing")?0:i.outerHeight()-i.height());i.css("min-height",n+"px")})}};e.row?(i.first().width(),setTimeout(function(){var e=!1,s=[];i.each(function(){var i=t.$(this),a=i.offset().top;a!=e&&s.length&&(n(t.$(s)),s=[],a=i.offset().top),s.push(i),e=a}),s.length&&n(t.$(s))},0)):n(i)},function(i){t.Utils.inlineSvg=function(e,n){t.$(e||'img[src$=".svg"]',n||document).each(function(){var e=t.$(this),n=e.attr("src");if(!i[n]){var s=t.$.Deferred();t.$.get(n,{nc:Math.random()},function(i){s.resolve(t.$(i).find("svg"))}),i[n]=s.promise()}i[n].then(function(i){var n=t.$(i).clone();e.attr("id")&&n.attr("id",e.attr("id")),e.attr("class")&&n.attr("class",e.attr("class")),e.attr("style")&&n.attr("style",e.attr("style")),e.attr("width")&&(n.attr("width",e.attr("width")),e.attr("height")||n.removeAttr("height")),e.attr("height")&&(n.attr("height",e.attr("height")),e.attr("width")||n.removeAttr("width")),e.replaceWith(n)})})},t.ready(function(i){t.Utils.inlineSvg("[data-uk-svg]",i)})}({}),t.Utils.getCssVar=function(t){var i,e=document.documentElement,n=e.appendChild(document.createElement("div"));n.classList.add("var-"+t);try{i=JSON.parse(i=getComputedStyle(n,":before").content.replace(/^["'](.*)["']$/,"$1"))}catch(s){i=void 0}return e.removeChild(n),i}}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/less/components/accordion.less b/lib/api/uikit/src/less/components/accordion.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/datepicker.less b/lib/api/uikit/src/less/components/datepicker.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/dotnav.less b/lib/api/uikit/src/less/components/dotnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/form-advanced.less b/lib/api/uikit/src/less/components/form-advanced.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/form-file.less b/lib/api/uikit/src/less/components/form-file.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/form-password.less b/lib/api/uikit/src/less/components/form-password.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/form-select.less b/lib/api/uikit/src/less/components/form-select.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/htmleditor.less b/lib/api/uikit/src/less/components/htmleditor.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/notify.less b/lib/api/uikit/src/less/components/notify.less old mode 100644 new mode 100755 index 44a13067..991ba59c --- a/lib/api/uikit/src/less/components/notify.less +++ b/lib/api/uikit/src/less/components/notify.less @@ -136,7 +136,7 @@ .uk-notify-message:hover > .uk-close { visibility: visible; } -/* Modifier: `uk-alert-info` +/* Modifier: `uk-notify-message-primary` ========================================================================== */ .uk-notify-message-primary { @@ -146,7 +146,7 @@ } -/* Modifier: `uk-alert-success` +/* Modifier: `uk-notify-message-success` ========================================================================== */ .uk-notify-message-success { diff --git a/lib/api/uikit/src/less/components/placeholder.less b/lib/api/uikit/src/less/components/placeholder.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/progress.less b/lib/api/uikit/src/less/components/progress.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/slidenav.less b/lib/api/uikit/src/less/components/slidenav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/tooltip.less b/lib/api/uikit/src/less/components/tooltip.less old mode 100644 new mode 100755 index d162e37a..3e2b76fc --- a/lib/api/uikit/src/less/components/tooltip.less +++ b/lib/api/uikit/src/less/components/tooltip.less @@ -174,4 +174,4 @@ .hook-tooltip-misc; .hook-tooltip() {} -.hook-tooltip-misc() {} \ No newline at end of file +.hook-tooltip-misc() {} diff --git a/lib/api/uikit/src/less/components/upload.less b/lib/api/uikit/src/less/components/upload.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/alert.less b/lib/api/uikit/src/less/core/alert.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/animation.less b/lib/api/uikit/src/less/core/animation.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/article.less b/lib/api/uikit/src/less/core/article.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/badge.less b/lib/api/uikit/src/less/core/badge.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/breadcrumb.less b/lib/api/uikit/src/less/core/breadcrumb.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/button.less b/lib/api/uikit/src/less/core/button.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/close.less b/lib/api/uikit/src/less/core/close.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/column.less b/lib/api/uikit/src/less/core/column.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/comment.less b/lib/api/uikit/src/less/core/comment.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/cover.less b/lib/api/uikit/src/less/core/cover.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/description-list.less b/lib/api/uikit/src/less/core/description-list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/dropdown.less b/lib/api/uikit/src/less/core/dropdown.less old mode 100644 new mode 100755 index e8042c02..008e15b5 --- a/lib/api/uikit/src/less/core/dropdown.less +++ b/lib/api/uikit/src/less/core/dropdown.less @@ -95,6 +95,9 @@ .hook-dropdown; } +/* Focus */ +.uk-dropdown:focus { outline: none; } + /* * 1. Show dropdown * 2. Set animation diff --git a/lib/api/uikit/src/less/core/flex.less b/lib/api/uikit/src/less/core/flex.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/icon.less b/lib/api/uikit/src/less/core/icon.less index 8f4ab723..89976a3e 100755 --- a/lib/api/uikit/src/less/core/icon.less +++ b/lib/api/uikit/src/less/core/icon.less @@ -916,6 +916,65 @@ .uk-icon-wpforms:before { content: "\f298"; } .uk-icon-yoast:before { content: "\f2b1"; } +// added 4.7.0 +.uk-icon-adress-book:before { content: "\f2b9"; } +.uk-icon-adress-book-o:before { content: "\f2ba"; } +.uk-icon-adress-card:before { content: "\f2bb"; } +.uk-icon-adress-card-o:before { content: "\f2bc"; } +.uk-icon-bandcamp:before { content: "\f2d5"; } +.uk-icon-bath:before { content: "\f2cd"; } +.uk-icon-bathub:before { content: "\f2cd"; } +.uk-icon-drivers-license:before { content: "\f2c2"; } +.uk-icon-drivers-license-o:before { content: "\f2c3"; } +.uk-icon-eercast:before { content: "\f2da"; } +.uk-icon-envelope-open:before { content: "\f2b6"; } +.uk-icon-envelope-open-o:before { content: "\f2b7"; } +.uk-icon-etsy:before { content: "\f2d7"; } +.uk-icon-free-code-camp:before { content: "\f2c5"; } +.uk-icon-grav:before { content: "\f2d6"; } +.uk-icon-handshake-o:before { content: "\f2b5"; } +.uk-icon-id-badge:before { content: "\f2c1"; } +.uk-icon-id-card:before { content: "\f2c2"; } +.uk-icon-id-card-o:before { content: "\f2c3"; } +.uk-icon-imdb:before { content: "\f2d8"; } +.uk-icon-linode:before { content: "\f2b8"; } +.uk-icon-meetup:before { content: "\f2e0"; } +.uk-icon-microchip:before { content: "\f2db"; } +.uk-icon-podcast:before { content: "\f2ce"; } +.uk-icon-quora:before { content: "\f2c4"; } +.uk-icon-ravelry:before { content: "\f2d9"; } +.uk-icon-s15:before { content: "\f2cd"; } +.uk-icon-shower:before { content: "\f2cc"; } +.uk-icon-snowflake-o:before { content: "\f2dc"; } +.uk-icon-superpowers:before { content: "\f2dd"; } +.uk-icon-telegram:before { content: "\f2c6"; } +.uk-icon-thermometer:before { content: "\f2c7"; } +.uk-icon-thermometer-0:before { content: "\f2cb"; } +.uk-icon-thermometer-1:before { content: "\f2ca"; } +.uk-icon-thermometer-2:before { content: "\f2c9"; } +.uk-icon-thermometer-3:before { content: "\f2c8"; } +.uk-icon-thermometer-4:before { content: "\f2c7"; } +.uk-icon-thermometer-empty:before { content: "\f2cb"; } +.uk-icon-thermometer-full:before { content: "\f2c7"; } +.uk-icon-thermometer-half:before { content: "\f2c9"; } +.uk-icon-thermometer-quarter:before { content: "\f2ca"; } +.uk-icon-thermometer-three-quarters:before { content: "\f2c8"; } +.uk-icon-times-rectangle:before { content: "\f2d3"; } +.uk-icon-times-rectangle-o:before { content: "\f2d4"; } +.uk-icon-user-circle:before { content: "\f2bd"; } +.uk-icon-user-circle-o:before { content: "\f2be"; } +.uk-icon-user-o:before { content: "\f2c0"; } +.uk-icon-vcard:before { content: "\f2bb"; } +.uk-icon-vcard-o:before { content: "\f2bc"; } +.uk-icon-widow-close:before { content: "\f2d3"; } +.uk-icon-widow-close-o:before { content: "\f2d4"; } +.uk-icon-window-maximize:before { content: "\f2d0"; } +.uk-icon-window-minimize:before { content: "\f2d1"; } +.uk-icon-window-restore:before { content: "\f2d2"; } +.uk-icon-wpexplorer:before { content: "\f2de"; } + + + // Hooks // ======================================================================== diff --git a/lib/api/uikit/src/less/core/list.less b/lib/api/uikit/src/less/core/list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/nav.less b/lib/api/uikit/src/less/core/nav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/navbar.less b/lib/api/uikit/src/less/core/navbar.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/pagination.less b/lib/api/uikit/src/less/core/pagination.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/subnav.less b/lib/api/uikit/src/less/core/subnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/switcher.less b/lib/api/uikit/src/less/core/switcher.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/tab.less b/lib/api/uikit/src/less/core/tab.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/table.less b/lib/api/uikit/src/less/core/table.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/thumbnail.less b/lib/api/uikit/src/less/core/thumbnail.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/thumbnav.less b/lib/api/uikit/src/less/core/thumbnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/variables.less b/lib/api/uikit/src/less/core/variables.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/accordion.less b/lib/api/uikit/src/themes/almost-flat/accordion.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/alert.less b/lib/api/uikit/src/themes/almost-flat/alert.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/article.less b/lib/api/uikit/src/themes/almost-flat/article.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/autocomplete.less b/lib/api/uikit/src/themes/almost-flat/autocomplete.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/badge.less b/lib/api/uikit/src/themes/almost-flat/badge.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/block.less b/lib/api/uikit/src/themes/almost-flat/block.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/breadcrumb.less b/lib/api/uikit/src/themes/almost-flat/breadcrumb.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/close.less b/lib/api/uikit/src/themes/almost-flat/close.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/column.less b/lib/api/uikit/src/themes/almost-flat/column.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/comment.less b/lib/api/uikit/src/themes/almost-flat/comment.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/customizer.json b/lib/api/uikit/src/themes/almost-flat/customizer.json old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/datepicker.less b/lib/api/uikit/src/themes/almost-flat/datepicker.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/description-list.less b/lib/api/uikit/src/themes/almost-flat/description-list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/dotnav.less b/lib/api/uikit/src/themes/almost-flat/dotnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/dropdown.less b/lib/api/uikit/src/themes/almost-flat/dropdown.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/form-advanced.less b/lib/api/uikit/src/themes/almost-flat/form-advanced.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/form-password.less b/lib/api/uikit/src/themes/almost-flat/form-password.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/form.less b/lib/api/uikit/src/themes/almost-flat/form.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/htmleditor.less b/lib/api/uikit/src/themes/almost-flat/htmleditor.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/icon.less b/lib/api/uikit/src/themes/almost-flat/icon.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/list.less b/lib/api/uikit/src/themes/almost-flat/list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/modal.less b/lib/api/uikit/src/themes/almost-flat/modal.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/nav.less b/lib/api/uikit/src/themes/almost-flat/nav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/navbar.less b/lib/api/uikit/src/themes/almost-flat/navbar.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/nestable.less b/lib/api/uikit/src/themes/almost-flat/nestable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/notify.less b/lib/api/uikit/src/themes/almost-flat/notify.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/offcanvas.less b/lib/api/uikit/src/themes/almost-flat/offcanvas.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/overlay.less b/lib/api/uikit/src/themes/almost-flat/overlay.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/pagination.less b/lib/api/uikit/src/themes/almost-flat/pagination.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/panel.less b/lib/api/uikit/src/themes/almost-flat/panel.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/placeholder.less b/lib/api/uikit/src/themes/almost-flat/placeholder.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/progress.less b/lib/api/uikit/src/themes/almost-flat/progress.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/search.less b/lib/api/uikit/src/themes/almost-flat/search.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/slidenav.less b/lib/api/uikit/src/themes/almost-flat/slidenav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/sortable.less b/lib/api/uikit/src/themes/almost-flat/sortable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/sticky.less b/lib/api/uikit/src/themes/almost-flat/sticky.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/subnav.less b/lib/api/uikit/src/themes/almost-flat/subnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/tab.less b/lib/api/uikit/src/themes/almost-flat/tab.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/table.less b/lib/api/uikit/src/themes/almost-flat/table.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/text.less b/lib/api/uikit/src/themes/almost-flat/text.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/thumbnail.less b/lib/api/uikit/src/themes/almost-flat/thumbnail.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/thumbnav.less b/lib/api/uikit/src/themes/almost-flat/thumbnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/tooltip.less b/lib/api/uikit/src/themes/almost-flat/tooltip.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/uikit.less b/lib/api/uikit/src/themes/almost-flat/uikit.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/utility.less b/lib/api/uikit/src/themes/almost-flat/utility.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/accordion.less b/lib/api/uikit/src/themes/default/accordion.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/alert.less b/lib/api/uikit/src/themes/default/alert.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/article.less b/lib/api/uikit/src/themes/default/article.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/autocomplete.less b/lib/api/uikit/src/themes/default/autocomplete.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/badge.less b/lib/api/uikit/src/themes/default/badge.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/block.less b/lib/api/uikit/src/themes/default/block.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/breadcrumb.less b/lib/api/uikit/src/themes/default/breadcrumb.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/button.less b/lib/api/uikit/src/themes/default/button.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/close.less b/lib/api/uikit/src/themes/default/close.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/column.less b/lib/api/uikit/src/themes/default/column.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/comment.less b/lib/api/uikit/src/themes/default/comment.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/customizer.json b/lib/api/uikit/src/themes/default/customizer.json old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/datepicker.less b/lib/api/uikit/src/themes/default/datepicker.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/description-list.less b/lib/api/uikit/src/themes/default/description-list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/dotnav.less b/lib/api/uikit/src/themes/default/dotnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/dropdown.less b/lib/api/uikit/src/themes/default/dropdown.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/form-advanced.less b/lib/api/uikit/src/themes/default/form-advanced.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/form-password.less b/lib/api/uikit/src/themes/default/form-password.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/form.less b/lib/api/uikit/src/themes/default/form.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/htmleditor.less b/lib/api/uikit/src/themes/default/htmleditor.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/icon.less b/lib/api/uikit/src/themes/default/icon.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/list.less b/lib/api/uikit/src/themes/default/list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/modal.less b/lib/api/uikit/src/themes/default/modal.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/nav.less b/lib/api/uikit/src/themes/default/nav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/navbar.less b/lib/api/uikit/src/themes/default/navbar.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/nestable.less b/lib/api/uikit/src/themes/default/nestable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/notify.less b/lib/api/uikit/src/themes/default/notify.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/offcanvas.less b/lib/api/uikit/src/themes/default/offcanvas.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/overlay.less b/lib/api/uikit/src/themes/default/overlay.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/pagination.less b/lib/api/uikit/src/themes/default/pagination.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/panel.less b/lib/api/uikit/src/themes/default/panel.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/placeholder.less b/lib/api/uikit/src/themes/default/placeholder.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/progress.less b/lib/api/uikit/src/themes/default/progress.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/search.less b/lib/api/uikit/src/themes/default/search.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/slidenav.less b/lib/api/uikit/src/themes/default/slidenav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/sortable.less b/lib/api/uikit/src/themes/default/sortable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/sticky.less b/lib/api/uikit/src/themes/default/sticky.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/subnav.less b/lib/api/uikit/src/themes/default/subnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/tab.less b/lib/api/uikit/src/themes/default/tab.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/table.less b/lib/api/uikit/src/themes/default/table.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/text.less b/lib/api/uikit/src/themes/default/text.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/thumbnail.less b/lib/api/uikit/src/themes/default/thumbnail.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/thumbnav.less b/lib/api/uikit/src/themes/default/thumbnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/tooltip.less b/lib/api/uikit/src/themes/default/tooltip.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/uikit.less b/lib/api/uikit/src/themes/default/uikit.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/utility.less b/lib/api/uikit/src/themes/default/utility.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/accordion.less b/lib/api/uikit/src/themes/gradient/accordion.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/alert.less b/lib/api/uikit/src/themes/gradient/alert.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/article.less b/lib/api/uikit/src/themes/gradient/article.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/autocomplete.less b/lib/api/uikit/src/themes/gradient/autocomplete.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/badge.less b/lib/api/uikit/src/themes/gradient/badge.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/block.less b/lib/api/uikit/src/themes/gradient/block.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/breadcrumb.less b/lib/api/uikit/src/themes/gradient/breadcrumb.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/button.less b/lib/api/uikit/src/themes/gradient/button.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/close.less b/lib/api/uikit/src/themes/gradient/close.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/column.less b/lib/api/uikit/src/themes/gradient/column.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/comment.less b/lib/api/uikit/src/themes/gradient/comment.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/customizer.json b/lib/api/uikit/src/themes/gradient/customizer.json old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/datepicker.less b/lib/api/uikit/src/themes/gradient/datepicker.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/description-list.less b/lib/api/uikit/src/themes/gradient/description-list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/dotnav.less b/lib/api/uikit/src/themes/gradient/dotnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/dropdown.less b/lib/api/uikit/src/themes/gradient/dropdown.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/form-advanced.less b/lib/api/uikit/src/themes/gradient/form-advanced.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/form-password.less b/lib/api/uikit/src/themes/gradient/form-password.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/form.less b/lib/api/uikit/src/themes/gradient/form.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/htmleditor.less b/lib/api/uikit/src/themes/gradient/htmleditor.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/icon.less b/lib/api/uikit/src/themes/gradient/icon.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/list.less b/lib/api/uikit/src/themes/gradient/list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/modal.less b/lib/api/uikit/src/themes/gradient/modal.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/nav.less b/lib/api/uikit/src/themes/gradient/nav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/navbar.less b/lib/api/uikit/src/themes/gradient/navbar.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/nestable.less b/lib/api/uikit/src/themes/gradient/nestable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/notify.less b/lib/api/uikit/src/themes/gradient/notify.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/offcanvas.less b/lib/api/uikit/src/themes/gradient/offcanvas.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/overlay.less b/lib/api/uikit/src/themes/gradient/overlay.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/pagination.less b/lib/api/uikit/src/themes/gradient/pagination.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/panel.less b/lib/api/uikit/src/themes/gradient/panel.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/placeholder.less b/lib/api/uikit/src/themes/gradient/placeholder.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/progress.less b/lib/api/uikit/src/themes/gradient/progress.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/search.less b/lib/api/uikit/src/themes/gradient/search.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/slidenav.less b/lib/api/uikit/src/themes/gradient/slidenav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/sortable.less b/lib/api/uikit/src/themes/gradient/sortable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/sticky.less b/lib/api/uikit/src/themes/gradient/sticky.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/subnav.less b/lib/api/uikit/src/themes/gradient/subnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/tab.less b/lib/api/uikit/src/themes/gradient/tab.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/table.less b/lib/api/uikit/src/themes/gradient/table.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/text.less b/lib/api/uikit/src/themes/gradient/text.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/thumbnail.less b/lib/api/uikit/src/themes/gradient/thumbnail.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/thumbnav.less b/lib/api/uikit/src/themes/gradient/thumbnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/tooltip.less b/lib/api/uikit/src/themes/gradient/tooltip.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/uikit.less b/lib/api/uikit/src/themes/gradient/uikit.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/utility.less b/lib/api/uikit/src/themes/gradient/utility.less old mode 100644 new mode 100755 From 85b46081a3172ba7b7e3e07f684b1fefcc47c94b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 19 Jun 2018 10:42:19 -0500 Subject: [PATCH 728/800] Fixed documentation and naming per code review. --- lib/api/utilities/functions.php | 4 ++-- .../api/compiler/beansCompileCssFragments.php | 2 +- .../unit/api/compiler/beansFlushCompiler.php | 2 +- .../unit/api/utilities/beansScandir.php | 4 ++-- .../unit/api/utilities/beansStrEndsWith.php | 19 +++++++++---------- .../unit/api/utilities/beansStrStartsWith.php | 18 +++++++++--------- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index c15e4a49..4722ac81 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -142,7 +142,7 @@ function beans_str_ends_with( $haystack, $needles ) { } /** - * Checks if the given string ends with the given substring(s). + * Check if the given string starts with the given substring(s). * * When passing an array of needles, the first needle match returns `true`. Therefore, only one word in the array * needs to match. @@ -150,7 +150,7 @@ function beans_str_ends_with( $haystack, $needles ) { * @since 1.5.0 * * @param string $haystack The given string to check. - * @param string|array $needles The substring(s) to check for at the end of the given string. + * @param string|array $needles The substring(s) to check for at the beginning of the given string. * * @return bool */ diff --git a/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php b/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php index 1da426a3..d97d12fe 100644 --- a/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php +++ b/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php @@ -23,7 +23,7 @@ class Test_BeansCompileCssFragments extends Compiler_Test_Case { /** - * Test beans_compile_css_fragments() should return false when no fragments when no fragments are given. + * Test beans_compile_css_fragments() should return false when no fragments are given. */ public function test_should_return_false_when_no_fragments_given() { $this->assertFalse( beans_compile_css_fragments( 'foo', '' ) ); diff --git a/tests/phpunit/unit/api/compiler/beansFlushCompiler.php b/tests/phpunit/unit/api/compiler/beansFlushCompiler.php index f95d7a2e..7ffcdfbb 100644 --- a/tests/phpunit/unit/api/compiler/beansFlushCompiler.php +++ b/tests/phpunit/unit/api/compiler/beansFlushCompiler.php @@ -27,7 +27,7 @@ class Tests_BeansFlushCompiler extends Compiler_Options_Test_Case { /** * Test beans_flush_compiler() should bail out when the directory does not exist. */ - public function test_should_return_absolute_path_to_compiler_folder() { + public function test_should_bail_out_when_directory_does_not_exist() { $compiler_dir = vfsStream::url( 'compiled/beans/compiler/' ); Monkey\Functions\expect( 'beans_get_compiler_dir' ) ->twice() diff --git a/tests/phpunit/unit/api/utilities/beansScandir.php b/tests/phpunit/unit/api/utilities/beansScandir.php index 9b213a5f..b7018539 100644 --- a/tests/phpunit/unit/api/utilities/beansScandir.php +++ b/tests/phpunit/unit/api/utilities/beansScandir.php @@ -32,12 +32,12 @@ protected function setUp() { /** * Test beans_scandir() should return false when directory is invalid. */ - public function test_should_find_needle_when_array_given() { + public function test_should_return_false_when_directory_is_invalid() { $this->assertFalse( beans_scandir( 'directory-does-not-exist' ) ); } /** - * Test beans_scandir() should return all files in given directory. + * Test beans_scandir() should return all files in the given directory. */ public function test_should_return_all_files_in_given_directory() { $files = beans_scandir( __DIR__ ); diff --git a/tests/phpunit/unit/api/utilities/beansStrEndsWith.php b/tests/phpunit/unit/api/utilities/beansStrEndsWith.php index 35519274..f7f24a1d 100644 --- a/tests/phpunit/unit/api/utilities/beansStrEndsWith.php +++ b/tests/phpunit/unit/api/utilities/beansStrEndsWith.php @@ -30,23 +30,23 @@ protected function setUp() { } /** - * Test beans_str_ends_with() should return false when case is wrong. + * Test beans_str_ends_with() should return false when case does not match. */ - public function test_should_return_false_when_case_is_wrong() { + public function test_should_return_false_when_case_does_not_match() { $this->assertFalse( beans_str_ends_with( 'Foo', 'O' ) ); $this->assertFalse( beans_str_ends_with( 'Checking the Case?', 'case?' ) ); } /** - * Test beans_str_ends_with() should return true when the case is correct. + * Test beans_str_ends_with() should return true when the case matches. */ - public function test_should_return_true_when_case_is_correct() { + public function test_should_return_true_when_case_matches() { $this->assertTrue( beans_str_ends_with( 'Foo', 'o' ) ); $this->assertTrue( beans_str_ends_with( 'Checking the Case?', 'Case?' ) ); } /** - * Test beans_str_ends_with() should correctly identify ending string pattern. + * Test beans_str_ends_with() should correctly identify the ending string pattern. */ public function test_should_correctly_identify_ending_string_pattern() { $this->assertTrue( beans_str_ends_with( 'This is a string test.', '.' ) ); @@ -63,7 +63,7 @@ public function test_should_correctly_identify_ending_string_pattern() { } /** - * Test beans_str_ends_with() should correctly identify when different data type is given. + * Test beans_str_ends_with() should correctly identify when a different data type is given. */ public function test_should_correctly_identify_when_different_data_type_given() { $this->assertTrue( beans_str_ends_with( 104, '04' ) ); @@ -82,9 +82,9 @@ public function test_should_correctly_identify_when_different_data_type_given() } /** - * Test beans_str_ends_with() should correctly identify when given an array of needles. + * Test beans_str_ends_with() should correctly identify when an array of needles is given. */ - public function test_should_correctly_identify_when_given_an_array_of_needles() { + public function test_should_correctly_identify_when_array_of_needles_given() { $this->assertTrue( beans_str_ends_with( 'This is a string test', [ 'Test', 'test' ] ) ); $this->assertFalse( beans_str_ends_with( 'This is a string test', [ 'string', 'are' ] ) ); $this->assertTrue( beans_str_ends_with( 'This is a string test', [ 'tests', 'test!', 'Test', 'test' ] ) ); @@ -106,12 +106,11 @@ public function test_should_correctly_identify_when_given_an_array_of_needles() } /** - * Test beans_str_ends_with() should correctly identify when non-Latin given. + * Test beans_str_ends_with() should correctly identify when non-Latin is given. */ public function test_should_correctly_identify_when_non_latin_given() { $string = 'Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός'; - $this->assertFalse( beans_str_ends_with( $string, ' ' ) ); $this->assertFalse( beans_str_ends_with( $string, ' ' ) ); $this->assertTrue( beans_str_ends_with( $string, 'ς' ) ); $this->assertFalse( beans_str_ends_with( $string, 'Δρασκελίζει' ) ); diff --git a/tests/phpunit/unit/api/utilities/beansStrStartsWith.php b/tests/phpunit/unit/api/utilities/beansStrStartsWith.php index 20164357..154d6944 100644 --- a/tests/phpunit/unit/api/utilities/beansStrStartsWith.php +++ b/tests/phpunit/unit/api/utilities/beansStrStartsWith.php @@ -30,9 +30,9 @@ protected function setUp() { } /** - * Test beans_str_starts_with() should return false when case is wrong. + * Test beans_str_starts_with() should return false when case does not match. */ - public function test_should_return_false_when_case_is_wrong() { + public function test_should_return_false_when_case_does_not_match() { $this->assertFalse( beans_str_starts_with( 'Foo', 'f' ) ); $this->assertFalse( beans_str_starts_with( 'Checking the Case?', 'check' ) ); $this->assertFalse( beans_str_starts_with( 'WordPress Community Rocks!', [ @@ -43,9 +43,9 @@ public function test_should_return_false_when_case_is_wrong() { } /** - * Test beans_str_starts_with() should return true when the case is correct. + * Test beans_str_starts_with() should return true when the case matches. */ - public function test_should_return_true_when_case_is_correct() { + public function test_should_return_true_when_case_matches() { $this->assertTrue( beans_str_starts_with( 'Foo', 'F' ) ); $this->assertTrue( beans_str_starts_with( 'Checking the Case?', 'Checking' ) ); $this->assertTrue( beans_str_starts_with( 'WordPress Community Rocks!', [ @@ -56,7 +56,7 @@ public function test_should_return_true_when_case_is_correct() { } /** - * Test beans_str_starts_with() should correctly identify starting string pattern. + * Test beans_str_starts_with() should correctly identify the starting string pattern. */ public function test_should_correctly_identify_starting_string_pattern() { $this->assertTrue( beans_str_starts_with( 'This is a string test.', 'This is' ) ); @@ -73,7 +73,7 @@ public function test_should_correctly_identify_starting_string_pattern() { } /** - * Test beans_str_starts_with() should correctly identify when different data type is given. + * Test beans_str_starts_with() should correctly identify when a different data type is given. */ public function test_should_correctly_identify_when_different_data_type_given() { $this->assertTrue( beans_str_starts_with( 104, '1' ) ); @@ -90,9 +90,9 @@ public function test_should_correctly_identify_when_different_data_type_given() } /** - * Test beans_str_starts_with() should correctly identify when given an array of needles. + * Test beans_str_starts_with() should correctly identify when an array of needles is given. */ - public function test_should_correctly_identify_when_given_an_array_of_needles() { + public function test_should_correctly_identify_when_array_of_needles_given() { $this->assertTrue( beans_str_starts_with( 'This is a string test', [ 'this', ' this', ' This', 'This' ] @@ -127,7 +127,7 @@ public function test_should_correctly_identify_when_given_an_array_of_needles() } /** - * Test beans_str_starts_with() should correctly identify when non-Latin given. + * Test beans_str_starts_with() should correctly identify when non-Latin is given. */ public function test_should_correctly_identify_when_non_latin_given() { $string = 'Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός'; From 1c923f5730c5fb140800a06000109486d287e38a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 19 Jun 2018 20:02:54 -0500 Subject: [PATCH 729/800] Added tests for compiling assets. --- lib/api/uikit/class-beans-uikit.php | 4 +- .../api/uikit/beans-uikit/compile.php | 272 ++++++++++++++++++ .../api/uikit/beansUikitEnqueueAssets.php | 118 ++++++++ .../api/uikit/fixtures/less/alert.less | 20 ++ .../api/uikit/fixtures/less/close.less | 17 ++ .../api/uikit/fixtures/less/panel.less | 25 ++ .../api/uikit/fixtures/less/uikit.less | 5 + .../api/uikit/fixtures/less/variables.less | 68 +++++ .../uikit/includes/class-uikit-test-case.php | 58 +++- .../unit/api/uikit/beans-uikit/compile.php | 150 ++++++++++ 10 files changed, 726 insertions(+), 11 deletions(-) create mode 100644 tests/phpunit/integration/api/uikit/beans-uikit/compile.php create mode 100644 tests/phpunit/integration/api/uikit/beansUikitEnqueueAssets.php create mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/alert.less create mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/close.less create mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/panel.less create mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/uikit.less create mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/variables.less create mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/compile.php diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index dd695bf5..46875fee 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -40,8 +40,6 @@ final class _Beans_Uikit { * @return void */ public function compile() { - global $_beans_uikit_enqueued_items; - /** * Filter UIkit enqueued style components. * @@ -79,7 +77,7 @@ public function compile() { $scripts_args = apply_filters( 'beans_uikit_euqueued_scripts_args', array( - 'depedencies' => array( 'jquery' ), + 'dependencies' => array( 'jquery' ), ) ); diff --git a/tests/phpunit/integration/api/uikit/beans-uikit/compile.php b/tests/phpunit/integration/api/uikit/beans-uikit/compile.php new file mode 100644 index 00000000..170decd1 --- /dev/null +++ b/tests/phpunit/integration/api/uikit/beans-uikit/compile.php @@ -0,0 +1,272 @@ +compiled_uikit_path = vfsStream::url( 'virtual-wp-content/uploads/beans/compiler/uikit/' ); + + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['themes'] = []; + } + + /** + * Cleans up the test environment after each test. + */ + public function tearDown() { + remove_all_filters( 'beans_uikit_euqueued_styles' ); + remove_all_filters( 'beans_uikit_euqueued_styles_args' ); + remove_all_filters( 'beans_uikit_euqueued_scripts' ); + remove_all_filters( 'beans_uikit_euqueued_scripts_args' ); + + parent::tearDown(); + } + + /** + * Test _Beans_Uikit::compile() should not compile when there are no assets to compile. + */ + public function test_should_not_compile_when_no_assets_to_compile() { + add_filter( 'beans_uikit_euqueued_styles', '__return_empty_array' ); + add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); + + // Make sure the compilers do not get called. + Monkey\Functions\expect( 'beans_compile_less_fragments' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + $this->assertNull( ( new _Beans_Uikit() )->compile() ); + } + + /** + * Test _Beans_Uikit::compile() should compile the styles. + */ + public function test_should_compile_styles() { + beans_uikit_enqueue_components( [ + 'alert', + 'button', + 'overlay', + ], 'core', false ); + + add_filter( 'beans_uikit_euqueued_styles', function( $styles ) { + $this->assertSame( [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_API_PATH . 'uikit/src/less/core/alert.less', + BEANS_API_PATH . 'uikit/src/less/core/button.less', + BEANS_API_PATH . 'uikit/src/less/core/overlay.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], $styles ); + + return $styles; + }, 9999 ); + add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + $this->assertEmpty( $this->get_compiled_filename( $this->compiled_uikit_path ) ); + ( new _Beans_Uikit() )->compile(); + $filename = $this->get_compiled_filename( $this->compiled_uikit_path ); + $this->assertFileExists( $this->compiled_uikit_path . $filename ); + $this->assertStringEndsWith( '.css', $filename ); + + // Check the compiled CSS. + $compiled_css = $this->get_cached_contents( $filename, 'uikit' ); + $alert_css = <<assertContains( $alert_css, $compiled_css ); + + $button_css = <<assertContains( $button_css, $compiled_css ); + + $overlay_css = <<:first-child{margin-bottom:0} +.uk-overlay-panel{position:absolute;top:0;bottom:0;left:0;right:0;padding:20px;color:#fff} +EOB; + $this->assertContains( $overlay_css, $compiled_css ); + } + + /** + * Test _Beans_Uikit::compile() should compile the styles with the default theme. + */ + public function test_should_compile_styles_with_default_theme() { + $theme_path = BEANS_API_PATH . 'uikit/src/themes/default/'; + beans_uikit_enqueue_theme( 'default', $theme_path ); + beans_uikit_enqueue_components( 'alert', 'core', false ); + + add_filter( 'beans_uikit_euqueued_styles', function( $styles ) use ( $theme_path ) { + $this->assertSame( [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + $theme_path . 'variables.less', + BEANS_API_PATH . 'uikit/src/less/core/alert.less', + $theme_path . 'alert.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], $styles ); + + return $styles; + }, 9999 ); + add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + $this->assertEmpty( $this->get_compiled_filename( $this->compiled_uikit_path ) ); + ( new _Beans_Uikit() )->compile(); + $filename = $this->get_compiled_filename( $this->compiled_uikit_path ); + $this->assertFileExists( $this->compiled_uikit_path . $filename ); + $this->assertStringEndsWith( '.css', $filename ); + + // Check the compiled CSS. + $compiled_css = $this->get_cached_contents( $filename, 'uikit' ); + $alert_css = <<assertContains( $alert_css, $compiled_css ); + } + + /** + * Test _Beans_Uikit::compile() should compile the styles with thje child theme. + */ + public function test_should_compile_styles_with_child_theme() { + $theme_path = dirname( __DIR__ ) . '/fixtures/less/'; + beans_uikit_enqueue_theme( 'beans-child', $theme_path ); + beans_uikit_enqueue_components( [ 'alert', 'close', 'panel' ], 'core', false ); + + add_filter( 'beans_uikit_euqueued_styles', function( $styles ) use ( $theme_path ) { + $this->assertSame( [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + $theme_path . 'variables.less', + BEANS_API_PATH . 'uikit/src/less/core/alert.less', + $theme_path . 'alert.less', + BEANS_API_PATH . 'uikit/src/less/core/close.less', + $theme_path . 'close.less', + BEANS_API_PATH . 'uikit/src/less/core/panel.less', + $theme_path . 'panel.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], $styles ); + + return $styles; + }, 9999 ); + add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + $this->assertEmpty( $this->get_compiled_filename( $this->compiled_uikit_path ) ); + ( new _Beans_Uikit() )->compile(); + $filename = $this->get_compiled_filename( $this->compiled_uikit_path ); + $this->assertFileExists( $this->compiled_uikit_path . $filename ); + $this->assertStringEndsWith( '.css', $filename ); + + // Check the compiled CSS. + $compiled_css = $this->get_cached_contents( $filename, 'uikit' ); + $alert_css = <<assertContains( $alert_css, $compiled_css ); + + $alert_css = <<assertContains( $alert_css, $compiled_css ); + + $close_css = <<assertContains( $close_css, $compiled_css ); + + $close_css = <<assertContains( $close_css, $compiled_css ); + + $panel_css = <<assertContains( $panel_css, $compiled_css ); + } + + /** + * Test _Beans_Uikit::compile() should compile the scripts. + */ + public function test_should_compile_scripts() { + beans_uikit_enqueue_components( [ + 'alert', + 'button', + ], 'core', false ); + + add_filter( 'beans_uikit_euqueued_styles', '__return_empty_array' ); + Monkey\Functions\expect( 'beans_compile_less_fragments' )->never(); + add_filter( 'beans_uikit_euqueued_scripts', function( $scripts ) { + $this->assertSame( [ + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/utility.min.js', + BEANS_API_PATH . 'uikit/src/js/core/touch.min.js', + BEANS_API_PATH . 'uikit/src/js/core/alert.min.js', + BEANS_API_PATH . 'uikit/src/js/core/button.min.js', + ], $scripts ); + + return $scripts; + }, 9999 ); + + $this->assertEmpty( $this->get_compiled_filename( $this->compiled_uikit_path ) ); + ( new _Beans_Uikit() )->compile(); + $filename = $this->get_compiled_filename( $this->compiled_uikit_path ); + $this->assertFileExists( $this->compiled_uikit_path . $filename ); + $this->assertStringEndsWith( '.js', $filename ); + + // Check the compiled JavaScript. + $compiled_js = $this->get_cached_contents( $filename, 'uikit' ); + $this->assertContains( '!function(t){"use strict";t.component("alert"', $compiled_js ); + $this->assertContains( '!function(t){"use strict";t.component("buttonRadio",', $compiled_js ); + $this->assertContains( '!function(e){function t(e,t,n,o){return Math.abs(e-t)>=Math.abs(n-o)?e-t>0?"Left":"Right"', $compiled_js ); + } +} diff --git a/tests/phpunit/integration/api/uikit/beansUikitEnqueueAssets.php b/tests/phpunit/integration/api/uikit/beansUikitEnqueueAssets.php new file mode 100644 index 00000000..f346a8ac --- /dev/null +++ b/tests/phpunit/integration/api/uikit/beansUikitEnqueueAssets.php @@ -0,0 +1,118 @@ +never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + // Run the test. + $this->assertNull( _beans_uikit_enqueue_assets() ); + } + + /** + * Test _beans_uikit_enqueue_assets() should fire 'beans_uikit_enqueue_scripts'. + */ + public function test_should_fire_beans_uikit_enqueue_scripts() { + // Needs a callback registered to run this function. + add_action( 'beans_uikit_enqueue_scripts', '__return_false' ); + + // Disable both scripts and styles to disable the compiler. + add_filter( 'beans_uikit_euqueued_styles', '__return_empty_array' ); + add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); + + // Run the tests. + _beans_uikit_enqueue_assets(); + $this->assertSame( 1, did_action( 'beans_uikit_enqueue_scripts' ) ); + } + + /** + * Test _beans_uikit_enqueue_assets() should compile the styles. + */ + public function test_should_compile_styles() { + // Needs a callback registered to run this function. + add_action( 'beans_uikit_enqueue_scripts', '__return_false' ); + + // Register some components. + beans_uikit_enqueue_components( [ + 'alert', + 'button', + 'overlay', + ], 'core', false ); + + // Disable the scripts from running. + add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); + + // Run the tests. + $compiled_uikit_path = vfsStream::url( 'virtual-wp-content/uploads/beans/compiler/uikit/' ); + $this->assertEmpty( $this->get_compiled_filename( $compiled_uikit_path ) ); + _beans_uikit_enqueue_assets(); + $filename = $this->get_compiled_filename( $compiled_uikit_path ); + $this->assertFileExists( $compiled_uikit_path . $filename ); + $this->assertStringEndsWith( '.css', $filename ); + } + + /** + * Test _beans_uikit_enqueue_assets() should compile the scripts. + */ + public function test_should_compile_scripts() { + // Needs a callback registered to run this function. + add_action( 'beans_uikit_enqueue_scripts', '__return_false' ); + + // Register some components. + beans_uikit_enqueue_components( [ + 'alert', + 'button', + ], 'core', false ); + + // Disable the styles from running. + add_filter( 'beans_uikit_euqueued_styles', '__return_empty_array' ); + + // Run the tests. + $compiled_uikit_path = vfsStream::url( 'virtual-wp-content/uploads/beans/compiler/uikit/' ); + $this->assertEmpty( $this->get_compiled_filename( $compiled_uikit_path ) ); + _beans_uikit_enqueue_assets(); + $filename = $this->get_compiled_filename( $compiled_uikit_path ); + $this->assertFileExists( $compiled_uikit_path . $filename ); + $this->assertStringEndsWith( '.js', $filename ); + } +} diff --git a/tests/phpunit/integration/api/uikit/fixtures/less/alert.less b/tests/phpunit/integration/api/uikit/fixtures/less/alert.less new file mode 100755 index 00000000..1b4e68ab --- /dev/null +++ b/tests/phpunit/integration/api/uikit/fixtures/less/alert.less @@ -0,0 +1,20 @@ +// +// Component: Alert +// +// ======================================================================== + + +// Variables +// ======================================================================== + +@alert-margin-vertical: @global-margin; + +// +// New +// + +@alert-background: #ccc; +@alert-success-background: @global-success-background; +@alert-warning-background: @global-warning-background; +@alert-danger-background: @global-danger-background; +@alert-large-padding: 40px; \ No newline at end of file diff --git a/tests/phpunit/integration/api/uikit/fixtures/less/close.less b/tests/phpunit/integration/api/uikit/fixtures/less/close.less new file mode 100755 index 00000000..9c1dad4c --- /dev/null +++ b/tests/phpunit/integration/api/uikit/fixtures/less/close.less @@ -0,0 +1,17 @@ +// +// Component: Close +// +// ======================================================================== + + +// Variables +// ======================================================================== + +@close-size: 40px; + +@close-alt-padding: 10px; +@close-alt-background: #cc0000; + +.hook-close() { + background: #ccc; +} \ No newline at end of file diff --git a/tests/phpunit/integration/api/uikit/fixtures/less/panel.less b/tests/phpunit/integration/api/uikit/fixtures/less/panel.less new file mode 100755 index 00000000..85cd8ae8 --- /dev/null +++ b/tests/phpunit/integration/api/uikit/fixtures/less/panel.less @@ -0,0 +1,25 @@ +// +// Component: Panel +// +// ======================================================================== + + +// Variables +// ======================================================================== + +@panel-title-margin-bottom: @global-margin; +@panel-title-font-size: 20px; +@panel-title-line-height: 26px; +@panel-title-color: @global-color; + +@panel-box-padding: @global-margin; +@panel-box-background: @global-link-color; +@panel-box-color: @global-color; +@panel-box-title-color: @global-color; + +@panel-box-secondary-background: #fff; + +@panel-hover-padding: @global-margin; +@panel-hover-color: @global-color; +@panel-hover-hover-color: @global-color; +@panel-hover-hover-background: @global-link-hover-color; \ No newline at end of file diff --git a/tests/phpunit/integration/api/uikit/fixtures/less/uikit.less b/tests/phpunit/integration/api/uikit/fixtures/less/uikit.less new file mode 100755 index 00000000..c657bb5b --- /dev/null +++ b/tests/phpunit/integration/api/uikit/fixtures/less/uikit.less @@ -0,0 +1,5 @@ +@import "variables.less"; + +@import "close.less"; +@import "alert.less"; +@import "panel.less"; diff --git a/tests/phpunit/integration/api/uikit/fixtures/less/variables.less b/tests/phpunit/integration/api/uikit/fixtures/less/variables.less new file mode 100755 index 00000000..a5a49a7e --- /dev/null +++ b/tests/phpunit/integration/api/uikit/fixtures/less/variables.less @@ -0,0 +1,68 @@ +// +// Component: Variables +// +// ======================================================================== + + +// Global variables +// ======================================================================== + +// +// Text +// + +@global-color: #444; +@global-muted-color: #999; +@global-text-shadow: #fff; + +@global-link-color: #cb4b14; +@global-link-hover-color: #059; + +@global-contrast-color: #fff; +@global-contrast-text-shadow: rgba(0,0,0,0.1); + +@global-font-size: 18px; +@global-line-height: 22px; + +// +// Backgrounds & Borders +// + +@global-background: #fff; +@global-border: #ddd; + +@global-border-radius: 0; + +@global-default-background: #DCDCDC; +@global-default-hover-background: #fafafa; +@global-default-active-background: #eee; + +@global-primary-background: #1c202c; +@global-success-background: #627f00; +@global-warning-background: #faa732; +@global-danger-background: #cc0000; + +// +// Spacings +// + +@global-margin: 15px; +@global-margin-large: 25px; +@global-grid-gutter: 25px; +@global-grid-gutter-large: 35px; +@global-grid-gutter-xlarge: 50px; + +// +// Controls +// + +@global-height: 30px; +@global-height-mini: 20px; +@global-height-small: 25px; +@global-height-large: 40px; + +// +// Z-index +// + +@global-z-index: 1000; \ No newline at end of file diff --git a/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php index bfbe9142..935802ef 100644 --- a/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php @@ -10,6 +10,7 @@ namespace Beans\Framework\Tests\Integration\API\UIkit\Includes; use Beans\Framework\Tests\Integration\Test_Case; +use Brain\Monkey; use org\bovigo\vfs\vfsStream; /** @@ -33,6 +34,7 @@ public function setUp() { parent::setUp(); $this->set_up_virtual_filesystem(); + $this->set_up_mocks(); $this->set_up_uploads_directory(); $this->reset_globals(); @@ -78,9 +80,7 @@ protected function get_virtual_structure() { 'uploads' => [ 'beans' => [ 'compiler' => [ - 'uikit' => [ - 'index.php' => '', - ], + 'uikit' => [], ], ], ], @@ -88,7 +88,15 @@ protected function get_virtual_structure() { } /** - * Set the Uploads directory to our virtual filesystem. + * Set up the mocks. + */ + protected function set_up_mocks() { + // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. + Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); + } + + /** + * Set up the Uploads directory to our virtual filesystem. */ protected function set_up_uploads_directory() { add_filter( 'upload_dir', function( array $uploads_dir ) { @@ -117,13 +125,47 @@ protected function reset_globals() { 'themes' => array(), ); - $_beans_uikit_registered_items = array( - 'themes' => array( + $_beans_uikit_registered_items = [ + 'themes' => [ 'default' => BEANS_API_PATH . 'uikit/src/themes/default', 'almost-flat' => BEANS_API_PATH . 'uikit/src/themes/almost-flat', 'gradient' => BEANS_API_PATH . 'uikit/src/themes/gradient', 'wordpress-admin' => BEANS_API_PATH . 'uikit/themes/wordpress-admin', - ), - ); + ], + ]; + } + + /** + * Get the file's content. + * + * @since 1.5.0 + * + * @param string $filename Name of the file. + * @param string $id File's ID. + * + * @return string + */ + protected function get_cached_contents( $filename, $id ) { + return $this->mock_filesystem + ->getChild( 'virtual-wp-content/uploads/beans/compiler/' . $id ) + ->getChild( $filename ) + ->getContent(); + } + + /** + * Get the compiled file's name. + * + * @param string $path The virtual filesystem's path. + * + * @return string + */ + protected function get_compiled_filename( $path ) { + $files = beans_scandir( $path ); + + if ( empty( $files ) ) { + return ''; + } + + return array_pop( $files ); } } diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/compile.php b/tests/phpunit/unit/api/uikit/beans-uikit/compile.php new file mode 100644 index 00000000..04cde046 --- /dev/null +++ b/tests/phpunit/unit/api/uikit/beans-uikit/compile.php @@ -0,0 +1,150 @@ +once() + ->andReturn( [] ); + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_scripts' ) + ->once() + ->andReturn( [] ); + Monkey\Functions\expect( 'beans_compile_less_fragments' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + $this->assertNull( $beans_uikit->compile() ); + } + + /** + * Test _Beans_Uikit::compile() should compile the styles. + */ + public function test_should_compile_styles() { + $beans_uikit = new _Beans_Uikit(); + + $styles = [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ]; + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_styles' ) + ->once() + ->with( $styles ) + ->andReturn( $styles ); + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_scripts' )->andReturn( false ); + Monkey\Functions\expect( 'beans_compile_less_fragments' ) + ->once() + ->with( 'uikit', $styles, [] ) + ->andReturnNull(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + $this->assertNull( $beans_uikit->compile() ); + } + + /** + * Test _Beans_Uikit::compile() should compile the styles with filtered args. + */ + public function test_should_compile_styles_with_filtered_args() { + $beans_uikit = new _Beans_Uikit(); + + $styles = [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ]; + $args = [ 'dependencies' => [ 'foo' ] ]; + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_styles' )->andReturn( $styles ); + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_scripts' )->andReturn( false ); + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_styles_args' ) + ->once() + ->with( [] ) + ->andReturn( $args ); + Monkey\Functions\expect( 'beans_compile_less_fragments' ) + ->once() + ->with( 'uikit', $styles, $args ) + ->andReturnNull(); + Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); + + $this->assertNull( $beans_uikit->compile() ); + } + + /** + * Test _Beans_Uikit::compile() should compile the scripts. + */ + public function test_should_compile_scripts() { + $beans_uikit = new _Beans_Uikit(); + + $scripts = [ + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/utility.min.js', + BEANS_API_PATH . 'uikit/src/js/core/touch.min.js', + ]; + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_styles' )->andReturn( false ); + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_scripts' ) + ->once() + ->with( $scripts ) + ->andReturn( $scripts ); + Monkey\Functions\expect( 'beans_compile_less_fragments' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' ) + ->once() + ->with( 'uikit', $scripts, [ 'dependencies' => [ 'jquery' ] ] ) + ->andReturnNull(); + + $this->assertNull( $beans_uikit->compile() ); + } + + /** + * Test _Beans_Uikit::compile() should compile the scripts with filtered args. + */ + public function test_should_compile_scripts_with_filtered_args() { + $beans_uikit = new _Beans_Uikit(); + + $scripts = [ + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/utility.min.js', + BEANS_API_PATH . 'uikit/src/js/core/touch.min.js', + ]; + $args = [ + 'dependencies' => [ 'jquery' ], + 'in_footer' => true, + 'minify_js' => true, + ]; + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_styles' )->andReturn( false ); + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_scripts' )->andReturn( $scripts ); + Monkey\Filters\expectApplied( 'beans_uikit_euqueued_scripts_args' ) + ->once() + ->with( [ 'dependencies' => [ 'jquery' ] ] ) + ->andReturn( $args ); + Monkey\Functions\expect( 'beans_compile_less_fragments' )->never(); + Monkey\Functions\expect( 'beans_compile_js_fragments' ) + ->once() + ->with( 'uikit', $scripts, $args ) + ->andReturnNull(); + + $this->assertNull( $beans_uikit->compile() ); + } +} From 82cb12f05634b0570e1a9d65448cc4efb23e20e4 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 19 Jun 2018 20:10:07 -0500 Subject: [PATCH 730/800] Refactored _Beans_Uikit::compile, splitting into separate methods. Refactored to create 2 new private methods: - compile_styles() - compile_styles() With this change, the args are not processed if there are no assets to compile. That is an optimization. --- lib/api/uikit/class-beans-uikit.php | 57 +++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 46875fee..4ee00edf 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -40,6 +40,18 @@ final class _Beans_Uikit { * @return void */ public function compile() { + $this->compile_styles(); + $this->compile_scripts(); + } + + /** + * Compile the styles. + * + * @since 1.5.0 + * + * @return void + */ + private function compile_styles() { /** * Filter UIkit enqueued style components. * @@ -49,23 +61,44 @@ public function compile() { */ $styles = apply_filters( 'beans_uikit_euqueued_styles', $this->register_less_components() ); + // If there are not styles to compile, bail out. + if ( empty( $styles ) ) { + return; + } + /** - * Filter UIkit enqueued script components. + * Filter UIkit style compiler arguments. * * @since 1.0.0 * - * @param array $components An array of UIkit script component files. + * @param array $components An array of UIkit style compiler arguments. */ - $scripts = apply_filters( 'beans_uikit_euqueued_scripts', $this->register_js_components() ); + $args = apply_filters( 'beans_uikit_euqueued_styles_args', array() ); + + beans_compile_less_fragments( 'uikit', array_unique( $styles ), $args ); + } + /** + * Compile the scripts. + * + * @since 1.5.0 + * + * @return void + */ + private function compile_scripts() { /** - * Filter UIkit style compiler arguments. + * Filter UIkit enqueued script components. * * @since 1.0.0 * - * @param array $components An array of UIkit style compiler arguments. + * @param array $components An array of UIkit script component files. */ - $styles_args = apply_filters( 'beans_uikit_euqueued_styles_args', array() ); + $scripts = apply_filters( 'beans_uikit_euqueued_scripts', $this->register_js_components() ); + + // If there are not styles to compile, bail out. + if ( empty( $scripts ) ) { + return; + } /** * Filter UIkit script compiler arguments. @@ -74,22 +107,14 @@ public function compile() { * * @param array $components An array of UIkit script compiler arguments. */ - $scripts_args = apply_filters( + $args = apply_filters( 'beans_uikit_euqueued_scripts_args', array( 'dependencies' => array( 'jquery' ), ) ); - // Compile less. - if ( $styles ) { - beans_compile_less_fragments( 'uikit', array_unique( $styles ), $styles_args ); - } - - // Compile js. - if ( $scripts ) { - beans_compile_js_fragments( 'uikit', array_unique( $scripts ), $scripts_args ); - } + beans_compile_js_fragments( 'uikit', array_unique( $scripts ), $args ); } /** From 1e4dc7eb91aad0bc80c3e8e41d2a1a5437f657d7 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 19 Jun 2018 20:44:22 -0500 Subject: [PATCH 731/800] Fixed documentation. --- lib/api/uikit/class-beans-uikit.php | 4 ++-- tests/phpunit/integration/api/uikit/beans-uikit/compile.php | 2 +- tests/phpunit/unit/api/uikit/beans-uikit/compile.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php index 4ee00edf..a8a389bb 100644 --- a/lib/api/uikit/class-beans-uikit.php +++ b/lib/api/uikit/class-beans-uikit.php @@ -61,7 +61,7 @@ private function compile_styles() { */ $styles = apply_filters( 'beans_uikit_euqueued_styles', $this->register_less_components() ); - // If there are not styles to compile, bail out. + // If there are no styles to compile, bail out. if ( empty( $styles ) ) { return; } @@ -95,7 +95,7 @@ private function compile_scripts() { */ $scripts = apply_filters( 'beans_uikit_euqueued_scripts', $this->register_js_components() ); - // If there are not styles to compile, bail out. + // If there are no scripts to compile, bail out. if ( empty( $scripts ) ) { return; } diff --git a/tests/phpunit/integration/api/uikit/beans-uikit/compile.php b/tests/phpunit/integration/api/uikit/beans-uikit/compile.php index 170decd1..b1eb115b 100644 --- a/tests/phpunit/integration/api/uikit/beans-uikit/compile.php +++ b/tests/phpunit/integration/api/uikit/beans-uikit/compile.php @@ -169,7 +169,7 @@ public function test_should_compile_styles_with_default_theme() { } /** - * Test _Beans_Uikit::compile() should compile the styles with thje child theme. + * Test _Beans_Uikit::compile() should compile the styles with the child theme. */ public function test_should_compile_styles_with_child_theme() { $theme_path = dirname( __DIR__ ) . '/fixtures/less/'; diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/compile.php b/tests/phpunit/unit/api/uikit/beans-uikit/compile.php index 04cde046..d4d034f3 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/compile.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/compile.php @@ -25,7 +25,7 @@ class Tests_BeansUikit_Compile extends UIkit_Test_Case { /** - * Test _Beans_Uikit::compile() should not compile when there are not assets to compile. + * Test _Beans_Uikit::compile() should not compile when there are no assets to compile. */ public function test_should_not_compile_when_no_assets_to_compile() { $beans_uikit = new _Beans_Uikit(); From 79da1c4b2e8704f0e74f0b9132acf3f13ce4cb92 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 19 Jun 2018 21:44:40 -0500 Subject: [PATCH 732/800] Fixed #255 bug where all whitespace was stripped out of CSS. --- lib/api/compiler/class-beans-compiler.php | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index f13fca07..cf41a138 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -785,26 +785,28 @@ private function remove_modified_files( $hash, $filemtime_hash ) { private function strip_whitespace( $content ) { $replace = array( '#/\*.*?\*/#s' => '', // Strip comments. + '#\s\s+#' => ' ', // Strip excess whitespace. ); $search = array_keys( $replace ); $content = preg_replace( $search, $replace, $content ); - // Strip all new lines, tabs, and whitespace. - $content = str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', $content ); + // Strip all new lines and tabs. + $content = str_replace( array( "\r\n", "\r", "\n", "\t" ), '', $content ); $replace = array( - ': ' => ':', - '; ' => ';', - ' {' => '{', - ' }' => '}', - ', ' => ',', - '{ ' => '{', - ';}' => '}', // Strip optional semicolons. - ',\n' => ',', // Don't wrap multiple selectors. - '\n}' => '}', // Don't wrap closing braces. - '}' => "}\n", // Put each rule on it's own line. - '\n' => '', // Remove all line breaks. + ': ' => ':', + '; ' => ';', + ' {' => '{', + ' }' => '}', + ', ' => ',', + '{ ' => '{', + ';}' => '}', // Strip optional semicolons. + ',\n' => ',', // Don't wrap multiple selectors. + '\n}' => '}', // Don't wrap closing braces. + '}' => "}\n", // Put each rule on it's own line. + '\n' => '', // Remove all line breaks. + "}\n " => "}\n", // Remove the whitespace at start of each new line. ); $search = array_keys( $replace ); From f90cd6156d71d5047c82a32a1f75eacdc8a72137 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 19 Jun 2018 21:58:32 -0500 Subject: [PATCH 733/800] Adjusted UIkit compiler CSS tests for the fixed formatting. --- .../api/uikit/beans-uikit/compile.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/uikit/beans-uikit/compile.php b/tests/phpunit/integration/api/uikit/beans-uikit/compile.php index b1eb115b..8605da67 100644 --- a/tests/phpunit/integration/api/uikit/beans-uikit/compile.php +++ b/tests/phpunit/integration/api/uikit/beans-uikit/compile.php @@ -111,19 +111,27 @@ public function test_should_compile_styles() { $this->assertContains( $alert_css, $compiled_css ); $button_css = <<assertContains( $button_css, $compiled_css ); $overlay_css = <<:first-child{margin-bottom:0} +.uk-overlay.uk-border-circle{-webkit-mask-image:-webkit-radial-gradient(circle,white 100%,black 100%)} +.uk-overlay > :first-child{margin-bottom:0} .uk-overlay-panel{position:absolute;top:0;bottom:0;left:0;right:0;padding:20px;color:#fff} EOB; $this->assertContains( $overlay_css, $compiled_css ); From 5a76d5bdd04339162d8f859b7e8782b85851600c Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 08:16:13 -0500 Subject: [PATCH 734/800] Updated languages POT file. --- lib/languages/tm-beans.pot | 430 ++++++++++++++++++++++++++----------- style.css | 4 +- 2 files changed, 312 insertions(+), 122 deletions(-) diff --git a/lib/languages/tm-beans.pot b/lib/languages/tm-beans.pot index f63935b8..436147ee 100644 --- a/lib/languages/tm-beans.pot +++ b/lib/languages/tm-beans.pot @@ -2,16 +2,17 @@ msgid "" msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -"Project-Id-Version: Beans\n" -"POT-Creation-Date: 2015-11-28 12:29+0200\n" -"PO-Revision-Date: 2015-11-28 12:29+0200\n" +"Project-Id-Version: Beans v.1.5.0-beta\n" +"POT-Creation-Date: 2018-06-20 08:14-0500\n" +"PO-Revision-Date: 2018-06-20 08:10-0500\n" "Last-Translator: \n" -"Language-Team: \n" +"Language-Team: Beans Team\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.8.4\n" -"X-Poedit-Basepath: ../..\n" +"X-Generator: Poedit 2.0.8\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-Flags-xgettext: --add-comments=translators:\n" "X-Poedit-WPHeader: style.css\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" @@ -19,18 +20,20 @@ msgstr "" "_nx_noop:3c,1,2;__ngettext_noop:1,2\n" "X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPathExcluded-0: *.js\n" +"X-Poedit-SearchPathExcluded-1: vendor\n" +"X-Poedit-SearchPathExcluded-2: tests\n" -#: lib/admin/options.php:27 +#: lib/admin/options.php:30 msgctxt "term meta" msgid "Layout" msgstr "" -#: lib/admin/options.php:58 +#: lib/admin/options.php:60 msgctxt "post meta" msgid "Layout" msgstr "" -#: lib/admin/options.php:65 +#: lib/admin/options.php:67 msgid "Post Options" msgstr "" @@ -38,375 +41,559 @@ msgstr "" msgid "Logo Image" msgstr "" -#: lib/admin/wp-customize.php:40 +#: lib/admin/wp-customize.php:39 msgid "Branding" msgstr "" -#: lib/admin/wp-customize.php:51 lib/admin/wp-customize.php:59 +#: lib/admin/wp-customize.php:49 lib/admin/wp-customize.php:60 msgid "Default Layout" msgstr "" -#: lib/admin/wp-customize.php:66 +#: lib/admin/wp-customize.php:69 msgid "Viewport Width" msgstr "" -#: lib/admin/wp-customize.php:87 +#: lib/admin/wp-customize.php:90 msgid "Viewport Height" msgstr "" -#: lib/admin/wp-customize.php:108 +#: lib/admin/wp-customize.php:115 msgid "Preview Tools" msgstr "" -#: lib/api/admin-menu.php:25 +#: lib/api/admin-menu.php:37 msgid "Settings" msgstr "" -#: lib/api/admin-menu.php:37 +#: lib/api/admin-menu.php:50 msgid "Beans Settings" msgstr "" -#: lib/api/admin-menu.php:37 +#: lib/api/admin-menu.php:50 msgid "Version " msgstr "" -#: lib/api/admin-menu.php:56 +#: lib/api/admin-menu.php:69 msgid "Enable development mode" msgstr "" -#: lib/api/admin-menu.php:58 +#: lib/api/admin-menu.php:70 +msgid "Select to activate development mode." +msgstr "" + +#: lib/api/admin-menu.php:72 msgid "This option should be enabled while your website is in development." msgstr "" -#: lib/api/admin-menu.php:63 +#: lib/api/admin-menu.php:81 msgid "Mode options" msgstr "" -#: lib/api/compiler/class-options.php:35 +#: lib/api/compiler/class-beans-compiler-options.php:56 +msgid "Compiler options" +msgstr "" + +#: lib/api/compiler/class-beans-compiler-options.php:165 +msgid "Styles are not compiled in development mode." +msgstr "" + +#: lib/api/compiler/class-beans-compiler-options.php:187 +msgid "Scripts are not compiled in development mode." +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:848 +msgid "Not cool, Beans cannot work its magic :(" +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:853 +msgid "" +"Your current install or file permission prevents Beans from working its " +"magic. Please get in touch with Beans support. We will gladly get you " +"started within 24 - 48 hours (working days)." +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:858 +msgid "Contact Beans Support" +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:863 +msgid "Send us an automatic report" +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:864 +msgid "" +"We respect your time and understand you might not be able to contact us." +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:898 +msgid "" +"Thanks for your contribution by reporting this issue. We hope to hear from " +"you again." +msgstr "" + +#: lib/api/compiler/config/fields.php:14 msgid "" "Clear CSS and Javascript cached files. New cached versions will be compiled " "on page load." msgstr "" -#: lib/api/compiler/class-options.php:45 +#: lib/api/compiler/config/fields.php:18 msgid "Compile all WordPress styles" msgstr "" -#: lib/api/compiler/class-options.php:48 +#: lib/api/compiler/config/fields.php:19 +msgid "Select to compile styles." +msgstr "" + +#: lib/api/compiler/config/fields.php:22 msgid "" "Compile and cache all the CSS files that have been enqueued to the WordPress " "head." msgstr "" -#: lib/api/compiler/class-options.php:58 +#: lib/api/compiler/config/fields.php:26 msgid "Compile all WordPress scripts" msgstr "" -#: lib/api/compiler/class-options.php:61 -msgid "" -"Compile and cache all the Javascript files that have been enqueued to the " -"WordPress head." +#: lib/api/compiler/config/fields.php:32 +msgid "Select to compile scripts." msgstr "" -#: lib/api/compiler/class-options.php:66 -msgid "Compiler options" +#: lib/api/compiler/config/fields.php:38 +msgid "Choose the level of compilation." msgstr "" -#: lib/api/compiler/class-options.php:94 -msgid "Cache flushed successfully!" +#: lib/api/compiler/config/fields.php:41 +msgid "Aggressive" msgstr "" -#: lib/api/compiler/class-options.php:107 -msgid "Flush assets cache" +#: lib/api/compiler/config/fields.php:42 +msgid "Standard" msgstr "" -#: lib/api/compiler/class-options.php:118 -msgid "Styles are not compiled in development mode." +#: lib/api/compiler/config/fields.php:46 +msgid "" +"Compile and cache all the JavaScript files that have been enqueued to the " +"WordPress head.
                JavaScript is outputted in the footer if the level is " +"set to Aggressive and might conflict with some third-party " +"plugins which are not following WordPress standards." msgstr "" -#: lib/api/compiler/class-options.php:128 -msgid "Scripts are not compiled in development mode." +#: lib/api/compiler/views/flush-button.php:12 +msgid "Flush assets cache" msgstr "" -#: lib/api/fields/types/field.php:61 -msgid "More..." +#: lib/api/compiler/views/flushed-notice.php:13 +msgid "Cache flushed successfully!" +msgstr "" + +#: lib/api/fields/types/checkbox.php:27 +msgid "Enable" msgstr "" -#: lib/api/fields/types/image.php:52 +#: lib/api/fields/types/image.php:43 msgid "Add Image" msgid_plural "Add Images" msgstr[0] "" msgstr[1] "" -#: lib/api/image/class-options.php:36 -msgid "Clear all edited images. New images will be created on page load." +#: lib/api/fields/types/image.php:127 +msgid "Sorry, no description was given for this image." +msgstr "" + +#: lib/api/fields/types/views/field-description.php:13 +msgid "More..." +msgstr "" + +#: lib/api/fields/types/views/image.php:48 +msgid "Manage Images" +msgstr "" + +#: lib/api/fields/types/views/image.php:50 +msgid "Edit Image" +msgstr "" + +#: lib/api/fields/types/views/image.php:51 +msgid "Delete Image" +msgstr "" + +#: lib/api/html/accessibility.php:22 +msgid "Skip to the primary navigation." +msgstr "" + +#: lib/api/html/accessibility.php:25 +msgid "Skip to the content." +msgstr "" + +#: lib/api/html/accessibility.php:30 +msgid "Skip to the primary sidebar." +msgstr "" + +#: lib/api/html/accessibility.php:34 +msgid "Skip to the secondary sidebar." msgstr "" -#: lib/api/image/class-options.php:41 +#: lib/api/image/class-beans-image-options.php:48 msgid "Images options" msgstr "" -#: lib/api/image/class-options.php:69 -msgid "Images flushed successfully!" +#: lib/api/image/config/fields.php:14 +msgid "Clear all edited images. New images will be created on page load." msgstr "" -#: lib/api/image/class-options.php:82 +#: lib/api/image/views/flush-button.php:12 msgid "Flush images" msgstr "" -#: lib/api/layout/functions.php:276 +#: lib/api/image/views/flushed-notice.php:13 +msgid "Images flushed successfully!" +msgstr "" + +#: lib/api/layout/functions.php:229 +msgid "Full-Width Content Layout" +msgstr "" + +#: lib/api/layout/functions.php:230 +msgid "Option for the Full-Width Content Layout." +msgstr "" + +#: lib/api/layout/functions.php:239 +msgid "Content and Primary Sidebar Layout" +msgstr "" + +#: lib/api/layout/functions.php:240 +msgid "Option for the Content and Primary Sidebar Layout." +msgstr "" + +#: lib/api/layout/functions.php:243 +msgid "Primary Sidebar and Content Layout" +msgstr "" + +#: lib/api/layout/functions.php:244 +msgid "Option for the Primary Sidebar and Content Layout." +msgstr "" + +#: lib/api/layout/functions.php:250 +msgid "Content, Primary Sidebar and Secondary Sidebar Layout" +msgstr "" + +#: lib/api/layout/functions.php:251 +msgid "Option for the Content, Primary Sidebar and Secondary Sidebar Layout." +msgstr "" + +#: lib/api/layout/functions.php:254 +msgid "Primary Sidebar, Secondary Sidebar and Content Layout" +msgstr "" + +#: lib/api/layout/functions.php:255 +msgid "Option for the Primary Sidebar, Secondary Sidebar and Content Layout." +msgstr "" + +#: lib/api/layout/functions.php:258 +msgid "Primary Sidebar, Content and Secondary Sidebar Layout" +msgstr "" + +#: lib/api/layout/functions.php:259 +msgid "Option for the Primary Sidebar, Content and Secondary Sidebar Layout." +msgstr "" + +#. translators: The (%s) placeholder is for the "Modify" hyperlink. +#: lib/api/layout/functions.php:282 #, php-format msgid "Use Default Layout (%s)" msgstr "" -#: lib/api/layout/functions.php:277 +#: lib/api/layout/functions.php:283 msgctxt "Default layout" msgid "Modify" msgstr "" -#: lib/api/options/class.php:39 lib/api/post-meta/class.php:32 -#: lib/api/wp-customize/class.php:25 +#: lib/api/options/class-beans-options.php:54 +#: lib/api/post-meta/class-beans-post-meta.php:43 +#: lib/api/wp-customize/class-beans-wp-customize.php:43 msgid "Undefined" msgstr "" -#: lib/api/options/class.php:196 -msgid "Settings saved successfully!" +#: lib/api/options/views/page.php:28 +msgid "Save" msgstr "" -#: lib/api/options/class.php:198 -msgid "Settings could not be saved, please try again." +#: lib/api/options/views/page.php:29 +msgid "Reset" msgstr "" -#: lib/api/options/class.php:210 +#: lib/api/options/views/reset-notice-error.php:15 +msgid "Settings could not be reset, please try again." +msgstr "" + +#: lib/api/options/views/reset-notice-success.php:15 msgid "Settings reset successfully!" msgstr "" -#: lib/api/options/class.php:212 -msgid "Settings could not be reset, please try again." +#: lib/api/options/views/save-notice-error.php:15 +msgid "Settings could not be saved, please try again." +msgstr "" + +#: lib/api/options/views/save-notice-success.php:15 +msgid "Settings saved successfully!" msgstr "" -#: lib/api/widget/functions.php:57 +#: lib/api/widget/functions.php:62 msgid "Hello" msgstr "" -#: lib/render/menu.php:23 +#: lib/render/menu.php:25 msgid "Navigation" msgstr "" -#: lib/render/menu.php:26 lib/templates/fragments/breadcrumb.php:25 +#: lib/render/menu.php:33 lib/templates/fragments/breadcrumb.php:30 msgid "Home" msgstr "" -#: lib/render/menu.php:46 +#: lib/render/menu.php:52 msgid "Primary Menu" msgstr "" -#: lib/render/widget-area.php:19 +#: lib/render/widget-area.php:21 msgid "Sidebar Primary" msgstr "" -#: lib/render/widget-area.php:24 +#: lib/render/widget-area.php:26 msgid "Sidebar Secondary" msgstr "" -#: lib/render/widget-area.php:30 +#: lib/render/widget-area.php:32 msgid "Off-Canvas Menu" msgstr "" -#: lib/templates/fragments/breadcrumb.php:83 +#: lib/templates/fragments/breadcrumb.php:80 msgid "Results:" msgstr "" -#: lib/templates/fragments/breadcrumb.php:92 +#: lib/templates/fragments/breadcrumb.php:83 msgid "Author Archives:" msgstr "" -#: lib/templates/fragments/breadcrumb.php:99 +#: lib/templates/fragments/breadcrumb.php:85 msgid "Tag Archives:" msgstr "" -#: lib/templates/fragments/breadcrumb.php:106 +#: lib/templates/fragments/breadcrumb.php:87 msgid "Archives:" msgstr "" -#: lib/templates/fragments/breadcrumb.php:113 +#: lib/templates/fragments/breadcrumb.php:89 msgid "404" msgstr "" -#: lib/templates/fragments/comments.php:20 +#. translators: Number of comments, one or many. +#: lib/templates/fragments/comments.php:25 #, php-format msgid "%s Comment" msgid_plural "%s Comments" msgstr[0] "" msgstr[1] "" -#: lib/templates/fragments/comments.php:92 +#: lib/templates/fragments/comments.php:98 msgid "Trackback" msgstr "" -#: lib/templates/fragments/comments.php:103 +#: lib/templates/fragments/comments.php:107 msgid "Pingback" msgstr "" -#: lib/templates/fragments/comments.php:115 +#: lib/templates/fragments/comments.php:116 msgid "Awaiting Moderation" msgstr "" -#: lib/templates/fragments/comments.php:127 +#: lib/templates/fragments/comments.php:125 msgid "Moderator" msgstr "" +#. translators: Date of the comment, time of the comment. #: lib/templates/fragments/comments.php:154 #, php-format msgctxt "1: date, 2: time" msgid "%1$s at %2$s" msgstr "" -#: lib/templates/fragments/comments.php:211 +#: lib/templates/fragments/comments.php:215 msgid "Edit" msgstr "" -#: lib/templates/fragments/comments.php:226 +#: lib/templates/fragments/comments.php:233 msgid "Link" msgstr "" -#: lib/templates/fragments/comments.php:248 +#: lib/templates/fragments/comments.php:253 msgid "No comment yet, add your voice below!" msgstr "" -#: lib/templates/fragments/comments.php:266 +#: lib/templates/fragments/comments.php:269 msgid "Comments are closed for this article!" msgstr "" -#: lib/templates/fragments/comments.php:301 -#: lib/templates/fragments/post.php:435 lib/templates/fragments/post.php:504 -msgid "Previous" +#: lib/templates/fragments/comments.php:295 +msgid "Comments Pagination Navigation" +msgstr "" + +#: lib/templates/fragments/comments.php:322 +msgid "Previous Comments" msgstr "" -#: lib/templates/fragments/comments.php:319 -#: lib/templates/fragments/post.php:446 lib/templates/fragments/post.php:590 -msgid "Next" +#: lib/templates/fragments/comments.php:343 +msgid "Next Comments " msgstr "" -#: lib/templates/fragments/comments.php:361 +#: lib/templates/fragments/comments.php:377 msgid "Add a Comment" msgstr "" -#: lib/templates/fragments/comments.php:368 +#: lib/templates/fragments/comments.php:390 msgid "Post Comment" msgstr "" -#: lib/templates/fragments/comments.php:435 -msgid "Name" +#: lib/templates/fragments/comments.php:458 +msgid "Comment *" +msgstr "" + +#: lib/templates/fragments/comments.php:533 +msgid "Name *" msgstr "" -#: lib/templates/fragments/comments.php:463 +#. translators: Whether or not submitting an email address is required. +#: lib/templates/fragments/comments.php:568 #, php-format msgid "Email %s" msgstr "" -#: lib/templates/fragments/comments.php:492 +#: lib/templates/fragments/comments.php:602 msgid "Website" msgstr "" -#: lib/templates/fragments/comments.php:542 -msgid "Comment *" -msgstr "" - -#: lib/templates/fragments/deprecated.php:57 +#. translators: Page number. +#: lib/templates/fragments/deprecated.php:59 #, php-format msgid "Page %s" msgstr "" -#: lib/templates/fragments/footer.php:24 +#. translators: Footer credits. Date followed by the name of the website. +#: lib/templates/fragments/footer.php:27 #, php-format msgid "© %1$s - %2$s. All rights reserved." msgstr "" -#: lib/templates/fragments/footer.php:45 +#. translators: Link to the Beans website. +#: lib/templates/fragments/footer.php:54 #, php-format msgid "%1$s theme for WordPress." msgstr "" -#: lib/templates/fragments/menu.php:67 +#: lib/templates/fragments/menu.php:31 +msgid "Primary Navigation Menu" +msgstr "" + +#: lib/templates/fragments/menu.php:96 msgid "Menu" msgstr "" -#: lib/templates/fragments/menu.php:115 +#: lib/templates/fragments/menu.php:121 +msgid "Off-Canvas Primary Navigation Menu" +msgstr "" + +#: lib/templates/fragments/menu.php:158 msgid "Whoops, your site does not have a menu!" msgstr "" -#: lib/templates/fragments/post-shortcodes.php:17 +#: lib/templates/fragments/post-shortcodes.php:19 msgid "Posted on " msgstr "" -#: lib/templates/fragments/post-shortcodes.php:40 +#: lib/templates/fragments/post-shortcodes.php:44 msgid "By " msgstr "" -#: lib/templates/fragments/post-shortcodes.php:73 +#: lib/templates/fragments/post-shortcodes.php:90 msgid "Leave a comment" msgstr "" -#: lib/templates/fragments/post-shortcodes.php:75 +#: lib/templates/fragments/post-shortcodes.php:92 msgid "1 comment" msgstr "" -#: lib/templates/fragments/post-shortcodes.php:77 +#. translators: Number of comments. Plural. +#: lib/templates/fragments/post-shortcodes.php:97 #, php-format msgid "%s comments" msgstr "" -#: lib/templates/fragments/post-shortcodes.php:104 +#: lib/templates/fragments/post-shortcodes.php:124 msgid "Tagged with: " msgstr "" -#: lib/templates/fragments/post-shortcodes.php:124 +#: lib/templates/fragments/post-shortcodes.php:142 msgid "Filed under: " msgstr "" -#: lib/templates/fragments/post.php:67 +#: lib/templates/fragments/post.php:74 msgid "Search results for: " msgstr "" -#: lib/templates/fragments/post.php:254 +#: lib/templates/fragments/post.php:339 msgid "Continue reading" msgstr "" -#: lib/templates/fragments/post.php:278 +#: lib/templates/fragments/post.php:367 msgid "Pages:" msgstr "" -#: lib/templates/fragments/post.php:624 +#: lib/templates/fragments/post.php:543 +msgid "Pagination Navigation" +msgstr "" + +#: lib/templates/fragments/post.php:561 lib/templates/fragments/post.php:655 +msgid "Previous Page" +msgstr "" + +#: lib/templates/fragments/post.php:573 lib/templates/fragments/post.php:744 +msgid "Next Page" +msgstr "" + +#: lib/templates/fragments/post.php:619 +msgid "Posts Pagination Navigation" +msgstr "" + +#: lib/templates/fragments/post.php:782 msgid "Whoops, no result found!" msgstr "" -#: lib/templates/fragments/post.php:636 +#: lib/templates/fragments/post.php:794 msgid "It looks like nothing was found at this location. Maybe try a search?" msgstr "" -#: lib/templates/fragments/post.php:670 +#: lib/templates/fragments/post.php:824 msgid "This post is protected. To view it, enter the password below!" msgstr "" -#: lib/templates/fragments/post.php:684 +#: lib/templates/fragments/post.php:845 msgid "Password" msgstr "" -#: lib/templates/fragments/post.php:692 +#: lib/templates/fragments/post.php:857 msgid "Submit" msgstr "" -#: lib/templates/fragments/searchform.php:30 +#: lib/templates/fragments/searchform.php:37 msgid "Search" msgstr "" -#: lib/templates/fragments/widget.php:83 +#. translators: Name of the widget area. +#: lib/templates/fragments/widget.php:89 #, php-format msgid "%s does not have any widget assigned!" msgstr "" -#: lib/templates/fragments/widget.php:103 +#: lib/templates/fragments/widget.php:107 msgid "Read feed" msgstr "" @@ -416,11 +603,14 @@ msgid "Beans" msgstr "" #. Theme URI of the plugin/theme -#. Author URI of the plugin/theme -msgid "http://www.getbeans.io" +msgid "https://www.getbeans.io/themes/beans/" msgstr "" #. Description of the plugin/theme msgid "" "The most innovative theme for WordPress. The real magic is under the hood." msgstr "" + +#. Author URI of the plugin/theme +msgid "https://www.getbeans.io" +msgstr "" diff --git a/style.css b/style.css index f1a5a63f..051bb0fc 100644 --- a/style.css +++ b/style.css @@ -1,8 +1,8 @@ /* Theme Name: Beans -Theme URI: http://www.getbeans.io/themes/beans/ +Theme URI: https://www.getbeans.io/themes/beans/ Author: Beans -Author URI: http://www.getbeans.io +Author URI: https://www.getbeans.io Description: The most innovative theme for WordPress. The real magic is under the hood. Version: 1.5.0-beta Text Domain: tm-beans From cf9b219863d71f378ed405012c79ee45bf12e060 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 16:07:23 -0500 Subject: [PATCH 735/800] Changed customizer transport to postMessage. It is a smoother experience than refresh. --- lib/api/wp-customize/class-beans-wp-customize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/wp-customize/class-beans-wp-customize.php b/lib/api/wp-customize/class-beans-wp-customize.php index 2fa9a15d..62de34e6 100644 --- a/lib/api/wp-customize/class-beans-wp-customize.php +++ b/lib/api/wp-customize/class-beans-wp-customize.php @@ -143,7 +143,7 @@ private function add_setting( WP_Customize_Manager $wp_customize, array $field ) $defaults = array( 'db_type' => 'theme_mod', 'capability' => 'edit_theme_options', - 'transport' => 'refresh', + 'transport' => 'postMessage', ); $field = array_merge( $defaults, $field ); From 1918635981cbd30c6bc5d418fa3cf2f330d08104 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:24:49 +0200 Subject: [PATCH 736/800] Updated array syntax of test for actions/fixtures/test-actions.php --- .../api/actions/fixtures/test-actions.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/integration/api/actions/fixtures/test-actions.php b/tests/phpunit/integration/api/actions/fixtures/test-actions.php index b73c61a2..291530a8 100644 --- a/tests/phpunit/integration/api/actions/fixtures/test-actions.php +++ b/tests/phpunit/integration/api/actions/fixtures/test-actions.php @@ -7,23 +7,23 @@ * @since 1.5.0 */ -return array( - 'beans_post_meta' => array( +return [ + 'beans_post_meta' => [ 'hook' => 'beans_post_header', 'callback' => 'beans_post_meta', 'priority' => 15, 'args' => 1, - ), - 'beans_post_image' => array( + ], + 'beans_post_image' => [ 'hook' => 'beans_post_body', 'callback' => 'beans_post_image', 'priority' => 5, 'args' => 1, - ), - 'beans_previous_post_link' => array( + ], + 'beans_previous_post_link' => [ 'hook' => 'previous_post_link', 'callback' => 'beans_previous_post_link', 'priority' => 10, 'args' => 4, - ), -); + ], +]; From cbe86647ae2072837c689aac0d3b76328463f24c Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:27:30 +0200 Subject: [PATCH 737/800] Updated array syntax of test for actions/includes/class-actions-test-case.php --- .../includes/class-actions-test-case.php | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index c4cd5bbb..78a815c1 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -56,12 +56,12 @@ public static function tearDownAfterClass() { parent::tearDownAfterClass(); global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); + $_beans_registered_actions = [ + 'added' => [], + 'modified' => [], + 'removed' => [], + 'replaced' => [], + ]; // Remove the test actions. foreach ( static::$test_actions as $beans_id => $action ) { @@ -82,12 +82,12 @@ public function tearDown() { } global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); + $_beans_registered_actions = [ + 'added' => [], + 'modified' => [], + 'removed' => [], + 'replaced' => [], + ]; parent::tearDown(); } @@ -174,12 +174,12 @@ protected function check_parameters_registered_in_wp( array $action, $remove_act * @return array */ protected function setup_original_action( $id = 'foo' ) { - $action = array( + $action = [ 'hook' => "{$id}_hook", 'callback' => "callback_{$id}", 'priority' => 10, 'args' => 1, - ); + ]; $this->check_not_added( $id, $action['hook'] ); @@ -208,7 +208,7 @@ protected function go_to_post() { $this->restore_original( $beans_id ); } - $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); + $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); $this->go_to( get_permalink( $post_id ) ); do_action( 'template_redirect' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Valid use case as we need to fire this action as part of our tests. } From 58757014a32d9576a56396ead13e6dfec7b1550f Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:28:18 +0200 Subject: [PATCH 738/800] Updated array syntax of test for actions/includes/class-replace-action-test-case.php --- .../api/actions/includes/class-replace-action-test-case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php index 8f50d55a..0b4658db 100644 --- a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php @@ -80,12 +80,12 @@ private function remove_original_action() { */ protected function merge_action_with_defaults( array $action ) { return array_merge( - array( + [ 'hook' => null, 'callback' => null, 'priority' => null, 'args' => null, - ), + ], $action ); } From e2dd46e8871178db9b974bc99bfa58c58000a1f6 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:29:30 +0200 Subject: [PATCH 739/800] Updated array syntax of test for actions/beansAddAction --- .../integration/api/actions/beansAddAction.php | 12 ++++++------ tests/phpunit/unit/api/actions/beansAddAction.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansAddAction.php b/tests/phpunit/integration/api/actions/beansAddAction.php index ab5ad1f1..86ffda41 100644 --- a/tests/phpunit/integration/api/actions/beansAddAction.php +++ b/tests/phpunit/integration/api/actions/beansAddAction.php @@ -66,10 +66,10 @@ public function test_should_overwrite_add_action_in_beans_and_wordpress() { * Test beans_add_action() should use the action configuration in "replaced" status, when it's available. */ public function test_should_use_replaced_action_when_available() { - $replaced_action = array( + $replaced_action = [ 'callback' => 'my_new_callback', 'priority' => 47, - ); + ]; foreach ( static::$test_actions as $beans_id => $original_action ) { // We want to store the "replaced" action first, before we add the original action. @@ -96,12 +96,12 @@ public function test_should_use_replaced_action_when_available() { * Test beans_add_action() should return false when the ID is registered to the "removed" status. */ public function test_should_return_false_when_removed() { - $empty_action = array( + $empty_action = [ 'hook' => null, 'callback' => null, 'priority' => null, 'args' => null, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { // Store the "removed" action before we call beans_add_action(). @@ -122,10 +122,10 @@ public function test_should_return_false_when_removed() { * Test beans_add_action() should merge the "modified" action configuration parameters. */ public function test_should_merge_modified_action_parameters() { - $modified_action = array( + $modified_action = [ 'callback' => 'foo', 'priority' => 17, - ); + ]; foreach ( static::$test_actions as $beans_id => $original_action ) { // We want to store the "modified" action first, before we add the original action. diff --git a/tests/phpunit/unit/api/actions/beansAddAction.php b/tests/phpunit/unit/api/actions/beansAddAction.php index 3a0be3ad..95de13bc 100644 --- a/tests/phpunit/unit/api/actions/beansAddAction.php +++ b/tests/phpunit/unit/api/actions/beansAddAction.php @@ -109,10 +109,10 @@ public function test_should_overwrite_add_action_in_beans_and_wordpress() { */ public function test_should_use_replaced_action_when_available() { global $_beans_registered_actions; - $replaced_action = array( + $replaced_action = [ 'callback' => 'my_new_callback', 'priority' => 47, - ); + ]; foreach ( static::$test_actions as $beans_id => $original_action ) { // Set up the mocks. @@ -164,12 +164,12 @@ public function test_should_use_replaced_action_when_available() { */ public function test_should_return_false_when_removed() { global $_beans_registered_actions; - $empty_action = array( + $empty_action = [ 'hook' => null, 'callback' => null, 'priority' => null, 'args' => null, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { // Set up the mocks. @@ -214,10 +214,10 @@ public function test_should_return_false_when_removed() { */ public function test_should_merge_modified_action_parameters() { global $_beans_registered_actions; - $modified_action = array( + $modified_action = [ 'callback' => 'foo', 'priority' => 17, - ); + ]; foreach ( static::$test_actions as $beans_id => $original_action ) { // Set up the mocks. From 81dcbffe291a570b9122c210643a68e90673a6e0 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:36:38 +0200 Subject: [PATCH 740/800] Updated array syntax of test for actions/beansAddAnonymousAction --- .../integration/api/actions/beansAddAnonymousAction.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php index 0f03cf8a..1012a2f9 100644 --- a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php +++ b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php @@ -25,7 +25,7 @@ class Tests_BeansAddAnonymousAction extends WP_UnitTestCase { * Test _beans_add_anonymous_action() should register callback to the given hook. */ public function test_should_register_callback_to_hook() { - _beans_add_anonymous_action( 'do_foo', array( 'foo_test_callback', array( 'foo' ) ) ); + _beans_add_anonymous_action( 'do_foo', [ 'foo_test_callback', [ 'foo' ] ] ); $this->assertTrue( has_action( 'do_foo' ) ); } @@ -34,7 +34,7 @@ public function test_should_register_callback_to_hook() { * Test _beans_add_anonymous_action() should call callback on the given hook. */ public function test_should_call_callback() { - _beans_add_anonymous_action( 'beans_test_do_foo', array( 'foo_test_callback', array( 'foo' ) ) ); + _beans_add_anonymous_action( 'beans_test_do_foo', [ 'foo_test_callback', [ 'foo' ] ] ); Functions\when( 'foo_test_callback' ) ->justReturn( 'foo' ); From 3677a7249b2ac04622cccb594e69a22124be00df Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:38:41 +0200 Subject: [PATCH 741/800] Updated array syntax of test for actions/beansGetCurrentAction --- .../phpunit/integration/api/actions/beansGetCurrentAction.php | 4 ++-- tests/phpunit/unit/api/actions/beansGetCurrentAction.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansGetCurrentAction.php b/tests/phpunit/integration/api/actions/beansGetCurrentAction.php index 04785660..eec30ff8 100644 --- a/tests/phpunit/integration/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/integration/api/actions/beansGetCurrentAction.php @@ -75,11 +75,11 @@ public function test_should_return_false_when_modified_but_no_added_action() { public function test_should_return_merged_added_and_modified_action() { global $_beans_registered_actions; - $modified_action = array( + $modified_action = [ 'callback' => 'callback', 'priority' => 27, 'args' => 14, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { // Store the action in the registry. diff --git a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php index 9b044a28..f9c25c1d 100644 --- a/tests/phpunit/unit/api/actions/beansGetCurrentAction.php +++ b/tests/phpunit/unit/api/actions/beansGetCurrentAction.php @@ -96,11 +96,11 @@ public function test_should_return_false_when_modified_but_no_added_action() { * Test _beans_get_current_action() should return the merged "added" and "modified" action. */ public function test_should_return_merged_added_and_modified_action() { - $modified_action = array( + $modified_action = [ 'callback' => 'callback', 'priority' => 27, 'args' => 14, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { Monkey\Functions\expect( '_beans_get_action' ) From 06b036091d030c0744511b3a5716c3cd75720737 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:40:21 +0200 Subject: [PATCH 742/800] Updated array syntax of test for actions/beansMergeAction --- tests/phpunit/integration/api/actions/beansMergeAction.php | 6 +++--- tests/phpunit/unit/api/actions/beansMergeAction.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansMergeAction.php b/tests/phpunit/integration/api/actions/beansMergeAction.php index 8a8520b9..bb4330a9 100644 --- a/tests/phpunit/integration/api/actions/beansMergeAction.php +++ b/tests/phpunit/integration/api/actions/beansMergeAction.php @@ -27,7 +27,7 @@ class Tests_BeansMergeAction extends Actions_Test_Case { * * @var array */ - protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); + protected $statuses = [ 'added', 'modified', 'removed', 'replaced' ]; /** * Test _beans_set_action() should merge the new action's configuration with the registered one and then return it. @@ -35,9 +35,9 @@ class Tests_BeansMergeAction extends Actions_Test_Case { public function test_should_merge_and_return() { global $_beans_registered_actions; - $modified_action = array( + $modified_action = [ 'priority' => 29, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { $merged_action = array_merge( $action, $modified_action ); diff --git a/tests/phpunit/unit/api/actions/beansMergeAction.php b/tests/phpunit/unit/api/actions/beansMergeAction.php index 7944a1ef..4de4df29 100644 --- a/tests/phpunit/unit/api/actions/beansMergeAction.php +++ b/tests/phpunit/unit/api/actions/beansMergeAction.php @@ -28,15 +28,15 @@ class Tests_BeansMergeAction extends Actions_Test_Case { * * @var array */ - protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); + protected $statuses = [ 'added', 'modified', 'removed', 'replaced' ]; /** * Test _beans_set_action() should merge the new action's configuration with the registered one and then return it. */ public function test_should_merge_and_return() { - $modified_action = array( + $modified_action = [ 'priority' => 29, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { $merged_action = array_merge( $action, $modified_action ); From f0e96a157966bca0fdd35cdb726c3757faba941c Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:42:51 +0200 Subject: [PATCH 743/800] Updated array syntax of test for actions/beansModifyAction --- .../api/actions/beansModifyAction.php | 24 +++++++++---------- .../unit/api/actions/beansModifyAction.php | 16 ++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansModifyAction.php b/tests/phpunit/integration/api/actions/beansModifyAction.php index 4b141c80..18d844e8 100644 --- a/tests/phpunit/integration/api/actions/beansModifyAction.php +++ b/tests/phpunit/integration/api/actions/beansModifyAction.php @@ -68,9 +68,9 @@ public function test_should_register_as_modified_but_not_add_action() { * Test beans_modify_action() should modify the registered action's hook. */ public function test_should_modify_the_action_hook() { - $modified_action = array( + $modified_action = [ 'hook' => 'foo', - ); + ]; $this->go_to_post(); @@ -97,9 +97,9 @@ public function test_should_modify_the_action_hook() { * Test beans_modify_action() should modify the registered action's callback. */ public function test_should_modify_the_action_callback() { - $modified_action = array( + $modified_action = [ 'callback' => 'my_callback', - ); + ]; $this->go_to_post(); @@ -128,19 +128,19 @@ public function test_should_modify_the_action_callback() { public function test_should_modify_the_action_priority() { global $wp_filter; - $modified_action = array( + $modified_action = [ 'priority' => 20, - ); + ]; $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { // Check the starting state. $this->assertEquals( - array( + [ 'function' => $original_action['callback'], 'accepted_args' => $original_action['args'], - ), + ], $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] ); @@ -160,10 +160,10 @@ public function test_should_modify_the_action_priority() { // Check that the action's priority was modified in WordPress. $this->assertEquals( - array( + [ 'function' => $original_action['callback'], 'accepted_args' => $original_action['args'], - ), + ], $callbacks_in_wp[ $modified_action['priority'] ][ $original_action['callback'] ] ); } @@ -175,9 +175,9 @@ public function test_should_modify_the_action_priority() { public function test_should_modify_the_action_args() { global $wp_filter; - $modified_action = array( + $modified_action = [ 'args' => 7, - ); + ]; $this->go_to_post(); diff --git a/tests/phpunit/unit/api/actions/beansModifyAction.php b/tests/phpunit/unit/api/actions/beansModifyAction.php index e12a7c78..e05943a3 100644 --- a/tests/phpunit/unit/api/actions/beansModifyAction.php +++ b/tests/phpunit/unit/api/actions/beansModifyAction.php @@ -97,8 +97,8 @@ public function test_should_modify_the_action_hook() { // When called, return the modified action. Monkey\Functions\expect( '_beans_merge_action' ) ->once() - ->with( $beans_id, array( 'hook' => $modified_hook ), 'modified' ) - ->andReturn( array( 'hook' => $modified_hook ) ); + ->with( $beans_id, [ 'hook' => $modified_hook ], 'modified' ) + ->andReturn( [ 'hook' => $modified_hook ] ); // Expect the modified hook is added, but not the original hook. Monkey\Actions\expectAdded( $original_action['hook'] )->never(); @@ -131,8 +131,8 @@ public function test_should_modify_the_action_callback() { // When called, return the modified action. Monkey\Functions\expect( '_beans_merge_action' ) ->once() - ->with( $beans_id, array( 'callback' => $modified_callback ), 'modified' ) - ->andReturn( array( 'callback' => $modified_callback ) ); + ->with( $beans_id, [ 'callback' => $modified_callback ], 'modified' ) + ->andReturn( [ 'callback' => $modified_callback ] ); // Expect the original hook with the modified callback. Monkey\Actions\expectAdded( $original_action['hook'] ) @@ -164,8 +164,8 @@ public function test_should_modify_the_action_priority() { // When called, return the modified action. Monkey\Functions\expect( '_beans_merge_action' ) ->once() - ->with( $beans_id, array( 'priority' => $modified_priority ), 'modified' ) - ->andReturn( array( 'priority' => $modified_priority ) ); + ->with( $beans_id, [ 'priority' => $modified_priority ], 'modified' ) + ->andReturn( [ 'priority' => $modified_priority ] ); // Expect the original hook with the modified callback. Monkey\Actions\expectAdded( $original_action['hook'] ) @@ -198,8 +198,8 @@ public function test_should_modify_the_action_args() { // When called, return the modified action. Monkey\Functions\expect( '_beans_merge_action' ) ->once() - ->with( $beans_id, array( 'args' => $modified_args ), 'modified' ) - ->andReturn( array( 'args' => $modified_args ) ); + ->with( $beans_id, [ 'args' => $modified_args ], 'modified' ) + ->andReturn( [ 'args' => $modified_args ] ); // Expect the original hook with the modified callback. Monkey\Actions\expectAdded( $original_action['hook'] ) From e4c6ad275d5786f721b6baa9cbbcc73841233559 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:44:43 +0200 Subject: [PATCH 744/800] Updated array syntax of test for actions/beansModifyActionArguments --- .../api/actions/beansModifyActionArguments.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansModifyActionArguments.php b/tests/phpunit/integration/api/actions/beansModifyActionArguments.php index fec8c9de..0676f24c 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionArguments.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionArguments.php @@ -28,12 +28,12 @@ class Tests_BeansModifyActionArguments extends Actions_Test_Case { public function test_should_return_false_when_args_is_non_integer() { global $wp_filter; - $arguments = array( + $arguments = [ null, - array( 10 ), + [ 10 ], false, '', - ); + ]; $this->go_to_post(); @@ -66,7 +66,7 @@ public function test_should_return_false_when_args_is_non_integer() { public function test_should_modify_action_when_args_is_zero() { global $wp_filter; - $arguments = array( 0, 0.0, '0', '0.0' ); + $arguments = [ 0, 0.0, '0', '0.0' ]; $this->go_to_post(); @@ -82,7 +82,7 @@ public function test_should_modify_action_when_args_is_zero() { $this->assertTrue( beans_modify_action_arguments( $beans_id, $number_of_args ) ); // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( array( 'args' => (int) $number_of_args ), _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( [ 'args' => (int) $number_of_args ], _beans_get_action( $beans_id, 'modified' ) ); // Check that the action's number of arguments was modified in WordPress. $this->assertEquals( @@ -107,7 +107,7 @@ public function test_should_register_as_modified_but_not_add_action() { $this->assertFalse( beans_modify_action_arguments( $beans_id, $action['args'] ) ); // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( array( 'args' => $action['args'] ), _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( [ 'args' => $action['args'] ], _beans_get_action( $beans_id, 'modified' ) ); // Check that the action was not added in WordPress. $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); @@ -120,9 +120,9 @@ public function test_should_register_as_modified_but_not_add_action() { public function test_should_modify_the_action_args() { global $wp_filter; - $modified_action = array( + $modified_action = [ 'args' => 7, - ); + ]; $this->go_to_post(); From ac5b8e398ccc6d6fd0ba2e6593ab132ebb4cd3b5 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:45:54 +0200 Subject: [PATCH 745/800] Updated array syntax of test for actions/beansModifyActionCallback --- .../api/actions/beansModifyActionCallback.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansModifyActionCallback.php b/tests/phpunit/integration/api/actions/beansModifyActionCallback.php index 90ab2678..137cdf40 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionCallback.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionCallback.php @@ -26,11 +26,11 @@ class Tests_BeansModifyActionCallback extends Actions_Test_Case { * Test beans_modify_action_callback() should not modify when the callback is invalid. */ public function test_should_not_modify_when_invalid_callback() { - $callbacks = array( + $callbacks = [ null, false, '', - ); + ]; $this->go_to_post(); @@ -65,7 +65,7 @@ public function test_should_register_as_modified_but_not_add_action() { $this->assertFalse( beans_modify_action_callback( $beans_id, $action['callback'] ) ); // Check that it did register as "modified" in Beans. - $this->assertEquals( array( 'callback' => $action['callback'] ), _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( [ 'callback' => $action['callback'] ], _beans_get_action( $beans_id, 'modified' ) ); // Check that the action was not added in WordPress. $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); @@ -76,9 +76,9 @@ public function test_should_register_as_modified_but_not_add_action() { * Test beans_modify_action_callback() should modify the registered action's callback. */ public function test_should_modify_the_action_callback() { - $modified_action = array( + $modified_action = [ 'callback' => 'my_callback', - ); + ]; $this->go_to_post(); From a14559d5f8edfbce7dd605ac8a156fe385018e9d Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:47:12 +0200 Subject: [PATCH 746/800] Updated array syntax of test for actions/beansModifyActionHook --- .../api/actions/beansModifyActionHook.php | 12 ++++++------ .../unit/api/actions/beansModifyActionHook.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansModifyActionHook.php b/tests/phpunit/integration/api/actions/beansModifyActionHook.php index d364f26d..45a691a8 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionHook.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionHook.php @@ -26,15 +26,15 @@ class Tests_BeansModifyActionHook extends Actions_Test_Case { * Test beans_modify_action_hook() should not modify the action when the hook is invalid. */ public function test_should_not_modify_when_invalid_hook() { - $hooks = array( + $hooks = [ null, false, - array( 'foo' ), + [ 'foo' ], '', 0, 0.0, '0', - ); + ]; $this->go_to_post(); @@ -69,7 +69,7 @@ public function test_should_register_as_modified_but_not_add_action() { $this->assertFalse( beans_modify_action_hook( $beans_id, $action['hook'] ) ); // Check that it did register as "modified" in Beans. - $this->assertEquals( array( 'hook' => $action['hook'] ), _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( [ 'hook' => $action['hook'] ], _beans_get_action( $beans_id, 'modified' ) ); // Check that the action was not added in WordPress. $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); @@ -80,9 +80,9 @@ public function test_should_register_as_modified_but_not_add_action() { * Test beans_modify_action_hook() should modify the registered action's hook. */ public function test_should_modify_the_action_hook() { - $modified_action = array( + $modified_action = [ 'hook' => 'foo', - ); + ]; $this->go_to_post(); diff --git a/tests/phpunit/unit/api/actions/beansModifyActionHook.php b/tests/phpunit/unit/api/actions/beansModifyActionHook.php index cd479f6f..cfbc17c9 100644 --- a/tests/phpunit/unit/api/actions/beansModifyActionHook.php +++ b/tests/phpunit/unit/api/actions/beansModifyActionHook.php @@ -32,7 +32,7 @@ public function test_should_return_false_when_hook_is_empty_or_not_string() { Monkey\Functions\expect( 'beans_modify_action' )->never(); $this->assertFalse( beans_modify_action_hook( $beans_id, '' ) ); - $this->assertFalse( beans_modify_action_hook( $beans_id, array( 'not-a-string' ) ) ); + $this->assertFalse( beans_modify_action_hook( $beans_id, [ 'not-a-string' ] ) ); } } From aa62082f97514f03a4f5208fe74c96d67ee6ee11 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:49:12 +0200 Subject: [PATCH 747/800] Updated array syntax of test for actions/beansModifyActionPriority --- .../api/actions/beansModifyActionPriority.php | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansModifyActionPriority.php b/tests/phpunit/integration/api/actions/beansModifyActionPriority.php index 9de1af95..334219cd 100644 --- a/tests/phpunit/integration/api/actions/beansModifyActionPriority.php +++ b/tests/phpunit/integration/api/actions/beansModifyActionPriority.php @@ -28,22 +28,22 @@ class Tests_BeansModifyActionPriority extends Actions_Test_Case { public function test_should_return_false_when_priority_is_non_integer() { global $wp_filter; - $priorities = array( + $priorities = [ null, - array( 10 ), + [ 10 ], false, '', - ); + ]; $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { // Check the starting state. $this->assertEquals( - array( + [ 'function' => $original_action['callback'], 'accepted_args' => $original_action['args'], - ), + ], $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] ); @@ -56,10 +56,10 @@ public function test_should_return_false_when_priority_is_non_integer() { // Check that the priority did not change in WordPress. $this->assertEquals( - array( + [ 'function' => $original_action['callback'], 'accepted_args' => $original_action['args'], - ), + ], $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] ); } @@ -72,17 +72,17 @@ public function test_should_return_false_when_priority_is_non_integer() { public function test_should_modify_action_when_priority_is_zero() { global $wp_filter; - $priorities = array( 0, 0.0, '0', '0.0' ); + $priorities = [ 0, 0.0, '0', '0.0' ]; $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { // Check the starting state. $this->assertEquals( - array( + [ 'function' => $original_action['callback'], 'accepted_args' => $original_action['args'], - ), + ], $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] ); @@ -91,7 +91,7 @@ public function test_should_modify_action_when_priority_is_zero() { $this->assertTrue( beans_modify_action_priority( $beans_id, $priority ) ); // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( array( 'priority' => (int) $priority ), _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( [ 'priority' => (int) $priority ], _beans_get_action( $beans_id, 'modified' ) ); // Check that the priority did change in WordPress. $this->check_modified_in_wp( $original_action, (int) $priority ); @@ -113,7 +113,7 @@ public function test_should_register_as_modified_but_not_add_action() { $this->assertFalse( beans_modify_action_priority( $beans_id, $action['priority'] ) ); // Check that it did register as "modified" in Beans. - $this->assertEquals( array( 'priority' => $action['priority'] ), _beans_get_action( $beans_id, 'modified' ) ); + $this->assertEquals( [ 'priority' => $action['priority'] ], _beans_get_action( $beans_id, 'modified' ) ); // Check that the action was not added in WordPress. $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); @@ -126,19 +126,19 @@ public function test_should_register_as_modified_but_not_add_action() { public function test_should_modify_the_action_priority() { global $wp_filter; - $modified_action = array( + $modified_action = [ 'priority' => 20, - ); + ]; $this->go_to_post(); foreach ( static::$test_actions as $beans_id => $original_action ) { // Check the starting state. $this->assertEquals( - array( + [ 'function' => $original_action['callback'], 'accepted_args' => $original_action['args'], - ), + ], $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] ); @@ -177,10 +177,10 @@ protected function check_modified_in_wp( $original_action, $new_priority ) { // Check that the action's priority was modified in WordPress. $this->assertEquals( - array( + [ 'function' => $original_action['callback'], 'accepted_args' => $original_action['args'], - ), + ], $callbacks_in_wp[ $new_priority ][ $original_action['callback'] ] ); } From 3729bbb68c20234ef30d0919aa680947bebe36fc Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:50:08 +0200 Subject: [PATCH 748/800] Updated array syntax of test for actions/beansRemoveAction --- tests/phpunit/integration/api/actions/beansRemoveAction.php | 4 ++-- tests/phpunit/unit/api/actions/beansRemoveAction.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansRemoveAction.php b/tests/phpunit/integration/api/actions/beansRemoveAction.php index ffdebd3c..1f7ba3cb 100644 --- a/tests/phpunit/integration/api/actions/beansRemoveAction.php +++ b/tests/phpunit/integration/api/actions/beansRemoveAction.php @@ -29,12 +29,12 @@ class Tests_BeansRemoveAction extends Actions_Test_Case { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_when_action_is_not_registered() { - $empty_action = array( + $empty_action = [ 'hook' => null, 'callback' => null, 'priority' => null, 'args' => null, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { // Test that the original action has not yet been added. diff --git a/tests/phpunit/unit/api/actions/beansRemoveAction.php b/tests/phpunit/unit/api/actions/beansRemoveAction.php index 39bff31c..8deab4a9 100644 --- a/tests/phpunit/unit/api/actions/beansRemoveAction.php +++ b/tests/phpunit/unit/api/actions/beansRemoveAction.php @@ -29,12 +29,12 @@ class Tests_BeansRemoveAction extends Replace_Action_Test_Case { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_when_action_is_not_registered() { - $expected = array( + $expected = [ 'hook' => null, 'callback' => null, 'priority' => null, 'args' => null, - ); + ]; foreach ( static::$test_actions as $beans_id => $original_action ) { // Simulate that there is no "added" action. From 95093a542c188a27c25a60429d87813669a646a5 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:51:24 +0200 Subject: [PATCH 749/800] Updated array syntax of test for actions/beansReplaceAction --- .../api/actions/beansReplaceAction.php | 24 +++++++++---------- .../unit/api/actions/beansReplaceAction.php | 10 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansReplaceAction.php b/tests/phpunit/integration/api/actions/beansReplaceAction.php index 6ee48232..9c15f413 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceAction.php +++ b/tests/phpunit/integration/api/actions/beansReplaceAction.php @@ -30,7 +30,7 @@ class Tests_BeansReplaceAction extends Replace_Action_Test_Case { */ public function test_should_store_when_action_is_not_registered() { $replaced_callback = 'my_replaced_callback'; - $replaced_action = array( 'callback' => $replaced_callback ); + $replaced_action = [ 'callback' => $replaced_callback ]; foreach ( static::$test_ids as $beans_id ) { // Test that the original action has not yet been added. @@ -55,7 +55,7 @@ public function test_should_store_when_action_is_not_registered() { */ public function test_should_store_and_then_replace_action() { $replaced_callback = 'my_replaced_callback'; - $replaced_action = array( 'callback' => $replaced_callback ); + $replaced_action = [ 'callback' => $replaced_callback ]; // Store the "replaced" action. foreach ( static::$test_ids as $beans_id ) { @@ -103,9 +103,9 @@ public function test_should_return_false_when_nothing_to_replace() { * Test beans_replace_action() should replace the registered action's hook. */ public function test_should_replace_the_action_hook() { - $replaced_action = array( + $replaced_action = [ 'hook' => 'foo', - ); + ]; $this->go_to_post(); @@ -134,9 +134,9 @@ public function test_should_replace_the_action_hook() { * Test beans_replace_action() should replace the registered action's callback. */ public function test_should_replace_the_action_callback() { - $replaced_action = array( + $replaced_action = [ 'callback' => 'foo', - ); + ]; $this->go_to_post(); @@ -165,9 +165,9 @@ public function test_should_replace_the_action_callback() { * Test beans_replace_action() should replace the registered action's priority level. */ public function test_should_replace_the_action_priority() { - $replaced_action = array( + $replaced_action = [ 'priority' => 52, - ); + ]; $this->go_to_post(); @@ -196,9 +196,9 @@ public function test_should_replace_the_action_priority() { * Test beans_replace_action() should replace the registered action's number of arguments. */ public function test_should_replace_the_action_args() { - $replaced_action = array( + $replaced_action = [ 'args' => 6, - ); + ]; $this->go_to_post(); @@ -227,12 +227,12 @@ public function test_should_replace_the_action_args() { * Test beans_replace_action() should replace the original registered action. */ public function test_should_replace_the_action() { - $replaced_action = array( + $replaced_action = [ 'hook' => 'new_hook', 'callback' => 'new_callback', 'priority' => 99, 'args' => 10, - ); + ]; $this->go_to_post(); diff --git a/tests/phpunit/unit/api/actions/beansReplaceAction.php b/tests/phpunit/unit/api/actions/beansReplaceAction.php index 2a0945fd..b899149e 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceAction.php +++ b/tests/phpunit/unit/api/actions/beansReplaceAction.php @@ -46,7 +46,7 @@ public function test_should_return_false_when_nothing_to_replace() { */ public function test_should_store_when_action_is_not_registered() { $replaced_callback = 'my_new_callback'; - $replaced_action = array( 'callback' => $replaced_callback ); + $replaced_action = [ 'callback' => $replaced_callback ]; foreach ( static::$test_ids as $beans_id ) { Monkey\Functions\expect( '_beans_merge_action' ) @@ -75,7 +75,7 @@ public function test_should_store_when_action_is_not_registered() { */ public function test_should_replace_the_action_hook() { $replaced_hook = 'foo'; - $replaced_action = array( 'hook' => $replaced_hook ); + $replaced_action = [ 'hook' => $replaced_hook ]; foreach ( static::$test_ids as $beans_id ) { Monkey\Functions\expect( '_beans_merge_action' ) @@ -104,7 +104,7 @@ public function test_should_replace_the_action_hook() { */ public function test_should_replace_the_action_callback() { $replaced_callback = 'my_replaced_callback'; - $replaced_action = array( 'callback' => $replaced_callback ); + $replaced_action = [ 'callback' => $replaced_callback ]; foreach ( static::$test_ids as $beans_id ) { Monkey\Functions\expect( '_beans_merge_action' ) @@ -133,7 +133,7 @@ public function test_should_replace_the_action_callback() { */ public function test_should_replace_the_action_priority() { $replaced_priority = - 2; - $replaced_action = array( 'priority' => $replaced_priority ); + $replaced_action = [ 'priority' => $replaced_priority ]; foreach ( static::$test_ids as $beans_id ) { Monkey\Functions\expect( '_beans_merge_action' ) @@ -162,7 +162,7 @@ public function test_should_replace_the_action_priority() { */ public function test_should_replace_the_action_args() { $replaced_args = 6; - $replaced_action = array( 'args' => $replaced_args ); + $replaced_action = [ 'args' => $replaced_args ]; foreach ( static::$test_ids as $beans_id ) { Monkey\Functions\expect( '_beans_merge_action' ) From ac7bb8a79e26504d906b32d0a27f640a3fb31324 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:52:44 +0200 Subject: [PATCH 750/800] Updated array syntax of test for actions/beansReplaceActionArguments --- .../api/actions/beansReplaceActionArguments.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php b/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php index 728b6733..9241ec27 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php @@ -29,9 +29,9 @@ class Tests_BeansReplaceActionArguments extends Replace_Action_Test_Case { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_when_action_is_not_registered() { - $replaced_action = array( + $replaced_action = [ 'args' => 10, - ); + ]; // Store the "replaced" action. foreach ( static::$test_ids as $beans_id ) { @@ -53,9 +53,9 @@ public function test_should_store_when_action_is_not_registered() { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_and_then_replace_the_args() { - $replaced_action = array( + $replaced_action = [ 'args' => 10, - ); + ]; // Now replace the actions. foreach ( static::$test_ids as $beans_id ) { @@ -101,9 +101,9 @@ public function test_should_return_false_when_no_args() { * Test beans_replace_action_arguments() should replace the registered action's args. */ public function test_should_replace_the_action_args() { - $replaced_action = array( + $replaced_action = [ 'args' => 14, - ); + ]; $this->go_to_post(); From 716f246bd803eb9d8b207cfa7b44c9249f07f9e9 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:53:39 +0200 Subject: [PATCH 751/800] Updated array syntax of test for actions/beansReplaceActionCallback --- .../api/actions/beansReplaceActionCallback.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php b/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php index 00c33dd4..3610c0ab 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php @@ -29,9 +29,9 @@ class Tests_BeansReplaceActionCallback extends Replace_Action_Test_Case { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_when_action_is_not_registered() { - $replaced_action = array( + $replaced_action = [ 'callback' => 'my_new_callback', - ); + ]; foreach ( static::$test_ids as $beans_id ) { // Test that the original action has not yet been added. @@ -52,9 +52,9 @@ public function test_should_store_when_action_is_not_registered() { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_and_then_replace_the_callback() { - $replaced_action = array( + $replaced_action = [ 'callback' => 'foo', - ); + ]; // Now replace the actions. foreach ( static::$test_ids as $beans_id ) { @@ -100,9 +100,9 @@ public function test_should_return_false_when_no_hook() { * Test beans_replace_action_callback() should replace the registered action's callback. */ public function test_should_replace_the_action_callback() { - $replaced_action = array( + $replaced_action = [ 'callback' => 'beans_foo', - ); + ]; $this->go_to_post(); From c07429600120a902e5466f19622547342b7ee1a0 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:54:48 +0200 Subject: [PATCH 752/800] Updated array syntax of test for actions/beansReplaceActionHook --- .../api/actions/beansReplaceActionHook.php | 12 ++++++------ .../unit/api/actions/beansReplaceActionHook.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionHook.php b/tests/phpunit/integration/api/actions/beansReplaceActionHook.php index be3f9a81..51431c24 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionHook.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionHook.php @@ -29,9 +29,9 @@ class Tests_BeansReplaceActionHook extends Replace_Action_Test_Case { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_when_action_is_not_registered() { - $replaced_action = array( + $replaced_action = [ 'hook' => 'my_new_hook', - ); + ]; foreach ( static::$test_ids as $beans_id ) { // Test that the original action has not yet been added. @@ -52,9 +52,9 @@ public function test_should_store_when_action_is_not_registered() { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_and_then_replace_the_hook() { - $replaced_action = array( + $replaced_action = [ 'hook' => 'foo', - ); + ]; // Now replace the actions. foreach ( static::$test_ids as $beans_id ) { @@ -110,9 +110,9 @@ public function test_should_replace_the_action_hook() { $this->assertEquals( $action_config['hook'], $original_action['hook'] ); // Set up what will get stored in Beans. - $replaced_action = array( + $replaced_action = [ 'hook' => 'beans_foo', - ); + ]; // Run the replace. $this->assertTrue( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); diff --git a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php index cf2dca3e..755538a4 100644 --- a/tests/phpunit/unit/api/actions/beansReplaceActionHook.php +++ b/tests/phpunit/unit/api/actions/beansReplaceActionHook.php @@ -32,7 +32,7 @@ public function test_should_return_false_when_hook_is_empty_or_not_string() { Monkey\Functions\expect( 'beans_replace_action' )->never(); $this->assertFalse( beans_replace_action_hook( $beans_id, '' ) ); - $this->assertFalse( beans_replace_action_hook( $beans_id, array( 'not-a-string' ) ) ); + $this->assertFalse( beans_replace_action_hook( $beans_id, [ 'not-a-string' ] ) ); } } From c12a5829ac5c18867c1cb9423cf1b08622cba734 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:56:26 +0200 Subject: [PATCH 753/800] Updated array syntax of test for actions/beansReplaceActionPriority --- .../api/actions/beansReplaceActionPriority.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php b/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php index 14f353c4..0e10b3f6 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php +++ b/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php @@ -29,9 +29,9 @@ class Tests_BeansReplaceActionPriority extends Replace_Action_Test_Case { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_when_action_is_not_registered() { - $replaced_action = array( + $replaced_action = [ 'priority' => 99, - ); + ]; foreach ( static::$test_ids as $beans_id ) { // Test that the original action has not yet been added. @@ -52,9 +52,9 @@ public function test_should_store_when_action_is_not_registered() { * Intent: We are testing to ensure Beans is "load order" agnostic. */ public function test_should_store_and_then_replace_the_priority() { - $replaced_action = array( + $replaced_action = [ 'priority' => 10000, - ); + ]; // Now replace the actions. foreach ( static::$test_ids as $beans_id ) { @@ -100,9 +100,9 @@ public function test_should_return_false_when_no_hook() { * Test beans_replace_action_priority() should replace the registered action's priority. */ public function test_should_replace_the_action_priority() { - $replaced_action = array( + $replaced_action = [ 'priority' => 999, - ); + ]; $this->go_to_post(); From 37b55bec1aeaccf563b69900e00e96056a9cdb48 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:58:04 +0200 Subject: [PATCH 754/800] Updated array syntax of test for actions/beansResetAction --- .../api/actions/beansResetAction.php | 60 +++++++++---------- .../unit/api/actions/beansResetAction.php | 6 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansResetAction.php b/tests/phpunit/integration/api/actions/beansResetAction.php index 6088746a..6f014de5 100644 --- a/tests/phpunit/integration/api/actions/beansResetAction.php +++ b/tests/phpunit/integration/api/actions/beansResetAction.php @@ -63,9 +63,9 @@ public function test_should_reset_after_remove() { * Test beans_reset_action() should reset the original action's hook after it was "modified". */ public function test_should_reset_after_modifying_the_hook() { - $modified_action = array( + $modified_action = [ 'hook' => 'foo', - ); + ]; $this->go_to_post(); @@ -97,9 +97,9 @@ public function test_should_reset_after_modifying_the_hook() { public function test_should_reset_after_modifying_the_callback() { global $wp_filter; - $modified_action = array( + $modified_action = [ 'callback' => 'my_callback', - ); + ]; $this->go_to_post(); @@ -132,9 +132,9 @@ public function test_should_reset_after_modifying_the_callback() { public function test_should_reset_after_modifying_the_priority() { global $wp_filter; - $modified_action = array( + $modified_action = [ 'priority' => 9999, - ); + ]; $this->go_to_post(); @@ -170,9 +170,9 @@ public function test_should_reset_after_modifying_the_priority() { public function test_should_reset_after_modifying_the_args() { global $wp_filter; - $modified_action = array( + $modified_action = [ 'args' => 14, - ); + ]; $this->go_to_post(); @@ -210,10 +210,10 @@ public function test_should_reset_after_modifying_callback_and_args() { $this->go_to_post(); - $modified_action = array( + $modified_action = [ 'callback' => 'my_callback', 'args' => 14, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { // Before we start, check that the action is registered. @@ -227,10 +227,10 @@ public function test_should_reset_after_modifying_callback_and_args() { $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); $this->assertTrue( has_action( $action['hook'], $modified_action['callback'] ) !== false ); $this->assertEquals( - array( + [ 'function' => $modified_action['callback'], 'accepted_args' => $modified_action['args'], - ), + ], $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $modified_action['callback'] ] ); @@ -251,10 +251,10 @@ public function test_should_reset_after_modifying_priority_and_args() { $this->go_to_post(); - $modified_action = array( + $modified_action = [ 'priority' => 79, 'args' => 14, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { // Before we start, check that the action is registered. @@ -266,10 +266,10 @@ public function test_should_reset_after_modifying_priority_and_args() { // Check that the action was modified. $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); $this->assertEquals( - array( + [ 'function' => $action['callback'], 'accepted_args' => $modified_action['args'], - ), + ], $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $action['callback'] ] ); @@ -290,10 +290,10 @@ public function test_should_reset_after_modifying_callback_and_priority() { $this->go_to_post(); - $modified_action = array( + $modified_action = [ 'callback' => 'foo', 'priority' => 39, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { // Before we start, check that the action is registered. @@ -305,10 +305,10 @@ public function test_should_reset_after_modifying_callback_and_priority() { // Check that the action was modified. $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); $this->assertEquals( - array( + [ 'function' => $modified_action['callback'], 'accepted_args' => $action['args'], - ), + ], $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $modified_action['callback'] ] ); @@ -330,11 +330,11 @@ public function test_should_reset_after_modifying_all_but_hook() { $this->go_to_post(); - $modified_action = array( + $modified_action = [ 'callback' => 'foo', 'priority' => 39, 'args' => 24, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { // Before we start, check that the action is registered. @@ -346,10 +346,10 @@ public function test_should_reset_after_modifying_all_but_hook() { // Check that the action was modified. $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); $this->assertEquals( - array( + [ 'function' => $modified_action['callback'], 'accepted_args' => $modified_action['args'], - ), + ], $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $modified_action['callback'] ] ); @@ -429,10 +429,10 @@ public function test_should_not_reset_after_replacing_priority() { foreach ( static::$test_actions as $beans_id => $action ) { // Before we start, do a hard check to ensure the original priority is registered. $this->assertEquals( - array( + [ 'function' => $action['callback'], 'accepted_args' => $action['args'], - ), + ], $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ] ); @@ -444,10 +444,10 @@ public function test_should_not_reset_after_replacing_priority() { // Check that the action was not reset. $this->assertEquals( - array( + [ 'function' => $action['callback'], 'accepted_args' => $action['args'], - ), + ], $wp_filter[ $action['hook'] ]->callbacks[ $priority ][ $action['callback'] ] ); } @@ -503,10 +503,10 @@ protected function check_the_action( $beans_id, array $action ) { $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); $this->assertEquals( - array( + [ 'function' => $action['callback'], 'accepted_args' => $action['args'], - ), + ], $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ] ); } diff --git a/tests/phpunit/unit/api/actions/beansResetAction.php b/tests/phpunit/unit/api/actions/beansResetAction.php index 7d78b76d..0f4bf783 100644 --- a/tests/phpunit/unit/api/actions/beansResetAction.php +++ b/tests/phpunit/unit/api/actions/beansResetAction.php @@ -81,10 +81,10 @@ public function test_should_reset_after_remove() { public function test_should_reset_after_modifying_the_action() { Monkey\Functions\when( '_beans_unset_action' ); - $modified_action = array( + $modified_action = [ 'callback' => 'my_new_callback', 'priority' => 47, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { // Simulate modifying the action. @@ -125,7 +125,7 @@ public function test_should_not_reset_after_replacing_action() { Monkey\Functions\when( '_beans_unset_action' ); foreach ( static::$test_actions as $beans_id => $action ) { - $replaced_action = array_merge( $action, array( 'hook' => 'replaced_hook' ) ); + $replaced_action = array_merge( $action, [ 'hook' => 'replaced_hook' ] ); // Simulate that the replaced action is registered. Monkey\Functions\expect( '_beans_get_action' ) From 925a63e34f790e3352f03081e9515b546e52e3e4 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:59:09 +0200 Subject: [PATCH 755/800] Updated array syntax of test for actions/beansSetAction --- .../phpunit/integration/api/actions/beansSetAction.php | 10 +++++----- tests/phpunit/unit/api/actions/beansSetAction.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansSetAction.php b/tests/phpunit/integration/api/actions/beansSetAction.php index b8f6ef8c..b9254c9f 100644 --- a/tests/phpunit/integration/api/actions/beansSetAction.php +++ b/tests/phpunit/integration/api/actions/beansSetAction.php @@ -27,7 +27,7 @@ class Tests_BeansSetAction extends Actions_Test_Case { * * @var array */ - protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); + protected $statuses = [ 'added', 'modified', 'removed', 'replaced' ]; /** * Test _beans_set_action() should set (registered) the action and then return it. @@ -56,12 +56,12 @@ public function test_should_set_and_return_action() { public function test_should_not_overwrite_existing_registered_action() { global $_beans_registered_actions; - $new_action = array( + $new_action = [ 'hook' => 'bar', 'callback' => 'callback_bar', 'priority' => 20, 'args' => 2, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { @@ -84,12 +84,12 @@ public function test_should_not_overwrite_existing_registered_action() { public function test_should_overwrite_existing_registered_action() { global $_beans_registered_actions; - $new_action = array( + $new_action = [ 'hook' => 'bar', 'callback' => 'callback_bar', 'priority' => 20, 'args' => 2, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { diff --git a/tests/phpunit/unit/api/actions/beansSetAction.php b/tests/phpunit/unit/api/actions/beansSetAction.php index 17527598..b513dab7 100644 --- a/tests/phpunit/unit/api/actions/beansSetAction.php +++ b/tests/phpunit/unit/api/actions/beansSetAction.php @@ -28,7 +28,7 @@ class Tests_BeansSetAction extends Actions_Test_Case { * * @var array */ - protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); + protected $statuses = [ 'added', 'modified', 'removed', 'replaced' ]; /** * Test _beans_set_action() should set (register) the action and then return it. @@ -62,12 +62,12 @@ public function test_should_set_and_return_action() { public function test_should_not_overwrite_existing_registered_action() { global $_beans_registered_actions; - $new_action = array( + $new_action = [ 'hook' => 'bar', 'callback' => 'callback_bar', 'priority' => 20, 'args' => 2, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { @@ -96,12 +96,12 @@ public function test_should_not_overwrite_existing_registered_action() { public function test_should_overwrite_existing_registered_action() { global $_beans_registered_actions; - $new_action = array( + $new_action = [ 'hook' => 'bar', 'callback' => 'callback_bar', 'priority' => 20, 'args' => 2, - ); + ]; foreach ( static::$test_actions as $beans_id => $action ) { From d159fdf81c502078b5263825198ada9c0e2b4e7c Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 00:59:50 +0200 Subject: [PATCH 756/800] Updated array syntax of test for actions/beansUnsetAction --- tests/phpunit/integration/api/actions/beansUnsetAction.php | 2 +- tests/phpunit/unit/api/actions/beansUnsetAction.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/integration/api/actions/beansUnsetAction.php b/tests/phpunit/integration/api/actions/beansUnsetAction.php index ff60ea13..d70eec53 100644 --- a/tests/phpunit/integration/api/actions/beansUnsetAction.php +++ b/tests/phpunit/integration/api/actions/beansUnsetAction.php @@ -27,7 +27,7 @@ class Tests_BeansUnsetAction extends Actions_Test_Case { * * @var array */ - protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); + protected $statuses = [ 'added', 'modified', 'removed', 'replaced' ]; /** * Test _beans_unset_action() should return false when action is not registered. diff --git a/tests/phpunit/unit/api/actions/beansUnsetAction.php b/tests/phpunit/unit/api/actions/beansUnsetAction.php index 5227db9c..86960c9a 100644 --- a/tests/phpunit/unit/api/actions/beansUnsetAction.php +++ b/tests/phpunit/unit/api/actions/beansUnsetAction.php @@ -28,7 +28,7 @@ class Tests_BeansUnsetAction extends Actions_Test_Case { * * @var array */ - protected $statuses = array( 'added', 'modified', 'removed', 'replaced' ); + protected $statuses = [ 'added', 'modified', 'removed', 'replaced' ]; /** * Test _beans_unset_action() should return false when action is not registered. From 21e550b2695c8593bae0895a417775be4deab4d3 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 01:02:06 +0200 Subject: [PATCH 757/800] Updated array syntax of test for actions/unit-mixed --- .../beans-anonymous-action/__construct.php | 16 ++++++++-------- .../actions/beans-anonymous-action/callback.php | 10 +++++----- .../unit/api/actions/fixtures/test-actions.php | 16 ++++++++-------- .../actions/includes/class-actions-test-case.php | 16 ++++++++-------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php index 37607274..bc12e9cc 100644 --- a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php @@ -36,24 +36,24 @@ protected function setUp() { * Test __construct() should set the callback and arguments. */ public function test_should_set_callback_and_arguments() { - $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', array( + $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', [ 'foo_test_callback', - array( 'foo', 'bar', 'baz' ), - ) ); + [ 'foo', 'bar', 'baz' ], + ] ); $this->assertSame( 'foo_test_callback', $anonymous_action->callback[0] ); - $this->assertSame( array( 'foo', 'bar', 'baz' ), $anonymous_action->callback[1] ); + $this->assertSame( [ 'foo', 'bar', 'baz' ], $anonymous_action->callback[1] ); } /** * Test __construct() should add the action's hook. */ public function test_should_add_action_hook() { - $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', array( + $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', [ 'foo_test_callback', - array( 'foo' ), - ), 50, 3 ); + [ 'foo' ], + ], 50, 3 ); - $this->assertTrue( has_action( 'beans_test_do_foo', array( $anonymous_action, 'callback' ) ) ); + $this->assertTrue( has_action( 'beans_test_do_foo', [ $anonymous_action, 'callback' ] ) ); } } diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php index 41a09637..a2819049 100644 --- a/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php @@ -37,10 +37,10 @@ protected function setUp() { * Test _Beans_Anonymous_Action::callback() should invoke the given callback, passing the arguments to it. */ public function test_should_invoke_callback() { - $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', array( + $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', [ 'foo_test_callback', - array( 'foo', 'bar' ), - ), 20, 2 ); + [ 'foo', 'bar' ], + ], 20, 2 ); // Check that the callback is invoked with each of its parameters. Monkey\Functions\expect( 'foo_test_callback' ) @@ -60,9 +60,9 @@ public function test_should_invoke_callback() { * Test _Beans_Anonymous_Action::callback() should echo the returned content. */ public function test_should_echo_returned_content() { - $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', array( + $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', [ 'foo_test_callback', - array( 'Cool Beans!', 'It worked!' ), + [ 'Cool Beans!', 'It worked!' ], ) ); Monkey\Functions\when( 'foo_test_callback' )->alias( function( $arg1, $arg2 ) { diff --git a/tests/phpunit/unit/api/actions/fixtures/test-actions.php b/tests/phpunit/unit/api/actions/fixtures/test-actions.php index b73c61a2..291530a8 100644 --- a/tests/phpunit/unit/api/actions/fixtures/test-actions.php +++ b/tests/phpunit/unit/api/actions/fixtures/test-actions.php @@ -7,23 +7,23 @@ * @since 1.5.0 */ -return array( - 'beans_post_meta' => array( +return [ + 'beans_post_meta' => [ 'hook' => 'beans_post_header', 'callback' => 'beans_post_meta', 'priority' => 15, 'args' => 1, - ), - 'beans_post_image' => array( + ], + 'beans_post_image' => [ 'hook' => 'beans_post_body', 'callback' => 'beans_post_image', 'priority' => 5, 'args' => 1, - ), - 'beans_previous_post_link' => array( + ], + 'beans_previous_post_link' => [ 'hook' => 'previous_post_link', 'callback' => 'beans_previous_post_link', 'priority' => 10, 'args' => 4, - ), -); + ], +]; diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index d748685c..223d4d49 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -50,12 +50,12 @@ public static function tearDownAfterClass() { parent::tearDownAfterClass(); global $_beans_registered_actions; - $_beans_registered_actions = array( - 'added' => array(), - 'modified' => array(), - 'removed' => array(), - 'replaced' => array(), - ); + $_beans_registered_actions = [ + 'added' => [], + 'modified' => [], + 'removed' => [], + 'replaced' => [], + ]; // Remove the test actions. foreach ( static::$test_actions as $beans_id => $action ) { @@ -72,10 +72,10 @@ public static function tearDownAfterClass() { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/actions/functions.php', 'api/utilities/functions.php', - ) ); + ] ); Monkey\Functions\when( 'beans_get' )->alias( function ( $needle, $haystack ) { From 3354ed8d2c9f0cffe3cf11efc1c208283859ed80 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 01:08:46 +0200 Subject: [PATCH 758/800] Updated array syntax of test for actions/beansRenderAction --- .../unit/api/actions/beansRenderAction.php | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansRenderAction.php b/tests/phpunit/unit/api/actions/beansRenderAction.php index 97edf65f..d938b721 100644 --- a/tests/phpunit/unit/api/actions/beansRenderAction.php +++ b/tests/phpunit/unit/api/actions/beansRenderAction.php @@ -38,7 +38,7 @@ protected function setUp() { public function test_should_return_false_when_a_callback_is_not_registered() { $this->assertFalse( _beans_render_action( 'foo' ) ); $this->assertFalse( _beans_render_action( 'foo', 'bar' ) ); - $this->assertFalse( _beans_render_action( 'foo', 'bar', array( 'baz' => 'zab' ) ) ); + $this->assertFalse( _beans_render_action( 'foo', 'bar', [ 'baz' => 'zab' ] ) ); $this->assertFalse( _beans_render_action( 'foo_bar' ) ); $this->assertFalse( _beans_render_action( 'foo.bar' ) ); $this->assertFalse( _beans_render_action( 'beans_footer_before_markup' ) ); @@ -50,10 +50,10 @@ public function test_should_return_false_when_a_callback_is_not_registered() { */ public function test_should_return_after_calling_hook_with_no_subhook() { // Testing with a closure. - $expected_args = array( - array( 'foo' ), - array( 'foo', 'bar' ), - array( 'foo', 'bar', 'baz' ), + $expected_args = [ + [ 'foo' ], + [ 'foo', 'bar' ], + [ 'foo', 'bar', 'baz' ], ); $callback = function() use ( $expected_args ) { $args = func_get_args(); @@ -73,16 +73,16 @@ public function test_should_return_after_calling_hook_with_no_subhook() { // Testing with a stubbed method. $stub = new Actions_Stub(); $message = 'Beans rocks!'; - add_action( 'beans_stub_with_object', array( $stub, 'echo_static' ) ); + add_action( 'beans_stub_with_object', [ $stub, 'echo_static' ] ); $this->assertTrue( has_action( 'beans_stub_with_object' ) ); - Actions\expectDone( 'beans_stub_with_object' )->whenHappen( array( $stub, 'echo_static' ) ); + Actions\expectDone( 'beans_stub_with_object' )->whenHappen( [ $stub, 'echo_static' ] ); $this->assertEquals( $message, _beans_render_action( 'beans_stub_with_object', $message ) ); // Testing with a stubbed static method. $stub = Actions_Stub::class; - add_action( 'beans_stub_with_static_method', array( $stub, 'echo_static' ) ); + add_action( 'beans_stub_with_static_method', [ $stub, 'echo_static' ] ); $this->assertTrue( has_action( 'beans_stub_with_static_method' ) ); - Actions\expectDone( 'beans_stub_with_static_method' )->times( 3 )->whenHappen( array( $stub, 'echo_static' ) ); + Actions\expectDone( 'beans_stub_with_static_method' )->times( 3 )->whenHappen( [ $stub, 'echo_static' ] ); $message = 'Calling the static method...and Beans rocks!'; $this->assertEquals( $message, _beans_render_action( 'beans_stub_with_static_method', $message ) ); @@ -108,28 +108,28 @@ public function test_should_render_base_hook() { $stub = Actions_Stub::class; // Test with a single sub-hook. - add_action( 'foo', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo' )->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo' )->whenHappen( [ $stub, 'echo_static' ] ); Actions\expectDone( 'bar' )->never(); $this->assertEquals( 'Called foo.', _beans_render_action( 'foo[bar]', 'Called foo.' ) ); // Test with a suffix. - add_action( 'foo_bar', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo_bar' )->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo_bar', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo_bar' )->whenHappen( [ $stub, 'echo_static' ] ); Actions\expectDone( 'baz_bar' )->never(); $this->assertEquals( 'Called foo_bar.', _beans_render_action( 'foo[baz]_bar', 'Called foo_bar.' ) ); // Test with multiple sub-hooks. - add_action( 'beans_stub', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'beans_stub' )->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'beans_stub', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'beans_stub' )->whenHappen( [ $stub, 'echo_static' ] ); Actions\expectDone( 'beans_stub[_pre]' )->never(); Actions\expectDone( 'beans_stub[_before]' )->never(); Actions\expectDone( 'beans_stub[_pre][_before]' )->never(); $this->assertEquals( 'Beans rocks!', _beans_render_action( 'beans_stub[_pre][_before]', 'Beans rocks!' ) ); // Test with multiple sub-hooks. - add_action( 'beans_stub_after', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'beans_stub_after' )->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'beans_stub_after', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'beans_stub_after' )->whenHappen( [ $stub, 'echo_static' ] ); Actions\expectDone( 'beans_stub[_pre]_after' )->never(); Actions\expectDone( 'beans_stub[_before]_after' )->never(); Actions\expectDone( 'beans_stub[_pre][_before]_after' )->never(); @@ -145,13 +145,13 @@ public function test_should_render_one_level_of_sub_hooks() { $message = 'Called me. '; // The root hook renders. - add_action( 'foo', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo' )->once()->whenHappen( [ $stub, 'echo_static' ] ); $expected = $message; // The 1st sub-hook renders. - add_action( 'foo[bar]', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo[bar]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo[bar]', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo[bar]' )->once()->whenHappen( [ $stub, 'echo_static' ] ); $expected .= $message; // Run the test. @@ -168,13 +168,13 @@ public function test_should_render_two_levels_of_sub_hooks_but_not_original() { $message = 'Called me. '; // The root hook renders. - add_action( 'foo', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo' )->once()->whenHappen( [ $stub, 'echo_static' ] ); $expected = $message; // The 1st sub-hook renders. - add_action( 'foo[bar]', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo[bar]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo[bar]', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo[bar]' )->once()->whenHappen( [ $stub, 'echo_static' ] ); $expected .= $message; // These hooks will not render as they are not registered. @@ -194,23 +194,23 @@ public function test_should_render_hook_and_all_subhooks() { $message = 'Called me. '; // The root hook renders. - add_action( 'foo', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo' )->once()->whenHappen( [ $stub, 'echo_static' ] ); $expected = $message; // The 1st sub-hook renders. - add_action( 'foo[bar]', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo[bar]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo[bar]', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo[bar]' )->once()->whenHappen( [ $stub, 'echo_static' ] ); $expected .= $message; // The 2nd sub-hook renders. - add_action( 'foo[baz]', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo[baz]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo[baz]', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo[baz]' )->once()->whenHappen( [ $stub, 'echo_static' ] ); $expected .= $message; // The original hook renders. - add_action( 'foo[bar][baz]', array( $stub, 'echo_static' ) ); - Actions\expectDone( 'foo[bar][baz]' )->once()->whenHappen( array( $stub, 'echo_static' ) ); + add_action( 'foo[bar][baz]', [ $stub, 'echo_static' ] ); + Actions\expectDone( 'foo[bar][baz]' )->once()->whenHappen( [ $stub, 'echo_static' ] ); $expected .= $message; // Run the test. From 8e8af5f20a183cfd30bcc375cfb98696e1ad8076 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 01:09:40 +0200 Subject: [PATCH 759/800] Updated array syntax of test for actions/beansUniqueActionId --- .../unit/api/actions/beansUniqueActionId.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/unit/api/actions/beansUniqueActionId.php b/tests/phpunit/unit/api/actions/beansUniqueActionId.php index 56719795..e6c1c5dc 100644 --- a/tests/phpunit/unit/api/actions/beansUniqueActionId.php +++ b/tests/phpunit/unit/api/actions/beansUniqueActionId.php @@ -52,17 +52,17 @@ public function test_should_return_when_string_given() { public function test_should_convert_static_method() { $this->assertEquals( 'Foo::bar', - _beans_unique_action_id( array( 'Foo', 'bar' ) ) + _beans_unique_action_id( [ 'Foo', 'bar' ] ) ); $this->assertEquals( 'Tests_BeansUniqueActionId::test_should_return_when_string', - _beans_unique_action_id( array( 'Tests_BeansUniqueActionId', 'test_should_return_when_string' ) ) + _beans_unique_action_id( [ 'Tests_BeansUniqueActionId', 'test_should_return_when_string' ] ) ); $stub_classname = __NAMESPACE__ . '\Actions_Stub'; $this->assertEquals( $stub_classname . '::dummy_static_method', - _beans_unique_action_id( array( $stub_classname, 'dummy_static_method' ) ) + _beans_unique_action_id( [ $stub_classname, 'dummy_static_method' ] ) ); $this->assertEquals( $stub_classname . '::dummy_static_method', @@ -72,15 +72,15 @@ public function test_should_convert_static_method() { $stub = new Actions_Stub(); $this->assertNotEquals( $stub_classname . '::dummy_static_method', - _beans_unique_action_id( array( $stub, 'dummy_static_method' ) ) + _beans_unique_action_id( [ $stub, 'dummy_static_method' ] ) ); $this->assertStringEndsWith( 'dummy_static_method', - _beans_unique_action_id( array( $stub, 'dummy_static_method' ) ) + _beans_unique_action_id( [ $stub, 'dummy_static_method' ] ) ); $this->assertEquals( spl_object_hash( $stub ) . 'dummy_static_method', - _beans_unique_action_id( array( $stub, 'dummy_static_method' ) ) + _beans_unique_action_id( [ $stub, 'dummy_static_method' ] ) ); } @@ -96,7 +96,7 @@ public function test_should_convert_object() { $this->assertEquals( spl_object_hash( $stub ), _beans_unique_action_id( $stub ) ); $this->assertEquals( spl_object_hash( $stub ) . 'dummy_method', - _beans_unique_action_id( array( $stub, 'dummy_method' ) ) + _beans_unique_action_id( [ $stub, 'dummy_method' ] ) ); } From bdd536cebc14d2775880c421fbbb8f30420bc07e Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 01:14:34 +0200 Subject: [PATCH 760/800] Updated array syntax of test for actions/beans-anonymous-action/callback.php --- .../unit/api/actions/beans-anonymous-action/callback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php index a2819049..18bb601f 100644 --- a/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php @@ -63,7 +63,7 @@ public function test_should_echo_returned_content() { $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', [ 'foo_test_callback', [ 'Cool Beans!', 'It worked!' ], - ) ); + ] ); Monkey\Functions\when( 'foo_test_callback' )->alias( function( $arg1, $arg2 ) { return "{$arg1} {$arg2}"; From 1254d34ff4cf2d672540ee173c12e9bc4784251f Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 01:15:07 +0200 Subject: [PATCH 761/800] Updated array syntax of test for actions/beansRenderAction --- tests/phpunit/unit/api/actions/beansRenderAction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/unit/api/actions/beansRenderAction.php b/tests/phpunit/unit/api/actions/beansRenderAction.php index d938b721..496f7438 100644 --- a/tests/phpunit/unit/api/actions/beansRenderAction.php +++ b/tests/phpunit/unit/api/actions/beansRenderAction.php @@ -54,7 +54,7 @@ public function test_should_return_after_calling_hook_with_no_subhook() { [ 'foo' ], [ 'foo', 'bar' ], [ 'foo', 'bar', 'baz' ], - ); + ]; $callback = function() use ( $expected_args ) { $args = func_get_args(); $this->assertTrue( doing_action( 'beans_stub' ) ); From b9dfb8b061d399b507a8185d97f962dea22db635 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 18:27:58 -0500 Subject: [PATCH 762/800] Fixed slider field for Customizer to pick up change trigger. Customizer as of WordPress 4.7 does not pick up `.keyup()` on the text input of our custom slider. But it does pick up `.trigger( 'change' )`. Switching it to `.trigger( 'change' )` works on older versions too. This change partial solves bug #260. --- lib/api/fields/assets/js/fields.js | 14 +++++++------- lib/api/fields/assets/js/fields.min.js | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/api/fields/assets/js/fields.js b/lib/api/fields/assets/js/fields.js index 2a399a38..5c8732e7 100644 --- a/lib/api/fields/assets/js/fields.js +++ b/lib/api/fields/assets/js/fields.js @@ -1,5 +1,5 @@ !(function( $ ) { - "use strict"; + 'use strict'; var beansFields = function( element, options ) { this.container = $( element ); @@ -32,13 +32,13 @@ max: max, step: interval, slide: function( event, ui ) { - // Update visible output. - $(this).parent().find( '.bs-slider-value' ).text( ui.value ); + // Update visible output. + $(this).parent().find( '.bs-slider-value' ).text( ui.value ); - // Update hidden input. - $(this).find( 'input[type=text]' ) - .val( ui.value ) - .keyup(); + // Update text hidden input. Then trigger the change. + var sliderField = $(this).find( 'input[type=text]' ); + sliderField.val( ui.value ); + sliderField.trigger( 'change' ); } }); diff --git a/lib/api/fields/assets/js/fields.min.js b/lib/api/fields/assets/js/fields.min.js index f809b97d..eba06861 100644 --- a/lib/api/fields/assets/js/fields.min.js +++ b/lib/api/fields/assets/js/fields.min.js @@ -1 +1 @@ -!(function(b){var a=function(d,c){this.container=b(d);this.init();this.listen()};a.prototype={constructor:a,checkboxLabelToggle:function(c){c.parent().find('input[type="checkbox"]').click()},imageradio:function(c){c.closest("fieldset").find("label").removeClass("selected");c.closest("label.bs-has-image").addClass("selected")},slider:function(d){var g=parseInt(d.find("input[type=text]").val()),f=parseInt(d.attr("slider_min")),c=parseInt(d.attr("slider_max")),e=parseInt(d.attr("slider_interval"));d.slider({range:"min",value:g,min:f,max:c,step:e,slide:function(h,i){b(this).parent().find(".bs-slider-value").text(i.value);b(this).find("input[type=text]").val(i.value).keyup()}});d.find(".ui-slider-handle").removeAttr("href")},activation:function(c){if(c.is(":checked")){c.parent().next().removeClass("deactivated")}else{c.parent().next().addClass("deactivated")}},readmore:function(c){c.parents(".bs-field-description").find(".bs-extended-content").slideToggle(400,function(){if(b(this).is(":visible")){c.text("Less...")}else{c.text("More...")}})},postbox:function(c){b(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles(c.data("page"))},init:function(){var c=this;this.container.find(".bs-slider-wrap").each(function(){c.slider(b(this))});this.container.find(".bs-field.bs-radio .bs-has-image input:checked:enabled").closest("label").addClass("selected");this.container.find('.bs-field.bs-activation input[type="checkbox"]').each(function(){c.activation(b(this))});if((typeof postboxes!="undefined")&&this.container.hasClass("bs-options")){this.postbox(this.container)}},listen:function(){var c=this;this.container.on("click",".bs-checkbox-label",function(d){c.checkboxLabelToggle(b(this))});this.container.on("click",".bs-field.bs-radio label",function(d){c.imageradio(b(this))});this.container.on("click",'.bs-field.bs-activation input[type="checkbox"]',function(){c.activation(b(this))});this.container.on("click",".bs-read-more",function(d){d.preventDefault();c.readmore(b(this))});this.container.on("click",'[name="beans_reset_options"]',function(d){return confirm("Are you sure you would like to reset?")})}};b.fn.beansFields=function(c){return this.each(function(){if(!b.data(this,"plugin_beansFields")){b.data(this,"plugin_beansFields",new a(this,c))}})};b(document).ready(function(c){c("#edittag, #post-body, .bs-options").beansFields();if(wp.customize!==undefined){wp.customize.bind("ready",function(){c("#customize-controls").beansFields()})}})})(window.jQuery); \ No newline at end of file +!function(a){"use strict";var t=function(e,t){this.container=a(e),this.init(),this.listen()};t.prototype={constructor:t,checkboxLabelToggle:function(e){e.parent().find('input[type="checkbox"]').click()},imageradio:function(e){e.closest("fieldset").find("label").removeClass("selected"),e.closest("label.bs-has-image").addClass("selected")},slider:function(e){var t=parseInt(e.find("input[type=text]").val()),i=parseInt(e.attr("slider_min")),n=parseInt(e.attr("slider_max")),s=parseInt(e.attr("slider_interval"));e.slider({range:"min",value:t,min:i,max:n,step:s,slide:function(e,t){a(this).parent().find(".bs-slider-value").text(t.value);var i=a(this).find("input[type=text]");i.attr("value",t.value),i.trigger("change")}}),e.find(".ui-slider-handle").removeAttr("href")},activation:function(e){e.is(":checked")?e.parent().next().removeClass("deactivated"):e.parent().next().addClass("deactivated")},readmore:function(e){e.parents(".bs-field-description").find(".bs-extended-content").slideToggle(400,function(){a(this).is(":visible")?e.text("Less..."):e.text("More...")})},postbox:function(e){a(".if-js-closed").removeClass("if-js-closed").addClass("closed"),postboxes.add_postbox_toggles(e.data("page"))},init:function(){var e=this;this.container.find(".bs-slider-wrap").each(function(){e.slider(a(this))}),this.container.find(".bs-field.bs-radio .bs-has-image input:checked:enabled").closest("label").addClass("selected"),this.container.find('.bs-field.bs-activation input[type="checkbox"]').each(function(){e.activation(a(this))}),"undefined"!=typeof postboxes&&this.container.hasClass("bs-options")&&this.postbox(this.container)},listen:function(){var t=this;this.container.on("click",".bs-checkbox-label",function(e){t.checkboxLabelToggle(a(this))}),this.container.on("click",".bs-field.bs-radio label",function(e){t.imageradio(a(this))}),this.container.on("click",'.bs-field.bs-activation input[type="checkbox"]',function(){t.activation(a(this))}),this.container.on("click",".bs-read-more",function(e){e.preventDefault(),t.readmore(a(this))}),this.container.on("click",'[name="beans_reset_options"]',function(e){return confirm("Are you sure you would like to reset?")})}},a.fn.beansFields=function(e){return this.each(function(){a.data(this,"plugin_beansFields")||a.data(this,"plugin_beansFields",new t(this,e))})},a(document).ready(function(e){e("#edittag, #post-body, .bs-options").beansFields(),void 0!==wp.customize&&wp.customize.bind("ready",function(){e("#customize-controls").beansFields()})})}(window.jQuery); \ No newline at end of file From 25edf039c027f23c09b0cf6de1a338d6800e240b Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 18:33:00 -0500 Subject: [PATCH 763/800] Switched to update slider field's attr value. Why? It's difficult to debug issues when the text input field's `value` attribute does not update. Switched from `.val( ui.value )` to `.attr( 'value', ui.value )`. Lovely. So helpful to see the value as it changes...right in the DOM on the text input. --- lib/api/fields/assets/js/fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/fields/assets/js/fields.js b/lib/api/fields/assets/js/fields.js index 5c8732e7..c1302ef7 100644 --- a/lib/api/fields/assets/js/fields.js +++ b/lib/api/fields/assets/js/fields.js @@ -37,7 +37,7 @@ // Update text hidden input. Then trigger the change. var sliderField = $(this).find( 'input[type=text]' ); - sliderField.val( ui.value ); + sliderField.attr( 'value', ui.value ); sliderField.trigger( 'change' ); } }); From c36d3b84cd573fb11f8d214efe93e0ce4959f699 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 18:47:10 -0500 Subject: [PATCH 764/800] Improved wp-customize-preview script. 1. Fixed the formatting. 2. Cached the wp.customize into an `api` variable. 3. Fixed the `this` bindings. 4. Added function DocBlocks. Tested on WordPress 4.2.20 and up to 4.9.6. --- lib/admin/assets/js/wp-customize-preview.js | 75 ++++++++++----------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/lib/admin/assets/js/wp-customize-preview.js b/lib/admin/assets/js/wp-customize-preview.js index 4ec4b253..c1822440 100644 --- a/lib/admin/assets/js/wp-customize-preview.js +++ b/lib/admin/assets/js/wp-customize-preview.js @@ -1,39 +1,50 @@ -!(function($) { - - "use strict"; +!(function( $, api ) { + 'use strict'; var beansWpCustomize = function() { - this.wpIframe = $( '#customize-preview iframe', window.parent.document.body ); this.init(); this.listen(); - } beansWpCustomize.prototype = { - constructor: beansWpCustomize, - viewportWidth: function() { + /** + * Viewport width adjustment handler. Sets the previewer's width. + * + * @since 1.0.0 + */ + viewportWidth: function() { - if ( true == wp.customize.value( 'beans_enable_viewport_width' )() ) { - this.wpIframe.css( 'width', wp.customize.value( 'beans_viewport_width' )() ); + if ( true === api.value( 'beans_enable_viewport_width' )() ) { + this.wpIframe.css( 'width', api.value( 'beans_viewport_width' )() ); } else { this.wpIframe.css( 'width', '100%' ); } - }, + + /** + * Viewport height adjustment handler. Sets the previewer's height. + * + * @since 1.0.0 + */ viewportHeight: function() { - if ( true == wp.customize.value( 'beans_enable_viewport_height' )() ) { - this.wpIframe.css( 'height', wp.customize.value( 'beans_viewport_height' )() ); + if ( true === api.value( 'beans_enable_viewport_height' )() ) { + this.wpIframe.css( 'height', api.value( 'beans_viewport_height' )() ); } else { this.wpIframe.css( 'height', '100%' ); } }, - init: function() { + /** + * Initialize. + * + * @since 1.0.0 + */ + init: function() { this.wpIframe.css( { 'position': 'absolute', 'margin': 'auto', @@ -44,41 +55,27 @@ this.viewportWidth(); this.viewportHeight(); - }, - listen: function() { - - var that = this; - - // Fire viewport width. - wp.customize.value( 'beans_enable_viewport_width' ).bind( function( to ) { - that.viewportWidth(); - } ); + /** + * Listens for change events on the fields. + * + * @since 1.5.0 + */ + listen: function() { // Fire viewport width. - wp.customize.value( 'beans_viewport_width' ).bind( function( to ) { - that.viewportWidth(); - } ); - - // Fire viewport height. - wp.customize.value( 'beans_enable_viewport_height' ).bind( function( to ) { - that.viewportHeight(); - } ); + api.value( 'beans_enable_viewport_width' ).bind( this.viewportWidth.bind( this ) ); + api.value( 'beans_viewport_width' ).bind( this.viewportWidth.bind( this ) ); // Fire viewport height. - wp.customize.value( 'beans_viewport_height' ).bind( function( to ) { - that.viewportHeight(); - } ); - + api.value( 'beans_enable_viewport_height' ).bind( this.viewportHeight.bind( this ) ); + api.value( 'beans_viewport_height' ).bind( this.viewportHeight.bind( this ) ); } - }; // Fire the plugin. - $(document).ready(function($) { - + $(document).ready(function() { new beansWpCustomize(); - }); -})( window.jQuery ); +})( window.jQuery, wp.customize ); From a34957a78bce941a1620ac02b4847f3f364d67d8 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 19:08:07 -0500 Subject: [PATCH 765/800] Added label to each activation field. Added description for each group. This change helps users to understand what the activation field does. But it also fixes the problem of the slider jumping down on WordPress < 4.3. Partial fix for bug #260. --- lib/admin/wp-customize.php | 49 ++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index ccd66604..ca08d03f 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -16,7 +16,10 @@ * @return void */ function beans_do_enqueue_wp_customize_assets() { - wp_enqueue_script( 'beans-wp-customize-preview', BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', array( 'jquery', 'customize-preview' ), BEANS_VERSION, true ); + wp_enqueue_script( 'beans-wp-customize-preview', BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', array( + 'jquery', + 'customize-preview', + ), BEANS_VERSION, true ); } beans_add_smart_action( 'customize_register', 'beans_do_register_wp_customize_options' ); @@ -67,42 +70,46 @@ function beans_do_register_wp_customize_options() { array( 'id' => 'beans_viewport_width_group', 'label' => __( 'Viewport Width', 'tm-beans' ), + 'description' => __( 'Slide left or right to change the viewport width.', 'tm-beans' ), 'type' => 'group', 'fields' => array( array( - 'id' => 'beans_enable_viewport_width', - 'type' => 'activation', - 'default' => false, + 'id' => 'beans_enable_viewport_width', + 'label' => __( 'Enable changing of the viewport width.', 'tm-beans' ), + 'type' => 'activation', + 'default' => false, ), array( - 'id' => 'beans_viewport_width', - 'type' => 'slider', - 'default' => 1000, - 'min' => 300, - 'max' => 2500, - 'interval' => 10, - 'unit' => 'px', + 'id' => 'beans_viewport_width', + 'type' => 'slider', + 'default' => 1000, + 'min' => 300, + 'max' => 2500, + 'interval' => 10, + 'unit' => 'px', ), ), ), array( 'id' => 'beans_viewport_height_group', 'label' => __( 'Viewport Height', 'tm-beans' ), + 'description' => __( 'Slide left or right to change the viewport height.', 'tm-beans' ), 'type' => 'group', 'fields' => array( array( - 'id' => 'beans_enable_viewport_height', - 'type' => 'activation', - 'default' => false, + 'id' => 'beans_enable_viewport_height', + 'label' => __( 'Enable changing of the viewport height.', 'tm-beans' ), + 'type' => 'activation', + 'default' => false, ), array( - 'id' => 'beans_viewport_height', - 'type' => 'slider', - 'default' => 1000, - 'min' => 300, - 'max' => 2500, - 'interval' => 10, - 'unit' => 'px', + 'id' => 'beans_viewport_height', + 'type' => 'slider', + 'default' => 1000, + 'min' => 300, + 'max' => 2500, + 'interval' => 10, + 'unit' => 'px', ), ), ), From 9ef8848c524a6da0879f1d64a42f3f8aeffbe77a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 19:31:55 -0500 Subject: [PATCH 766/800] Improved customize preview script to use preferred binding to Customizer. All examples from Weston shows to use the new bindings vs. using `.value()`. To keep with his guidance, this commit switches the script to this preferred method. Tested on WordPress 4.2.20 up to 4.9.6. --- lib/admin/assets/js/wp-customize-preview.js | 35 ++++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/admin/assets/js/wp-customize-preview.js b/lib/admin/assets/js/wp-customize-preview.js index c1822440..7674e472 100644 --- a/lib/admin/assets/js/wp-customize-preview.js +++ b/lib/admin/assets/js/wp-customize-preview.js @@ -16,12 +16,13 @@ * @since 1.0.0 */ viewportWidth: function() { + var newWidth = '100%'; - if ( true === api.value( 'beans_enable_viewport_width' )() ) { - this.wpIframe.css( 'width', api.value( 'beans_viewport_width' )() ); - } else { - this.wpIframe.css( 'width', '100%' ); + if ( true === api( 'beans_enable_viewport_width' ).get() ) { + newWidth = api( 'beans_viewport_width' ).get(); } + + this.wpIframe.css( 'width', newWidth ); }, /** @@ -30,13 +31,13 @@ * @since 1.0.0 */ viewportHeight: function() { + var newHeight = '100%'; - if ( true === api.value( 'beans_enable_viewport_height' )() ) { - this.wpIframe.css( 'height', api.value( 'beans_viewport_height' )() ); - } else { - this.wpIframe.css( 'height', '100%' ); + if ( true === api( 'beans_enable_viewport_height' ).get() ) { + newHeight = api( 'beans_viewport_height' ).get(); } + this.wpIframe.css( 'height', newHeight ); }, /** @@ -63,13 +64,23 @@ * @since 1.5.0 */ listen: function() { + var that = this; + // Fire viewport width. - api.value( 'beans_enable_viewport_width' ).bind( this.viewportWidth.bind( this ) ); - api.value( 'beans_viewport_width' ).bind( this.viewportWidth.bind( this ) ); + api( 'beans_enable_viewport_width', function( setting ) { + setting.bind( that.viewportWidth.bind(that) ); + } ); + api( 'beans_viewport_width', function( setting ) { + setting.bind( that.viewportWidth.bind(that) ); + } ); // Fire viewport height. - api.value( 'beans_enable_viewport_height' ).bind( this.viewportHeight.bind( this ) ); - api.value( 'beans_viewport_height' ).bind( this.viewportHeight.bind( this ) ); + api( 'beans_enable_viewport_height', function( setting ) { + setting.bind( that.viewportHeight.bind(that) ); + } ); + api( 'beans_viewport_height', function( setting ) { + setting.bind( that.viewportHeight.bind(that) ); + } ); } }; From fe5c5f2816f0857ca5f44ca49bc0ed1269caf5bc Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 19:46:39 -0500 Subject: [PATCH 767/800] Fixed formatting. --- lib/admin/wp-customize.php | 60 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index ca08d03f..4c621f1e 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -68,48 +68,48 @@ function beans_do_register_wp_customize_options() { $fields = array( array( - 'id' => 'beans_viewport_width_group', - 'label' => __( 'Viewport Width', 'tm-beans' ), + 'id' => 'beans_viewport_width_group', + 'label' => __( 'Viewport Width', 'tm-beans' ), 'description' => __( 'Slide left or right to change the viewport width.', 'tm-beans' ), - 'type' => 'group', - 'fields' => array( + 'type' => 'group', + 'fields' => array( array( - 'id' => 'beans_enable_viewport_width', - 'label' => __( 'Enable changing of the viewport width.', 'tm-beans' ), - 'type' => 'activation', - 'default' => false, + 'id' => 'beans_enable_viewport_width', + 'label' => __( 'Enable changing of the viewport width.', 'tm-beans' ), + 'type' => 'activation', + 'default' => false, ), array( - 'id' => 'beans_viewport_width', - 'type' => 'slider', - 'default' => 1000, - 'min' => 300, - 'max' => 2500, - 'interval' => 10, - 'unit' => 'px', + 'id' => 'beans_viewport_width', + 'type' => 'slider', + 'default' => 1000, + 'min' => 300, + 'max' => 2500, + 'interval' => 10, + 'unit' => 'px', ), ), ), array( - 'id' => 'beans_viewport_height_group', - 'label' => __( 'Viewport Height', 'tm-beans' ), + 'id' => 'beans_viewport_height_group', + 'label' => __( 'Viewport Height', 'tm-beans' ), 'description' => __( 'Slide left or right to change the viewport height.', 'tm-beans' ), - 'type' => 'group', - 'fields' => array( + 'type' => 'group', + 'fields' => array( array( - 'id' => 'beans_enable_viewport_height', - 'label' => __( 'Enable changing of the viewport height.', 'tm-beans' ), - 'type' => 'activation', - 'default' => false, + 'id' => 'beans_enable_viewport_height', + 'label' => __( 'Enable changing of the viewport height.', 'tm-beans' ), + 'type' => 'activation', + 'default' => false, ), array( - 'id' => 'beans_viewport_height', - 'type' => 'slider', - 'default' => 1000, - 'min' => 300, - 'max' => 2500, - 'interval' => 10, - 'unit' => 'px', + 'id' => 'beans_viewport_height', + 'type' => 'slider', + 'default' => 1000, + 'min' => 300, + 'max' => 2500, + 'interval' => 10, + 'unit' => 'px', ), ), ), From 1615df47d7f968e732d1c188fbd3edb43978ca01 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 19:54:59 -0500 Subject: [PATCH 768/800] Added notes for preview only in labels and descriptions. --- lib/admin/wp-customize.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index 4c621f1e..8dd3fe8f 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -69,13 +69,13 @@ function beans_do_register_wp_customize_options() { $fields = array( array( 'id' => 'beans_viewport_width_group', - 'label' => __( 'Viewport Width', 'tm-beans' ), - 'description' => __( 'Slide left or right to change the viewport width.', 'tm-beans' ), + 'label' => __( 'Viewport Width - for Previewing Only', 'tm-beans' ), + 'description' => __( 'Slide left or right to change the viewport width. Publishing will not change the height of your website.', 'tm-beans' ), 'type' => 'group', 'fields' => array( array( 'id' => 'beans_enable_viewport_width', - 'label' => __( 'Enable changing of the viewport width.', 'tm-beans' ), + 'label' => __( 'Enable to change the viewport width.', 'tm-beans' ), 'type' => 'activation', 'default' => false, ), @@ -92,13 +92,13 @@ function beans_do_register_wp_customize_options() { ), array( 'id' => 'beans_viewport_height_group', - 'label' => __( 'Viewport Height', 'tm-beans' ), - 'description' => __( 'Slide left or right to change the viewport height.', 'tm-beans' ), + 'label' => __( 'Viewport Height - for Previewing Only', 'tm-beans' ), + 'description' => __( 'Slide left or right to change the viewport height. Publishing will not change the height of your website.', 'tm-beans' ), 'type' => 'group', 'fields' => array( array( 'id' => 'beans_enable_viewport_height', - 'label' => __( 'Enable changing of the viewport height.', 'tm-beans' ), + 'label' => __( 'Enable to change the viewport height.', 'tm-beans' ), 'type' => 'activation', 'default' => false, ), From c6a174f60b8442a08a8a7a9e94721f034e5089d9 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 20:30:33 -0500 Subject: [PATCH 769/800] Fixed typo in label. --- lib/admin/wp-customize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index 8dd3fe8f..d0322b88 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -70,7 +70,7 @@ function beans_do_register_wp_customize_options() { array( 'id' => 'beans_viewport_width_group', 'label' => __( 'Viewport Width - for Previewing Only', 'tm-beans' ), - 'description' => __( 'Slide left or right to change the viewport width. Publishing will not change the height of your website.', 'tm-beans' ), + 'description' => __( 'Slide left or right to change the viewport width. Publishing will not change the width of your website.', 'tm-beans' ), 'type' => 'group', 'fields' => array( array( From a70ccd32af6a7711a7205045e2bcdd0c00177e7a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Wed, 20 Jun 2018 20:48:44 -0500 Subject: [PATCH 770/800] Updated pot file from Customizer fix. --- lib/languages/tm-beans.pot | 43 ++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/lib/languages/tm-beans.pot b/lib/languages/tm-beans.pot index 436147ee..54cc9f88 100644 --- a/lib/languages/tm-beans.pot +++ b/lib/languages/tm-beans.pot @@ -3,7 +3,7 @@ msgid "" msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" "Project-Id-Version: Beans v.1.5.0-beta\n" -"POT-Creation-Date: 2018-06-20 08:14-0500\n" +"POT-Creation-Date: 2018-06-20 20:46-0500\n" "PO-Revision-Date: 2018-06-20 08:10-0500\n" "Last-Translator: \n" "Language-Team: Beans Team\n" @@ -11,7 +11,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.0.8\n" -"X-Poedit-Basepath: ..\n" +"X-Poedit-Basepath: ../..\n" "X-Poedit-Flags-xgettext: --add-comments=translators:\n" "X-Poedit-WPHeader: style.css\n" "X-Poedit-SourceCharset: UTF-8\n" @@ -20,8 +20,9 @@ msgstr "" "_nx_noop:3c,1,2;__ngettext_noop:1,2\n" "X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPathExcluded-0: *.js\n" -"X-Poedit-SearchPathExcluded-1: vendor\n" +"X-Poedit-SearchPathExcluded-1: bin\n" "X-Poedit-SearchPathExcluded-2: tests\n" +"X-Poedit-SearchPathExcluded-3: vendor\n" #: lib/admin/options.php:30 msgctxt "term meta" @@ -37,27 +38,47 @@ msgstr "" msgid "Post Options" msgstr "" -#: lib/admin/wp-customize.php:34 +#: lib/admin/wp-customize.php:37 msgid "Logo Image" msgstr "" -#: lib/admin/wp-customize.php:39 +#: lib/admin/wp-customize.php:42 msgid "Branding" msgstr "" -#: lib/admin/wp-customize.php:49 lib/admin/wp-customize.php:60 +#: lib/admin/wp-customize.php:52 lib/admin/wp-customize.php:63 msgid "Default Layout" msgstr "" -#: lib/admin/wp-customize.php:69 -msgid "Viewport Width" +#: lib/admin/wp-customize.php:72 +msgid "Viewport Width - for Previewing Only" msgstr "" -#: lib/admin/wp-customize.php:90 -msgid "Viewport Height" +#: lib/admin/wp-customize.php:73 +msgid "" +"Slide left or right to change the viewport width. Publishing will not change " +"the width of your website." +msgstr "" + +#: lib/admin/wp-customize.php:78 +msgid "Enable to change the viewport width." +msgstr "" + +#: lib/admin/wp-customize.php:95 +msgid "Viewport Height - for Previewing Only" +msgstr "" + +#: lib/admin/wp-customize.php:96 +msgid "" +"Slide left or right to change the viewport height. Publishing will not " +"change the height of your website." +msgstr "" + +#: lib/admin/wp-customize.php:101 +msgid "Enable to change the viewport height." msgstr "" -#: lib/admin/wp-customize.php:115 +#: lib/admin/wp-customize.php:122 msgid "Preview Tools" msgstr "" From c55d5ab234e31b6f2c2d61b1051f8023cea9781f Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 17:51:37 +0200 Subject: [PATCH 771/800] Updated array syntax of test for filters API. (PR #265) --- .../api/filters/beansAddAnonymousFilter.php | 8 ++-- .../api/filters/beansAddFilter.php | 4 +- .../api/filters/beansApplyFilters.php | 10 ++-- .../api/filters/fixtures/test-filters.php | 24 +++++----- .../includes/class-filters-test-case.php | 4 +- .../beans-anonymous-filters/_construct.php | 6 +-- .../unit/api/filters/beansAddFilter.php | 4 +- .../unit/api/filters/beansApplyFilters.php | 48 +++++++++---------- .../api/filters/fixtures/test-filters.php | 24 +++++----- .../includes/class-filters-test-case.php | 6 +-- 10 files changed, 69 insertions(+), 69 deletions(-) diff --git a/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php b/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php index 2a4ef7a3..a60b5527 100644 --- a/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php +++ b/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php @@ -29,7 +29,7 @@ public function test_should_store_callback() { $this->assertSame( 'foo', $object->value_to_return ); // Clean up. - remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + remove_action( 'do_foo', [ $object, 'callback' ], 20 ); } /** @@ -38,10 +38,10 @@ public function test_should_store_callback() { public function test_should_register_callback_to_hook() { $object = _beans_add_anonymous_filter( 'do_foo', false, 20 ); - $this->assertTrue( has_filter( 'do_foo', array( $object, 'callback' ) ) !== false ); + $this->assertTrue( has_filter( 'do_foo', [ $object, 'callback' ] ) !== false ); // Clean up. - remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + remove_action( 'do_foo', [ $object, 'callback' ], 20 ); } /** @@ -54,7 +54,7 @@ public function test_should_call_callback() { $this->assertSame( $value, apply_filters( 'beans_test_do_foo', 'foo' ) ); // Clean up. - remove_action( 'beans_test_do_foo', array( $object, 'callback' ), 20 ); + remove_action( 'beans_test_do_foo', [ $object, 'callback' ], 20 ); } } } diff --git a/tests/phpunit/integration/api/filters/beansAddFilter.php b/tests/phpunit/integration/api/filters/beansAddFilter.php index 9e046ffa..c0fbca4e 100644 --- a/tests/phpunit/integration/api/filters/beansAddFilter.php +++ b/tests/phpunit/integration/api/filters/beansAddFilter.php @@ -68,10 +68,10 @@ public function test_should_add_anonymous_filter() { $this->assertSame( $filter['value_to_return'], $object->value_to_return ); // Check that the filter was registered. - $this->assertTrue( has_filter( $filter['hook'], array( $object, 'callback' ) ) !== false ); + $this->assertTrue( has_filter( $filter['hook'], [ $object, 'callback' ] ) !== false ); // Clean up. - remove_filter( $filter['hook'], array( $object, 'callback' ), $filter['priority'] ); + remove_filter( $filter['hook'], [ $object, 'callback' ], $filter['priority'] ); } } } diff --git a/tests/phpunit/integration/api/filters/beansApplyFilters.php b/tests/phpunit/integration/api/filters/beansApplyFilters.php index 42497e0e..e1d112b0 100644 --- a/tests/phpunit/integration/api/filters/beansApplyFilters.php +++ b/tests/phpunit/integration/api/filters/beansApplyFilters.php @@ -26,10 +26,10 @@ class Tests_BeansApplyFilters extends Filters_Test_Case { * Test beans_apply_filters() should return value after calling the hook with no sub-hook. */ public function test_should_return_value_after_calling_hook_no_subhook() { - $filters = array( + $filters = [ 'beans_field_description_markup', 'beans_widget_content_categories_output', - ); + ]; foreach ( $filters as $filter ) { $this->assertSame( 'foo', beans_apply_filters( $filter, 'foo' ) ); @@ -43,7 +43,7 @@ public function test_should_return_value_after_calling_one_level_of_sub_hooks() add_filter( 'beans_test_query_args', 'beans_test_query_args_base' ); add_filter( 'beans_test_query_args[_main]', 'beans_test_query_args_main' ); - $this->assertSame( array( 'base', '_main' ), beans_apply_filters( 'beans_test_query_args[_main]', 'foo' ) ); + $this->assertSame( [ 'base', '_main' ], beans_apply_filters( 'beans_test_query_args[_main]', 'foo' ) ); } /** @@ -62,7 +62,7 @@ public function test_should_return_value_after_calling_two_levels_of_sub_hooks() } ); $this->assertSame( - array( 'base', '_main', '_second', '[_main][_second]' ), + [ 'base', '_main', '_second', '[_main][_second]' ], beans_apply_filters( 'beans_test_query_args[_main][_second]', 'foo' ) ); } @@ -91,7 +91,7 @@ public function test_should_return_value_after_calling_three_levels_of_sub_hooks } ); $this->assertSame( - array( 'base', '_main', '_second', '[_main][_second]', '_third', '[_main][_second][_third]' ), + [ 'base', '_main', '_second', '[_main][_second]', '_third', '[_main][_second][_third]' ], beans_apply_filters( 'beans_test_query_args[_main][_second][_third]', 'foo' ) ); } diff --git a/tests/phpunit/integration/api/filters/fixtures/test-filters.php b/tests/phpunit/integration/api/filters/fixtures/test-filters.php index 53272d51..701a7241 100644 --- a/tests/phpunit/integration/api/filters/fixtures/test-filters.php +++ b/tests/phpunit/integration/api/filters/fixtures/test-filters.php @@ -7,35 +7,35 @@ * @since 1.5.0 */ -return array( - 'beans_field_description_markup' => array( +return [ + 'beans_field_description_markup' => [ 'hook' => 'beans_field_description_markup', 'value_to_return' => 'p', 'priority' => 10, 'args' => 1, - ), - 'beans_widget_content_categories_output' => array( + ], + 'beans_widget_content_categories_output' => [ 'hook' => 'beans_widget_content_categories_output', 'callback' => 'beans_test_modify_widget_count', 'priority' => 10, 'args' => 1, - ), - 'beans_test_query_args' => array( + ], + 'beans_test_query_args' => [ 'hook' => 'beans_test_query_args', 'callback' => 'beans_test_query_args_base', 'priority' => 20, 'args' => 1, - ), - 'beans_test_query_args[_main]' => array( + ], + 'beans_test_query_args[_main]' => [ 'hook' => 'beans_test_query_args[_main]', 'callback' => 'beans_test_query_args_main', 'priority' => 20, 'args' => 1, - ), - 'the_content' => array( + ], + 'the_content' => [ 'hook' => 'the_content', 'callback' => 'beans_test_the_content', 'priority' => 20, 'args' => 2, - ), -); + ], +]; diff --git a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php index a116fa01..c8508603 100644 --- a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php @@ -89,7 +89,7 @@ protected function check_parameters_registered_in_wp( array $filter, $remove_fil * Create a post, load it, and force the "template redirect" to fire. */ protected function go_to_post() { - $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); + $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); $this->go_to( get_permalink( $post_id ) ); do_action( 'template_redirect' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Valid use case as we need to fire this action as part of our tests. } @@ -102,7 +102,7 @@ protected function mock_filter_callbacks() { return $post_title . '_' . $post_id; } ); Monkey\Functions\when( 'beans_test_modify_widget_count' )->justReturn( 20 ); - Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( array( 'base' ) ); + Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( [ 'base' ] ); Monkey\Functions\when( 'beans_test_query_args_main' )->alias( function ( $args ) { $args[] = '_main'; return $args; diff --git a/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php b/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php index 66790f29..1ab56794 100644 --- a/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php +++ b/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php @@ -39,7 +39,7 @@ public function test_should_store_callback() { $this->assertSame( 'foo', $object->value_to_return ); // Clean up. - remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + remove_action( 'do_foo', [ $object, 'callback' ], 20 ); } /** @@ -48,9 +48,9 @@ public function test_should_store_callback() { public function test_should_register_callback_to_hook() { $object = new _Beans_Anonymous_Filters( 'do_foo', false, 20 ); - $this->assertTrue( has_filter( 'do_foo', array( $object, 'callback' ) ) !== false ); + $this->assertTrue( has_filter( 'do_foo', [ $object, 'callback' ] ) !== false ); // Clean up. - remove_action( 'do_foo', array( $object, 'callback' ), 20 ); + remove_action( 'do_foo', [ $object, 'callback' ], 20 ); } } diff --git a/tests/phpunit/unit/api/filters/beansAddFilter.php b/tests/phpunit/unit/api/filters/beansAddFilter.php index 28d2a6d0..64c7c465 100644 --- a/tests/phpunit/unit/api/filters/beansAddFilter.php +++ b/tests/phpunit/unit/api/filters/beansAddFilter.php @@ -65,10 +65,10 @@ public function test_should_add_anonymous_filter() { $this->assertSame( $filter['value_to_return'], $object->value_to_return ); // Check that the filter was registered. - $this->assertTrue( has_filter( $filter['hook'], array( $object, 'callback' ) ) !== false ); + $this->assertTrue( has_filter( $filter['hook'], [ $object, 'callback' ] ) !== false ); // Clean up. - remove_filter( $filter['hook'], array( $object, 'callback' ), $filter['priority'] ); + remove_filter( $filter['hook'], [ $object, 'callback' ], $filter['priority'] ); } } } diff --git a/tests/phpunit/unit/api/filters/beansApplyFilters.php b/tests/phpunit/unit/api/filters/beansApplyFilters.php index 76cb3a19..913fd6a3 100644 --- a/tests/phpunit/unit/api/filters/beansApplyFilters.php +++ b/tests/phpunit/unit/api/filters/beansApplyFilters.php @@ -27,12 +27,12 @@ class Tests_BeansApplyFilters extends Filters_Test_Case { * Test beans_apply_filters() should return value after calling the hook with no sub-hook. */ public function test_should_return_value_after_calling_hook_no_subhook() { - $filters = array( + $filters = [ 'beans_field_description_markup', 'the_content', 'post_title', 'beans_widget_content_categories_output', - ); + ]; foreach ( $filters as $filter ) { $this->assertSame( 'foo', beans_apply_filters( $filter, 'foo' ) ); @@ -43,24 +43,24 @@ public function test_should_return_value_after_calling_hook_no_subhook() { * Test beans_apply_filters() should return value after calling one level of sub-hooks. */ public function test_should_return_value_after_calling_one_level_of_sub_hooks() { - $filters = array( - 'beans_loop_query_args[_main]' => array( + $filters = [ + 'beans_loop_query_args[_main]' => [ 'beans_loop_query_args', 'beans_loop_query_args[_main]', - ), - 'beans_loop_query_args[_foo]' => array( + ], + 'beans_loop_query_args[_foo]' => [ 'beans_loop_query_args', 'beans_loop_query_args[_foo]', - ), - 'beans_widgets_area_args[_sidebar_primary]' => array( + ], + 'beans_widgets_area_args[_sidebar_primary]' => [ 'beans_widgets_area_args', 'beans_widgets_area_args[_sidebar_primary]', - ), - 'beans_widgets_area_args[_offcanvas_menu]' => array( + ], + 'beans_widgets_area_args[_offcanvas_menu]' => [ 'beans_widgets_area_args', 'beans_widgets_area_args[_offcanvas_menu]', - ), - ); + ], + ]; foreach ( $filters as $filter => $events ) { @@ -80,20 +80,20 @@ public function test_should_return_value_after_calling_one_level_of_sub_hooks() * Test beans_apply_filters() should return value after calling two levels of sub-hooks. */ public function test_should_return_value_after_calling_two_levels_of_sub_hooks() { - $filters = array( - 'beans_loop_query_args[_first][_second]' => array( + $filters = [ + 'beans_loop_query_args[_first][_second]' => [ 'beans_loop_query_args', 'beans_loop_query_args[_first]', 'beans_loop_query_args[_second]', 'beans_loop_query_args[_first][_second]', - ), - 'beans_widgets_area_args[_first][_second]' => array( + ], + 'beans_widgets_area_args[_first][_second]' => [ 'beans_widgets_area_args', 'beans_widgets_area_args[_first]', 'beans_widgets_area_args[_second]', 'beans_widgets_area_args[_first][_second]', - ), - ); + ], + ]; foreach ( $filters as $filter => $events ) { @@ -113,24 +113,24 @@ public function test_should_return_value_after_calling_two_levels_of_sub_hooks() * Test beans_apply_filters() should return value after calling three levels of sub-hooks. */ public function test_should_return_value_after_calling_three_levels_of_sub_hooks() { - $filters = array( - 'beans_loop_query_args[_first][_second][_third]' => array( + $filters = [ + 'beans_loop_query_args[_first][_second][_third]' => [ 'beans_loop_query_args', 'beans_loop_query_args[_first]', 'beans_loop_query_args[_second]', 'beans_loop_query_args[_first][_second]', 'beans_loop_query_args[_third]', 'beans_loop_query_args[_first][_second][_third]', - ), - 'beans_widgets_area_args[_first][_second][_third]' => array( + ], + 'beans_widgets_area_args[_first][_second][_third]' => [ 'beans_widgets_area_args', 'beans_widgets_area_args[_first]', 'beans_widgets_area_args[_second]', 'beans_widgets_area_args[_first][_second]', 'beans_widgets_area_args[_third]', 'beans_widgets_area_args[_first][_second][_third]', - ), - ); + ], + ]; foreach ( $filters as $filter => $events ) { diff --git a/tests/phpunit/unit/api/filters/fixtures/test-filters.php b/tests/phpunit/unit/api/filters/fixtures/test-filters.php index 432f0f3f..81c19b31 100644 --- a/tests/phpunit/unit/api/filters/fixtures/test-filters.php +++ b/tests/phpunit/unit/api/filters/fixtures/test-filters.php @@ -7,35 +7,35 @@ * @since 1.5.0 */ -return array( - 'beans_field_description_markup' => array( +return [ + 'beans_field_description_markup' => [ 'hook' => 'beans_field_description_markup', 'value_to_return' => 'p', 'priority' => 10, 'args' => 1, - ), - 'beans_widget_content_categories_output' => array( + ], + 'beans_widget_content_categories_output' => [ 'hook' => 'beans_widget_content_categories_output', 'callback' => 'beans_test_modify_widget_count', 'priority' => 10, 'args' => 1, - ), - 'beans_test_query_args[_main]' => array( + ], + 'beans_test_query_args[_main]' => [ 'hook' => 'beans_test_query_args[_main]', 'callback' => 'beans_test_query_args_base', 'priority' => 20, 'args' => 1, - ), - 'beans_test_query_args[_main]' => array( + ], + 'beans_test_query_args[_main]' => [ 'hook' => 'beans_test_query_args[_main]', 'callback' => 'beans_test_query_args_main', 'priority' => 20, 'args' => 1, - ), - 'the_content' => array( + ], + 'the_content' => [ 'hook' => 'the_content', 'callback' => 'beans_test_the_content', 'priority' => 20, 'args' => 2, - ), -); + ], +]; diff --git a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php index 257e9462..f7350b2d 100644 --- a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php @@ -43,9 +43,9 @@ protected function setUp() { $this->mock_filter_callbacks(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/filters/functions.php', - ) ); + ] ); } /** @@ -73,7 +73,7 @@ protected function mock_filter_callbacks() { return $post_title . '_' . $post_id; } ); Monkey\Functions\when( 'beans_test_modify_widget_count' )->justReturn( 20 ); - Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( array( 'base' ) ); + Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( [ 'base' ] ); Monkey\Functions\when( 'beans_test_query_args_main' )->alias( function ( $args ) { $args[] = '_main'; return $args; From 8f0a4f1375c73d743f42860acc14560bd1b9ab21 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 21 Jun 2018 11:58:03 -0500 Subject: [PATCH 772/800] Add CHANGELOG.md (PR #264) --- CHANGELOG.md | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..8de8b49a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,170 @@ +# Beans Changelog + +## 2018.06.21 - version 1.5.0-beta + +This pre-release includes security, web accessibility, code quality improvements, performance improvements, and bug fixes. The entire framework is now WPCS compliant. The APIs are now fully and thoroughly well-tested. All found issues are resolved. New functionality is added. + +### Improved +* Improved web accessibility by adding skip links, ARIA, labels, tabs, and more. +* Improved the performance of the APIs by reducing expensive processes, memory usage, and execution time. +* Improved the APIs by adding thorough unit and integration test suites. +* Improved the APIs by adding type hinting, reducing redundant code, and removing unused code. +* Improved Beans by making it WPCS compliant. +* Improved CSS compiler to have one block of declarations per line. +* Improved security by auditing and applying escaping and sanitizing best practices. +* Improved the Actions API by no longer storing actions in encoded strings. +* Improved code documentation and readability. + +### Updated +* Updated the language's tm-beans.pot file. +* Updated UIkit to version 2.27.5 (see [UIkit changelog](https://github.com/uikit/uikit/blob/v2/master/CHANGELOG.md#2275) for more information). + +### Added +* Added `beans_str_ends_with()` to check if the given string ends with the given substring(s). +* Added `beans_str_starts_with()` to check if the given string starts with the given substring(s). +* Added `beans_multi_array_key_exists()` to check if a key or index exists in a multi-dimensional array. +* Added `beans_join_arrays()` to join two arrays together. +* Added `beans_array_unique()` to remove duplicate values and re-index the array. +* Added `beans_join_arrays_clean()` to join two arrays, remove the duplicate values and empties, and provide an option to re-index the clean array. +* Added `beans_scandir()` to scan the given directory path, list all the files and directories, and remove the `.` and `..` files. +* Added `beans_uikit_get_all_components()` to check all of the UIkit components for the given type. +* Added `beans_uikit_get_all_dependencies()` to check all of the UIkit dependencies for the given component(s). +* Added `beans_get_widget_area_output()` to replace `beans_get_widget_area()`. +* Added `beans_add_compiler_options_to_settings()` to instantiate `_Beans_Compiler_Options` through a hook instead of on file load. +* Added `beans_add_page_assets_compiler()` to instantiate `__Beans_Page_Compiler` through a hook instead of on file load. +* Added `beans_add_image_options_to_settings()` to instantiate `___Beans_Image_Options` through a hook instead of on file load. +* Added `beans_has_primary_sidebar()` to check if the given layout has a primary sidebar. +* Added `beans_has_secondary_sidebar()` to check if the given layout has a secondary sidebar. +* Added `beans_skip_links_list()` to filter the skip links. +* Added `beans_output_skip_links()` to render the skip links. +* Added `beans_accessibility_skip_link_fix()` to enqueue skip link fix script for IE 11. +* Added many new private functions. + +### Changes +* `beans_add_action()` returns `false` when the action is not added via `add_action`. +* `beans_add_smart_action()` returns `false` when the action is not added via `add_action`. +* `beans_modify_action()` returns `false` when hook, callback, priority, and args are not given. +* `beans_modify_action_hook()` returns `false` when the hook is empty or not a string. +* `beans_modify_action_callback()` returns `false` when the callback is empty. +* `beans_replace_action()` returns `false` when hook, callback, priority, and args are not given. +* `beans_replace_action_hook()` returns `false` when the hook is empty or not a string. +* `beans_replace_action_callback()` returns `false` when the callback is empty. +* `beans_remove_action()` sets "removed" to the default when no current action exists. +* `beans_reset_action()` bails out if the action does not need to be reset. +* Unset the global variable in `beans_selfclose_markup()` to reduce memory usage. +* `beans_wrap_markup()` bails out and returns `false` if the given `$tag` is empty. +* `beans_wrap_inner_markup()` bails out and returns `false` if the given `$tag` is empty. +* `beans_add_attribute()` returns an instance of `_Beans_Attribute`. +* `beans_replace_attribute()` replaces all values when the `value` argument is empty. +* `beans_replace_attribute()` returns an instance of `_Beans_Attribute`. +* `beans_remove_attribute()` returns an instance of `_Beans_Attribute`. +* Moved the API's HTML to view files to improve code quality. +* Changes to private functions and methods are not noted here. + +### Fixed +* Fixed `depedencies` typo in Compiler's configuration (now `dependencies`). Provided fallback. +* Fixed Customizer Preview Tools. +* Fixed UIkit API bug when not returning all dependency components. +* Fixed Beans Image Editor for ARRAY_A. +* Fixed `beans_get_post_meta()`. +* Fixed `beans_get_term_meta()`. +* Fixed Compiler to recompile when a fragment changes and not in development mode. +* Fixed replacing action to remove from WordPress. +* Fixed Actions API to allow priority of 0 to be modified. +* Fixed Actions API double subhook calls. +* Fixed `beans_path_to_url()` to bail out when relative URL. +* Fixed count for `beans_count_recursive()`. +* Fixed removing tilde from `beans_url_to_path()`. +* Fixed processing relative URLs in `beans_url_to_path()`. +* Fixed altering of non-internal URLs in `beans_url_to_path()`. +* Fixed `beans_get_layout_class()` not returning correct classes when secondary is no longer registered. +* Fixed 'Next Post' icon close markup ID. +* Fixed 'Read More' icon markup IDs. +* Fixed `beans_get_widget_area()` to return `false` on fail. +* Fixed `beans_get_widget()` to return `false` on fail. +* Fixes to private functions and methods are not noted here. + +### Deprecated +* Deprecated `beans_count_recursive()` as it is unused in Beans. +* Deprecated `beans_widget_area()` by replacing it with a renamed function `beans_get_widget_area_output()` that better describes the expected behavior. +* Deprecated the image toolbar's dashicons' class attributes. + +## 2016.10.12 - version 1.4.0 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.4.0) for more information. + +## 2016.10.10 - version 1.4.0-rc + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.4.0-rc) for more information. + +## 2016.09.30 - version 1.4.0-beta + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.4.0-beta) for more information. + +## 2016.04.28 - version 1.3.1 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.3.1) for more information. + +## 2016.04.25 - version 1.3.1-rc2 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.3.1-rc2) for more information. + +## 2016.04.22 - version 1.3.1-rc + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.3.1-rc) for more information. + +## 2016.04.09 - version 1.3.1-beta + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.3.1-beta) for more information. + +## 2016.02.18 - version 1.3.0 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.3.0) for more information. + +## 2016.02.15 - version 1.3.0-rc + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.3.0-rc) for more information. + +## 2016.02.10 - version 1.3.0-beta + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.3.0-beta) for more information. + +## 2016.01.05 - version 1.2.5 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.2.5) for more information. + +## 2015.12.13 - version 1.2.4 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.2.4) for more information. + +## 2015.11.30 - version 1.2.3 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.2.3) for more information. + +## 2015.11.28 - version 1.2.2 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.2.2) for more information. + +## 2015.11.11 - version 1.2.1 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.2.1) for more information. + +## 2015.09.28 - version 1.2.0 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.2.0) for more information. + +## 2016.01.15 - version 1.2.0-rc + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.2.0-rc) for more information. + +## 2016.01.15 - version 1.2.0-beta + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.2.0-beta) for more information. + +## 2015.09.08- version 1.1.2 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.1.2) for more information. + +## 2015.09.08- version 1.1.1 + +See the [release changelog](https://github.com/Getbeans/Beans/releases/tag/1.1.1) for more information. \ No newline at end of file From 21182a4ded5dd6ac7ef5b96ac907f2ffa0983191 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 22:42:50 +0200 Subject: [PATCH 773/800] Updated array syntax for Fields API's tests. (PR #269) --- .../integration/api/fields/beansField.php | 34 +++++----- .../integration/api/fields/beansGetFields.php | 8 +-- .../api/fields/beansRegisterFields.php | 4 +- .../api/fields/fixtures/test-fields.php | 62 +++++++++---------- .../includes/class-fields-test-case.php | 6 +- .../api/fields/types/beansFieldActivation.php | 12 ++-- .../api/fields/types/beansFieldCheckbox.php | 16 ++--- .../fields/types/beansFieldDescription.php | 12 ++-- .../api/fields/types/beansFieldImage.php | 30 ++++----- .../api/fields/types/beansFieldLabel.php | 58 ++++++++--------- .../api/fields/types/beansFieldRadio.php | 28 ++++----- .../api/fields/types/beansFieldSelect.php | 20 +++--- .../api/fields/types/beansFieldSlider.php | 20 +++--- .../api/fields/types/beansFieldText.php | 12 ++-- .../api/fields/types/beansFieldTextarea.php | 12 ++-- .../api/fields/types/beansGetImageAlt.php | 8 +-- .../api/fields/types/beansGetImageUrl.php | 4 +- .../api/fields/types/beansIsRadioImage.php | 24 +++---- .../types/beansStandardizeRadioImage.php | 60 +++++++++--------- .../unit/api/fields/beansGetFields.php | 8 +-- .../unit/api/fields/beansRegisterFields.php | 4 +- .../unit/api/fields/fixtures/test-fields.php | 62 +++++++++---------- .../includes/class-fields-test-case.php | 10 +-- .../api/fields/types/beansFieldActivation.php | 12 ++-- .../api/fields/types/beansFieldCheckbox.php | 16 ++--- .../unit/api/fields/types/beansFieldImage.php | 14 ++--- .../unit/api/fields/types/beansFieldRadio.php | 28 ++++----- .../api/fields/types/beansFieldSelect.php | 20 +++--- .../api/fields/types/beansFieldSlider.php | 20 +++--- .../unit/api/fields/types/beansFieldText.php | 12 ++-- .../api/fields/types/beansFieldTextarea.php | 12 ++-- .../api/fields/types/beansGetImageUrl.php | 4 +- .../api/fields/types/beansIsRadioImage.php | 24 +++---- .../types/beansStandardizeRadioImage.php | 60 +++++++++--------- 34 files changed, 368 insertions(+), 368 deletions(-) diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 838678d6..102d05a7 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -50,13 +50,13 @@ public function test_should_render_checkbox_field() { // Set up the test. require_once BEANS_THEME_DIR . '/lib/api/fields/types/checkbox.php'; beans_add_smart_action( 'beans_field_checkbox', 'beans_field_checkbox' ); - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_styles', 'label' => false, 'checkbox_label' => 'Compile all WordPress styles', 'type' => 'checkbox', 'default' => false, - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -90,17 +90,17 @@ public function test_should_render_radio_field() { // Set up the test. require_once BEANS_THEME_DIR . '/lib/api/fields/types/radio.php'; beans_add_smart_action( 'beans_field_radio', 'beans_field_radio' ); - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_radio_test', 'label' => 'Having fun?', 'description' => 'Radio buttons', 'type' => 'radio', 'default' => 'no', - 'options' => array( + 'options' => [ 'no' => 'No', 'yes' => 'Yes', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -145,32 +145,32 @@ public function test_should_render_group_of_fields() { beans_add_smart_action( 'beans_field_select', 'beans_field_select' ); // Prepare the group of fields. - $group = $this->merge_field_with_default( array( + $group = $this->merge_field_with_default( [ 'id' => 'beans_group_test', 'label' => 'Group of fields', 'description' => 'This is a group of fields.', 'type' => 'group', 'context' => 'beans_group_tests', - 'fields' => array( - array( + 'fields' => [ + [ 'id' => 'beans_group_activation_test', 'label' => 'Activate Foo', 'type' => 'activation', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_group_select_test', 'label' => 'Select Foo', 'type' => 'select', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ), - ), - ) ); + ], + ], + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/beansGetFields.php b/tests/phpunit/integration/api/fields/beansGetFields.php index 3504eb84..9b1ba4c7 100644 --- a/tests/phpunit/integration/api/fields/beansGetFields.php +++ b/tests/phpunit/integration/api/fields/beansGetFields.php @@ -28,11 +28,11 @@ class Tests_BeansGetFields extends Fields_Test_Case { public function test_should_return_registered_fields() { foreach ( static::$test_data as $test_data ) { - $data_set = array( - 'beans_tests' => array( + $data_set = [ + 'beans_tests' => [ $test_data['section'] => $test_data['fields'], - ), - ); + ], + ]; // Register the fields first. $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); diff --git a/tests/phpunit/integration/api/fields/beansRegisterFields.php b/tests/phpunit/integration/api/fields/beansRegisterFields.php index 9848b122..7cb1ada1 100644 --- a/tests/phpunit/integration/api/fields/beansRegisterFields.php +++ b/tests/phpunit/integration/api/fields/beansRegisterFields.php @@ -27,8 +27,8 @@ class Tests_BeansRegisterFields extends Fields_Test_Case { * Test beans_register_fields() should return false when there are no fields. */ public function test_should_return_false_when_no_fields() { - $this->assertFalse( beans_register_fields( array(), '', '' ) ); - $this->assertFalse( beans_register_fields( array(), 'post_meta', 'tm-beans' ) ); + $this->assertFalse( beans_register_fields( [], '', '' ) ); + $this->assertFalse( beans_register_fields( [], 'post_meta', 'tm-beans' ) ); } /** diff --git a/tests/phpunit/integration/api/fields/fixtures/test-fields.php b/tests/phpunit/integration/api/fields/fixtures/test-fields.php index 84a33a75..1b5d6533 100644 --- a/tests/phpunit/integration/api/fields/fixtures/test-fields.php +++ b/tests/phpunit/integration/api/fields/fixtures/test-fields.php @@ -7,74 +7,74 @@ * @since 1.5.0 */ -return array( +return [ // Single fields. - 'single_fields' => array( - 'fields' => array( - array( + 'single_fields' => [ + 'fields' => [ + [ 'id' => 'beans_layout', 'label' => 'Layout', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', - ), - ), - array( + ], + ], + [ 'id' => 'beans_checkbox_test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_text_test', 'type' => 'text', 'default' => 'Testing the text field.', - ), - ), + ], + ], 'context' => 'tests', 'section' => 'tm-beans', - ), + ], // Group of fields. - 'group' => array( - 'fields' => array( - array( + 'group' => [ + 'fields' => [ + [ 'id' => 'beans_group_test', 'label' => 'Group of fields', 'description' => 'This is a group of fields.', 'type' => 'group', - 'fields' => array( - array( + 'fields' => [ + [ 'id' => 'beans_compile_all_scripts', 'type' => 'activation', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ), - array( + ], + ], + [ 'id' => 'beans_checkbox_test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - ), - ), - ), + ], + ], + ], + ], 'context' => 'group_tests', 'section' => 'tm-beans', - ), -); + ], +]; diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index b709657f..da4c0285 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -69,14 +69,14 @@ public function tearDown() { * @return array */ protected function merge_field_with_default( array $field, $set_value = true ) { - $field = array_merge( array( + $field = array_merge( [ 'label' => false, 'description' => false, 'default' => false, 'context' => 'beans_tests', - 'attributes' => array(), + 'attributes' => [], 'db_group' => false, - ), $field ); + ], $field ); $field['name'] = 'beans_fields[' . $field['id'] . ']'; if ( 'group' === $field['type'] ) { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php index 2c0460aa..ca2052d1 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php @@ -36,11 +36,11 @@ public function setUp() { * Test beans_field_activation() should render the activation field. */ public function test_should_render_activation_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_scripts', 'type' => 'activation', 'default' => false, - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -60,14 +60,14 @@ public function test_should_render_activation_field() { * Test beans_field_activation() should render the activation field with attributes when given. */ public function test_should_render_activation_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_scripts', 'type' => 'activation', 'default' => false, - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php index b3c21784..10d86c97 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php @@ -36,13 +36,13 @@ public function setUp() { * Test beans_field_checkbox() should render the checkbox with the label when given. */ public function test_should_render_checkbox_with_label_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_styles', 'label' => false, 'checkbox_label' => 'Compile all WordPress styles', 'type' => 'checkbox', 'default' => false, - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -62,11 +62,11 @@ public function test_should_render_checkbox_with_label_when_given() { * Test beans_field_checkbox() should render the checkbox with the default label when none is given. */ public function test_should_render_checkbox_with_default_label_when_none_is_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_styles', 'type' => 'checkbox', 'default' => false, - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -86,15 +86,15 @@ public function test_should_render_checkbox_with_default_label_when_none_is_give * Test beans_field_checkbox() should render the checkbox with attributes when given. */ public function test_should_render_checkbox_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_styles', 'checkbox_label' => 'Compile all WordPress styles', 'type' => 'checkbox', 'default' => false, - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php index a675df3e..eee8a65a 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php @@ -36,11 +36,11 @@ public function setUp() { * Test beans_field_description() should not render the field's description when none is given. */ public function test_should_not_render_field_description_when_none_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_text_test', 'type' => 'text', 'default' => '', - ) ); + ] ); $this->assertNull( beans_field_description( $field ) ); @@ -52,12 +52,12 @@ public function test_should_not_render_field_description_when_none_given() { * Test beans_field_description() should render the field's description. */ public function test_should_render_field_description() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_text_test', 'type' => 'text', 'description' => 'Testing the text field.', 'default' => '', - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -76,12 +76,12 @@ public function test_should_render_field_description() { * Test beans_field_description() should render the field's extended description. */ public function test_should_render_extended_description() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_text_test', 'type' => 'text', 'description' => 'Testing the text field.This is the extended part of the description.', 'default' => '', - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index d5e62b79..adbe4d34 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -37,18 +37,18 @@ public function setUp() { */ public function test_should_render_single_image_field() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, array( + $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, [ 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', - ) ); + ] ); update_post_meta( $image_id, '_wp_attachment_image_alt', 'This is the alt value.', true ); - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_image_test', 'type' => 'image', 'label' => 'Image Test', 'value' => $image_id, - ), false ); + ], false ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -87,26 +87,26 @@ public function test_should_render_single_image_field() { * Test beans_field_image() should render multiple images field. */ public function test_should_render_multiple_images_field() { - $images = array(); + $images = []; $post_id = self::factory()->post->create(); - $images[] = self::factory()->attachment->create_object( 'image-1.png', $post_id, array( + $images[] = self::factory()->attachment->create_object( 'image-1.png', $post_id, [ 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', - ) ); + ] ); update_post_meta( $images[0], '_wp_attachment_image_alt', 'Image 1 alt.', true ); - $images[] = self::factory()->attachment->create_object( 'image-2.png', $post_id, array( + $images[] = self::factory()->attachment->create_object( 'image-2.png', $post_id, [ 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', - ) ); + ] ); update_post_meta( $images[1], '_wp_attachment_image_alt', 'Image 2 alt.', true ); - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_image_test', 'type' => 'image', 'label' => 'Image Test', 'value' => $images, 'multiple' => true, - ), false ); + ], false ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -158,17 +158,17 @@ public function test_should_render_multiple_images_field() { */ public function test_should_render_single_image_field_with_default_alt_when_none_exists() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, array( + $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, [ 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', - ) ); + ] ); - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_image_test', 'type' => 'image', 'label' => 'Image Test', 'value' => $image_id, - ), false ); + ], false ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php index c5aacc17..0794ba9a 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php @@ -36,11 +36,11 @@ public function setUp() { * Test beans_field_label() should not render the field's label when none is given. */ public function test_should_not_render_field_label_when_none_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_text_test', 'type' => 'text', 'default' => '', - ) ); + ] ); $this->assertNull( beans_field_label( $field ) ); @@ -52,12 +52,12 @@ public function test_should_not_render_field_label_when_none_given() { * Test beans_field_label() should render the field's label. */ public function test_should_render_field_label() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_text_test', 'type' => 'text', 'label' => 'Testing the text field.', 'default' => '', - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -75,29 +75,29 @@ public function test_should_render_field_label() { * Test beans_field_label() should not render the radio field's group label. */ public function test_should_not_render_radio_group_label() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_layout', 'label' => 'Layout', 'description' => 'The layout settings.', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', - 'c' => array( + 'c' => [ 'src' => 'http://example.com/images/layouts/c.png', 'alt' => 'Content Only Layout', 'screen_reader_text' => 'Option for the Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'http://example.com/images/layouts/sp_c.png', 'alt' => 'Sidebar Primary + Content Layout', - ), - ), - ) ); + ], + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -112,38 +112,38 @@ public function test_should_not_render_radio_group_label() { * Test beans_field_label() should not render the group field's label. */ public function test_should_not_render_group_label() { - $field = array( + $field = [ 'id' => 'beans_group_test', 'label' => 'Group of fields', 'description' => 'This is a group of fields.', 'type' => 'group', - 'fields' => array( - array( + 'fields' => [ + [ 'id' => 'beans_group_activation_test', 'label' => 'Activate', 'type' => 'activation', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_group_select_test', 'label' => 'Select', 'type' => 'select', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ), - array( + ], + ], + [ 'id' => 'beans_group_checkbox_test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - ), - ); + ], + ], + ]; // Run the function and grab the HTML out of the buffer. ob_start(); @@ -157,12 +157,12 @@ public function test_should_not_render_group_label() { * Test beans_field_label() should not render the activation field's label. */ public function test_should_not_render_activation_field_label() { - $field = array( + $field = [ 'id' => 'beans_group_activation_test', 'label' => 'Activate', 'type' => 'activation', 'default' => false, - ); + ]; // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php index f992c365..6270880a 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php @@ -36,19 +36,19 @@ public function setUp() { * Test beans_field_radio() should render the radio field with image options. */ public function test_should_render_radio_field_with_image_options() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_layout', 'label' => 'Layout', 'description' => 'The layout settings.', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', 'c' => 'http://example.com/images/layouts/c.png', 'c_sp' => 'http://example.com/images/layouts/c_sp.png', 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -86,29 +86,29 @@ public function test_should_render_radio_field_with_image_options() { * Test beans_field_radio() should render accessible images when accessibility parameters are given. */ public function test_should_render_accessible_images_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_layout', 'label' => 'Layout', 'description' => 'The layout settings.', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', - 'c' => array( + 'c' => [ 'src' => 'http://example.com/images/layouts/c.png', 'alt' => 'Content Only Layout', 'screen_reader_text' => 'Option for the Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'http://example.com/images/layouts/sp_c.png', 'alt' => 'Sidebar Primary + Content Layout', - ), - ), - ) ); + ], + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php index 16b24bab..283096c1 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php @@ -36,15 +36,15 @@ public function setUp() { * Test beans_field_select() should render the select field. */ public function test_should_render_select_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', 'default' => 'aggressive', - 'options' => array( + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -65,18 +65,18 @@ public function test_should_render_select_field() { * Test beans_field_select() should render the select field with attributes when given. */ public function test_should_render_select_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', 'default' => 'standard', - 'options' => array( + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - 'attributes' => array( + ], + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php index cc958716..a816c6f2 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php @@ -36,7 +36,7 @@ public function setUp() { * Test beans_field_slider() should render the slider field. */ public function test_should_render_slider_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_test_slider', 'label' => 'Test Slider', 'description' => 'Testing the slider', @@ -45,7 +45,7 @@ public function test_should_render_slider_field() { 'min' => 0, 'max' => 100, 'interval' => 1, - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -66,7 +66,7 @@ public function test_should_render_slider_field() { * Test beans_field_slider() should render the slider field with unit when given. */ public function test_should_render_slider_field_with_unit_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_test_slider', 'label' => 'Test Slider', 'description' => 'Testing the slider', @@ -76,7 +76,7 @@ public function test_should_render_slider_field_with_unit_when_given() { 'max' => 100, 'interval' => 5, 'unit' => 'Number of beans', - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -98,7 +98,7 @@ public function test_should_render_slider_field_with_unit_when_given() { * Test beans_field_slider() should render the slider with the current value. */ public function test_should_render_slider_with_current_value() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_test_slider', 'label' => 'Test Slider', 'description' => 'Testing the slider', @@ -107,7 +107,7 @@ public function test_should_render_slider_with_current_value() { 'min' => 10, 'max' => 100, 'interval' => 5, - ) ); + ] ); $field['value'] = 15; // Run the function and grab the HTML out of the buffer. @@ -129,7 +129,7 @@ public function test_should_render_slider_with_current_value() { * Test beans_field_slider() should render the slider field with attributes when given. */ public function test_should_render_slider_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_test_slider', 'label' => 'Test Slider', 'description' => 'Testing the slider', @@ -139,10 +139,10 @@ public function test_should_render_slider_field_with_attributes_when_given() { 'max' => 20, 'interval' => 1, 'unit' => 'Number of beans', - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php index 7eafba5f..b093d7a3 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldText.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldText.php @@ -36,11 +36,11 @@ public function setUp() { * Test beans_field_text() should render the text field. */ public function test_should_render_text_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_text_test', 'type' => 'text', 'default' => '', - ) ); + ] ); $field['value'] = 'Testing the text field.'; // Run the function and grab the HTML out of the buffer. @@ -59,14 +59,14 @@ public function test_should_render_text_field() { * Test beans_field_text() should render the text field with attributes when given. */ public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_text_test', 'type' => 'text', 'default' => '', - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); $field['value'] = 'Testing the text field with attributes.'; // Run the function and grab the HTML out of the buffer. diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php index edf99144..ea00fe18 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -36,11 +36,11 @@ public function setUp() { * Test beans_field_textarea() should render the textarea field. */ public function test_should_render_textarea_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_textarea_test', 'type' => 'textarea', 'default' => '', - ) ); + ] ); $field['value'] = 'Testing the textarea field.'; // Run the function and grab the HTML out of the buffer. @@ -59,14 +59,14 @@ public function test_should_render_textarea_field() { * Test beans_field_textarea() should render the textarea field with attributes when given. */ public function test_should_render_textarea_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_textarea_test', 'type' => 'textarea', 'default' => '', - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); $field['value'] = 'Testing the textarea field with attributes.'; // Run the function and grab the HTML out of the buffer. diff --git a/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php b/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php index 3ccac780..204daaf2 100644 --- a/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php +++ b/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php @@ -47,10 +47,10 @@ public function test_should_return_null_when_invalid_image_id_given() { */ public function test_should_return_default_alt_when_image_alt_not_defined() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, array( + $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, [ 'post_mime_type' => 'image/png', 'post_type' => 'attachment', - ) ); + ] ); // Run the test. $this->assertSame( 'Sorry, no description was given for this image.', _beans_get_image_alt( $image_id ) ); @@ -61,10 +61,10 @@ public function test_should_return_default_alt_when_image_alt_not_defined() { */ public function test_should_return_image_alt() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, array( + $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, [ 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', - ) ); + ] ); $alt = 'This is the alt value.'; update_post_meta( $image_id, '_wp_attachment_image_alt', $alt, true ); diff --git a/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php b/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php index 57dc9826..53ea86de 100644 --- a/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php +++ b/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php @@ -54,10 +54,10 @@ public function test_should_return_null_when_image_does_not_exist() { */ public function test_should_return_image_url() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, array( + $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, [ 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment', - ) ); + ] ); // Run the test. $this->assertSame( 'http://example.org/wp-content/uploads/image.jpeg', _beans_get_image_url( $image_id ) ); diff --git a/tests/phpunit/integration/api/fields/types/beansIsRadioImage.php b/tests/phpunit/integration/api/fields/types/beansIsRadioImage.php index fea89d1e..8684337b 100644 --- a/tests/phpunit/integration/api/fields/types/beansIsRadioImage.php +++ b/tests/phpunit/integration/api/fields/types/beansIsRadioImage.php @@ -36,11 +36,11 @@ public function setUp() { * Test _beans_is_radio_image() should return true when an image source is given. */ public function test_should_return_true_when_image_src_given() { - $test_data = array( + $test_data = [ 'c' => 'http://example.com/images/layouts/c.png', 'c_sp' => 'http://example.com/images/layouts/c_sp.png', 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ); + ]; foreach ( $test_data as $src ) { $this->assertTrue( _beans_is_radio_image( $src ) ); @@ -51,12 +51,12 @@ public function test_should_return_true_when_image_src_given() { * Test _beans_is_radio_image() should return false when a non-image source is given. */ public function test_should_return_false_when_non_image_src_given() { - $test_data = array( + $test_data = [ __FILE__, 'path/to/fields.js', BEANS_THEME_DIR . 'style.css', 'http://example.com/path/to/some.pdf', - ); + ]; foreach ( $test_data as $src ) { $this->assertFalse( _beans_is_radio_image( $src ) ); @@ -67,21 +67,21 @@ public function test_should_return_false_when_non_image_src_given() { * Test _beans_is_radio_image() should return true when an array is given, an array that configures the image. */ public function test_should_return_true_when_array_is_given() { - $test_data = array( - 'c' => array( + $test_data = [ + 'c' => [ 'src' => 'http://example.com/images/layouts/c.png', 'screen_reader_text' => 'Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', - ), - ); + ], + ]; foreach ( $test_data as $radio ) { $this->assertTrue( _beans_is_radio_image( $radio ) ); diff --git a/tests/phpunit/integration/api/fields/types/beansStandardizeRadioImage.php b/tests/phpunit/integration/api/fields/types/beansStandardizeRadioImage.php index b5b8065b..a5040ca6 100644 --- a/tests/phpunit/integration/api/fields/types/beansStandardizeRadioImage.php +++ b/tests/phpunit/integration/api/fields/types/beansStandardizeRadioImage.php @@ -36,18 +36,18 @@ public function setUp() { * Test _beans_standardize_radio_image() should standardize when only the image's source is given. */ public function test_should_standardize_when_only_src_given() { - $test_data = array( + $test_data = [ 'c' => 'http://example.com/images/layouts/c.png', 'c_sp' => 'http://example.com/images/layouts/c_sp.png', 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ); + ]; foreach ( $test_data as $value => $radio ) { - $expected = array( + $expected = [ 'src' => $radio, 'alt' => "Option for {$value}", 'screen_reader_text' => "Option for {$value}", - ); + ]; $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); } } @@ -56,27 +56,27 @@ public function test_should_standardize_when_only_src_given() { * Test _beans_standardize_radio_image() should standardize when the image's alt value is not given. */ public function test_should_standardize_when_alt_is_not_given() { - $test_data = array( - 'c' => array( + $test_data = [ + 'c' => [ 'src' => 'http://example.com/images/layouts/c.png', 'screen_reader_text' => 'Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Sidebar Primary + Content Layout', - ), - ); + ], + ]; foreach ( $test_data as $value => $radio ) { - $expected = array( + $expected = [ 'src' => $radio['src'], 'alt' => $radio['screen_reader_text'], 'screen_reader_text' => $radio['screen_reader_text'], - ); + ]; $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); } } @@ -85,20 +85,20 @@ public function test_should_standardize_when_alt_is_not_given() { * Test _beans_standardize_radio_image() should standardize when the image's `screen_reader_text` is not given. */ public function test_should_standardize_when_screen_reader_text_is_not_given() { - $test_data = array( - 'c' => array( + $test_data = [ + 'c' => [ 'src' => 'http://example.com/images/layouts/c.png', 'alt' => 'Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', - ), - ); + ], + ]; foreach ( $test_data as $value => $radio ) { $expected = $radio; @@ -111,23 +111,23 @@ public function test_should_standardize_when_screen_reader_text_is_not_given() { * Test _beans_standardize_radio_image() should standardize when all of the image's parameters are given. */ public function test_should_standardize_when_all_parameters_given() { - $test_data = array( - 'c' => array( + $test_data = [ + 'c' => [ 'src' => 'c.png', 'alt' => 'Content Only Layout', 'screen_reader_text' => 'Option to select the Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', 'screen_reader_text' => 'Option to select the Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', 'screen_reader_text' => 'Option to select the Sidebar Primary + Content Layout', - ), - ); + ], + ]; foreach ( $test_data as $value => $radio ) { $this->assertSame( $radio, _beans_standardize_radio_image( $value, $radio ) ); diff --git a/tests/phpunit/unit/api/fields/beansGetFields.php b/tests/phpunit/unit/api/fields/beansGetFields.php index 05c0e18f..ba174825 100644 --- a/tests/phpunit/unit/api/fields/beansGetFields.php +++ b/tests/phpunit/unit/api/fields/beansGetFields.php @@ -28,11 +28,11 @@ class Tests_BeansGetFields extends Fields_Test_Case { public function test_should_return_registered_fields() { foreach ( static::$test_data as $test_data ) { - $data_set = array( - 'beans_tests' => array( + $data_set = [ + 'beans_tests' => [ $test_data['section'] => $test_data['fields'], - ), - ); + ], + ]; // Register the fields first. $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); diff --git a/tests/phpunit/unit/api/fields/beansRegisterFields.php b/tests/phpunit/unit/api/fields/beansRegisterFields.php index d3562cee..dca0c7c9 100644 --- a/tests/phpunit/unit/api/fields/beansRegisterFields.php +++ b/tests/phpunit/unit/api/fields/beansRegisterFields.php @@ -27,8 +27,8 @@ class Tests_BeansRegisterFields extends Fields_Test_Case { * Test beans_register_fields() should return false when there are no fields. */ public function test_should_return_false_when_no_fields() { - $this->assertFalse( beans_register_fields( array(), '', '' ) ); - $this->assertFalse( beans_register_fields( array(), 'post_meta', 'tm-beans' ) ); + $this->assertFalse( beans_register_fields( [], '', '' ) ); + $this->assertFalse( beans_register_fields( [], 'post_meta', 'tm-beans' ) ); } /** diff --git a/tests/phpunit/unit/api/fields/fixtures/test-fields.php b/tests/phpunit/unit/api/fields/fixtures/test-fields.php index 57b14eac..82ab361a 100644 --- a/tests/phpunit/unit/api/fields/fixtures/test-fields.php +++ b/tests/phpunit/unit/api/fields/fixtures/test-fields.php @@ -7,74 +7,74 @@ * @since 1.5.0 */ -return array( +return [ // Single fields. - 'single_fields' => array( - 'fields' => array( - array( + 'single_fields' => [ + 'fields' => [ + [ 'id' => 'beans_layout', 'label' => 'Layout', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', - ), - ), - array( + ], + ], + [ 'id' => 'beans_checkbox_test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_text_test', 'type' => 'text', 'default' => 'Testing the text field.', - ), - ), + ], + ], 'context' => 'tests', 'section' => 'tm-beans', - ), + ], // Group of fields. - 'group' => array( - 'fields' => array( - array( + 'group' => [ + 'fields' => [ + [ 'id' => 'beans_group_test', 'label' => 'Group of fields', 'description' => 'This is a group of fields.', 'type' => 'group', - 'fields' => array( - array( + 'fields' => [ + [ 'id' => 'beans_compile_all_scripts', 'type' => 'activation', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ), - array( + ], + ], + [ 'id' => 'beans_checkbox_test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - ), - ), - ), + ], + ], + ], + ], 'context' => 'group_tests', 'section' => 'tm-beans', - ), -); + ], +]; diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index e3bb9086..28859a6f 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -43,12 +43,12 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/actions/functions.php', 'api/fields/functions.php', 'api/fields/class-beans-fields.php', 'api/utilities/functions.php', - ) ); + ] ); $this->setup_function_mocks(); $this->setup_common_wp_stubs(); @@ -65,14 +65,14 @@ protected function setUp() { * @return array */ protected function merge_field_with_default( array $field, $set_value = true ) { - $merged_field = array_merge( array( + $merged_field = array_merge( [ 'label' => false, 'description' => false, 'default' => false, 'context' => 'beans_tests', - 'attributes' => array(), + 'attributes' => [], 'db_group' => false, - ), $field ); + ], $field ); $merged_field['name'] = 'beans_fields[' . $field['id'] . ']'; if ( $set_value ) { diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php index d18133a7..579b5d84 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php @@ -36,11 +36,11 @@ protected function setUp() { * Test beans_field_activation() should render the activation field. */ public function test_should_render_activation_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_scripts', 'type' => 'activation', 'default' => false, - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -60,14 +60,14 @@ public function test_should_render_activation_field() { * Test beans_field_activation() should render the activation field with attributes when given. */ public function test_should_render_activation_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_scripts', 'type' => 'activation', 'default' => false, - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php index 91f95d3f..136aa915 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php @@ -36,13 +36,13 @@ protected function setUp() { * Test beans_field_checkbox() should render the checkbox with the label when given. */ public function test_should_render_checkbox_with_label_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_styles', 'label' => false, 'checkbox_label' => 'Compile all WordPress styles', 'type' => 'checkbox', 'default' => false, - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -62,11 +62,11 @@ public function test_should_render_checkbox_with_label_when_given() { * Test beans_field_checkbox() should render the checkbox with the default label when none is given. */ public function test_should_render_checkbox_with_default_label_when_none_is_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_styles', 'type' => 'checkbox', 'default' => false, - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -86,15 +86,15 @@ public function test_should_render_checkbox_with_default_label_when_none_is_give * Test beans_field_checkbox() should render the checkbox with attributes when given. */ public function test_should_render_checkbox_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_styles', 'checkbox_label' => 'Compile all WordPress styles', 'type' => 'checkbox', 'default' => false, - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 1f6ff1d6..6204aec0 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -45,12 +45,12 @@ public function test_should_render_single_image_field() { ->once() ->andReturn( 'This is the image alt value.' ); - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_image_test', 'type' => 'image', 'label' => 'Image Test', 'value' => 1, // attachment ID. - ), false ); + ], false ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -101,13 +101,13 @@ public function test_should_render_multiple_images_field() { ->times( 2 ) ->andReturn( 'This is the image alt value.' ); - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_image_test', 'type' => 'image', 'label' => 'Image Test', - 'value' => array( 1, 2 ), // attachment IDs. + 'value' => [ 1, 2 ], // attachment IDs. 'multiple' => true, - ), false ); + ], false ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -163,12 +163,12 @@ public function test_should_render_single_image_field_with_default_alt_when_none ->once() ->andReturn( '' ); - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_image_test', 'type' => 'image', 'label' => 'Image Test', 'value' => 1, // attachment ID. - ), false ); + ], false ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php index e4571edd..e6a197c1 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php @@ -36,19 +36,19 @@ protected function setUp() { * Test beans_field_radio() should render the radio field with image options. */ public function test_should_render_radio_field_with_image_options() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_layout', 'label' => 'Layout', 'description' => 'The layout settings.', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', 'c' => 'http://example.com/images/layouts/c.png', 'c_sp' => 'http://example.com/images/layouts/c_sp.png', 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -86,29 +86,29 @@ public function test_should_render_radio_field_with_image_options() { * Test beans_field_radio() should render accessible images when accessibility parameters are given. */ public function test_should_render_accessible_images_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_layout', 'label' => 'Layout', 'description' => 'The layout settings.', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', - 'c' => array( + 'c' => [ 'src' => 'http://example.com/images/layouts/c.png', 'alt' => 'Content Only Layout', 'screen_reader_text' => 'Option for the Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'http://example.com/images/layouts/sp_c.png', 'alt' => 'Sidebar Primary + Content Layout', - ), - ), - ) ); + ], + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index 002c0e1a..a7d50c18 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -36,15 +36,15 @@ protected function setUp() { * Test beans_field_checkbox() should render the select field. */ public function test_should_render_select_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', 'default' => 'aggressive', - 'options' => array( + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -65,18 +65,18 @@ public function test_should_render_select_field() { * Test beans_field_select() should render the select field with attributes when given. */ public function test_should_render_select_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', 'default' => 'standard', - 'options' => array( + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - 'attributes' => array( + ], + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php index 592a9ced..9fcf4acb 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php @@ -36,7 +36,7 @@ protected function setUp() { * Test beans_field_slider() should render the slider field. */ public function test_should_render_slider_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_test_slider', 'label' => 'Test Slider', 'description' => 'Testing the slider', @@ -45,7 +45,7 @@ public function test_should_render_slider_field() { 'min' => 0, 'max' => 100, 'interval' => 1, - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -66,7 +66,7 @@ public function test_should_render_slider_field() { * Test beans_field_slider() should render the slider field with unit when given. */ public function test_should_render_slider_field_with_unit_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_test_slider', 'label' => 'Test Slider', 'description' => 'Testing the slider', @@ -76,7 +76,7 @@ public function test_should_render_slider_field_with_unit_when_given() { 'max' => 100, 'interval' => 5, 'unit' => 'Number of beans', - ) ); + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -98,7 +98,7 @@ public function test_should_render_slider_field_with_unit_when_given() { * Test beans_field_slider() should render the slider with the current value. */ public function test_should_render_slider_with_current_value() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_test_slider', 'label' => 'Test Slider', 'description' => 'Testing the slider', @@ -107,7 +107,7 @@ public function test_should_render_slider_with_current_value() { 'min' => 10, 'max' => 100, 'interval' => 5, - ) ); + ] ); $field['value'] = 15; // Run the function and grab the HTML out of the buffer. @@ -129,7 +129,7 @@ public function test_should_render_slider_with_current_value() { * Test beans_field_slider() should render the slider field with attributes when given. */ public function test_should_render_slider_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_test_slider', 'label' => 'Test Slider', 'description' => 'Testing the slider', @@ -139,10 +139,10 @@ public function test_should_render_slider_field_with_attributes_when_given() { 'max' => 20, 'interval' => 1, 'unit' => 'Number of beans', - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index 1b099045..95860f44 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -36,11 +36,11 @@ protected function setUp() { * Test beans_field_text() should render the text field. */ public function test_should_render_text_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_text_test', 'type' => 'text', 'default' => '', - ) ); + ] ); $field['value'] = 'Testing the text field.'; // Run the function and grab the HTML out of the buffer. @@ -59,14 +59,14 @@ public function test_should_render_text_field() { * Test beans_field_text() should render the text field with attributes when given. */ public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_text_test', 'type' => 'text', 'default' => '', - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); $field['value'] = 'Testing the text field with attributes.'; // Run the function and grab the HTML out of the buffer. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index 855d4fea..db7c0fd0 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -36,11 +36,11 @@ protected function setUp() { * Test beans_field_textarea() should render the textarea field. */ public function test_should_render_textarea_field() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_textarea_test', 'type' => 'textarea', 'default' => '', - ) ); + ] ); $field['value'] = 'Testing the textarea field.'; // Run the function and grab the HTML out of the buffer. @@ -59,14 +59,14 @@ public function test_should_render_textarea_field() { * Test beans_field_textarea() should render the textarea field with attributes when given. */ public function test_should_render_textarea_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( array( + $field = $this->merge_field_with_default( [ 'id' => 'beans_textarea_test', 'type' => 'textarea', 'default' => '', - 'attributes' => array( + 'attributes' => [ 'data-test' => 'foo', - ), - ) ); + ], + ] ); $field['value'] = 'Testing the textarea field with attributes.'; // Run the function and grab the HTML out of the buffer. diff --git a/tests/phpunit/unit/api/fields/types/beansGetImageUrl.php b/tests/phpunit/unit/api/fields/types/beansGetImageUrl.php index f03c6672..fa9b7dca 100644 --- a/tests/phpunit/unit/api/fields/types/beansGetImageUrl.php +++ b/tests/phpunit/unit/api/fields/types/beansGetImageUrl.php @@ -63,11 +63,11 @@ public function test_should_return_image_url() { ->with( 1, 'thumbnail' ) ->once() ->andReturn( - array( + [ 'http://example.org/wp-content/uploads/image.jpeg', 300, 300, - ) + ] ); // Run the test. diff --git a/tests/phpunit/unit/api/fields/types/beansIsRadioImage.php b/tests/phpunit/unit/api/fields/types/beansIsRadioImage.php index ec4f167f..2e0621bb 100644 --- a/tests/phpunit/unit/api/fields/types/beansIsRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/beansIsRadioImage.php @@ -36,11 +36,11 @@ protected function setUp() { * Test _beans_is_radio_image() should return true when an image source is given. */ public function test_should_return_true_when_image_src_given() { - $test_data = array( + $test_data = [ 'c' => 'http://example.com/images/layouts/c.png', 'c_sp' => 'http://example.com/images/layouts/c_sp.png', 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ); + ]; foreach ( $test_data as $src ) { $this->assertTrue( _beans_is_radio_image( $src ) ); @@ -51,12 +51,12 @@ public function test_should_return_true_when_image_src_given() { * Test _beans_is_radio_image() should false when a non-image source is given. */ public function test_should_return_false_when_non_image_src_given() { - $test_data = array( + $test_data = [ __FILE__, 'path/to/fields.js', BEANS_THEME_DIR . 'style.css', 'http://example.com/path/to/some.pdf', - ); + ]; foreach ( $test_data as $src ) { $this->assertFalse( _beans_is_radio_image( $src ) ); @@ -67,21 +67,21 @@ public function test_should_return_false_when_non_image_src_given() { * Test _beans_is_radio_image() should return true when an array is given, an array that configures the image. */ public function test_should_return_true_when_array_is_given() { - $test_data = array( - 'c' => array( + $test_data = [ + 'c' => [ 'src' => 'http://example.com/images/layouts/c.png', 'screen_reader_text' => 'Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', - ), - ); + ], + ]; foreach ( $test_data as $radio ) { $this->assertTrue( _beans_is_radio_image( $radio ) ); diff --git a/tests/phpunit/unit/api/fields/types/beansStandardizeRadioImage.php b/tests/phpunit/unit/api/fields/types/beansStandardizeRadioImage.php index 7b50e8ff..a8b23427 100644 --- a/tests/phpunit/unit/api/fields/types/beansStandardizeRadioImage.php +++ b/tests/phpunit/unit/api/fields/types/beansStandardizeRadioImage.php @@ -36,18 +36,18 @@ protected function setUp() { * Test _beans_standardize_radio_image() should standardize when only the image's source is given. */ public function test_should_standardize_when_only_src_given() { - $test_data = array( + $test_data = [ 'c' => 'http://example.com/images/layouts/c.png', 'c_sp' => 'http://example.com/images/layouts/c_sp.png', 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ); + ]; foreach ( $test_data as $value => $radio ) { - $expected = array( + $expected = [ 'src' => $radio, 'alt' => "Option for {$value}", 'screen_reader_text' => "Option for {$value}", - ); + ]; $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); } } @@ -56,27 +56,27 @@ public function test_should_standardize_when_only_src_given() { * Test _beans_standardize_radio_image() should standardize when the image's alt value is not given. */ public function test_should_standardize_when_alt_is_not_given() { - $test_data = array( - 'c' => array( + $test_data = [ + 'c' => [ 'src' => 'http://example.com/images/layouts/c.png', 'screen_reader_text' => 'Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'screen_reader_text' => 'Sidebar Primary + Content Layout', - ), - ); + ], + ]; foreach ( $test_data as $value => $radio ) { - $expected = array( + $expected = [ 'src' => $radio['src'], 'alt' => $radio['screen_reader_text'], 'screen_reader_text' => $radio['screen_reader_text'], - ); + ]; $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); } } @@ -85,20 +85,20 @@ public function test_should_standardize_when_alt_is_not_given() { * Test _beans_standardize_radio_image() should standardize when the image's `screen_reader_text` is not given. */ public function test_should_standardize_when_screen_reader_text_is_not_given() { - $test_data = array( - 'c' => array( + $test_data = [ + 'c' => [ 'src' => 'http://example.com/images/layouts/c.png', 'alt' => 'Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'http://example.com/images/layouts/c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', - ), - ); + ], + ]; foreach ( $test_data as $value => $radio ) { $expected = $radio; @@ -111,23 +111,23 @@ public function test_should_standardize_when_screen_reader_text_is_not_given() { * Test _beans_standardize_radio_image() should standardize when all of the image's parameters are given. */ public function test_should_standardize_when_all_parameters_given() { - $test_data = array( - 'c' => array( + $test_data = [ + 'c' => [ 'src' => 'c.png', 'alt' => 'Content Only Layout', 'screen_reader_text' => 'Option to select the Content Only Layout', - ), - 'c_sp' => array( + ], + 'c_sp' => [ 'src' => 'c_sp.png', 'alt' => 'Content + Sidebar Primary Layout', 'screen_reader_text' => 'Option to select the Content + Sidebar Primary Layout', - ), - 'sp_c' => array( + ], + 'sp_c' => [ 'src' => 'c_sp.png', 'alt' => 'Sidebar Primary + Content Layout', 'screen_reader_text' => 'Option to select the Sidebar Primary + Content Layout', - ), - ); + ], + ]; foreach ( $test_data as $value => $radio ) { $this->assertSame( $radio, _beans_standardize_radio_image( $value, $radio ) ); From e2e8605743595874993302b61670963fe0e388e5 Mon Sep 17 00:00:00 2001 From: ibes Date: Thu, 21 Jun 2018 23:04:23 +0200 Subject: [PATCH 774/800] Updated array syntax for non-API tests. (PR #270) --- tests/phpunit/class-beans-resetter.php | 2 +- tests/phpunit/unit/class-test-case.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/class-beans-resetter.php b/tests/phpunit/class-beans-resetter.php index 0912ffa2..3f189cbb 100644 --- a/tests/phpunit/class-beans-resetter.php +++ b/tests/phpunit/class-beans-resetter.php @@ -101,7 +101,7 @@ protected function reset_fields_api() { ] ); // Reset the other static properties. - foreach ( array( 'field_types_loaded', 'field_assets_hook_loaded' ) as $property_name ) { + foreach ( [ 'field_types_loaded', 'field_assets_hook_loaded' ] as $property_name ) { $property = $this->get_reflective_property( $property_name, '_Beans_Fields' ); $property->setValue( new _Beans_Fields(), [] ); } diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 5e717497..10104943 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -64,23 +64,23 @@ protected function setUp() { */ protected function setup_common_wp_stubs() { // Common escaping functions. - Monkey\Functions\stubs( array( + Monkey\Functions\stubs( [ 'esc_attr', 'esc_html', 'esc_textarea', 'esc_url', 'wp_kses_post', - ) ); + ] ); // Common internationalization functions. - Monkey\Functions\stubs( array( + Monkey\Functions\stubs( [ '__', 'esc_html__', 'esc_html_x', 'esc_attr_x', - ) ); + ] ); - foreach ( array( 'esc_attr_e', 'esc_html_e', '_e' ) as $wp_function ) { + foreach ( [ 'esc_attr_e', 'esc_html_e', '_e' ] as $wp_function ) { Monkey\Functions\when( $wp_function )->echoArg(); } } From 28cbe17533823f1d2407fa697defaefd2aded9bb Mon Sep 17 00:00:00 2001 From: ibes Date: Fri, 22 Jun 2018 07:56:47 +0200 Subject: [PATCH 775/800] Updated array syntax of Options API tests. (PR #271) --- .../options/beans-options/processActions.php | 28 +++---- .../api/options/beans-options/register.php | 12 +-- .../api/options/fixtures/test-options.php | 78 +++++++++---------- .../includes/class-options-test-case.php | 2 +- .../api/options/beans-options/register.php | 24 +++--- .../api/options/beans-options/renderPage.php | 16 ++-- .../api/options/fixtures/test-options.php | 78 +++++++++---------- .../includes/class-options-test-case.php | 26 +++---- 8 files changed, 132 insertions(+), 132 deletions(-) diff --git a/tests/phpunit/integration/api/options/beans-options/processActions.php b/tests/phpunit/integration/api/options/beans-options/processActions.php index c7394e77..23a12c6c 100644 --- a/tests/phpunit/integration/api/options/beans-options/processActions.php +++ b/tests/phpunit/integration/api/options/beans-options/processActions.php @@ -35,8 +35,8 @@ public function test_should_do_nothing_when_no_save_or_reset_action() { $this->assertArrayNotHasKey( 'beans_save_options', $_POST ); $this->assertArrayNotHasKey( 'beans_reset_options', $_POST ); $this->assertNull( $instance->process_actions() ); - $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_save_notice' ) ) ); - $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_reset_notice' ) ) ); + $this->assertFalse( has_action( 'admin_notices', [ $instance, 'render_save_notice' ] ) ); + $this->assertFalse( has_action( 'admin_notices', [ $instance, 'render_reset_notice' ] ) ); } /** @@ -44,11 +44,11 @@ public function test_should_do_nothing_when_no_save_or_reset_action() { */ public function test_should_not_save_options_when_nonce_fails() { $_POST['beans_save_options'] = 1; - $test_data = array( + $test_data = [ 'beans_compile_all_styles' => 1, 'beans_compile_all_scripts' => 1, 'beans_dev_mode' => 1, - ); + ]; $_POST['beans_fields'] = $test_data; $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); $instance = new _Beans_Options(); @@ -82,11 +82,11 @@ public function test_should_save_field_values_when_save_action() { $nonce = wp_create_nonce( 'beans_options_nonce' ); $_POST['beans_options_nonce'] = $nonce; $_POST['beans_save_options'] = 1; - $test_data = array( + $test_data = [ 'beans_compile_all_styles' => 1, 'beans_compile_all_scripts' => 1, 'beans_dev_mode' => 1, - ); + ]; $_POST['beans_fields'] = $test_data; $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); @@ -98,11 +98,11 @@ public function test_should_save_field_values_when_save_action() { // Check the save. $this->assertArrayHasKey( 'beans_save_options', $_POST ); - $this->assertEquals( 10, has_action( 'admin_notices', array( $instance, 'render_save_notice' ) ) ); + $this->assertEquals( 10, has_action( 'admin_notices', [ $instance, 'render_save_notice' ] ) ); // Check the reset. $this->assertArrayNotHasKey( 'beans_reset_options', $_POST ); - $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_reset_notice' ) ) ); + $this->assertFalse( has_action( 'admin_notices', [ $instance, 'render_reset_notice' ] ) ); foreach ( $test_data as $option => $value ) { // Check that the value was saved. @@ -118,11 +118,11 @@ public function test_should_save_field_values_when_save_action() { */ public function test_should_not_reset_options_when_nonce_fails() { $_POST['beans_reset_options'] = 1; - $test_data = array( + $test_data = [ 'beans_compile_all_styles' => 1, 'beans_compile_all_scripts' => 1, 'beans_dev_mode' => 1, - ); + ]; // Add the options. foreach ( $test_data as $option => $value ) { @@ -165,11 +165,11 @@ public function test_should_delete_options_when_reset_action() { $nonce = wp_create_nonce( 'beans_options_nonce' ); $_POST['beans_options_nonce'] = $nonce; $_POST['beans_reset_options'] = 1; - $test_data = array( + $test_data = [ 'beans_compile_all_styles' => 1, 'beans_compile_all_scripts' => 1, 'beans_dev_mode' => 1, - ); + ]; $_POST['beans_fields'] = $test_data; // Add the options. @@ -186,11 +186,11 @@ public function test_should_delete_options_when_reset_action() { // Check the reset. $this->assertArrayHasKey( 'beans_options_nonce', $_POST ); - $this->assertEquals( 10, has_action( 'admin_notices', array( $instance, 'render_reset_notice' ) ) ); + $this->assertEquals( 10, has_action( 'admin_notices', [ $instance, 'render_reset_notice' ] ) ); // Check the save. $this->assertArrayNotHasKey( 'beans_save_options', $_POST ); - $this->assertFalse( has_action( 'admin_notices', array( $instance, 'render_save_notice' ) ) ); + $this->assertFalse( has_action( 'admin_notices', [ $instance, 'render_save_notice' ] ) ); // Check that the option was deleted. foreach ( $test_data as $option ) { diff --git a/tests/phpunit/integration/api/options/beans-options/register.php b/tests/phpunit/integration/api/options/beans-options/register.php index 0b0ed57f..c4750de1 100644 --- a/tests/phpunit/integration/api/options/beans-options/register.php +++ b/tests/phpunit/integration/api/options/beans-options/register.php @@ -34,10 +34,10 @@ public function test_should_register_callback_to_admin_enqueue_scripts_hook() { $instance->register( $options['section'], $options['args'] ); // Check that the callback is registered to the hook. - $this->assertEquals( 10, has_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ) ); + $this->assertEquals( 10, has_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ) ); // Clean up. - remove_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ); + remove_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ); } } @@ -58,15 +58,15 @@ public function test_should_register_metabox_with_wp() { $this->assertArrayHasKey( $option['args']['context'], $wp_meta_boxes['themesphppagebeans_settings'] ); $this->assertArrayHasKey( 'default', $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ] ); $this->assertArrayHasKey( $option['section'], $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'] ); - $this->assertSame( array( + $this->assertSame( [ 'id' => $option['section'], 'title' => $option['args']['title'], - 'callback' => array( $instance, 'render_metabox' ), + 'callback' => [ $instance, 'render_metabox' ], 'args' => null, - ), $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); + ], $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); // Clean up. - remove_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ); + remove_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ); } } } diff --git a/tests/phpunit/integration/api/options/fixtures/test-options.php b/tests/phpunit/integration/api/options/fixtures/test-options.php index 8d87247d..0549be3a 100644 --- a/tests/phpunit/integration/api/options/fixtures/test-options.php +++ b/tests/phpunit/integration/api/options/fixtures/test-options.php @@ -7,85 +7,85 @@ * @since 1.5.0 */ -return array( +return [ // Compiler Options. - array( - 'fields' => array( - array( + [ + 'fields' => [ + [ 'id' => 'beans_compiler_items', 'type' => 'flush_cache', 'description' => 'Clear CSS and Javascript cached files. New cached versions will be compiled on page load.', - ), - array( + ], + [ 'id' => 'beans_compile_all_styles', 'label' => false, 'checkbox_label' => 'Compile all WordPress styles', 'type' => 'checkbox', 'default' => false, 'description' => 'Compile and cache all the CSS files that have been enqueued to the WordPress head.', - ), - array( + ], + [ 'id' => 'beans_compile_all_scripts_group', 'label' => 'Compile all WordPress scripts', 'type' => 'group', - 'fields' => array( - array( + 'fields' => [ + [ 'id' => 'beans_compile_all_scripts', 'type' => 'activation', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ), - ), + ], + ], + ], 'description' => 'Compile and cache all the Javascript files that have been enqueued to the WordPress head.JavaSript is outputted in the footer if the level is set to Aggressive and might conflict with some third party plugins which are not following WordPress standards.', - ), - ), + ], + ], 'menu_slug' => 'beans_settings', 'section' => 'compiler_options', - 'args' => array( + 'args' => [ 'title' => 'Compiler options', 'context' => 'normal', - ), - ), + ], + ], // Images Options. - array( - 'fields' => array( - array( + [ + 'fields' => [ + [ 'id' => 'beans_edited_images_directories', 'type' => 'flush_edited_images', 'description' => 'Clear all edited images. New images will be created on page load.', - ), - ), + ], + ], 'menu_slug' => 'beans_settings', 'section' => 'images_options', - 'args' => array( + 'args' => [ 'title' => 'Images options', 'context' => 'column', - ), - ), + ], + ], // Mode Options. - array( - 'fields' => array( - array( + [ + 'fields' => [ + [ 'id' => 'beans_dev_mode', 'checkbox_label' => 'Enable development mode', 'type' => 'checkbox', 'description' => 'This option should be enabled while your website is in development.', - ), - ), + ], + ], 'menu_slug' => 'beans_settings', 'section' => 'mode_options', - 'args' => array( + 'args' => [ 'title' => 'Mode options', 'context' => 'column', - ), - ), -); + ], + ], +]; diff --git a/tests/phpunit/integration/api/options/includes/class-options-test-case.php b/tests/phpunit/integration/api/options/includes/class-options-test-case.php index a3681db3..6597f242 100644 --- a/tests/phpunit/integration/api/options/includes/class-options-test-case.php +++ b/tests/phpunit/integration/api/options/includes/class-options-test-case.php @@ -54,7 +54,7 @@ public function tearDown() { $this->clean_up_global_scope(); global $wp_meta_boxes; - $wp_meta_boxes = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. + $wp_meta_boxes = []; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. parent::tearDown(); } diff --git a/tests/phpunit/unit/api/options/beans-options/register.php b/tests/phpunit/unit/api/options/beans-options/register.php index 1460b253..e044ee1c 100644 --- a/tests/phpunit/unit/api/options/beans-options/register.php +++ b/tests/phpunit/unit/api/options/beans-options/register.php @@ -31,18 +31,18 @@ public function test_should_merge_default_args_and_set_property() { $property = $this->get_reflective_property( 'args', '_Beans_Options' ); $instance = new _Beans_Options(); - $instance->register( 'foo', array() ); - $this->assertSame( array( + $instance->register( 'foo', [] ); + $this->assertSame( [ 'title' => 'Undefined', 'context' => 'normal', - ), $property->getValue( $instance ) ); + ], $property->getValue( $instance ) ); $instance = new _Beans_Options(); - $instance->register( 'beans_test', array( 'title' => 'Beans Tests' ) ); - $this->assertSame( array( + $instance->register( 'beans_test', [ 'title' => 'Beans Tests' ] ); + $this->assertSame( [ 'title' => 'Beans Tests', 'context' => 'normal', - ), $property->getValue( $instance ) ); + ], $property->getValue( $instance ) ); } /** @@ -50,9 +50,9 @@ public function test_should_merge_default_args_and_set_property() { */ public function test_should_register_callback_to_admin_enqueue_scripts_hook() { $instance = new _Beans_Options(); - $instance->register( 'beans_test', array( 'title' => 'Beans Tests' ) ); + $instance->register( 'beans_test', [ 'title' => 'Beans Tests' ] ); - $this->assertEquals( 10, has_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ) ); + $this->assertEquals( 10, has_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ) ); } /** @@ -73,15 +73,15 @@ public function test_should_register_metabox_with_wp() { $this->assertArrayHasKey( $option['args']['context'], $wp_meta_boxes['beans_settings'] ); $this->assertArrayHasKey( 'default', $wp_meta_boxes['beans_settings'][ $option['args']['context'] ] ); $this->assertArrayHasKey( $option['section'], $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'] ); - $this->assertSame( array( + $this->assertSame( [ 'id' => $option['section'], 'title' => $option['args']['title'], - 'callback' => array( $instance, 'render_metabox' ), + 'callback' => [ $instance, 'render_metabox' ], 'args' => null, - ), $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); + ], $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); // Clean up. - remove_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_assets' ) ); + remove_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ); } } } diff --git a/tests/phpunit/unit/api/options/beans-options/renderPage.php b/tests/phpunit/unit/api/options/beans-options/renderPage.php index 367543f3..1acdc1de 100644 --- a/tests/phpunit/unit/api/options/beans-options/renderPage.php +++ b/tests/phpunit/unit/api/options/beans-options/renderPage.php @@ -28,7 +28,7 @@ class Tests_BeansOptions_RenderPage extends Options_Test_Case { * Test _Beans_Options::render_page() should return null when the page does not have a metabox. */ public function test_should_return_null_when_page_does_not_have_metabox() { - Monkey\Functions\expect( 'beans_get' )->with( 'beans_tests', array() )->once()->andReturn( null ); + Monkey\Functions\expect( 'beans_get' )->with( 'beans_tests', [] )->once()->andReturn( null ); $this->assertNull( ( new _Beans_Options() )->render_page( 'beans_tests' ) ); } @@ -38,13 +38,13 @@ public function test_should_return_null_when_page_does_not_have_metabox() { */ public function test_should_render_form_when_context_normal() { Monkey\Functions\expect( 'beans_get' ) - ->with( 'beans_tests', array() ) + ->with( 'beans_tests', [] ) ->once() - ->andReturn( array( 'column' => '' ) ) + ->andReturn( [ 'column' => '' ] ) ->andAlsoExpectIt() - ->with( 'column', array( 'column' => '' ), array() ) + ->with( 'column', [ 'column' => '' ], [] ) ->once() - ->andReturn( array() ) + ->andReturn( [] ) ->andAlsoExpectIt() ->with( 'page' ) ->once() @@ -77,11 +77,11 @@ public function test_should_render_form_when_context_normal() { */ public function test_should_render_form_when_column_context() { Monkey\Functions\expect( 'beans_get' ) - ->with( 'beans_tests', array() ) + ->with( 'beans_tests', [] ) ->once() - ->andReturn( array( 'column' => true ) ) + ->andReturn( [ 'column' => true ] ) ->andAlsoExpectIt() - ->with( 'column', array( 'column' => true ), array() ) + ->with( 'column', [ 'column' => true ], [] ) ->once() ->andReturn( true ) ->andAlsoExpectIt() diff --git a/tests/phpunit/unit/api/options/fixtures/test-options.php b/tests/phpunit/unit/api/options/fixtures/test-options.php index 1476a707..92f57f7b 100644 --- a/tests/phpunit/unit/api/options/fixtures/test-options.php +++ b/tests/phpunit/unit/api/options/fixtures/test-options.php @@ -7,85 +7,85 @@ * @since 1.5.0 */ -return array( +return [ // Compiler Options. - array( - 'fields' => array( - array( + [ + 'fields' => [ + [ 'id' => 'beans_compiler_items', 'type' => 'flush_cache', 'description' => 'Clear CSS and Javascript cached files. New cached versions will be compiled on page load.', - ), - array( + ], + [ 'id' => 'beans_compile_all_styles', 'label' => false, 'checkbox_label' => 'Compile all WordPress styles', 'type' => 'checkbox', 'default' => false, 'description' => 'Compile and cache all the CSS files that have been enqueued to the WordPress head.', - ), - array( + ], + [ 'id' => 'beans_compile_all_scripts_group', 'label' => 'Compile all WordPress scripts', 'type' => 'group', - 'fields' => array( - array( + 'fields' => [ + [ 'id' => 'beans_compile_all_scripts', 'type' => 'activation', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ), - ), + ], + ], + ], 'description' => 'Compile and cache all the Javascript files that have been enqueued to the WordPress head.JavaSript is outputted in the footer if the level is set to Aggressive and might conflict with some third party plugins which are not following WordPress standards.', - ), - ), + ], + ], 'menu_slug' => 'beans_settings', 'section' => 'compiler_options', - 'args' => array( + 'args' => [ 'title' => 'Compiler options', 'context' => 'normal', - ), - ), + ], + ], // Images Options. - array( - 'fields' => array( - array( + [ + 'fields' => [ + [ 'id' => 'beans_edited_images_directories', 'type' => 'flush_edited_images', 'description' => 'Clear all edited images. New images will be created on page load.', - ), - ), + ], + ], 'menu_slug' => 'beans_settings', 'section' => 'images_options', - 'args' => array( + 'args' => [ 'title' => 'Images options', 'context' => 'column', - ), - ), + ], + ], // Mode Options. - array( - 'fields' => array( - array( + [ + 'fields' => [ + [ 'id' => 'beans_dev_mode', 'checkbox_label' => 'Enable development mode', 'type' => 'checkbox', 'description' => 'This option should be enabled while your website is in development.', - ), - ), + ], + ], 'menu_slug' => 'beans_settings', 'section' => 'mode_options', - 'args' => array( + 'args' => [ 'title' => 'Mode options', 'context' => 'column', - ), - ), -); + ], + ], +]; diff --git a/tests/phpunit/unit/api/options/includes/class-options-test-case.php b/tests/phpunit/unit/api/options/includes/class-options-test-case.php index 81f85b41..a4f5c00c 100644 --- a/tests/phpunit/unit/api/options/includes/class-options-test-case.php +++ b/tests/phpunit/unit/api/options/includes/class-options-test-case.php @@ -41,12 +41,12 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/utilities/functions.php', 'api/options/class-beans-options.php', 'api/options/functions.php', 'api/fields/functions.php', - ) ); + ] ); $this->setup_function_mocks(); $this->setup_common_wp_stubs(); @@ -57,7 +57,7 @@ protected function setUp() { */ protected function tearDown() { global $wp_meta_boxes; - $wp_meta_boxes = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. + $wp_meta_boxes = []; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. parent::tearDown(); } @@ -74,20 +74,20 @@ protected function setup_function_mocks() { } // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Mocking global here for tests. - $wp_meta_boxes = array( - $screen => array( - $context => array( - $priority => array( - $id => array( + $wp_meta_boxes = [ + $screen => [ + $context => [ + $priority => [ + $id => [ 'id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args, - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; } ); } } From a60841c17133126e2370a72f6688afacf85fd823 Mon Sep 17 00:00:00 2001 From: ibes Date: Fri, 22 Jun 2018 07:58:48 +0200 Subject: [PATCH 776/800] Updated array syntax of Customize API tests. (PR #272) --- .../beansRegisterWPCustomizeOptions.php | 8 +-- .../api/wp-customize/fixtures/test-fields.php | 70 +++++++++---------- .../includes/class-wp-customize-test-case.php | 8 +-- .../wp-customize/beans-wp-customize/add.php | 4 +- .../beans-wp-customize/add_control.php | 2 +- .../beans-wp-customize/add_group_setting.php | 4 +- .../beans-wp-customize/add_section.php | 2 +- .../beans-wp-customize/add_setting.php | 2 +- .../beansRegisterWPCustomizeOptions.php | 16 ++--- .../api/wp-customize/fixtures/test-fields.php | 66 ++++++++--------- .../includes/class-wp-customize-test-case.php | 12 ++-- 11 files changed, 97 insertions(+), 97 deletions(-) diff --git a/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php b/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php index 154f3fbf..d52932fc 100644 --- a/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php +++ b/tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php @@ -29,8 +29,8 @@ class Tests_BeansRegisterWPCustomizeOptions extends WP_Customize_Test_Case { public function test_should_return_false_when_no_customizer() { $test_data = static::$test_data['single_fields']; - $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); - $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); + $this->assertFalse( beans_register_wp_customize_options( [], '', [] ) ); + $this->assertFalse( beans_register_wp_customize_options( [], 'post_meta', [ 1, 2, 3 ] ) ); $this->assertFalse( beans_register_wp_customize_options( $test_data['fields'], $test_data['section'], $test_data['args'] ) ); } @@ -40,8 +40,8 @@ public function test_should_return_false_when_no_customizer() { public function test_should_return_false_when_no_options() { $this->wp_customize->start_previewing_theme(); - $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); - $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); + $this->assertFalse( beans_register_wp_customize_options( [], '', [] ) ); + $this->assertFalse( beans_register_wp_customize_options( [], 'post_meta', [ 1, 2, 3 ] ) ); } /** diff --git a/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php b/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php index 93d63ea9..fa269867 100644 --- a/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php +++ b/tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php @@ -7,84 +7,84 @@ * @since 1.5.0 */ -return array( +return [ // Single fields. - 'single_fields' => array( - 'fields' => array( - array( + 'single_fields' => [ + 'fields' => [ + [ 'id' => 'beans_customizer_layout', 'label' => 'Layout', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', - ), - ), - array( + ], + ], + [ 'id' => 'beans_customizer_checkbox', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_customizer_text', 'type' => 'text', 'default' => 'Testing the text field.', - ), - ), + ], + ], 'context' => 'beans-test', 'section' => 'tm-beans-test-customizer', - 'args' => array( + 'args' => [ 'title' => 'Beans Customizer Section', 'priority' => 250, 'description' => 'Customizer Beans Section', - ), - ), + ], + ], // Group of fields. - 'group' => array( - 'fields' => array( - array( + 'group' => [ + 'fields' => [ + [ 'id' => 'beans_group_test', 'label' => 'Group of fields', 'description' => 'This is a group of fields.', 'type' => 'group', - 'fields' => array( - array( + 'fields' => [ + [ 'id' => 'beans_compile_all_scripts', 'type' => 'activation', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_compile_all_scripts_mode', 'type' => 'select', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ), - array( + ], + ], + [ 'id' => 'beans_checkbox_test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - ), - ), - ), + ], + ], + ], + ], 'context' => 'group_tests', 'section' => 'tm-beans-group-test-customizer', - 'args' => array( + 'args' => [ 'title' => 'Beans Customizer Group Section', 'priority' => 250, 'description' => 'Customizer Beans Group Section', - ), - ), -); + ], + ], +]; diff --git a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php index cd7ab074..8b30d51b 100644 --- a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php @@ -78,16 +78,16 @@ public function tearDown() { * @return array */ protected function merge_field_with_default( array $field, $set_value = true ) { - $field = array_merge( array( + $field = array_merge( [ 'label' => false, 'description' => false, 'default' => false, 'context' => 'wp_customize', - 'attributes' => array( + 'attributes' => [ 'data-customize-setting-link' => $field['id'], - ), + ], 'db_group' => false, - ), $field ); + ], $field ); $field['name'] = $field['id']; if ( 'group' === $field['type'] ) { diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add.php index 50c4381a..38f69ca0 100644 --- a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add.php +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add.php @@ -35,12 +35,12 @@ public function test_should_call_wp_customize_control() { ->with( 'wp_customize', $test_data['section'] ) ->once() ->ordered() - ->andReturn( array() ) + ->andReturn( [] ) ->andAlsoExpectIt() ->with( 'wp_customize', $test_data['section'] ) ->once() ->ordered() - ->andReturn( array() ); + ->andReturn( [] ); Monkey\Functions\expect( 'beans_add_attribute' ) ->with( 'beans_field_label', 'class', 'customize-control-title' ) diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_control.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_control.php index 4ad3b0e0..1739e307 100644 --- a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_control.php +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_control.php @@ -35,7 +35,7 @@ public function test_should_call_beans_wp_customize_control_and_wp_customize_man ->with( 'wp_customize', $test_data['section'] ) ->once() ->ordered() - ->andReturn( array() ); + ->andReturn( [] ); Monkey\Functions\expect( 'beans_add_attribute' ) ->with( 'beans_field_label', 'class', 'customize-control-title' ) diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_group_setting.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_group_setting.php index c273e812..d074a56d 100644 --- a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_group_setting.php +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_group_setting.php @@ -35,7 +35,7 @@ public function test_should_call_beans_get_when_grouped_fields() { ->with( 'wp_customize', $test_data['section'] ) ->once() ->ordered() - ->andReturn( array() ); + ->andReturn( [] ); Monkey\Functions\expect( 'beans_add_attribute' ) ->with( 'beans_field_label', 'class', 'customize-control-title' ) @@ -64,7 +64,7 @@ public function test_should_not_call_beans_get_when_no_grouped_fields() { ->with( 'wp_customize', $test_data['section'] ) ->once() ->ordered() - ->andReturn( array() ); + ->andReturn( [] ); Monkey\Functions\expect( 'beans_add_attribute' ) ->with( 'beans_field_label', 'class', 'customize-control-title' ) diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_section.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_section.php index ae1ec763..09537b49 100644 --- a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_section.php +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_section.php @@ -35,7 +35,7 @@ public function test_should_call_wp_customize_manager() { ->with( 'wp_customize', $test_data['section'] ) ->once() ->ordered() - ->andReturn( array() ); + ->andReturn( [] ); Monkey\Functions\expect( 'beans_add_attribute' ) ->with( 'beans_field_label', 'class', 'customize-control-title' ) diff --git a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_setting.php b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_setting.php index cce0025f..5a5d7ca6 100644 --- a/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_setting.php +++ b/tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_setting.php @@ -35,7 +35,7 @@ public function test_should_call_beans_get_and_wp_customize_manager() { ->with( 'wp_customize', $test_data['section'] ) ->once() ->ordered() - ->andReturn( array() ); + ->andReturn( [] ); Monkey\Functions\expect( 'beans_add_attribute' ) ->with( 'beans_field_label', 'class', 'customize-control-title' ) diff --git a/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php b/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php index af6515d7..7e32c9a2 100644 --- a/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php +++ b/tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php @@ -50,8 +50,8 @@ public function test_should_return_false_when_no_customizer() { Monkey\Functions\expect( 'beans_register_fields' )->never(); - $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); - $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); + $this->assertFalse( beans_register_wp_customize_options( [], '', [] ) ); + $this->assertFalse( beans_register_wp_customize_options( [], 'post_meta', [ 1, 2, 3 ] ) ); } /** @@ -70,18 +70,18 @@ public function test_should_return_false_when_no_options() { ->andReturn( true ); Monkey\Functions\expect( 'beans_register_fields' ) - ->with( array(), 'wp_customize', '' ) + ->with( [], 'wp_customize', '' ) ->once() ->ordered() ->andReturn( false ) ->andAlsoExpectIt() - ->with( array(), 'wp_customize', 'post_meta' ) + ->with( [], 'wp_customize', 'post_meta' ) ->once() ->ordered() ->andReturn( false ); - $this->assertFalse( beans_register_wp_customize_options( array(), '', array() ) ); - $this->assertFalse( beans_register_wp_customize_options( array(), 'post_meta', array( 1, 2, 3 ) ) ); + $this->assertFalse( beans_register_wp_customize_options( [], '', [] ) ); + $this->assertFalse( beans_register_wp_customize_options( [], 'post_meta', [ 1, 2, 3 ] ) ); } /** @@ -105,13 +105,13 @@ public function test_should_register_fields() { ->with( 'wp_customize', $test_data['section'] ) ->once() ->ordered() - ->andReturn( array() ); + ->andReturn( [] ); Monkey\Functions\expect( 'beans_add_attribute' ) ->with( 'beans_field_label', 'class', 'customize-control-title' ) ->once() ->ordered() - ->andReturn( array() ); + ->andReturn( [] ); Monkey\Functions\expect( 'beans_register_fields' ) ->with( $test_data['fields'], 'wp_customize', $test_data['section'] ) diff --git a/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php index f4b13e08..2b9e24ba 100644 --- a/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php +++ b/tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php @@ -7,90 +7,90 @@ * @since 1.5.0 */ -return array( +return [ // Single fields. - 'single_fields' => array( - 'fields' => array( + 'single_fields' => [ + 'fields' => [ 'name' => 'beans-test', 'type' => 'radio', 'label' => 'Layout', - array( + [ 'id' => 'beans_customizer_layout', 'name' => 'beans-test', 'label' => 'Layout', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', - ), - ), - array( + ], + ], + [ 'id' => 'beans_customizer_checkbox', 'name' => 'beans-test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_customizer_text', 'name' => 'beans-test', 'type' => 'text', 'default' => 'Testing the text field.', - ), - ), + ], + ], 'context' => 'beans-test', 'section' => 'tm-beans-customizer', - 'args' => array( + 'args' => [ 'title' => 'Beans Customizer Section', 'priority' => 250, 'description' => 'Customizer Beans Section', - ), - ), + ], + ], // Group of fields. - 'group' => array( - 'fields' => array( + 'group' => [ + 'fields' => [ 'name' => 'beans-test', 'type' => 'group', - 'fields' => array( - array( + 'fields' => [ + [ 'id' => 'beans_compile_all_scripts', 'name' => 'beans-test', 'type' => 'activation', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_compile_all_scripts_mode', 'name' => 'beans-test', 'type' => 'select', 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], + 'options' => [ 'aggressive' => 'Aggressive', 'standard' => 'Standard', - ), - ), - array( + ], + ], + [ 'id' => 'beans_checkbox_test', 'name' => 'beans-test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - ), - ), + ], + ], + ], 'context' => 'group_tests', 'section' => 'tm-beans-customizer', 'name' => 'beans-test', - 'args' => array( + 'args' => [ 'title' => 'Beans Customizer Section', 'priority' => 250, 'description' => 'Customizer Beans Section', - ), - ), -); + ], + ], +]; diff --git a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php index 2fdc70dc..ffb9b5de 100644 --- a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php @@ -49,11 +49,11 @@ public static function setUpBeforeClass() { public function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/wp-customize/functions.php', 'api/wp-customize/class-beans-wp-customize.php', 'api/wp-customize/class-beans-wp-customize-control.php', - ) ); + ] ); $this->setup_common_wp_stubs(); @@ -73,16 +73,16 @@ public function setUp() { * @return array */ protected function merge_field_with_default( array $field, $set_value = true ) { - $merged_field = array_merge( array( + $merged_field = array_merge( [ 'label' => false, 'description' => false, 'default' => false, 'context' => 'wp_customize', - 'attributes' => array( + 'attributes' => [ 'data-customize-setting-link' => $field['id'], - ), + ], 'db_group' => false, - ), $field ); + ], $field ); $merged_field['name'] = $field['id']; if ( $set_value ) { From f91ce6e7828b516f72dbdc921287ec76b9b2330c Mon Sep 17 00:00:00 2001 From: ibes Date: Fri, 22 Jun 2018 16:59:03 +0200 Subject: [PATCH 777/800] Updated array syntax for the Layout API tests. (PR #273) --- .../integration/api/layout/beansGetLayout.php | 10 +- .../api/layout/beansGetLayoutClass.php | 224 +++++++++--------- .../unit/api/layout/beansGetDefaultLayout.php | 4 +- .../unit/api/layout/beansGetLayout.php | 10 +- .../api/layout/beansHasSecondarySidebar.php | 4 +- 5 files changed, 126 insertions(+), 126 deletions(-) diff --git a/tests/phpunit/integration/api/layout/beansGetLayout.php b/tests/phpunit/integration/api/layout/beansGetLayout.php index f91a25d4..b2c2445b 100644 --- a/tests/phpunit/integration/api/layout/beansGetLayout.php +++ b/tests/phpunit/integration/api/layout/beansGetLayout.php @@ -95,7 +95,7 @@ public function test_should_return_default_layout_when_no_static_posts_page() { */ public function test_should_return_layout_for_category() { $post_id = self::factory()->post->create(); - $category_id = self::factory()->category->create( array( 'slug' => 'test-cat' ) ); + $category_id = self::factory()->category->create( [ 'slug' => 'test-cat' ] ); wp_set_object_terms( $post_id, $category_id, 'category' ); $meta_key = "beans_term_{$category_id}_beans_layout"; @@ -121,7 +121,7 @@ public function test_should_return_layout_for_category() { */ public function test_should_return_layout_for_tag() { $post_id = self::factory()->post->create(); - $tag_id = self::factory()->tag->create( array( 'slug' => 'test-tag' ) ); + $tag_id = self::factory()->tag->create( [ 'slug' => 'test-tag' ] ); wp_set_object_terms( $post_id, $tag_id, 'post_tag' ); $meta_key = "beans_term_{$tag_id}_beans_layout"; @@ -146,12 +146,12 @@ public function test_should_return_layout_for_tag() { * Test beans_get_layout() should return layout for a custom taxonomy. */ public function test_should_return_layout_for_custom_tax() { - register_taxonomy( 'test_tax', 'post', array( 'public' => true ) ); + register_taxonomy( 'test_tax', 'post', [ 'public' => true ] ); $post_id = self::factory()->post->create(); - $term_id = self::factory()->term->create( array( + $term_id = self::factory()->term->create( [ 'taxonomy' => 'test_tax', 'slug' => 'custom-term', - ) ); + ] ); wp_set_object_terms( $post_id, $term_id, 'test_tax' ); $meta_key = "beans_term_{$term_id}_beans_layout"; diff --git a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php index 761ed419..f253ee08 100644 --- a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php @@ -88,35 +88,35 @@ protected function run_the_tests( array $test_parameters, $layout_id ) { * Test beans_get_default_layout() should return classes when the layout is "c". */ public function test_should_return_classes_when_layout_is_c() { - $test_parameters = array( - array( - 'expected' => array( + $test_parameters = [ + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => false, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => true, - ), - ); + ], + ]; $this->run_the_tests( $test_parameters, 'c' ); } @@ -125,35 +125,35 @@ public function test_should_return_classes_when_layout_is_c() { * Test beans_get_default_layout() should return classes when the layout is "c_sp". */ public function test_should_return_classes_when_layout_is_c_sp() { - $test_parameters = array( - array( - 'expected' => array( + $test_parameters = [ + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => false, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-3-4', 'sidebar_primary' => 'uk-width-medium-1-4', 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-3-4', 'sidebar_primary' => 'uk-width-medium-1-4', 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => true, - ), - ); + ], + ]; $this->run_the_tests( $test_parameters, 'c_sp' ); } @@ -162,35 +162,35 @@ public function test_should_return_classes_when_layout_is_c_sp() { * Test beans_get_default_layout() should return classes when the layout is "sp_c". */ public function test_should_return_classes_when_layout_is_sp_c() { - $test_parameters = array( - array( - 'expected' => array( + $test_parameters = [ + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => false, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-3-4 uk-push-1-4', 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-3-4 uk-push-1-4', 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => true, - ), - ); + ], + ]; $this->run_the_tests( $test_parameters, 'sp_c' ); } @@ -199,35 +199,35 @@ public function test_should_return_classes_when_layout_is_sp_c() { * Test beans_get_default_layout() should return classes when the layout is "c_ss". */ public function test_should_return_classes_when_layout_is_c_ss() { - $test_parameters = array( - array( - 'expected' => array( + $test_parameters = [ + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => false, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-3-4', 'sidebar_primary' => null, 'sidebar_secondary' => 'uk-width-medium-1-4', - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => true, - ), - ); + ], + ]; $this->run_the_tests( $test_parameters, 'c_ss' ); } @@ -236,35 +236,35 @@ public function test_should_return_classes_when_layout_is_c_ss() { * Test beans_get_default_layout() should return classes when the layout is "c_sp_ss". */ public function test_should_return_classes_when_layout_is_c_sp_ss() { - $test_parameters = array( - array( - 'expected' => array( + $test_parameters = [ + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => false, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-3-4', 'sidebar_primary' => 'uk-width-medium-1-4', 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-2-4', 'sidebar_primary' => 'uk-width-medium-1-4', 'sidebar_secondary' => 'uk-width-medium-1-4', - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => true, - ), - ); + ], + ]; $this->run_the_tests( $test_parameters, 'c_sp_ss' ); } @@ -273,35 +273,35 @@ public function test_should_return_classes_when_layout_is_c_sp_ss() { * Test beans_get_default_layout() should return classes when the layout is "ss_c". */ public function test_should_return_classes_when_layout_is_ss_c() { - $test_parameters = array( - array( - 'expected' => array( + $test_parameters = [ + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => false, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-3-4 uk-push-1-4', 'sidebar_primary' => null, 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-3-4', - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => true, - ), - ); + ], + ]; $this->run_the_tests( $test_parameters, 'ss_c' ); } @@ -310,35 +310,35 @@ public function test_should_return_classes_when_layout_is_ss_c() { * Test beans_get_default_layout() should return classes when the layout is "sp_ss_c". */ public function test_should_return_classes_when_layout_is_sp_ss_c() { - $test_parameters = array( - array( - 'expected' => array( + $test_parameters = [ + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => false, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-3-4 uk-push-1-4', 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-2-4 uk-push-2-4', 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-2-4', - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => true, - ), - ); + ], + ]; $this->run_the_tests( $test_parameters, 'sp_ss_c' ); } @@ -347,35 +347,35 @@ public function test_should_return_classes_when_layout_is_sp_ss_c() { * Test beans_get_default_layout() should return classes when the layout is "sp_c_ss". */ public function test_should_return_classes_when_layout_is_sp_c_ss() { - $test_parameters = array( - array( - 'expected' => array( + $test_parameters = [ + [ + 'expected' => [ 'content' => 'uk-width-medium-4-4', 'sidebar_primary' => null, 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => false, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-3-4 uk-push-1-4', 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', 'sidebar_secondary' => null, - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => false, - ), - array( - 'expected' => array( + ], + [ + 'expected' => [ 'content' => 'uk-width-medium-2-4 uk-push-1-4', 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', 'sidebar_secondary' => 'uk-width-medium-1-4', - ), + ], 'sidebar_primary' => true, 'sidebar_secondary' => true, - ), - ); + ], + ]; $this->run_the_tests( $test_parameters, 'sp_c_ss' ); } diff --git a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php index 3194d242..4d43aefc 100644 --- a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php @@ -27,10 +27,10 @@ class Tests_BeansGetDefaultLayout extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/layout/functions.php', 'api/widget/functions.php', - ) ); + ] ); } /** diff --git a/tests/phpunit/unit/api/layout/beansGetLayout.php b/tests/phpunit/unit/api/layout/beansGetLayout.php index b5408b7e..ea94e30d 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetLayout.php @@ -27,11 +27,11 @@ class Tests_BeansGetLayout extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/layout/functions.php', 'api/post-meta/functions.php', 'api/term-meta/functions.php', - ) ); + ] ); } /** @@ -42,7 +42,7 @@ public function test_should_return_layout_for_singular() { ->times( 3 ) ->andReturn( true ); - foreach ( array( 'c', 'c_sp', 'sp_c_ss' ) as $layout ) { + foreach ( [ 'c', 'c_sp', 'sp_c_ss' ] as $layout ) { Monkey\Functions\expect( 'beans_get_post_meta' ) ->once() @@ -75,7 +75,7 @@ public function test_should_return_layout_for_static_posts_page() { ->with( 'page_for_posts' ) ->andReturn( 1 ); - foreach ( array( 'c', 'c_sp', 'sp_c_ss' ) as $layout ) { + foreach ( [ 'c', 'c_sp', 'sp_c_ss' ] as $layout ) { Monkey\Functions\expect( 'beans_get_post_meta' ) ->once() @@ -106,7 +106,7 @@ public function test_should_return_layout_for_cat_tag_tax() { ->times( 3 ) ->andReturn( true ); - foreach ( array( 'c', 'c_sp', 'sp_c_ss' ) as $layout ) { + foreach ( [ 'c', 'c_sp', 'sp_c_ss' ] as $layout ) { Monkey\Functions\expect( 'beans_get_term_meta' ) ->once() diff --git a/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php b/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php index 30c29d37..63d33d0d 100644 --- a/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php +++ b/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php @@ -27,9 +27,9 @@ class Tests_BeansHasSecondarySidebar extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/layout/functions.php', - ) ); + ] ); } /** From e4b9f247eba04ee2c89662d34cfa489c280e9675 Mon Sep 17 00:00:00 2001 From: ibes Date: Sat, 23 Jun 2018 01:30:15 +0200 Subject: [PATCH 778/800] Updated array syntax for Compiler API tests. (PR #275) --- .../beans-compiler/addContentMediaQuery.php | 14 ++-- .../api/compiler/beans-compiler/cacheFile.php | 18 ++-- .../beans-compiler/combineFragments.php | 82 +++++++++---------- .../api/compiler/beans-compiler/fileystem.php | 16 ++-- .../compiler/beans-compiler/formatContent.php | 36 ++++---- .../beans-compiler/getInternalContent.php | 18 ++-- .../beans-compiler/getRemoteContent.php | 26 +++--- .../compiler/beans-compiler/replaceCssUrl.php | 10 +-- .../compiler/beans-compiler/runCompiler.php | 46 +++++------ .../compiler/beans-compiler/setFilename.php | 22 ++--- .../compiler/beansCompileLessFragments.php | 4 +- .../includes/class-base-test-case.php | 16 ++-- .../includes/class-compiler-test-case.php | 12 +-- .../beans-compiler/addContentMediaQuery.php | 12 +-- .../api/compiler/beans-compiler/cacheFile.php | 36 ++++---- .../beans-compiler/cacheFileExist.php | 18 ++-- .../beans-compiler/combineFragments.php | 80 +++++++++--------- .../compiler/beans-compiler/formatContent.php | 36 ++++---- .../unit/api/compiler/beans-compiler/get.php | 40 ++++----- .../compiler/beans-compiler/getExtension.php | 12 +-- .../beans-compiler/getFunctionContent.php | 4 +- .../beans-compiler/getInternalContent.php | 6 +- .../beans-compiler/getRemoteContent.php | 50 +++++------ .../compiler/beans-compiler/runCompiler.php | 46 +++++------ .../compiler/beans-compiler/setFilename.php | 22 ++--- .../compiler/beans-compiler/setFragments.php | 36 ++++---- .../api/compiler/beansCompilerAddFragment.php | 8 +- .../includes/class-base-test-case.php | 20 ++--- .../class-compiler-options-test-case.php | 4 +- .../includes/class-compiler-test-case.php | 12 +-- .../class-page-compiler-test-case.php | 4 +- 31 files changed, 383 insertions(+), 383 deletions(-) diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php index 24adbb25..085359ea 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php @@ -27,7 +27,7 @@ class Tests_BeansCompiler_AddContentMediaQuery extends Compiler_Test_Case { * Test _Beans_Compiler::add_content_media_query() should return original content when current fragment is callable. */ public function test_should_return_content_when_fragment_is_callable() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); $css = <<set_current_fragment( $compiler, array( $this, __METHOD__ ) ); + $this->set_current_fragment( $compiler, [ $this, __METHOD__ ] ); $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); } @@ -43,7 +43,7 @@ public function test_should_return_content_when_fragment_is_callable() { * Test _Beans_Compiler::add_content_media_query() should return original content when there are no query args. */ public function test_should_return_content_when_no_query_args() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); $css = <<set_current_fragment( $compiler, 'http://foo.com/base.css?beans_compiler_media_query=' . $media_query ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php index d7841302..ece67172 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php @@ -32,8 +32,8 @@ public function test_should_create_compiled_jquery_file() { $config = [ 'id' => 'test-jquery', 'type' => 'script', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, ]; @@ -44,7 +44,7 @@ public function test_should_create_compiled_jquery_file() { $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); // Clean Up. - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } /** @@ -54,7 +54,7 @@ public function test_should_create_compiled_javascript_file() { $config = [ 'id' => 'test-js', 'type' => 'script', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ), + 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ], 'in_footer' => true, 'minify_js' => true, ]; @@ -65,7 +65,7 @@ public function test_should_create_compiled_javascript_file() { $this->assertSame( $this->get_compiled_js(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); // Clean Up. - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } /** @@ -75,7 +75,7 @@ public function test_should_create_compiled_css_file() { $config = [ 'id' => 'test-css', 'type' => 'style', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/style.css' ) ), + 'fragments' => [ vfsStream::url( 'compiled/fixtures/style.css' ) ], ]; $compiler = $this->initialize_compiler( $config ); @@ -84,7 +84,7 @@ public function test_should_create_compiled_css_file() { $this->assertSame( $this->get_compiled_css(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); // Clean Up. - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } /** @@ -107,7 +107,7 @@ public function test_should_create_compiled_less_file() { $this->assertSame( $this->get_compiled_less(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); // Clean Up. - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } /** @@ -123,7 +123,7 @@ public function test_should_create_compiled_less_file() { protected function initialize_compiler( array $config ) { $compiler = new _Beans_Compiler( $config ); - add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); $compiler->filesystem(); $this->add_virtual_directory( $config['id'] ); $this->set_current_fragment( $compiler, $config['fragments'][0] ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php index bcf7e9b0..462bdcf0 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php @@ -69,7 +69,7 @@ public function setUp() { * Test _Beans_Compiler::combine_fragments() should return an empty string when there are no fragments to combine. */ public function test_should_return_empty_string_when_no_fragments() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); // Run the test. $compiler->combine_fragments(); @@ -81,7 +81,7 @@ public function test_should_return_empty_string_when_no_fragments() { */ public function test_should_return_empty_string_when_fragment_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); $this->set_current_fragment( $compiler, $fragment ); // Run the test. @@ -93,15 +93,15 @@ public function test_should_return_empty_string_when_fragment_does_not_exist() { * Test _Beans_Compiler::combine_fragments() should compile the Less fragments and return the compiled CSS. */ public function test_should_compile_less_and_return_css() { - $compiler = new _Beans_Compiler( array( + $compiler = new _Beans_Compiler( [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), - ) ); + ], + ] ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -124,15 +124,15 @@ public function test_should_compile_less_and_return_css() { * Test _Beans_Compiler::combine_fragments() should return minified, compiled Less from the Less combined fragments. */ public function test_should_return_minified_compiled_less() { - $compiler = new _Beans_Compiler( array( + $compiler = new _Beans_Compiler( [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), - ) ); + ], + ] ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -148,15 +148,15 @@ public function test_should_return_minified_compiled_less() { * but "minify_js" is disabled. */ public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( array( + $compiler = new _Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => false, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ), - 'dependencies' => array( 'jquery' ), - ) ); + ], + 'dependencies' => [ 'jquery' ], + ] ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -172,15 +172,15 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = new _Beans_Compiler( array( + $compiler = new _Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ), - 'dependencies' => array( 'jquery' ), - ) ); + ], + 'dependencies' => [ 'jquery' ], + ] ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -195,15 +195,15 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * Test _Beans_Compiler::combine_fragments() should return minified jQuery. */ public function test_should_return_minified_jquery() { - $compiler = new _Beans_Compiler( array( + $compiler = new _Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ), - 'dependencies' => array( 'jquery' ), - ) ); + ], + 'dependencies' => [ 'jquery' ], + ] ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -219,14 +219,14 @@ public function test_should_return_minified_jquery() { * mode, but "minify_js" is disabled. */ public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( array( + $compiler = new _Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => false, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ), - ) ); + ], + ] ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -238,7 +238,7 @@ public function test_should_return_original_js_when_minify_js_disabled() { // Clean up. unset( $GLOBALS['wp_filesystem'] ); - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } /** @@ -246,14 +246,14 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = new _Beans_Compiler( array( + $compiler = new _Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ), - ) ); + ], + ] ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -264,21 +264,21 @@ public function test_should_always_return_original_js_when_in_dev_mode() { $this->assertSame( $this->js, $compiler->compiled_content ); // Clean up. - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } /** * Test _Beans_Compiler::combine_fragments() should return minified JavaScript. */ public function test_should_return_minified_javascript() { - $compiler = new _Beans_Compiler( array( + $compiler = new _Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ), - ) ); + ], + ] ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -289,7 +289,7 @@ public function test_should_return_minified_javascript() { $this->assertSame( $this->get_compiled_js(), $compiler->compiled_content ); // Clean up. - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } /** @@ -302,7 +302,7 @@ public function test_should_return_minified_javascript() { * @return void */ private function set_up_wp_filesystem( $compiler ) { - add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); $compiler->filesystem(); $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); } diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php index 91c4c29d..774d2a24 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php @@ -28,11 +28,11 @@ class Tests_BeansCompiler_Filesystem extends Compiler_Test_Case { * Test _Beans_Compiler::filesystem() should render a report and die when no filesystem is selected. */ public function test_should_render_report_and_die_when_no_filesystem_selected() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); // Let's just make sure we start without the WP Filesystem being initialized. unset( $GLOBALS['wp_filesystem'] ); - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); add_filter( 'filesystem_method', __NAMESPACE__ . '\set_filesystem_method_to_base' ); // Set up the mocks. @@ -62,9 +62,9 @@ public function test_should_render_report_and_die_when_no_filesystem_selected() * Test _Beans_Compiler::filesystem() should initialize the WP Filesystem. */ public function test_should_init_wp_filesystem() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); - add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); // Initialize the WP Filesystem. $this->assertTrue( $compiler->filesystem() ); @@ -75,7 +75,7 @@ public function test_should_init_wp_filesystem() { $this->assertArrayHasKey( 'wp_filesystem', $GLOBALS ); $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } /** @@ -93,11 +93,11 @@ public function test_should_set_wp_filesystem_direct() { remove_filter( 'filesystem_method', __NAMESPACE__ . '\set_filesystem_method_to_base' ); // Next, let's run our Compiler's filesystem and check that it did initialize WP_Filesystem_Direct. - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); - add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); $this->assertTrue( $compiler->filesystem() ); $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } } diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php index 9b9fc9af..9b3d083c 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -60,9 +60,9 @@ public function setUp() { * a style or script (per the configuration). */ public function test_should_return_original_content_when_type_not_style_or_script() { - $compiler = new \_Beans_Compiler( array( + $compiler = new \_Beans_Compiler( [ 'type' => 'foo', - ) ); + ] ); // Run the tests. $this->assertSame( $this->less, $compiler->format_content( $this->less ) ); @@ -75,11 +75,11 @@ public function test_should_return_original_content_when_type_not_style_or_scrip * fragments. */ public function test_should_return_compiled_css() { - $compiler = new \_Beans_Compiler( array( + $compiler = new \_Beans_Compiler( [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - ) ); + ] ); // Turn on development mode. update_option( 'beans_dev_mode', true ); @@ -101,11 +101,11 @@ public function test_should_return_compiled_css() { * Test _Beans_Compiler::format_content() should return minified, compiled CSS from the Less combined fragments. */ public function test_should_return_minified_compiled_css() { - $compiler = new \_Beans_Compiler( array( + $compiler = new \_Beans_Compiler( [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - ) ); + ] ); // Turn off development mode. update_option( 'beans_dev_mode', false ); @@ -123,11 +123,11 @@ public function test_should_return_minified_compiled_css() { * but "minify_js" is disabled. */ public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = new \_Beans_Compiler( array( + $compiler = new \_Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => false, - ) ); + ] ); // Turn off development mode. update_option( 'beans_dev_mode', false ); @@ -141,11 +141,11 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = new \_Beans_Compiler( array( + $compiler = new \_Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - ) ); + ] ); // Turn on development mode. update_option( 'beans_dev_mode', true ); @@ -159,11 +159,11 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = new \_Beans_Compiler( array( + $compiler = new \_Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - ) ); + ] ); // Turn off development mode. update_option( 'beans_dev_mode', false ); @@ -182,11 +182,11 @@ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_mini * mode, but "minify_js" is disabled. */ public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = new \_Beans_Compiler( array( + $compiler = new \_Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => false, - ) ); + ] ); // Turn off development mode. update_option( 'beans_dev_mode', false ); @@ -200,11 +200,11 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = new \_Beans_Compiler( array( + $compiler = new \_Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - ) ); + ] ); // Turn on development mode. update_option( 'beans_dev_mode', true ); @@ -218,11 +218,11 @@ public function test_should_always_return_original_js_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = new \_Beans_Compiler( array( + $compiler = new \_Beans_Compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - ) ); + ] ); // Turn off development mode. update_option( 'beans_dev_mode', false ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php index 462ca491..5f7d5cec 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php @@ -28,7 +28,7 @@ class Tests_BeansCompiler_GetInternalContent extends Compiler_Test_Case { * Test _Beans_Compiler::get_internal_content() should return false when fragment is empty. */ public function test_should_return_false_when_fragment_is_empty() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); // Run the test. $this->assertfalse( $compiler->get_internal_content( '' ) ); @@ -40,9 +40,9 @@ public function test_should_return_false_when_fragment_is_empty() { public function test_should_return_false_when_file_does_not_exist() { // Set up the compiler. $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = new _Beans_Compiler( array( - 'fragments' => array( $fragment ), - ) ); + $compiler = new _Beans_Compiler( [ + 'fragments' => [ $fragment ], + ] ); $this->set_current_fragment( $compiler, $fragment ); // Run the test. @@ -55,13 +55,13 @@ public function test_should_return_false_when_file_does_not_exist() { public function test_should_return_fragment_contents() { // Set up the compiler. $fragment = vfsStream::url( 'compiled/fixtures/test.less' ); - $compiler = new _Beans_Compiler( array( - 'fragments' => array( $fragment ), - ) ); + $compiler = new _Beans_Compiler( [ + 'fragments' => [ $fragment ], + ] ); $this->set_current_fragment( $compiler, $fragment ); // Set the WP Filesystem. - add_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); $compiler->filesystem(); $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); @@ -71,6 +71,6 @@ public function test_should_return_fragment_contents() { $this->assertContains( 'color: @body-color;', $contents ); // Clean up. - remove_filter( 'filesystem_method', array( $compiler, 'modify_filesystem_method' ) ); + remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); } } diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php index 4f238757..b36962f9 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php @@ -27,7 +27,7 @@ class Tests_BeansCompiler_GetRemoteContent extends Compiler_Test_Case { * Test _Beans_Compiler::get_remote_content() should return false when fragment is empty. */ public function test_should_return_false_when_fragment_is_empty() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); // Run the test. $this->assertfalse( $compiler->get_remote_content( '' ) ); @@ -39,9 +39,9 @@ public function test_should_return_false_when_fragment_is_empty() { */ public function test_should_return_empty_string_when_remote_does_not_exist() { $fragment = 'http://beans.local/invalid-file.js'; - $compiler = new _Beans_Compiler( array( - 'fragments' => array( $fragment ), - ) ); + $compiler = new _Beans_Compiler( [ + 'fragments' => [ $fragment ], + ] ); $this->set_current_fragment( $compiler, $fragment ); // Run the test. @@ -53,9 +53,9 @@ public function test_should_return_empty_string_when_remote_does_not_exist() { */ public function test_should_return_content_when_fragment_is_relative_url() { $fragment = '//fonts.googleapis.com/css?family=Lato'; - $compiler = new _Beans_Compiler( array( - 'fragments' => array( $fragment ), - ) ); + $compiler = new _Beans_Compiler( [ + 'fragments' => [ $fragment ], + ] ); $this->set_current_fragment( $compiler, $fragment ); $content = $compiler->get_remote_content( $fragment ); @@ -72,9 +72,9 @@ public function test_should_return_content_when_fragment_is_relative_url() { */ public function test_should_return_content_when_fragment_is_http() { $fragment = 'http://fonts.googleapis.com/css?family=Roboto'; - $compiler = new _Beans_Compiler( array( - 'fragments' => array( $fragment ), - ) ); + $compiler = new _Beans_Compiler( [ + 'fragments' => [ $fragment ], + ] ); $this->set_current_fragment( $compiler, $fragment ); $content = $compiler->get_remote_content( $fragment ); @@ -91,9 +91,9 @@ public function test_should_return_content_when_fragment_is_http() { */ public function test_should_return_content_when_fragment_is_https() { $fragment = 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'; - $compiler = new _Beans_Compiler( array( - 'fragments' => array( $fragment ), - ) ); + $compiler = new _Beans_Compiler( [ + 'fragments' => [ $fragment ], + ] ); $this->set_current_fragment( $compiler, $fragment ); $content = $compiler->get_remote_content( $fragment ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php index cdaddbf4..16e71381 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php @@ -27,7 +27,7 @@ class Tests_BeansCompiler_ReplaceCssUrl extends Compiler_Test_Case { * Test _Beans_Compiler::replace_css_url() should return original content when there is no url source in the CSS. */ public function test_should_return_original_content_when_no_url() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); $css = <<set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); @@ -91,7 +91,7 @@ public function test_should_convert_relative_url_when_no_up_levels() { * Test _Beans_Compiler::replace_css_url() should convert the relative URL. */ public function test_should_convert_relative_url() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); // Set up the mocks. $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); @@ -143,7 +143,7 @@ public function test_should_convert_relative_url() { * Test _Beans_Compiler::replace_css_url() should convert a deeper relative URL. */ public function test_should_convert_deeper_relative_url() { - $compiler = new _Beans_Compiler( array() ); + $compiler = new _Beans_Compiler( [] ); // Set up the mocks. $this->set_current_fragment( $compiler, 'http://example.com/assets/less/partials/hero.less' ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php index 3daf2cda..8657cd12 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php @@ -71,16 +71,16 @@ public function setUp() { */ public function test_should_enqueue_existing_cached_file_when_no_modifications() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test-jquery', 'type' => 'script', 'format' => 'js', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => '1.5.0', - ); + ]; $compiler = new _Beans_Compiler( $config ); // Store the cached file into the virtual filesystem. @@ -109,16 +109,16 @@ public function test_should_enqueue_existing_cached_file_when_no_modifications() */ public function test_should_recompile_when_fragments_change() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test-script', 'type' => 'script', 'format' => 'js', - 'fragments' => array( $fragment ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ $fragment ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = new _Beans_Compiler( $config ); /** @@ -179,16 +179,16 @@ public function test_should_recompile_when_fragments_change() { */ public function test_should_compile_save_and_enqueue_jquery() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test-jquery', 'type' => 'script', 'format' => 'js', - 'fragments' => array( $fragment ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ $fragment ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = new _Beans_Compiler( $config ); // Set up the virtual directory. @@ -211,16 +211,16 @@ public function test_should_compile_save_and_enqueue_jquery() { */ public function test_should_compile_save_and_enqueue_js() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $config = array( + $config = [ 'id' => 'test-js', 'type' => 'script', 'format' => 'js', - 'fragments' => array( $fragment ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ $fragment ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = new _Beans_Compiler( $config ); // Set up the virtual directory. @@ -243,16 +243,16 @@ public function test_should_compile_save_and_enqueue_js() { */ public function test_should_compile_save_and_enqueue_css() { $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); - $config = array( + $config = [ 'id' => 'test-css', 'type' => 'style', 'format' => 'css', - 'fragments' => array( $fragment ), + 'fragments' => [ $fragment ], 'dependencies' => false, 'in_footer' => false, 'minify_js' => false, 'version' => '1.5.0', - ); + ]; $compiler = new _Beans_Compiler( $config ); // Set up the virtual directory. @@ -274,19 +274,19 @@ public function test_should_compile_save_and_enqueue_css() { * WordPress. */ public function test_should_compile_save_and_enqueue_less() { - $config = array( + $config = [ 'id' => 'test-css', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), + ], 'dependencies' => false, 'in_footer' => false, 'minify_js' => false, 'version' => '1.5.0', - ); + ]; $compiler = new _Beans_Compiler( $config ); // Set up the virtual directory. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php index 9651c31f..b3bba301 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php @@ -41,16 +41,16 @@ public function setUp() { */ public function test_should_return_hash_created_with_fragments_filemtime() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test-script', 'type' => 'script', 'format' => false, - 'fragments' => array( $fragment ), + 'fragments' => [ $fragment ], 'dependencies' => false, 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = new _Beans_Compiler( $config ); // Set up the mocks. @@ -68,19 +68,19 @@ public function test_should_return_hash_created_with_fragments_filemtime() { */ public function test_should_exclude_external_fragments() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $config = array( + $config = [ 'id' => 'test-script', 'type' => 'script', 'format' => false, - 'fragments' => array( + 'fragments' => [ $fragment, 'http://foo.com/my-script.js', // Should skip this one. - ), + ], 'dependencies' => false, 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = new _Beans_Compiler( $config ); // Set up the mocks. @@ -103,16 +103,16 @@ public function test_should_exclude_external_fragments() { */ public function test_should_remove_old_file() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test', 'type' => 'script', 'format' => 'js', - 'fragments' => array( $fragment ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ $fragment ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = new _Beans_Compiler( $config ); // Set up the mocks. diff --git a/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php b/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php index 95127a3e..5fe9b0a1 100644 --- a/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php +++ b/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php @@ -29,10 +29,10 @@ class Tests_BeansCompileLessFragments extends Compiler_Test_Case { */ public function test_should_compile_save_and_enqueue_less() { $id = 'compile-less-fragments'; - $fragments = array( + $fragments = [ vfsStream::url( 'compiled/fixtures/test.less' ), vfsStream::url( 'compiled/fixtures/variables.less' ), - ); + ]; $this->add_virtual_directory( $id ); $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); diff --git a/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php index dee9913a..818d815b 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php @@ -77,16 +77,16 @@ protected function set_up_virtual_filesystem() { * Get the virtual filesystem's structure. */ protected function get_virtual_structure() { - return array( - 'beans' => array( - 'compiler' => array( + return [ + 'beans' => [ + 'compiler' => [ 'index.php' => '', - ), - 'admin-compiler' => array( + ], + 'admin-compiler' => [ 'index.php' => '', - ), - ), - ); + ], + ], + ]; } /** diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php index a0f202b2..c915c8e2 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php @@ -72,11 +72,11 @@ public function setUp() { // Set up the global fragments container. global $_beans_compiler_added_fragments; - $_beans_compiler_added_fragments = array( - 'css' => array(), - 'less' => array(), - 'js' => array(), - ); + $_beans_compiler_added_fragments = [ + 'css' => [], + 'less' => [], + 'js' => [], + ]; // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); @@ -185,7 +185,7 @@ protected function get_filename( $compiler, $config, $filemtime = null ) { $filemtimes[ $index ] = filemtime( $fragment ); } } else { - $filemtimes = array( $filemtime ); + $filemtimes = [ $filemtime ]; } return sprintf( diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php index e9736f56..a5b8841b 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php @@ -38,7 +38,7 @@ public function test_should_return_content_when_fragment_is_callable() { width: 100%; } EOB; - $this->set_current_fragment( $compiler, array( $this, __METHOD__ ) ); + $this->set_current_fragment( $compiler, [ $this, __METHOD__ ] ); $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); } @@ -72,7 +72,7 @@ public function test_should_return_content_when_no_media_query() { Monkey\Functions\expect( 'wp_parse_args' )->never(); Monkey\Functions\expect( 'beans_get' )->never(); - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); $css = <<create_compiler( array() ); + $compiler = $this->create_compiler( [] ); $css = <<set_current_fragment( $compiler, 'http://foo.com/base.css?beans_compiler_media_query=' . $media_query ); @@ -119,7 +119,7 @@ public function test_should_wrap_content_in_media_query() { } ); Monkey\Functions\expect( 'beans_get' ) ->once() - ->with( 'beans_compiler_media_query', array( 'beans_compiler_media_query' => $media_query ) ) + ->with( 'beans_compiler_media_query', [ 'beans_compiler_media_query' => $media_query ] ) ->andReturn( $media_query ); $this->assertSame( diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php index 1295b34e..65d4ee8d 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php @@ -28,14 +28,14 @@ class Tests_BeansCompiler_CacheFile extends Compiler_Test_Case { * Test _Beans_Compiler::cache_file() should not create the file when the filename is empty. */ public function test_should_not_create_the_file_when_filename_empty() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test-script', 'type' => 'script', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, - ) ); + ] ); // Run the tests. $this->assertFalse( $compiler->cache_file() ); @@ -48,14 +48,14 @@ public function test_should_not_create_the_file_when_filename_empty() { * Test _Beans_Compiler::cache_file() should create the compiled jQuery file. */ public function test_should_create_compiled_jquery_file() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test-jquery', 'type' => 'script', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, - ) ); + ] ); // Mock the compiler's properties. $compiled_content = $this->get_compiled_jquery(); @@ -77,13 +77,13 @@ public function test_should_create_compiled_jquery_file() { * Test _Beans_Compiler::cache_file() should create the compiled JavaScript file. */ public function test_should_create_compiled_javascript_file() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test-js', 'type' => 'script', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ), + 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ], 'in_footer' => true, 'minify_js' => true, - ) ); + ] ); // Mock the compiler's properties. $compiled_content = $this->get_compiled_jquery(); @@ -105,12 +105,12 @@ public function test_should_create_compiled_javascript_file() { * Test _Beans_Compiler::cache_file() should create the compiled CSS file. */ public function test_should_create_compiled_css_file() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test-css', 'type' => 'style', 'format' => 'css', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/style.css' ) ), - ) ); + 'fragments' => [ vfsStream::url( 'compiled/fixtures/style.css' ) ], + ] ); // Mock the compiler's properties. $compiled_content = $this->get_compiled_css(); @@ -132,15 +132,15 @@ public function test_should_create_compiled_css_file() { * Test _Beans_Compiler::cache_file() should create the compiled LESS file. */ public function test_should_create_compiled_less_file() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test-less', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), - ) ); + ], + ] ); // Mock the compiler's properties. $compiled_content = $this->get_compiled_less(); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php index 464262f8..94e80a35 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php @@ -28,11 +28,11 @@ class Tests_BeansCompiler_CacheFileExist extends Compiler_Test_Case { */ public function test_should_return_false_when_filename_not_generated() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', - 'fragments' => array( $fragment ), - ) ); + 'fragments' => [ $fragment ], + ] ); // Run cache_file_exist(). $this->assertFalse( $compiler->cache_file_exist() ); @@ -43,11 +43,11 @@ public function test_should_return_false_when_filename_not_generated() { */ public function test_should_return_false_when_file_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test-script', 'type' => 'script', - 'fragments' => array( $fragment ), - ) ); + 'fragments' => [ $fragment ], + ] ); // Mock the compiler's property. $filename = '9a71ddb-b8d5d01.js'; @@ -63,11 +63,11 @@ public function test_should_return_false_when_file_does_not_exist() { */ public function test_should_return_true_when_file_exists() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test-script', 'type' => 'script', - 'fragments' => array( $fragment ), - ) ); + 'fragments' => [ $fragment ], + ] ); // Mock the compiler's property. $filename = '9a71ddb-b8d5d01.js'; diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php index fa74b7e5..edf2fde1 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -69,7 +69,7 @@ protected function setUp() { * Test _Beans_Compiler::combine_fragments() should return an empty string when there are no fragments to combine. */ public function test_should_return_empty_string_when_no_fragments() { - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); // Run the test. $compiler->combine_fragments(); @@ -81,14 +81,14 @@ public function test_should_return_empty_string_when_no_fragments() { */ public function test_should_return_empty_string_when_fragment_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test-script', 'type' => 'script', - 'fragments' => array( $fragment ), - 'dependencies' => array( 'javascript' ), + 'fragments' => [ $fragment ], + 'dependencies' => [ 'javascript' ], 'in_footer' => true, 'minify_js' => true, - ) ); + ] ); // Set up the mocks. Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); @@ -104,15 +104,15 @@ public function test_should_return_empty_string_when_fragment_does_not_exist() { * Test _Beans_Compiler::combine_fragments() should compile the LESS fragments and return the compiled CSS. */ public function test_should_compile_less_and_return_css() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), - ) ); + ], + ] ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -137,15 +137,15 @@ public function test_should_compile_less_and_return_css() { * Test _Beans_Compiler::combine_fragments() should return minified, compiled CSS from the Less combined fragments. */ public function test_should_return_minified_compiled_css() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), - ) ); + ], + ] ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -167,15 +167,15 @@ public function test_should_return_minified_compiled_css() { * but "minify_js" is disabled. */ public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => false, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ), - 'dependencies' => array( 'jquery' ), - ) ); + ], + 'dependencies' => [ 'jquery' ], + ] ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -193,15 +193,15 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ), - 'dependencies' => array( 'jquery' ), - ) ); + ], + 'dependencies' => [ 'jquery' ], + ] ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -218,15 +218,15 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * Test _Beans_Compiler::combine_fragments() should return minified jQuery. */ public function test_should_return_minified_jquery() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ), - 'dependencies' => array( 'jquery' ), - ) ); + ], + 'dependencies' => [ 'jquery' ], + ] ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -244,14 +244,14 @@ public function test_should_return_minified_jquery() { * mode, but "minify_js" is disabled. */ public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => false, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ), - ) ); + ], + ] ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -269,14 +269,14 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ), - ) ); + ], + ] ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -293,14 +293,14 @@ public function test_should_always_return_original_js_when_in_dev_mode() { * Test _Beans_Compiler::combine_fragments() should return minified JavaScript. */ public function test_should_return_minified_javascript() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ), - ) ); + ], + ] ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php index 4918fe8c..df104f84 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -61,9 +61,9 @@ protected function setUp() { * a style or script (per the configuration). */ public function test_should_return_original_content_when_type_not_style_or_script() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'type' => 'foo', - ) ); + ] ); Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); @@ -78,11 +78,11 @@ public function test_should_return_original_content_when_type_not_style_or_scrip * fragments. */ public function test_should_return_compiled_css() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - ) ); + ] ); $compiled_css = <<create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - ) ); + ] ); $compiled_css = <<create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => false, - ) ); + ] ); // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); @@ -155,11 +155,11 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - ) ); + ] ); // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); @@ -174,11 +174,11 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - ) ); + ] ); $compiled_jquery = <<create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => false, - ) ); + ] ); // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); @@ -220,11 +220,11 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - ) ); + ] ); // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); @@ -239,11 +239,11 @@ public function test_should_always_return_original_js_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'script', 'minify_js' => true, - ) ); + ] ); $compiled_js = << 'test', 'type' => 'script', - 'depedencies' => array( 'jquery' ), - ); + 'depedencies' => [ 'jquery' ], + ]; $compiler = $this->create_compiler( $config ); // Run the tests. $this->assertArrayNotHasKey( 'depedencies', $compiler->config ); $this->assertArrayHasKey( 'dependencies', $compiler->config ); - $this->assertSame( array( 'jquery' ), $compiler->config['dependencies'] ); + $this->assertSame( [ 'jquery' ], $compiler->config['dependencies'] ); } /** * Test _Beans_Compiler::_get() should return the configuration. */ public function test_should_return_configuration() { - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - ) ); + ] ); $this->assertSame( - array( + [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - 'fragments' => array(), + 'fragments' => [], 'dependencies' => false, 'in_footer' => false, 'minify_js' => false, 'version' => false, - ), + ], $compiler->config ); - $compiler = $this->create_compiler( array( + $compiler = $this->create_compiler( [ 'id' => 'test_scripts', 'type' => 'script', - 'dependencies' => array( 'jquery' ), + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'version' => null, - ) ); + ] ); $this->assertSame( - array( + [ 'id' => 'test_scripts', 'type' => 'script', 'format' => false, - 'fragments' => array(), - 'dependencies' => array( 'jquery' ), + 'fragments' => [], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => false, 'version' => null, - ), + ], $compiler->config ); } @@ -90,11 +90,11 @@ public function test_should_return_configuration() { * Test _Beans_Compiler::_get() should return the absolute path to the compiled files directory. */ public function test_should_return_absolute_path_to_compiled_files_dir() { - $config = array( + $config = [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - ); + ]; $compiler = $this->create_compiler( $config ); @@ -106,10 +106,10 @@ public function test_should_return_absolute_path_to_compiled_files_dir() { * Test _Beans_Compiler::_get() should return URL to the compiled files directory. */ public function test_should_return_url_to_compiled_files_dir() { - $config = array( + $config = [ 'id' => 'test_scripts', 'type' => 'script', - ); + ]; $compiler = $this->create_compiler( $config ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php index ffbbc973..f8e13ce3 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php @@ -26,7 +26,7 @@ class Tests_BeansCompiler_GetExtension extends Compiler_Test_Case { * Test _Beans_Compiler::get_extension() should return "css" when the type is "style". */ public function test_should_return_css_when_style() { - $compiler = $this->create_compiler( array( 'type' => 'style' ) ); + $compiler = $this->create_compiler( [ 'type' => 'style' ] ); $this->assertSame( 'css', $compiler->get_extension() ); } @@ -35,7 +35,7 @@ public function test_should_return_css_when_style() { * Test _Beans_Compiler::get_extension() should return "js" when the type is "script". */ public function test_should_return_js_when_script() { - $compiler = $this->create_compiler( array( 'type' => 'script' ) ); + $compiler = $this->create_compiler( [ 'type' => 'script' ] ); $this->assertSame( 'js', $compiler->get_extension() ); } @@ -44,16 +44,16 @@ public function test_should_return_js_when_script() { * Test _Beans_Compiler::get_extension() should return null when the type is invalid. */ public function test_should_return_null_when_invalid_type() { - $compiler = $this->create_compiler( array( 'type' => 'invalid' ) ); + $compiler = $this->create_compiler( [ 'type' => 'invalid' ] ); $this->assertNull( $compiler->get_extension() ); - $compiler = $this->create_compiler( array( 'type' => null ) ); + $compiler = $this->create_compiler( [ 'type' => null ] ); $this->assertNull( $compiler->get_extension() ); - $compiler = $this->create_compiler( array( 'type' => false ) ); + $compiler = $this->create_compiler( [ 'type' => false ] ); $this->assertNull( $compiler->get_extension() ); - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); $this->assertNull( $compiler->get_extension() ); } } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php index b15ceaea..4ca5ab84 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php @@ -36,7 +36,7 @@ public function test_should_return_false_when_fragment_not_callable() { $this->set_current_fragment( $compiler, 'function_does_not_exists' ); $this->assertfalse( $compiler->get_function_content() ); - $this->set_current_fragment( $compiler, array( $this, 'method_does_not_exist' ) ); + $this->set_current_fragment( $compiler, [ $this, 'method_does_not_exist' ] ); $this->assertfalse( $compiler->get_function_content() ); } @@ -66,7 +66,7 @@ public function test_should_return_content_from_method() { $mock->shouldReceive( 'get_content' ) ->once() ->andReturn( 'Beans is innovative!' ); - $this->set_current_fragment( $compiler, array( $mock, 'get_content' ) ); + $this->set_current_fragment( $compiler, [ $mock, 'get_content' ] ); // Run the test. $this->assertSame( 'Beans is innovative!', $compiler->get_function_content() ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php index 13d8eef3..cde7b5c7 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php @@ -59,9 +59,9 @@ public function test_should_return_false_when_file_does_not_exist() { */ public function test_should_return_fragment_contents() { $fragment = vfsStream::url( 'compiled/fixtures/test.less' ); - $compiler = $this->create_compiler( array( - 'fragments' => array( $fragment ), - ) ); + $compiler = $this->create_compiler( [ + 'fragments' => [ $fragment ], + ] ); // Set up the mocks. $this->set_reflective_property( $fragment, 'current_fragment', $compiler ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index ae67783e..ed3ce5d1 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -27,7 +27,7 @@ class Tests_BeansCompiler_GetRemoteContent extends Compiler_Test_Case { * Test _Beans_Compiler::get_remote_content() should return false when the fragment is empty. */ public function test_should_return_false_when_fragment_is_empty() { - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); // Run the tests. $this->assertfalse( $compiler->get_remote_content() ); @@ -46,7 +46,7 @@ public function test_should_return_false_when_fragment_is_empty() { public function test_should_return_empty_string_when_remote_does_not_exist_on_http() { // Set up the compiler. $fragment = 'http://beans.local/invalid-file.js'; - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. @@ -64,12 +64,12 @@ public function test_should_return_empty_string_when_remote_does_not_exist_on_ht public function test_should_return_empty_string_when_remote_does_not_exist_on_https() { // Set up the compiler. $fragment = 'http://beans.local/invalid-file.js'; - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. Monkey\Functions\expect( 'wp_remote_get' )->twice(); - Monkey\Functions\expect( 'is_wp_error' )->twice()->andReturnValues( array( false, true ) ); + Monkey\Functions\expect( 'is_wp_error' )->twice()->andReturnValues( [ false, true ] ); // Run the test. $this->assertSame( '', $compiler->get_remote_content() ); @@ -82,7 +82,7 @@ public function test_should_return_empty_string_when_remote_does_not_exist_on_ht public function test_should_retry_and_return_false_when_remote_file_does_not_exist() { // Set up the compiler. $fragment = 'http://beans.local/invalid-file.js'; - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); $this->set_current_fragment( $compiler, $fragment ); // Set up the mocks. @@ -92,18 +92,18 @@ public function test_should_retry_and_return_false_when_remote_file_does_not_exi ->once() ->ordered() // No "body" element is returned. - ->andReturn( array() ) + ->andReturn( [] ) ->andAlsoExpectIt() // During the retry, it should change to URL to https. ->with( 'https://beans.local/invalid-file.js' ) ->once() ->ordered() - ->andReturn( array( + ->andReturn( [ 'body' => '', - 'response' => array( + 'response' => [ 'code' => 404, // HTTP code is 404 and not 200. - ), - ) ); + ], + ] ); // Run the test. $this->assertFalse( $compiler->get_remote_content() ); @@ -115,14 +115,14 @@ public function test_should_retry_and_return_false_when_remote_file_does_not_exi public function test_should_return_content_when_relative_url() { // Set up the compiler. $fragment = '//fonts.googleapis.com/css?family=Lato'; - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); $this->set_current_fragment( $compiler, $fragment ); - $request = array( + $request = [ 'body' => $this->get_expected_content(), - 'response' => array( + 'response' => [ 'code' => 200, - ), - ); + ], + ]; // Set up the mocks. Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( false ); @@ -151,14 +151,14 @@ public function test_should_return_content_when_relative_url() { public function test_should_return_content_when_http() { // Set up the compiler. $fragment = 'http://fonts.googleapis.com/css?family=Lato'; - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); $this->set_current_fragment( $compiler, $fragment ); - $request = array( + $request = [ 'body' => $this->get_expected_content(), - 'response' => array( + 'response' => [ 'code' => 200, - ), - ); + ], + ]; // Set up the mocks. Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( false ); @@ -187,14 +187,14 @@ public function test_should_return_content_when_http() { public function test_should_return_content_when_https() { // Set up the compiler. $fragment = 'https://fonts.googleapis.com/css?family=Lato'; - $compiler = $this->create_compiler( array() ); + $compiler = $this->create_compiler( [] ); $this->set_current_fragment( $compiler, $fragment ); - $request = array( + $request = [ 'body' => $this->get_expected_content(), - 'response' => array( + 'response' => [ 'code' => 200, - ), - ); + ], + ]; // Set up the mocks. Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( false ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index 494f1e7f..fc24e855 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -71,16 +71,16 @@ protected function setUp() { */ public function test_should_enqueue_existing_cached_file_when_no_modifications() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test-jquery', 'type' => 'script', 'format' => 'js', - 'fragments' => array( vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => '1.5.0', - ); + ]; $compiler = $this->create_compiler( $config ); // Store the cached file into the virtual filesystem. @@ -125,16 +125,16 @@ public function test_should_enqueue_existing_cached_file_when_no_modifications() */ public function test_should_recompile_when_fragments_change() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test-script', 'type' => 'script', 'format' => 'js', - 'fragments' => array( $fragment ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ $fragment ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = $this->create_compiler( $config ); /** @@ -201,16 +201,16 @@ public function test_should_recompile_when_fragments_change() { */ public function test_should_compile_save_and_enqueue_jquery() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test-jquery', 'type' => 'script', 'format' => 'js', - 'fragments' => array( $fragment ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ $fragment ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = $this->create_compiler( $config ); // Prepare the mocks. @@ -231,16 +231,16 @@ public function test_should_compile_save_and_enqueue_jquery() { */ public function test_should_compile_save_and_enqueue_js() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $config = array( + $config = [ 'id' => 'test-js', 'type' => 'script', 'format' => 'js', - 'fragments' => array( $fragment ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ $fragment ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = $this->create_compiler( $config ); // Prepare the mocks. @@ -261,16 +261,16 @@ public function test_should_compile_save_and_enqueue_js() { */ public function test_should_compile_save_and_enqueue_css() { $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); - $config = array( + $config = [ 'id' => 'test-css', 'type' => 'style', 'format' => 'css', - 'fragments' => array( $fragment ), + 'fragments' => [ $fragment ], 'dependencies' => false, 'in_footer' => false, 'minify_js' => false, 'version' => '1.5.0', - ); + ]; $compiler = $this->create_compiler( $config ); // Prepare the mocks. @@ -290,19 +290,19 @@ public function test_should_compile_save_and_enqueue_css() { * WordPress. */ public function test_should_compile_save_and_enqueue_less() { - $config = array( + $config = [ 'id' => 'test-css', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), + ], 'dependencies' => false, 'in_footer' => false, 'minify_js' => false, 'version' => '1.5.0', - ); + ]; $compiler = $this->create_compiler( $config ); // Prepare the mocks. diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php index 8c129389..a4d5413c 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php @@ -29,16 +29,16 @@ class Tests_BeansCompiler_SetFilename extends Compiler_Test_Case { */ public function test_should_return_hash_created_with_fragments_filemtime() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test-script', 'type' => 'script', 'format' => false, - 'fragments' => array( $fragment ), + 'fragments' => [ $fragment ], 'dependencies' => false, 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = $this->create_compiler( $config ); $this->add_virtual_directory( 'test-script' ); @@ -54,19 +54,19 @@ public function test_should_return_hash_created_with_fragments_filemtime() { */ public function test_should_exclude_external_fragments() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $config = array( + $config = [ 'id' => 'test-script', 'type' => 'script', 'format' => false, - 'fragments' => array( + 'fragments' => [ $fragment, 'http://foo.com/my-script.js', // Should skip this one. - ), + ], 'dependencies' => false, 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = $this->create_compiler( $config ); $this->add_virtual_directory( 'test-script' ); @@ -82,16 +82,16 @@ public function test_should_exclude_external_fragments() { */ public function test_should_remove_old_file() { $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = array( + $config = [ 'id' => 'test', 'type' => 'script', 'format' => 'js', - 'fragments' => array( $fragment ), - 'dependencies' => array( 'jquery' ), + 'fragments' => [ $fragment ], + 'dependencies' => [ 'jquery' ], 'in_footer' => true, 'minify_js' => true, 'version' => null, - ); + ]; $compiler = $this->create_compiler( $config ); $this->add_virtual_directory( $config['id'] ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php index 3b44d3e3..6e31379a 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php @@ -29,22 +29,22 @@ class Tests_BeansCompiler_SetFragments extends Compiler_Test_Case { * removed. */ public function test_should_return_unchanged_fragments() { - $config = array( + $config = [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), - ); + ], + ]; $compiler = $this->create_compiler( $config ); // Set up the mock. Monkey\Functions\expect( 'beans_get' ) ->once() - ->with( 'test', array() ) + ->with( 'test', [] ) ->andReturn(); // Check before we start. @@ -60,24 +60,24 @@ public function test_should_return_unchanged_fragments() { * variable. */ public function test_should_return_fragments_merged_with_global() { - $config = array( + $config = [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), - ); + ], + ]; $compiler = $this->create_compiler( $config ); global $_beans_compiler_added_fragments; - $_beans_compiler_added_fragments['less'] = array( - 'test' => array( + $_beans_compiler_added_fragments['less'] = [ + 'test' => [ 'some-file.less', 'another-file.less', - ), - ); + ], + ]; // Set up the mock. Monkey\Functions\expect( 'beans_get' ) @@ -98,22 +98,22 @@ public function test_should_return_fragments_merged_with_global() { * Test _Beans_Compiler::set_fragments() should fire the "beans_compiler_fragments_{id}" event. */ public function test_should_fire_event() { - $config = array( + $config = [ 'id' => 'test', 'type' => 'style', 'format' => 'less', - 'fragments' => array( + 'fragments' => [ vfsStream::url( 'compiled/fixtures/variables.less' ), vfsStream::url( 'compiled/fixtures/test.less' ), - ), - ); + ], + ]; $compiler = $this->create_compiler( $config ); // Set up the mock. Monkey\Functions\expect( 'beans_get' ) ->once() - ->with( 'test', array() ) + ->with( 'test', [] ) ->andReturn(); Monkey\Filters\expectApplied( 'beans_compiler_fragments_test' ) ->once() diff --git a/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php b/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php index a2b79b89..ab1a8f1e 100644 --- a/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php +++ b/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php @@ -56,10 +56,10 @@ public function test_should_add_fragments_when_format_is_valid() { $this->assertArrayHasKey( 'test-css', $_beans_compiler_added_fragments['css'] ); $this->assertSame( [ $fragment ], $_beans_compiler_added_fragments['css']['test-css'] ); - $fragments = array( + $fragments = [ vfsStream::url( 'compiled/fixtures/test.less' ), vfsStream::url( 'compiled/fixtures/variables.less' ), - ); + ]; $this->assertNull( beans_compiler_add_fragment( 'test-less', $fragments, 'less' ) ); $this->assertArrayHasKey( 'test-less', $_beans_compiler_added_fragments['less'] ); $this->assertSame( $fragments, $_beans_compiler_added_fragments['less']['test-less'] ); @@ -81,10 +81,10 @@ public function test_should_add_fragment_to_existing_id() { $_beans_compiler_added_fragments['less']['test-css'] = [ 'theme/base.less' ]; - $fragments = array( + $fragments = [ vfsStream::url( 'compiled/fixtures/test.less' ), vfsStream::url( 'compiled/fixtures/variables.less' ), - ); + ]; $this->assertNull( beans_compiler_add_fragment( 'test-less', $fragments, 'less' ) ); $this->assertContains( $fragments[0], $_beans_compiler_added_fragments['less']['test-less'] ); $this->assertContains( $fragments[1], $_beans_compiler_added_fragments['less']['test-less'] ); diff --git a/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php index a3fd1718..ff32f3de 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php @@ -50,10 +50,10 @@ protected function setUp() { $this->compiled_dir = vfsStream::url( 'compiled' ); $this->compiled_url = 'http:://beans.test/compiled/'; - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/utilities/functions.php', 'api/compiler/functions.php', - ) ); + ] ); $this->setup_common_wp_stubs(); } @@ -73,16 +73,16 @@ protected function set_up_virtual_filesystem() { * Get the virtual filesystem's structure. */ protected function get_virtual_structure() { - return array( - 'beans' => array( - 'compiler' => array( + return [ + 'beans' => [ + 'compiler' => [ 'index.php' => '', - ), - 'admin-compiler' => array( + ], + 'admin-compiler' => [ 'index.php' => '', - ), - ), - ); + ], + ], + ]; } /** diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php index c48df6e8..4e19c981 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php @@ -24,10 +24,10 @@ abstract class Compiler_Options_Test_Case extends Base_Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/compiler/class-beans-compiler-options.php', 'api/options/functions.php', - ) ); + ] ); $this->setup_common_wp_stubs(); } diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index a6a0f942..411ade7a 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -81,9 +81,9 @@ protected function setUp() { parent::setUp(); $this->set_up_function_mocks(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/compiler/class-beans-compiler.php', - ) ); + ] ); } /** @@ -127,14 +127,14 @@ private function get_fixtures_content() { * Set up function mocks. */ protected function set_up_function_mocks() { - Functions\when( 'wp_upload_dir' )->justReturn( array( + Functions\when( 'wp_upload_dir' )->justReturn( [ 'path' => '', 'url' => '', 'subdir' => '', 'basedir' => $this->compiled_dir, 'baseurl' => $this->compiled_url, 'error' => false, - ) ); + ] ); Functions\when( 'is_admin' )->justReturn( $this->is_admin ); Functions\when( 'site_url' )->justReturn( 'http:://beans.local' ); } @@ -187,7 +187,7 @@ protected function create_virtual_file( $folder_name, $filename, $content ) { * * @return _Beans_Compiler */ - protected function create_compiler( array $config = array() ) { + protected function create_compiler( array $config = [] ) { Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); @@ -227,7 +227,7 @@ protected function get_filename( $compiler, $config, $filemtime = null ) { $filemtimes[ $index ] = filemtime( $fragment ); } } else { - $filemtimes = array( $filemtime ); + $filemtimes = [ $filemtime ]; } return sprintf( diff --git a/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php index 4bf9f112..2eee3353 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php @@ -25,10 +25,10 @@ abstract class Page_Compiler_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/compiler/class-beans-page-compiler.php', 'api/options/functions.php', - ) ); + ] ); } /** From 87dba08ef30e02b8a6b328d874248abc90cfa03a Mon Sep 17 00:00:00 2001 From: ibes Date: Sat, 23 Jun 2018 01:32:09 +0200 Subject: [PATCH 779/800] Updated array syntax for Image API tests. (PR #276) --- .../beans-image-editor/createEditedImage.php | 8 +- .../api/image/beans-image-editor/run.php | 74 +++++++++---------- .../integration/api/image/beansEditImage.php | 14 ++-- .../image/includes/class-base-test-case.php | 12 +-- .../beans-image-editor/createEditedImage.php | 8 +- .../unit/api/image/beans-image-editor/run.php | 42 +++++------ .../image/includes/class-base-test-case.php | 16 ++-- .../image/includes/class-image-test-case.php | 6 +- .../includes/class-options-test-case.php | 4 +- 9 files changed, 92 insertions(+), 92 deletions(-) diff --git a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php index fc3e8289..f9495d3c 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php @@ -47,11 +47,11 @@ public static function setUpBeforeClass() { public function test_should_edit_create_and_store_image() { $created_edited_image = $this->get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + ]; + $args = [ 'resize' => [ 800, false ] ]; foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args ); @@ -76,7 +76,7 @@ public function test_should_return_false_when_no_image() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ) ); + $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ] ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); // Run the tests. diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php index ec6f1320..2848aa08 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -45,11 +45,11 @@ public static function setUpBeforeClass() { */ public function test_should_edit_store_image_and_return_its_url() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + ]; + $args = [ 'resize' => [ 800, false ] ]; foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args ); @@ -73,7 +73,7 @@ public function test_should_edit_store_image_and_return_its_url() { */ public function test_should_return_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ) ); + $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ] ); // Run the tests. $this->assertFileNotExists( $src ); @@ -86,11 +86,11 @@ public function test_should_return_original_src_when_no_image() { */ public function test_should_return_url_when_edited_image_exists() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + ]; + $args = [ 'resize' => [ 800, false ] ]; foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args ); @@ -111,11 +111,11 @@ public function test_should_return_url_when_edited_image_exists() { */ public function test_should_edit_store_image_and_return_indexed_array() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + ]; + $args = [ 'resize' => [ 800, false ] ]; foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); @@ -125,7 +125,7 @@ public function test_should_edit_store_image_and_return_indexed_array() { $this->assertFileNotExists( $edited_image_src ); $image_info = $editor->run(); $this->assertFileExists( $edited_image_src ); - $this->assertSame( array( beans_path_to_url( $edited_image_src ), 800, 420 ), $image_info ); + $this->assertSame( [ beans_path_to_url( $edited_image_src ), 800, 420 ], $image_info ); // Check the edited image's dimensions. list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. @@ -139,11 +139,11 @@ public function test_should_edit_store_image_and_return_indexed_array() { */ public function test_should_return_indexed_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ); + $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], ARRAY_N ); // Run the tests. $this->assertFileNotExists( $src ); - $this->assertSame( array( $src, null, null ), $editor->run() ); + $this->assertSame( [ $src, null, null ], $editor->run() ); } /** @@ -152,11 +152,11 @@ public function test_should_return_indexed_array_with_original_src_when_no_image */ public function test_should_return_index_array_when_edited_image_exists() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + ]; + $args = [ 'resize' => [ 800, false ] ]; foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); @@ -167,7 +167,7 @@ public function test_should_return_index_array_when_edited_image_exists() { // Run the tests. $this->assertFileExists( $edited_image_src ); - $this->assertSame( array( beans_path_to_url( $edited_image_src ), 800, 420 ), $editor->run() ); + $this->assertSame( [ beans_path_to_url( $edited_image_src ), 800, 420 ], $editor->run() ); } } @@ -177,11 +177,11 @@ public function test_should_return_index_array_when_edited_image_exists() { */ public function test_should_edit_store_image_and_return_object() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 400, false ) ); + ]; + $args = [ 'resize' => [ 400, false ] ]; foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args, OBJECT ); @@ -208,7 +208,7 @@ public function test_should_edit_store_image_and_return_object() { */ public function test_should_return_object_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), OBJECT ); + $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], OBJECT ); // Run the tests. $this->assertFileNotExists( $src ); @@ -225,11 +225,11 @@ public function test_should_return_object_with_original_src_when_no_image() { */ public function test_should_return_object_when_edited_image_exists() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 400, false ) ); + ]; + $args = [ 'resize' => [ 400, false ] ]; // Run the tests. foreach ( $image_sources as $src ) { @@ -255,11 +255,11 @@ public function test_should_return_object_when_edited_image_exists() { */ public function test_should_edit_store_image_and_return_associative_array() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 600, false ) ); + ]; + $args = [ 'resize' => [ 600, false ] ]; foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args, ARRAY_A ); @@ -270,11 +270,11 @@ public function test_should_edit_store_image_and_return_associative_array() { $image_info = $editor->run(); $this->assertFileExists( $edited_image_src ); $this->assertSame( - array( + [ 'src' => beans_path_to_url( $edited_image_src ), 'width' => 600, 'height' => 315, - ), + ], $image_info ); @@ -290,16 +290,16 @@ public function test_should_edit_store_image_and_return_associative_array() { */ public function test_should_return_associative_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ); + $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], ARRAY_A ); // Run the tests. $this->assertFileNotExists( $src ); $this->assertSame( - array( + [ 'src' => $src, 'width' => null, 'height' => null, - ), + ], $editor->run() ); } @@ -310,11 +310,11 @@ public function test_should_return_associative_array_with_original_src_when_no_i */ public function test_should_return_associatve_array_when_edited_image_exists() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 600, false ) ); + ]; + $args = [ 'resize' => [ 600, false ] ]; // Run the tests. foreach ( $image_sources as $src ) { @@ -327,11 +327,11 @@ public function test_should_return_associatve_array_when_edited_image_exists() { // Run the tests. $this->assertFileExists( $edited_image_src ); $this->assertSame( - array( + [ 'src' => beans_path_to_url( $edited_image_src ), 'width' => 600, 'height' => 315, - ), + ], $editor->run() ); } diff --git a/tests/phpunit/integration/api/image/beansEditImage.php b/tests/phpunit/integration/api/image/beansEditImage.php index 0c709ea0..a1170064 100644 --- a/tests/phpunit/integration/api/image/beansEditImage.php +++ b/tests/phpunit/integration/api/image/beansEditImage.php @@ -46,7 +46,7 @@ public function test_should_return_original_src_when_no_image() { // Run the tests. $this->assertFileNotExists( $src ); - $this->assertSame( $src, beans_edit_image( $src, array( 'resize' => array( 800, false ) ) ) ); + $this->assertSame( $src, beans_edit_image( $src, [ 'resize' => [ 800, false ] ] ) ); } /** @@ -58,8 +58,8 @@ public function test_should_return_indexed_array_with_original_src_when_no_image // Run the tests. $this->assertFileNotExists( $src ); $this->assertSame( - array( $src, null, null ), - beans_edit_image( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ) + [ $src, null, null ], + beans_edit_image( $src, [ 'resize' => [ 800, false ] ], ARRAY_N ) ); } @@ -71,7 +71,7 @@ public function test_should_return_object_with_original_src_when_no_image() { // Run the tests. $this->assertFileNotExists( $src ); - $image_info = beans_edit_image( $src, array( 'resize' => array( 800, false ) ), OBJECT ); + $image_info = beans_edit_image( $src, [ 'resize' => [ 800, false ] ], OBJECT ); $this->assertInstanceOf( 'stdClass', $image_info ); $this->assertSame( $src, $image_info->src ); $this->assertNull( $image_info->width ); @@ -87,12 +87,12 @@ public function test_should_return_associative_array_with_original_src_when_no_i // Run the tests. $this->assertFileNotExists( $src ); $this->assertSame( - array( + [ 'src' => $src, 'width' => null, 'height' => null, - ), - beans_edit_image( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ) + ], + beans_edit_image( $src, [ 'resize' => [ 800, false ] ], ARRAY_A ) ); } } diff --git a/tests/phpunit/integration/api/image/includes/class-base-test-case.php b/tests/phpunit/integration/api/image/includes/class-base-test-case.php index 2a709f2a..f569686c 100644 --- a/tests/phpunit/integration/api/image/includes/class-base-test-case.php +++ b/tests/phpunit/integration/api/image/includes/class-base-test-case.php @@ -76,13 +76,13 @@ protected function set_up_virtual_filesystem() { * Get the virtual filesystem's structure. */ protected function get_virtual_structure() { - return array( - 'beans' => array( - 'images' => array( + return [ + 'beans' => [ + 'images' => [ 'index.php' => '', - ), - ), - ); + ], + ], + ]; } /** diff --git a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php index 3762c66d..3bc90539 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php @@ -48,11 +48,11 @@ public static function setUpBeforeClass() { public function test_should_edit_create_and_store_image() { $create_edited_image = $this->get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = array( + $image_sources = [ static::$fixtures_dir . '/image1.jpg', static::$fixtures_dir . '/image2.jpg', - ); - $args = array( 'resize' => array( 800, false ) ); + ]; + $args = [ 'resize' => [ 800, false ] ]; foreach ( $image_sources as $src ) { $editor = new _Beans_Image_Editor( $src, $args ); @@ -84,7 +84,7 @@ public function test_should_return_false_when_no_image() { $create_edited_image = $this->get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); $src = 'path/does/not/exist/image.jpg'; - $args = array( 'resize' => array( 800, false ) ); + $args = [ 'resize' => [ 800, false ] ]; $editor = new _Beans_Image_Editor( $src, $args ); $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php index 077fab43..8b55617b 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -39,7 +39,7 @@ public static function setUpBeforeClass() { */ public function test_should_edit_store_image_and_return_its_url() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = array( 'resize' => array( 800, false ) ); + $args = [ 'resize' => [ 800, false ] ]; foreach ( $this->images as $actual_path ) { $editor = new _Beans_Image_Editor( $actual_path, $args ); @@ -70,7 +70,7 @@ public function test_should_edit_store_image_and_return_its_url() { */ public function test_should_return_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ) ); + $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ] ); // Set up the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); @@ -89,7 +89,7 @@ public function test_should_return_original_src_when_no_image() { public function test_should_return_url_when_edited_image_exists() { $this->load_images_into_vfs(); $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = array( 'resize' => array( 800, false ) ); + $args = [ 'resize' => [ 800, false ] ]; foreach ( $this->images as $virtual_path => $actual_path ) { $editor = new _Beans_Image_Editor( $actual_path, $args ); @@ -111,7 +111,7 @@ public function test_should_return_url_when_edited_image_exists() { */ public function test_should_edit_store_image_and_return_indexed_array() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = array( 'resize' => array( 800, false ) ); + $args = [ 'resize' => [ 800, false ] ]; foreach ( $this->images as $virtual_path => $actual_path ) { $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_N ); @@ -133,7 +133,7 @@ public function test_should_edit_store_image_and_return_indexed_array() { $this->assertFileNotExists( $edited_image_src ); $image_info = $editor->run(); $this->assertFileExists( $edited_image_src ); - $this->assertSame( array( $edited_image_src, 1200, 630 ), $image_info ); + $this->assertSame( [ $edited_image_src, 1200, 630 ], $image_info ); } } @@ -142,7 +142,7 @@ public function test_should_edit_store_image_and_return_indexed_array() { */ public function test_should_return_indexed_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_N ); + $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], ARRAY_N ); // Set up the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); @@ -151,7 +151,7 @@ public function test_should_return_indexed_array_with_original_src_when_no_image // Run the tests. $this->assertFileNotExists( $src ); - $this->assertSame( array( $src, null, null ), $editor->run() ); + $this->assertSame( [ $src, null, null ], $editor->run() ); } /** @@ -161,7 +161,7 @@ public function test_should_return_indexed_array_with_original_src_when_no_image public function test_should_return_index_array_when_edited_image_exists() { $this->load_images_into_vfs(); $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = array( 'resize' => array( 800, false ) ); + $args = [ 'resize' => [ 800, false ] ]; foreach ( $this->images as $virtual_path => $actual_path ) { $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_N ); @@ -173,7 +173,7 @@ public function test_should_return_index_array_when_edited_image_exists() { // Run the tests. $this->assertFileExists( $edited_image_src ); - $this->assertSame( array( $edited_image_src, 1200, 630 ), $editor->run() ); + $this->assertSame( [ $edited_image_src, 1200, 630 ], $editor->run() ); } } @@ -183,7 +183,7 @@ public function test_should_return_index_array_when_edited_image_exists() { */ public function test_should_edit_store_image_and_return_object() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = array( 'resize' => array( 400, false ) ); + $args = [ 'resize' => [ 400, false ] ]; foreach ( $this->images as $actual_path ) { $editor = new _Beans_Image_Editor( $actual_path, $args, OBJECT ); @@ -217,7 +217,7 @@ public function test_should_edit_store_image_and_return_object() { */ public function test_should_return_object_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), OBJECT ); + $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], OBJECT ); // Set up the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); @@ -240,7 +240,7 @@ public function test_should_return_object_with_original_src_when_no_image() { public function test_should_return_object_when_edited_image_exists() { $this->load_images_into_vfs(); $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = array( 'resize' => array( 400, false ) ); + $args = [ 'resize' => [ 400, false ] ]; foreach ( $this->images as $virtual_path => $actual_path ) { $editor = new _Beans_Image_Editor( $actual_path, $args, OBJECT ); @@ -266,7 +266,7 @@ public function test_should_return_object_when_edited_image_exists() { */ public function test_should_edit_store_image_and_return_associative_array() { $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = array( 'resize' => array( 600, false ) ); + $args = [ 'resize' => [ 600, false ] ]; foreach ( $this->images as $actual_path ) { $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_A ); @@ -289,11 +289,11 @@ public function test_should_edit_store_image_and_return_associative_array() { $image_info = $editor->run(); $this->assertFileExists( $edited_image_src ); $this->assertSame( - array( + [ 'src' => $edited_image_src, 'width' => 1200, 'height' => 630, - ), + ], $image_info ); } @@ -304,7 +304,7 @@ public function test_should_edit_store_image_and_return_associative_array() { */ public function test_should_return_associative_array_with_original_src_when_no_image() { $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, array( 'resize' => array( 800, false ) ), ARRAY_A ); + $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], ARRAY_A ); // Set up the mocks. Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); @@ -314,11 +314,11 @@ public function test_should_return_associative_array_with_original_src_when_no_i // Run the tests. $this->assertFileNotExists( $src ); $this->assertSame( - array( + [ 'src' => $src, 'width' => null, 'height' => null, - ), + ], $editor->run() ); } @@ -330,7 +330,7 @@ public function test_should_return_associative_array_with_original_src_when_no_i public function test_should_return_associative_array_when_edited_image_exists() { $this->load_images_into_vfs(); $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = array( 'resize' => array( 600, false ) ); + $args = [ 'resize' => [ 600, false ] ]; foreach ( $this->images as $virtual_path => $actual_path ) { $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_A ); @@ -343,11 +343,11 @@ public function test_should_return_associative_array_when_edited_image_exists() // Run the tests. $this->assertFileExists( $edited_image_src ); $this->assertSame( - array( + [ 'src' => $edited_image_src, 'width' => 1200, 'height' => 630, - ), + ], $editor->run() ); } diff --git a/tests/phpunit/unit/api/image/includes/class-base-test-case.php b/tests/phpunit/unit/api/image/includes/class-base-test-case.php index 4e99c05d..aa367885 100644 --- a/tests/phpunit/unit/api/image/includes/class-base-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-base-test-case.php @@ -48,10 +48,10 @@ protected function setUp() { $this->set_up_virtual_filesystem(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/utilities/functions.php', 'api/image/functions.php', - ) ); + ] ); $this->setup_common_wp_stubs(); } @@ -73,12 +73,12 @@ protected function set_up_virtual_filesystem() { * Get the virtual filesystem's structure. */ protected function get_virtual_structure() { - return array( - 'beans' => array( - 'images' => array( + return [ + 'beans' => [ + 'images' => [ 'index.php' => '', - ), - ), - ); + ], + ], + ]; } } diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index 9cb54a99..294a2a5a 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -59,7 +59,7 @@ public static function setUpBeforeClass() { static::$fixtures_dir = __DIR__ . '/fixtures'; - foreach ( array( 'ARRAY_N', 'ARRAY_A', 'STRING', 'OBJECT' ) as $constant ) { + foreach ( [ 'ARRAY_N', 'ARRAY_A', 'STRING', 'OBJECT' ] as $constant ) { if ( ! defined( $constant ) ) { define( $constant, $constant ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- WordPress defined constants. } @@ -127,13 +127,13 @@ protected function setup_function_mocks() { Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); Monkey\Functions\when( 'beans_path_to_url' )->returnArg(); - Monkey\Functions\expect( 'wp_upload_dir' )->andReturn( array( + Monkey\Functions\expect( 'wp_upload_dir' )->andReturn( [ 'path' => '', 'url' => '', 'subdir' => '', 'basedir' => vfsStream::url( 'uploads' ), 'baseurl' => $this->images_url, 'error' => false, - ) ); + ] ); } } diff --git a/tests/phpunit/unit/api/image/includes/class-options-test-case.php b/tests/phpunit/unit/api/image/includes/class-options-test-case.php index 2aae7273..6cfe3b5b 100644 --- a/tests/phpunit/unit/api/image/includes/class-options-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-options-test-case.php @@ -24,9 +24,9 @@ abstract class Options_Test_Case extends Base_Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/image/class-beans-image-options.php', 'api/options/functions.php', - ) ); + ] ); } } From 409aa93d9f04a730701e79dce1bd92adcfa9f52e Mon Sep 17 00:00:00 2001 From: ibes Date: Sat, 23 Jun 2018 01:39:12 +0200 Subject: [PATCH 780/800] Updated array syntax for Widget API tests. (PR #277) --- .../api/widget/beansDeregisterWidgetArea.php | 2 +- .../api/widget/beansForceTheWidget.php | 6 ++-- .../integration/api/widget/beansGetWidget.php | 4 +-- .../api/widget/beansGetWidgetArea.php | 12 ++++---- .../api/widget/beansGetWidgetAreaOutput.php | 4 +-- .../api/widget/beansHasWidgetArea.php | 4 +-- .../api/widget/beansHaveWidgets.php | 8 +++--- .../api/widget/beansIsActiveWidgetArea.php | 2 +- .../api/widget/beansPrepareWidgetData.php | 2 +- .../api/widget/beansRegisterWidgetArea.php | 4 +-- .../api/widget/beansSetupWidget.php | 4 +-- .../api/widget/beansSetupWidgetArea.php | 2 +- .../api/widget/beansSetupWidgets.php | 10 +++---- .../api/widget/beansWidgetAreaShortcodes.php | 2 +- .../api/widget/beansWidgetShortcodes.php | 2 +- .../includes/class-beans-widget-test-case.php | 12 ++++---- .../unit/api/widget/beansForceTheWidget.php | 6 ++-- .../unit/api/widget/beansGetWidget.php | 4 +-- .../unit/api/widget/beansGetWidgetArea.php | 4 +-- .../unit/api/widget/beansHasWidgetArea.php | 4 +-- .../unit/api/widget/beansHaveWidgets.php | 28 +++++++++---------- .../api/widget/beansPrepareWidgetData.php | 8 +++--- .../api/widget/beansRegisterWidgetArea.php | 14 +++++----- .../unit/api/widget/beansResetWidget.php | 8 +++--- .../unit/api/widget/beansResetWidgetArea.php | 2 +- .../unit/api/widget/beansSetupWidget.php | 28 +++++++++---------- .../unit/api/widget/beansSetupWidgetArea.php | 10 +++---- .../unit/api/widget/beansSetupWidgets.php | 26 ++++++++--------- .../api/widget/beansWidgetAreaShortcodes.php | 12 ++++---- .../api/widget/beansWidgetAreaSubfilters.php | 2 +- .../unit/api/widget/beansWidgetShortcodes.php | 12 ++++---- .../unit/api/widget/beansWidgetSubfilters.php | 6 ++-- .../includes/class-beans-widget-test-case.php | 4 +-- 33 files changed, 129 insertions(+), 129 deletions(-) diff --git a/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php index 504b8bbe..b67baf14 100644 --- a/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php @@ -28,7 +28,7 @@ class Tests_BeansDeregisterWidgetArea extends Beans_Widget_Test_Case { public function test_should_unregister_sidebar() { global $wp_registered_sidebars; - register_sidebar( array( 'id' => 'unwanted-sidebar' ) ); + register_sidebar( [ 'id' => 'unwanted-sidebar' ] ); $this->assertTrue( isset( $wp_registered_sidebars['unwanted-sidebar'] ) ); diff --git a/tests/phpunit/integration/api/widget/beansForceTheWidget.php b/tests/phpunit/integration/api/widget/beansForceTheWidget.php index f9579cc2..60c6d2a7 100644 --- a/tests/phpunit/integration/api/widget/beansForceTheWidget.php +++ b/tests/phpunit/integration/api/widget/beansForceTheWidget.php @@ -32,7 +32,7 @@ public function test_should_do_nothing_when_widget_not_instance_of_WP_Widget() { $wp_widget_factory->widgets['unorthodox'] = new \stdClass(); ob_start(); - _beans_force_the_widget( 'unorthodox', array(), array( 'before_widget' => '
                '
                assertEmpty( $output ); @@ -43,7 +43,7 @@ public function test_should_do_nothing_when_widget_not_instance_of_WP_Widget() { */ public function test_should_do_nothing_when_widget_has_id_registered() { ob_start(); - _beans_force_the_widget( 'WP_Widget_Text', array(), array( 'before_widget' => '
                '
                assertEmpty( $output ); @@ -54,7 +54,7 @@ public function test_should_do_nothing_when_widget_has_id_registered() { */ public function test_should_render_widget_id_html_when_widget_registered_without_id_arg() { ob_start(); - _beans_force_the_widget( 'WP_Widget_Text', '', array() ); + _beans_force_the_widget( 'WP_Widget_Text', '', [] ); $output = ob_get_clean(); $this->assertEquals( '', $output ); diff --git a/tests/phpunit/integration/api/widget/beansGetWidget.php b/tests/phpunit/integration/api/widget/beansGetWidget.php index aaa7a681..f91d00ec 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidget.php +++ b/tests/phpunit/integration/api/widget/beansGetWidget.php @@ -37,13 +37,13 @@ public function test_should_return_specific_widget_data_when_needle_specified() * Return an array of expected sidebar data. */ protected function get_widget_test_data() { - return array( + return [ 'name' => 'Test Widget', 'id' => 'text-2', 'description' => 'Some description', 'class' => 'widgettext', 'title' => 'Test Widget Title', 'text' => 'Arbitrary text content.', - ); + ]; } } diff --git a/tests/phpunit/integration/api/widget/beansGetWidgetArea.php b/tests/phpunit/integration/api/widget/beansGetWidgetArea.php index 24c8ca2e..751d6441 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansGetWidgetArea.php @@ -26,10 +26,10 @@ class Tests_BeansGetWidgetArea extends Beans_Widget_Test_Case { * Test beans_get_widget_area() should return all widget area data when needle is not specified. */ public function test_should_return_all_data_when_needle_not_specified() { - register_sidebar( array( + register_sidebar( [ 'id' => 'test_sidebar', 'name' => 'Test Sidebar', - ) ); + ] ); _beans_setup_widget_area( 'test_sidebar' ); $this->assertSame( $this->get_expected_sidebar_data(), beans_get_widget_area() ); @@ -39,10 +39,10 @@ public function test_should_return_all_data_when_needle_not_specified() { * Test beans_get_widget_area() should return specific widget data when a needle is specified. */ public function test_should_return_specific_widget_data_when_needle_specified() { - register_sidebar( array( + register_sidebar( [ 'id' => 'test_sidebar', 'name' => 'Test Sidebar', - ) ); + ] ); _beans_setup_widget_area( 'test_sidebar' ); $this->assertEquals( 'test_sidebar', beans_get_widget_area( 'id' ) ); @@ -52,7 +52,7 @@ public function test_should_return_specific_widget_data_when_needle_specified() * Return an array of expected sidebar data. */ protected function get_expected_sidebar_data() { - return array( + return [ 'name' => 'Test Sidebar', 'id' => 'test_sidebar', 'description' => '', @@ -63,6 +63,6 @@ protected function get_expected_sidebar_data() { 'after_title' => '', 'widgets_count' => 0, 'current_widget' => 0, - ); + ]; } } diff --git a/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php index d07ea8c2..eb75e889 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php +++ b/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php @@ -35,10 +35,10 @@ public function test_should_return_false_when_widget_area_not_registered() { public function test_should_return_widget_output_when_widget_area_is_registered() { global $wp_registered_sidebars; - beans_register_widget_area( array( + beans_register_widget_area( [ 'id' => 'test_sidebar', 'name' => 'Test Sidebar', - ) ); + ] ); $this->add_test_widget_to_test_sidebar(); $this->assertSame( $this->format_the_html( $this->get_expected_output() ), diff --git a/tests/phpunit/integration/api/widget/beansHasWidgetArea.php b/tests/phpunit/integration/api/widget/beansHasWidgetArea.php index 0d398e86..4ac75b41 100644 --- a/tests/phpunit/integration/api/widget/beansHasWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansHasWidgetArea.php @@ -35,10 +35,10 @@ public function test_should_return_false_when_widget_area_not_registered() { public function test_should_return_true_when_widget_area_registered() { global $wp_registered_sidebars; - register_sidebar( array( + register_sidebar( [ 'id' => 'test_sidebar', 'name' => 'Test Sidebar', - ) ); + ] ); // Confirm we have a test sidebar registered. $this->assertTrue( isset( $wp_registered_sidebars['test_sidebar'] ) ); diff --git a/tests/phpunit/integration/api/widget/beansHaveWidgets.php b/tests/phpunit/integration/api/widget/beansHaveWidgets.php index 8a3e1873..846cb37d 100644 --- a/tests/phpunit/integration/api/widget/beansHaveWidgets.php +++ b/tests/phpunit/integration/api/widget/beansHaveWidgets.php @@ -28,10 +28,10 @@ class Tests_BeansHaveWidgets extends Beans_Widget_Test_Case { public function test_should_return_true_when_widgets_available() { // Add a test sidebar with a test widget. beans_register_widget_area( - array( + [ 'id' => 'test_sidebar', 'name' => 'Test Sidebar', - ) + ] ); $this->add_test_widget_to_test_sidebar(); @@ -48,10 +48,10 @@ public function test_should_return_true_when_widgets_available() { public function test_should_return_false_when_no_widgets_are_available() { // Add a test sidebar with no widgets. beans_register_widget_area( - array( + [ 'id' => 'test_sidebar', 'name' => 'Test Sidebar', - ) + ] ); // Run the Beans widget area setup. diff --git a/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php b/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php index 9194051c..b8335e4f 100644 --- a/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php @@ -39,7 +39,7 @@ public function test_should_return_true_when_widget_area_is_active() { $_wp_sidebars_widgets = []; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: we need test to start with clean sidebars_widgets. // Prime the WP database with an active sidebar. - update_option( 'sidebars_widgets', array( 'an-active-sidebar' => array( 'text-2' ) ) ); + update_option( 'sidebars_widgets', [ 'an-active-sidebar' => [ 'text-2' ] ] ); $this->assertTrue( beans_is_active_widget_area( 'an-active-sidebar' ) ); } diff --git a/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php b/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php index 9b29cfa0..49bedc0d 100644 --- a/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php +++ b/tests/phpunit/integration/api/widget/beansPrepareWidgetData.php @@ -28,7 +28,7 @@ class Tests_BeansPrepareWidgetData extends Beans_Widget_Test_Case { public function test_should_prepare_widget_data() { global $_beans_widget; - beans_register_widget_area( array( 'id' => 'test_sidebar' ) ); + beans_register_widget_area( [ 'id' => 'test_sidebar' ] ); $this->add_test_widget_to_test_sidebar(); _beans_setup_widget_area( 'test_sidebar' ); diff --git a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php index 8bc20ae9..3eb67a9e 100644 --- a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php @@ -40,10 +40,10 @@ public function test_should_register_sidebar_and_return_widget_area_ID_when_widg $this->assertEquals( 'new-widget-area', - beans_register_widget_area( array( + beans_register_widget_area( [ 'id' => 'new-widget-area', 'beans_type' => 'grid', - ) ) + ] ) ); // Confirm that the sidebar is now in the WP global sidebar array. diff --git a/tests/phpunit/integration/api/widget/beansSetupWidget.php b/tests/phpunit/integration/api/widget/beansSetupWidget.php index 1cccd739..ff347f12 100644 --- a/tests/phpunit/integration/api/widget/beansSetupWidget.php +++ b/tests/phpunit/integration/api/widget/beansSetupWidget.php @@ -28,7 +28,7 @@ class Tests_BeansSetupWidget extends Beans_Widget_Test_Case { public function test_should_return_false_when_widget_id_not_found() { global $_beans_widget_area; - beans_register_widget_area( array( 'id' => 'test_sidebar' ) ); + beans_register_widget_area( [ 'id' => 'test_sidebar' ] ); $this->add_test_widget_to_test_sidebar(); _beans_setup_widget_area( 'test_sidebar' ); @@ -44,7 +44,7 @@ public function test_should_return_false_when_widget_id_not_found() { public function test_should_advance_widget_pointer_prepare_widget_data_and_return_true_when_widget_id_is_found() { global $_beans_widget_area, $_beans_widget; - beans_register_widget_area( array( 'id' => 'test_sidebar' ) ); + beans_register_widget_area( [ 'id' => 'test_sidebar' ] ); $this->add_test_widget_to_test_sidebar(); _beans_setup_widget_area( 'test_sidebar' ); diff --git a/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php b/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php index a7545e63..10eb80b3 100644 --- a/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansSetupWidgetArea.php @@ -32,7 +32,7 @@ public function test_should_build_widget_area_data_and_return_true_when_widget_a $this->add_test_widget_to_test_sidebar(); // Clear test widget area data global before running test. - $_beans_widget_area = array(); + $_beans_widget_area = []; // Run test. $this->assertTrue( _beans_setup_widget_area( 'test_sidebar' ) ); diff --git a/tests/phpunit/integration/api/widget/beansSetupWidgets.php b/tests/phpunit/integration/api/widget/beansSetupWidgets.php index c3d48b19..b728affa 100644 --- a/tests/phpunit/integration/api/widget/beansSetupWidgets.php +++ b/tests/phpunit/integration/api/widget/beansSetupWidgets.php @@ -41,9 +41,9 @@ public function test_should_return_widget_data_when_widget_is_registered() { * @return array Expected widget setup data */ protected function get_expected_widget_setup_data() { - return array( - 'text-2' => array( - 'options' => array(), + return [ + 'text-2' => [ + 'options' => [], 'type' => 'text', 'title' => '', 'count' => 1, @@ -55,7 +55,7 @@ protected function get_expected_widget_setup_data() { 'show_title' => true, 'badge' => false, 'badge_content' => 'Hello', - ), - ); + ], + ]; } } diff --git a/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php b/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php index 346018a0..6d4f1b1c 100644 --- a/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php +++ b/tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php @@ -40,7 +40,7 @@ public function test_should_return_content_with_shortcodes_filtered_out() { $this->assertEquals( 'someURLparemetername=URL content with a shortcode value.', beans_widget_area_shortcodes( - array( 'someURLparemetername' => 'URL content with a {key}.' ) + [ 'someURLparemetername' => 'URL content with a {key}.' ] ) ); } diff --git a/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php b/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php index 38d5d332..2c499eb5 100644 --- a/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php +++ b/tests/phpunit/integration/api/widget/beansWidgetShortcodes.php @@ -40,7 +40,7 @@ public function test_should_return_content_with_shortcodes_filetered_out() { $this->assertEquals( 'someURLparemetername=URL content with a shortcode value.', beans_widget_shortcodes( - array( 'someURLparemetername' => 'URL content with a {key}.' ) + [ 'someURLparemetername' => 'URL content with a {key}.' ] ) ); } diff --git a/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php index c5e79f38..ef722fe8 100644 --- a/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php +++ b/tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php @@ -42,17 +42,17 @@ protected function add_test_widget_to_test_sidebar() { $widget_object->widget_options['name'] = 'Test Sidebar'; $widget_object->widget_options['id'] = 'test_sidebar'; - $widget_registration_args = array( + $widget_registration_args = [ 'name' => $widget_object->name, 'id' => $widget_object->id, - 'callback' => array( $widget_object, 'widget' ), - 'params' => array( $widget_object->widget_options ), + 'callback' => [ $widget_object, 'widget' ], + 'params' => [ $widget_object->widget_options ], 'classname' => $widget_object->widget_options['classname'], - ); + ]; $wp_registered_widgets[ $widget_object->id ] = $widget_registration_args; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: we need to explicitly set the widget registration for widget API tests. - add_filter( 'sidebars_widgets', array( $this, 'add_a_widget' ) ); + add_filter( 'sidebars_widgets', [ $this, 'add_a_widget' ] ); } /** @@ -63,7 +63,7 @@ protected function add_test_widget_to_test_sidebar() { * @return array Modified sidebars_widgets. */ public function add_a_widget( $sidebars_widgets ) { - $sidebars_widgets['test_sidebar'] = array( 0 => 'text-2' ); + $sidebars_widgets['test_sidebar'] = [ 0 => 'text-2' ]; return $sidebars_widgets; } diff --git a/tests/phpunit/unit/api/widget/beansForceTheWidget.php b/tests/phpunit/unit/api/widget/beansForceTheWidget.php index b4440526..65c34c6d 100644 --- a/tests/phpunit/unit/api/widget/beansForceTheWidget.php +++ b/tests/phpunit/unit/api/widget/beansForceTheWidget.php @@ -32,7 +32,7 @@ public function test_should_do_nothing_when_widget_not_instance_of_WP_Widget() { $wp_widget_factory->widgets['unorthodox'] = new \stdClass(); ob_start(); - _beans_force_the_widget( 'unorthodox', array(), array( 'before_widget' => '
                '
                assertEmpty( $output ); @@ -51,7 +51,7 @@ public function test_should_do_nothing_when_widget_has_id_registered() { $wp_widget_factory->widgets['WP_Widget_Text'] = $widget; ob_start(); - _beans_force_the_widget( 'WP_Widget_Text', array(), array( 'before_widget' => '
                '
                assertEquals( '', $output ); @@ -70,7 +70,7 @@ public function test_should_render_widget_id_html_when_widget_registered_without $wp_widget_factory->widgets['WP_Widget_Text'] = $widget; ob_start(); - _beans_force_the_widget( 'WP_Widget_Text', '', array() ); + _beans_force_the_widget( 'WP_Widget_Text', '', [] ); $output = ob_get_clean(); $this->assertEquals( '', $output ); diff --git a/tests/phpunit/unit/api/widget/beansGetWidget.php b/tests/phpunit/unit/api/widget/beansGetWidget.php index 338c3507..35a7563c 100644 --- a/tests/phpunit/unit/api/widget/beansGetWidget.php +++ b/tests/phpunit/unit/api/widget/beansGetWidget.php @@ -65,13 +65,13 @@ public function test_should_return_specific_widget_data_when_needle_specified() * Return an array of expected sidebar data. */ protected function get_widget_test_data() { - return array( + return [ 'name' => 'Test Widget', 'id' => 'text-2', 'description' => 'Some description', 'class' => 'widgettext', 'title' => 'Test Widget Title', 'text' => 'Arbitrary text content.', - ); + ]; } } diff --git a/tests/phpunit/unit/api/widget/beansGetWidgetArea.php b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php index 0b357cf5..c7e7c0ed 100644 --- a/tests/phpunit/unit/api/widget/beansGetWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansGetWidgetArea.php @@ -65,7 +65,7 @@ public function test_should_return_specific_widget_data_when_needle_specified() * Return an array of expected sidebar data. */ protected function get_sidebar_test_data() { - return array( + return [ 'name' => 'Test Sidebar', 'id' => 'test_sidebar', 'description' => '', @@ -76,6 +76,6 @@ protected function get_sidebar_test_data() { 'after_title' => '', 'widgets_count' => 0, 'current_widget' => 0, - ); + ]; } } diff --git a/tests/phpunit/unit/api/widget/beansHasWidgetArea.php b/tests/phpunit/unit/api/widget/beansHasWidgetArea.php index 9313a151..14a5df83 100644 --- a/tests/phpunit/unit/api/widget/beansHasWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansHasWidgetArea.php @@ -36,10 +36,10 @@ public function test_should_return_false_when_widget_area_not_registered() { public function test_should_return_true_when_widget_area_registered() { global $wp_registered_sidebars; - $sidebars = array( + $sidebars = [ 'id' => 'test_sidebar', 'name' => 'Test Sidebar', - ); + ]; $wp_registered_sidebars['test_sidebar'] = $sidebars; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: setting up sidebars outside of WP. diff --git a/tests/phpunit/unit/api/widget/beansHaveWidgets.php b/tests/phpunit/unit/api/widget/beansHaveWidgets.php index f2f92bfd..06031503 100644 --- a/tests/phpunit/unit/api/widget/beansHaveWidgets.php +++ b/tests/phpunit/unit/api/widget/beansHaveWidgets.php @@ -29,11 +29,11 @@ class Tests_BeansHaveWidgets extends Beans_Widget_Test_Case { public function test_should_return_false_when_no_widgets_are_available() { global $_beans_widget_area; - $_beans_widget_area = array(); + $_beans_widget_area = []; Monkey\Functions\expect( 'beans_get' ) ->once() - ->with( 'widgets', array() ) + ->with( 'widgets', [] ) ->andReturn( false ); $this->assertFalse( beans_have_widgets() ); @@ -45,13 +45,13 @@ public function test_should_return_false_when_no_widgets_are_available() { public function test_should_return_true_when_widgets_available() { global $_beans_widget_area; - $_beans_widget_area = array( - 'widgets' => array( - 'text-1' => array( 'id' => 'text-1' ), - 'text-2' => array( 'id' => 'text-2' ), - ), + $_beans_widget_area = [ + 'widgets' => [ + 'text-1' => [ 'id' => 'text-1' ], + 'text-2' => [ 'id' => 'text-2' ], + ], 'current_widget' => 1, - ); + ]; Monkey\Functions\expect( 'beans_get' ) ->once() @@ -67,13 +67,13 @@ public function test_should_return_true_when_widgets_available() { public function test_should_call_beans_reset_widget_and_return_false_when_end_of_widget_loop() { global $_beans_widget_area; - $_beans_widget_area = array( - 'widgets' => array( - 'text-1' => array( 'id' => 'text-1' ), - 'text-2' => array( 'id' => 'text-2' ), - ), + $_beans_widget_area = [ + 'widgets' => [ + 'text-1' => [ 'id' => 'text-1' ], + 'text-2' => [ 'id' => 'text-2' ], + ], 'current_widget' => 2, - ); + ]; Monkey\Functions\expect( 'beans_get' ) ->once() diff --git a/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php b/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php index 9ef4a485..7c7cbc29 100644 --- a/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php +++ b/tests/phpunit/unit/api/widget/beansPrepareWidgetData.php @@ -33,12 +33,12 @@ public function test_should_prepare_widget_data() { ->once() ->with( 'widgets' ) ->andReturn( - array( - 'text-2' => array( + [ + 'text-2' => [ 'id' => 'text-2', 'name' => 'Test Widget', - ), - ) + ], + ] ); // Call the function. diff --git a/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php index 0f2151d2..b93dd4da 100644 --- a/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php @@ -32,7 +32,7 @@ public function test_should_return_empty_string_when_ID_not_set() { ->with( 'id', [] ) ->andReturn( false ); - $this->assertSame( '', beans_register_widget_area( array() ) ); + $this->assertSame( '', beans_register_widget_area( [] ) ); } /** @@ -42,10 +42,10 @@ public function test_should_return_widget_area_ID_when_widget_area_registered() Monkey\Functions\expect( 'beans_get' ) ->once()->with( 'id', - array( + [ 'id' => 'new-widget-area', 'beans_type' => 'grid', - ) + ] ) ->andReturn( 'new-widget-area' ); @@ -61,10 +61,10 @@ public function test_should_return_widget_area_ID_when_widget_area_registered() $this->assertEquals( 'new-widget-area', - beans_register_widget_area( array( + beans_register_widget_area( [ 'id' => 'new-widget-area', 'beans_type' => 'grid', - ) ) + ] ) ); } @@ -72,12 +72,12 @@ public function test_should_return_widget_area_ID_when_widget_area_registered() * Return the expected merged arguments array. */ protected function get_merged_args() { - return array( + return [ 'beans_type' => 'grid', 'beans_show_widget_title' => true, 'beans_show_widget_badge' => false, 'beans_widget_badge_content' => __( 'Hello', 'tm-beans' ), 'id' => 'new-widget-area', - ); + ]; } } diff --git a/tests/phpunit/unit/api/widget/beansResetWidget.php b/tests/phpunit/unit/api/widget/beansResetWidget.php index 59553327..faf3a46e 100644 --- a/tests/phpunit/unit/api/widget/beansResetWidget.php +++ b/tests/phpunit/unit/api/widget/beansResetWidget.php @@ -30,12 +30,12 @@ public function test_should_unset_widget_data() { global $_beans_widget; // We'll set the data via the function's view of the global since that's how it's ordinarily set in the API. - $test_widget = array( - array( + $test_widget = [ + [ 'id' => 'text-2', 'name' => 'Test Widget', - ), - ); + ], + ]; $_beans_widget = $test_widget; diff --git a/tests/phpunit/unit/api/widget/beansResetWidgetArea.php b/tests/phpunit/unit/api/widget/beansResetWidgetArea.php index 34ae2348..76a30d5e 100644 --- a/tests/phpunit/unit/api/widget/beansResetWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansResetWidgetArea.php @@ -30,7 +30,7 @@ public function test_should_unset_all_widget_area_data() { global $_beans_widget_area; // We'll set the data via the function's view of the global since that's how it's ordinarily set in the API. - $test_widget_area = array( array( 'text-2' => array( 'id' => 'text-2' ) ) ); + $test_widget_area = [ [ 'text-2' => [ 'id' => 'text-2' ] ] ]; $_beans_widget_area = $test_widget_area; // Confirm that it's stored in the GLOBALS superglobal. diff --git a/tests/phpunit/unit/api/widget/beansSetupWidget.php b/tests/phpunit/unit/api/widget/beansSetupWidget.php index 6488548b..47498fe4 100644 --- a/tests/phpunit/unit/api/widget/beansSetupWidget.php +++ b/tests/phpunit/unit/api/widget/beansSetupWidget.php @@ -29,17 +29,17 @@ class Tests_BeansSetupWidget extends Beans_Widget_Test_Case { public function test_should_return_false_when_widget_id_not_found() { global $_beans_widget_area; - $_beans_widget_area = array( - 'widgets' => array( - 'text-1' => array( 'id' => 'text-1' ), - 'text-2' => array( 'id' => 'text-2' ), - ), + $_beans_widget_area = [ + 'widgets' => [ + 'text-1' => [ 'id' => 'text-1' ], + 'text-2' => [ 'id' => 'text-2' ], + ], 'current_widget' => 2, - ); + ]; Monkey\Functions\expect( 'beans_get' ) ->once() - ->with( $_beans_widget_area['current_widget'], array( 'text-1', 'text-2' ) ) + ->with( $_beans_widget_area['current_widget'], [ 'text-1', 'text-2' ] ) ->andReturn( false ); $this->assertFalse( beans_setup_widget() ); @@ -51,17 +51,17 @@ public function test_should_return_false_when_widget_id_not_found() { public function test_should_advance_widget_pointer_prepare_widget_data_and_return_true_when_widget_id_is_found() { global $_beans_widget_area; - $_beans_widget_area = array( - 'widgets' => array( - 'text-1' => array( 'id' => 'text-1' ), - 'text-2' => array( 'id' => 'text-2' ), - ), + $_beans_widget_area = [ + 'widgets' => [ + 'text-1' => [ 'id' => 'text-1' ], + 'text-2' => [ 'id' => 'text-2' ], + ], 'current_widget' => 1, - ); + ]; Monkey\Functions\expect( 'beans_get' ) ->once() - ->with( $_beans_widget_area['current_widget'], array( 'text-1', 'text-2' ) ) + ->with( $_beans_widget_area['current_widget'], [ 'text-1', 'text-2' ] ) ->andReturn( 'text-2' ); Monkey\Functions\expect( '_beans_prepare_widget_data' ) diff --git a/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php b/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php index c1f6ac4a..d5959b29 100644 --- a/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansSetupWidgetArea.php @@ -36,11 +36,11 @@ public function test_should_return_false_when_sidebar_id_not_set() { public function test_should_build_widget_area_data_and_return_true_when_widget_area_exists() { global $_beans_widget_area, $wp_registered_sidebars; - $sidebars = array( - 'sidebar_primary' => array(), - 'sidebar_secondary' => array(), - 'test_sidebar' => array(), - ); + $sidebars = [ + 'sidebar_primary' => [], + 'sidebar_secondary' => [], + 'test_sidebar' => [], + ]; $wp_registered_sidebars = $sidebars; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: setting up sidebars outside of WP. diff --git a/tests/phpunit/unit/api/widget/beansSetupWidgets.php b/tests/phpunit/unit/api/widget/beansSetupWidgets.php index 0e432356..d0ebb44b 100644 --- a/tests/phpunit/unit/api/widget/beansSetupWidgets.php +++ b/tests/phpunit/unit/api/widget/beansSetupWidgets.php @@ -36,7 +36,7 @@ public function test_should_ignore_non_widgetized_content() { public function test_should_ignore_widget_when_widget_not_registered() { global $wp_registered_widgets; - $wp_registered_widgets = array(); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: ensures no widgets are registered for this test. + $wp_registered_widgets = []; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: ensures no widgets are registered for this test. $this->assertEmpty( _beans_setup_widgets( 'widget output' ) ); } @@ -51,15 +51,15 @@ public function test_should_return_widget_data_when_widget_is_registered() { $widget->id_base = 'text'; $widget->option_name = 'text'; - $sidebars = array( - 'text-2' => array( + $sidebars = [ + 'text-2' => [ 'id' => 'text-2', 'name' => 'Test Widget', 'classname' => 'widget_text', - 'callback' => array( $widget, 'display_callback' ), - 'params' => array( 0 => array( 'number' => 2 ) ), - ), - ); + 'callback' => [ $widget, 'display_callback' ], + 'params' => [ 0 => [ 'number' => 2 ] ], + ], + ]; // Prime the $wp_registered widgets and $_beans_widget_area globals. $wp_registered_widgets = $sidebars; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case: setting up sidebars outside of WP. @@ -76,7 +76,7 @@ public function test_should_return_widget_data_when_widget_is_registered() { Monkey\Functions\expect( 'get_option' ) ->once() ->with( 'text' ) - ->andReturn( array( 2 => array( 'widget_options' ) ) ); + ->andReturn( [ 2 => [ 'widget_options' ] ] ); $this->assertSame( $this->get_expected_widget_setup_data(), @@ -90,9 +90,9 @@ public function test_should_return_widget_data_when_widget_is_registered() { * @return array Expected widget setup data */ protected function get_expected_widget_setup_data() { - return array( - 'text-2' => array( - 'options' => array( 0 => 'widget_options' ), + return [ + 'text-2' => [ + 'options' => [ 0 => 'widget_options' ], 'type' => 'text', 'title' => '', 'count' => 1, @@ -104,7 +104,7 @@ protected function get_expected_widget_setup_data() { 'show_title' => true, 'badge' => false, 'badge_content' => 'Hello', - ), - ); + ], + ]; } } diff --git a/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php index 0037db4a..ea202c7d 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php +++ b/tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php @@ -39,13 +39,13 @@ public function test_should_return_content_when_beans_widget_area_global_not_set public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_string() { global $_beans_widget_area; - $_beans_widget_area = array( 'Widget Area Data' ); + $_beans_widget_area = [ 'Widget Area Data' ]; Monkey\Functions\expect( 'build_query' )->never(); Monkey\Functions\expect( 'beans_array_shortcodes' ) ->once() - ->with( 'Content with a {key}.', array( 'Widget Area Data' ) ) + ->with( 'Content with a {key}.', [ 'Widget Area Data' ] ) ->andReturn( 'Content with a shortcode value.' ); // Run test for content as a string. @@ -61,22 +61,22 @@ public function test_should_return_content_with_shortcodes_filtered_out_when_con public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_array() { global $_beans_widget_area; - $_beans_widget_area = array( 'Widget Area Data' ); + $_beans_widget_area = [ 'Widget Area Data' ]; Monkey\Functions\expect( 'build_query' ) ->once() - ->with( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) + ->with( [ 'someURLparemetername' => 'URL content with a {key}.' ] ) ->andReturn( 'someURLparemetername=URL content with a {key}.' ); Monkey\Functions\expect( 'beans_array_shortcodes' ) ->once() - ->with( 'someURLparemetername=URL content with a {key}.', array( 'Widget Area Data' ) ) + ->with( 'someURLparemetername=URL content with a {key}.', [ 'Widget Area Data' ] ) ->andReturn( 'someURLparemetername=URL content with a shortcode value.' ); // Run test for content as a string. $this->assertEquals( 'someURLparemetername=URL content with a shortcode value.', - beans_widget_area_shortcodes( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) + beans_widget_area_shortcodes( [ 'someURLparemetername' => 'URL content with a {key}.' ] ) ); } } diff --git a/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php b/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php index e98f46b6..da45537f 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php +++ b/tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php @@ -29,7 +29,7 @@ class Tests_BeansWidgetAreaSubfilters extends Beans_Widget_Test_Case { public function test_should_return_widget_area_subfilters_as_string() { global $_beans_widget_area; - $_beans_widget_area = array( 'id' => 'test_sidebar' ); + $_beans_widget_area = [ 'id' => 'test_sidebar' ]; $this->assertEquals( '[_test_sidebar]', _beans_widget_area_subfilters() ); } diff --git a/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php index 07e744bb..e4439539 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php +++ b/tests/phpunit/unit/api/widget/beansWidgetShortcodes.php @@ -39,13 +39,13 @@ public function test_should_return_content_when_beans_widget_area_global_not_set public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_string() { global $_beans_widget; - $_beans_widget = array( 'Widget Data' ); + $_beans_widget = [ 'Widget Data' ]; Monkey\Functions\expect( 'build_query' )->never(); Monkey\Functions\expect( 'beans_array_shortcodes' ) ->once() - ->with( 'Content with a {key}.', array( 'Widget Data' ) ) + ->with( 'Content with a {key}.', [ 'Widget Data' ] ) ->andReturn( 'Content with a shortcode value.' ); // Run test for content as a string. @@ -61,22 +61,22 @@ public function test_should_return_content_with_shortcodes_filtered_out_when_con public function test_should_return_content_with_shortcodes_filtered_out_when_content_given_as_arrau() { global $_beans_widget; - $_beans_widget = array( 'Widget Data' ); + $_beans_widget = [ 'Widget Data' ]; Monkey\Functions\expect( 'build_query' ) ->once() - ->with( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) + ->with( [ 'someURLparemetername' => 'URL content with a {key}.' ] ) ->andReturn( 'someURLparemetername=URL content with a {key}.' ); Monkey\Functions\expect( 'beans_array_shortcodes' ) ->once() - ->with( 'someURLparemetername=URL content with a {key}.', array( 'Widget Data' ) ) + ->with( 'someURLparemetername=URL content with a {key}.', [ 'Widget Data' ] ) ->andReturn( 'someURLparemetername=URL content with a shortcode value.' ); // Run test for content as a string. $this->assertEquals( 'someURLparemetername=URL content with a shortcode value.', - beans_widget_shortcodes( array( 'someURLparemetername' => 'URL content with a {key}.' ) ) + beans_widget_shortcodes( [ 'someURLparemetername' => 'URL content with a {key}.' ] ) ); } } diff --git a/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php b/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php index b47ae095..457de1aa 100644 --- a/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php +++ b/tests/phpunit/unit/api/widget/beansWidgetSubfilters.php @@ -29,11 +29,11 @@ class Tests_BeansWidgetSubfilters extends Beans_Widget_Test_Case { public function test_should_return_widget_subfilters_as_string() { global $_beans_widget_area, $_beans_widget; - $_beans_widget_area = array( 'id' => 'test_sidebar' ); - $_beans_widget = array( + $_beans_widget_area = [ 'id' => 'test_sidebar' ]; + $_beans_widget = [ 'id' => 'text-2', 'type' => 'text', - ); + ]; $this->assertEquals( '[_test_sidebar][_text][_text-2]', _beans_widget_subfilters() ); } diff --git a/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php index 993ea333..f144f463 100644 --- a/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php +++ b/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php @@ -24,10 +24,10 @@ abstract class Beans_Widget_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/widget/functions.php', 'api/utilities/functions.php', - ) ); + ] ); $this->setup_common_wp_stubs(); } From d80c98d5856199b6cc4feb9d87e004599b74f343 Mon Sep 17 00:00:00 2001 From: ibes Date: Sat, 23 Jun 2018 17:46:06 +0200 Subject: [PATCH 781/800] Updated array syntax for Utilities API tests. (PR #278) --- tests/phpunit/unit/api/utilities/beansGet.php | 20 +++---- .../utilities/beansMultiArrayKeyExists.php | 56 +++++++++---------- .../unit/api/utilities/beansPathToUrl.php | 12 ++-- .../api/utilities/beansRenderFunction.php | 4 +- .../utilities/beansRenderFunctionArray.php | 14 ++--- .../unit/api/utilities/beansUrlToPath.php | 8 +-- 6 files changed, 57 insertions(+), 57 deletions(-) diff --git a/tests/phpunit/unit/api/utilities/beansGet.php b/tests/phpunit/unit/api/utilities/beansGet.php index fdaedf4e..ad79074c 100644 --- a/tests/phpunit/unit/api/utilities/beansGet.php +++ b/tests/phpunit/unit/api/utilities/beansGet.php @@ -33,10 +33,10 @@ protected function setUp() { * Test beans_get() should find the needle when an array is given. */ public function test_should_find_needle_when_array_given() { - $haystack = array( + $haystack = [ 'post_type' => 'foo', 'number_of_posts' => 5, - ); + ]; $this->assertSame( $haystack['number_of_posts'], beans_get( 'number_of_posts', $haystack ) ); $this->assertSame( 'foo', beans_get( 'post_type', $haystack ) ); @@ -46,10 +46,10 @@ public function test_should_find_needle_when_array_given() { * Test beans_get() should return default value when an array is given. */ public function test_should_return_default_when_array_given() { - $haystack = array( + $haystack = [ 'post_type' => 'foo', 'number_of_posts' => 5, - ); + ]; $this->assertSame( 'published', beans_get( 'post_status', $haystack, 'published' ) ); $this->assertFalse( beans_get( 'post_status', $haystack, false ) ); @@ -60,10 +60,10 @@ public function test_should_return_default_when_array_given() { * Test beans_get() should find the needle when an object is given. */ public function test_should_find_needle_when_object_given() { - $haystack = (object) array( + $haystack = (object) [ 'post_type' => 'foo', 'number_of_posts' => 5, - ); + ]; $this->assertSame( $haystack->number_of_posts, beans_get( 'number_of_posts', $haystack ) ); $this->assertSame( 'foo', beans_get( 'post_type', $haystack ) ); @@ -73,10 +73,10 @@ public function test_should_find_needle_when_object_given() { * Test beans_get() should return default value when an object is given. */ public function test_should_return_default_when_object_given() { - $haystack = (object) array( + $haystack = (object) [ 'post_type' => 'foo', 'number_of_posts' => 5, - ); + ]; $this->assertSame( 'published', beans_get( 'post_status', $haystack, 'published' ) ); $this->assertFalse( beans_get( 'post_status', $haystack, false ) ); @@ -98,12 +98,12 @@ public function test_should_return_default_when_literal_given() { public function test_should_find_needle_when_index_given() { $this->assertEquals( 'bar', beans_get( 0, 'bar', 10 ) ); - $data = array( + $data = [ 'red', 'white', 'foo' => 'baz', 'green', - ); + ]; $this->assertEquals( 'red', beans_get( 0, $data ) ); $this->assertEquals( 'white', beans_get( 1, $data ) ); $this->assertEquals( 'green', beans_get( 2, $data ) ); diff --git a/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php index 9e2bf4a9..0268b30e 100644 --- a/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php +++ b/tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php @@ -33,11 +33,11 @@ protected function setUp() { * Test beans_multi_array_key_exists() should throw an error for non-array data type. */ public function test_should_throw_error_for_non_array() { - $args = array( + $args = [ 0 => 'bar', 'foo' => 10, 'bar' => new \stdClass(), - ); + ]; foreach ( $args as $arg1 => $arg2 ) { try { @@ -57,15 +57,15 @@ public function test_should_throw_error_for_non_array() { * Test beans_multi_array_key_exists() should return true when key does exist. */ public function test_should_return_true_when_key_exists() { - $data = array( + $data = [ 'oof' => 'found me', - ); + ]; $this->assertTrue( beans_multi_array_key_exists( 'oof', $data ) ); - $this->assertTrue( beans_multi_array_key_exists( 1, array( 10, 'bar', 'baz' ) ) ); - $data = array( + $this->assertTrue( beans_multi_array_key_exists( 1, [ 10, 'bar', 'baz' ] ) ); + $data = [ 'green' => 'grass', 'blue' => 'sky', - ); + ]; $this->assertTrue( beans_multi_array_key_exists( 'blue', $data ) ); } @@ -73,15 +73,15 @@ public function test_should_return_true_when_key_exists() { * Test beans_multi_array_key_exists() should return false when key does not exist. */ public function test_should_return_false_when_key_does_not_exist() { - $data = array( + $data = [ 'oof' => 'found me', - ); + ]; $this->assertFalse( beans_multi_array_key_exists( 'foo', $data ) ); - $this->assertFalse( beans_multi_array_key_exists( 'bar', array( 10, 'bar', 'baz' ) ) ); - $data = array( + $this->assertFalse( beans_multi_array_key_exists( 'bar', [ 10, 'bar', 'baz' ] ) ); + $data = [ 'green' => 'grass', 'blue' => 'sky', - ); + ]; $this->assertFalse( beans_multi_array_key_exists( 'red', $data ) ); } @@ -89,23 +89,23 @@ public function test_should_return_false_when_key_does_not_exist() { * Test beans_multi_array_key_exists() should return true when key exists within a multi-dimensional array. */ public function test_should_return_true_when_key_exists_multidimensional() { - $data = array( + $data = [ 'bar', - array( + [ 'zab' => 'foo', - ), - ); + ], + ]; $this->assertTrue( beans_multi_array_key_exists( 'zab', $data ) ); - $data = array( + $data = [ 'bar', - 'skill' => array( + 'skill' => [ 'javascript' => true, 'php' => true, 'sql' => true, 'beans' => 'rocks', - ), - ); + ], + ]; $this->assertTrue( beans_multi_array_key_exists( 'beans', $data ) ); } @@ -113,22 +113,22 @@ public function test_should_return_true_when_key_exists_multidimensional() { * Test beans_multi_array_key_exists() should return false when key does not exist within a multi-dimensional array. */ public function test_should_return_false_when_key_does_not_exist_multidimensional() { - $data = array( + $data = [ 'bar', - array( + [ 'zab' => 'foo', - ), - ); + ], + ]; $this->assertFalse( beans_multi_array_key_exists( 'foo', $data ) ); - $data = array( + $data = [ 'bar', - 'skill' => array( + 'skill' => [ 'javascript' => true, 'php' => true, 'sql' => true, 'beans' => 'rocks', - ), - ); + ], + ]; $this->assertFalse( beans_multi_array_key_exists( 'rocks', $data ) ); } } diff --git a/tests/phpunit/unit/api/utilities/beansPathToUrl.php b/tests/phpunit/unit/api/utilities/beansPathToUrl.php index 44fae5d2..e82d1bd0 100644 --- a/tests/phpunit/unit/api/utilities/beansPathToUrl.php +++ b/tests/phpunit/unit/api/utilities/beansPathToUrl.php @@ -312,11 +312,11 @@ public function test_should_convert_for_domain_subdirectory_multisite() { Functions\expect( 'get_current_blog_id' )->andReturn( 10 ); $url = 'http://example.com'; - Functions\expect( 'get_blog_details' )->once()->andReturn( (object) array( 'path' => '/shop/' ) ); + Functions\expect( 'get_blog_details' )->once()->andReturn( (object) [ 'path' => '/shop/' ] ); Functions\expect( 'site_url' )->once()->andReturn( $url . '/' ); $this->assertSame( "{$url}/shop/{$path}", beans_path_to_url( $path, true ) ); - Functions\expect( 'get_blog_details' )->once()->andReturn( (object) array( 'path' => '/shop/' ) ); + Functions\expect( 'get_blog_details' )->once()->andReturn( (object) [ 'path' => '/shop/' ] ); Functions\expect( 'site_url' )->once()->andReturn( $url . '/foo' ); $this->assertSame( "{$url}/shop/{$path}", beans_path_to_url( $path, true ) ); } @@ -330,11 +330,11 @@ public function test_should_convert_for_ip_subdirectory_multisite() { Functions\expect( 'get_current_blog_id' )->andReturn( 15 ); $url = 'http://8.8.8.8'; - Functions\expect( 'get_blog_details' )->once()->andReturn( (object) array( 'path' => '/support/' ) ); + Functions\expect( 'get_blog_details' )->once()->andReturn( (object) [ 'path' => '/support/' ] ); Functions\expect( 'site_url' )->once()->andReturn( $url . '/' ); $this->assertSame( "{$url}/support/{$path}", beans_path_to_url( $path, true ) ); - Functions\expect( 'get_blog_details' )->once()->andReturn( (object) array( 'path' => '/support/' ) ); + Functions\expect( 'get_blog_details' )->once()->andReturn( (object) [ 'path' => '/support/' ] ); Functions\expect( 'site_url' )->once()->andReturn( $url . '/ip-address' ); $this->assertSame( "{$url}/support/{$path}", beans_path_to_url( $path, true ) ); } @@ -348,7 +348,7 @@ public function test_should_convert_for_domain_subdomain_multisite() { Functions\expect( 'get_current_blog_id' )->andReturn( 10 ); $url = 'http://shop.example.com'; - Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); + Functions\expect( 'get_blog_details' )->andReturn( (object) [ 'path' => '/' ] ); Functions\expect( 'site_url' )->once()->andReturn( $url ); $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); @@ -365,7 +365,7 @@ public function test_should_convert_for_ip_subdomain_multisite() { Functions\expect( 'get_current_blog_id' )->andReturn( 10 ); $url = 'http://shop.8.8.8.8'; - Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); + Functions\expect( 'get_blog_details' )->andReturn( (object) [ 'path' => '/' ] ); Functions\expect( 'site_url' )->once()->andReturn( $url ); $this->assertSame( "{$url}/{$path}", beans_path_to_url( $path, true ) ); diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunction.php b/tests/phpunit/unit/api/utilities/beansRenderFunction.php index a69fb4c5..d3ee0d21 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunction.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunction.php @@ -65,7 +65,7 @@ public function test_should_work_with_arguments() { }; $this->assertSame( 'foo bar baz', - beans_render_function( $callback, array( 'foo', 'bar' ), 'baz' ) + beans_render_function( $callback, [ 'foo', 'bar' ], 'baz' ) ); $callback = function ( $object ) { @@ -74,7 +74,7 @@ public function test_should_work_with_arguments() { }; $this->assertSame( 'beans', - beans_render_function( $callback, (object) array( 'foo' => 'beans' ) ) + beans_render_function( $callback, (object) [ 'foo' => 'beans' ] ) ); } } diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php index 26e8f24b..5b897a0d 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php @@ -55,7 +55,7 @@ public function test_should_work_with_arguments() { }; $this->assertSame( 'foo bar baz', - beans_render_function_array( $callback, array( 'foo', 'bar', 'baz' ) ) + beans_render_function_array( $callback, [ 'foo', 'bar', 'baz' ] ) ); $callback = function ( $array, $baz ) { @@ -64,7 +64,7 @@ public function test_should_work_with_arguments() { }; $this->assertSame( 'foo bar baz', - beans_render_function_array( $callback, array( array( 'foo', 'bar' ), 'baz' ) ) + beans_render_function_array( $callback, [ [ 'foo', 'bar' ], 'baz' ] ) ); $callback = function ( $array1, $array2 ) { @@ -78,13 +78,13 @@ public function test_should_work_with_arguments() { 'oof', beans_render_function_array( $callback, - array( - array( + [ + [ 'foo' => 'oof', 'bar' => 'rab', - ), - array( 'baz' => 'zab' ), - ) + ], + [ 'baz' => 'zab' ], + ] ) ); } diff --git a/tests/phpunit/unit/api/utilities/beansUrlToPath.php b/tests/phpunit/unit/api/utilities/beansUrlToPath.php index 21cd4eff..9f02a50c 100644 --- a/tests/phpunit/unit/api/utilities/beansUrlToPath.php +++ b/tests/phpunit/unit/api/utilities/beansUrlToPath.php @@ -320,7 +320,7 @@ public function test_should_convert_domain_for_subdirectory_multisite() { Functions\expect( 'is_main_site' )->andReturn( false ); Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); - Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/shop/' ) ); + Functions\expect( 'get_blog_details' )->andReturn( (object) [ 'path' => '/shop/' ] ); Functions\expect( 'site_url' )->once()->andReturn( 'http://example.com/shop/' ); $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://example.com/shop/', true ) ); @@ -336,7 +336,7 @@ public function test_should_convert_ip_for_subdirectory_multisite() { Functions\expect( 'is_main_site' )->andReturn( false ); Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); - Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/shop/' ) ); + Functions\expect( 'get_blog_details' )->andReturn( (object) [ 'path' => '/shop/' ] ); Functions\expect( 'site_url' )->once()->andReturn( 'http://8.8.8.8/shop/' ); $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://8.8.8.8/shop/', true ) ); @@ -352,7 +352,7 @@ public function test_should_convert_domain_for_subdomain_multisite() { Functions\expect( 'is_main_site' )->andReturn( false ); Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); - Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); + Functions\expect( 'get_blog_details' )->andReturn( (object) [ 'path' => '/' ] ); Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.example.com' ); $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://shop.example.com', true ) ); @@ -367,7 +367,7 @@ public function test_should_convert_ip_for_subdomain_multisite() { Functions\expect( 'is_main_site' )->andReturn( false ); Functions\expect( 'get_current_blog_id' )->andReturn( 5 ); - Functions\expect( 'get_blog_details' )->andReturn( (object) array( 'path' => '/' ) ); + Functions\expect( 'get_blog_details' )->andReturn( (object) [ 'path' => '/' ] ); Functions\expect( 'site_url' )->once()->andReturn( 'http://shop.255.147.55.10' ); $this->assertSame( rtrim( $this->abspath, '/' ), beans_url_to_path( 'http://shop.255.147.55.10', true ) ); From fceb3af2c0a4e8bc188c48fe5cbf0cfc1c91d33d Mon Sep 17 00:00:00 2001 From: ibes Date: Sat, 23 Jun 2018 17:46:56 +0200 Subject: [PATCH 782/800] Updated array syntax for UIkit API tests. (PR #279) --- .../api/uikit/includes/class-uikit-test-case.php | 14 +++++++------- .../api/uikit/includes/class-uikit-test-case.php | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php index 935802ef..94bb4ea9 100644 --- a/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php @@ -117,13 +117,13 @@ protected function set_up_uploads_directory() { protected function reset_globals() { global $_beans_uikit_enqueued_items, $_beans_uikit_registered_items; - $_beans_uikit_enqueued_items = array( - 'components' => array( - 'core' => array(), - 'add-ons' => array(), - ), - 'themes' => array(), - ); + $_beans_uikit_enqueued_items = [ + 'components' => [ + 'core' => [], + 'add-ons' => [], + ], + 'themes' => [], + ]; $_beans_uikit_registered_items = [ 'themes' => [ diff --git a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php index cbada574..295c1d36 100644 --- a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php @@ -54,12 +54,12 @@ abstract class UIkit_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/utilities/functions.php', 'api/compiler/functions.php', 'api/uikit/functions.php', 'api/uikit/class-beans-uikit.php', - ) ); + ] ); $this->set_up_virtual_filesystem(); $this->set_up_mocked_functions(); From c9a612844cb87db114088409203730ec65102414 Mon Sep 17 00:00:00 2001 From: ibes Date: Sat, 23 Jun 2018 17:49:34 +0200 Subject: [PATCH 783/800] Updated array syntax for Term Meta API tests. (PR #280) --- .../term-meta/beans-term-meta/construct.php | 16 ++++++------- .../api/term-meta/beansRegisterTermMeta.php | 4 ++-- .../api/term-meta/fixtures/test-fields.php | 24 +++++++++---------- .../unit/api/term-meta/beansGetTermMeta.php | 10 ++++---- .../unit/api/term-meta/beansIsAdminTerm.php | 4 ++-- .../api/term-meta/beansRegisterTermMeta.php | 10 ++++---- .../api/term-meta/fixtures/test-fields.php | 8 +++---- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php b/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php index 5e0e032e..f7f8abd9 100644 --- a/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php +++ b/tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php @@ -33,16 +33,16 @@ public function test_should_set_correct_hooks_when_class_is_instantiated() { // First instantiation sets all hooks. $term_meta1 = new _Beans_Term_Meta( 'tm-beans' ); - $this->assertEquals( 10, has_action( 'sample-taxonomy_edit_form', array( $term_meta1, 'render_nonce' ) ) ); - $this->assertEquals( 10, has_action( 'edit_term', array( $term_meta1, 'save' ) ) ); - $this->assertEquals( 10, has_action( 'delete_term', array( $term_meta1, 'delete' ) ) ); - $this->assertEquals( 10, has_action( 'sample-taxonomy_edit_form_fields', array( $term_meta1, 'render_fields' ) ) ); + $this->assertEquals( 10, has_action( 'sample-taxonomy_edit_form', [ $term_meta1, 'render_nonce' ] ) ); + $this->assertEquals( 10, has_action( 'edit_term', [ $term_meta1, 'save' ] ) ); + $this->assertEquals( 10, has_action( 'delete_term', [ $term_meta1, 'delete' ] ) ); + $this->assertEquals( 10, has_action( 'sample-taxonomy_edit_form_fields', [ $term_meta1, 'render_fields' ] ) ); // Subsequent instantiation sets only {$taxonomy}_edit_form_fields hook. $term_meta2 = new _Beans_Term_Meta( 'tm-beans-child' ); - $this->assertFalse( has_action( 'sample-taxonomy_edit_form', array( $term_meta2, 'render_nonce' ) ) ); - $this->assertFalse( has_action( 'edit_term', array( $term_meta2, 'save' ) ) ); - $this->assertFalse( has_action( 'delete_term', array( $term_meta2, 'delete' ) ) ); - $this->assertEquals( 10, has_action( 'sample-taxonomy_edit_form_fields', array( $term_meta2, 'render_fields' ) ) ); + $this->assertFalse( has_action( 'sample-taxonomy_edit_form', [ $term_meta2, 'render_nonce' ] ) ); + $this->assertFalse( has_action( 'edit_term', [ $term_meta2, 'save' ] ) ); + $this->assertFalse( has_action( 'delete_term', [ $term_meta2, 'delete' ] ) ); + $this->assertEquals( 10, has_action( 'sample-taxonomy_edit_form_fields', [ $term_meta2, 'render_fields' ] ) ); } } diff --git a/tests/phpunit/integration/api/term-meta/beansRegisterTermMeta.php b/tests/phpunit/integration/api/term-meta/beansRegisterTermMeta.php index 2f8c0ad6..93079d51 100644 --- a/tests/phpunit/integration/api/term-meta/beansRegisterTermMeta.php +++ b/tests/phpunit/integration/api/term-meta/beansRegisterTermMeta.php @@ -28,7 +28,7 @@ class Tests_BeansRegisterTermMeta extends Beans_Term_Meta_Test_Case { * Test beans_register_term_meta() should return false when current taxonomy is not concerned. */ public function test_should_return_false_when_current_taxonomy_not_concerned() { - $this->assertFalse( beans_register_term_meta( static::$test_data['fields'], array( 'sample-taxonomy' ), 'tm-beans' ) ); + $this->assertFalse( beans_register_term_meta( static::$test_data['fields'], [ 'sample-taxonomy' ], 'tm-beans' ) ); } /** @@ -53,7 +53,7 @@ public function test_should_return_false_when_term_meta_fields_cannot_be_registe $_POST['taxonomy'] = 'sample-taxonomy'; set_current_screen( 'edit' ); - $this->assertFalse( beans_register_term_meta( array(), 'sample-taxonomy', 'tm-beans' ) ); + $this->assertFalse( beans_register_term_meta( [], 'sample-taxonomy', 'tm-beans' ) ); } /** diff --git a/tests/phpunit/integration/api/term-meta/fixtures/test-fields.php b/tests/phpunit/integration/api/term-meta/fixtures/test-fields.php index 495703be..b811703e 100644 --- a/tests/phpunit/integration/api/term-meta/fixtures/test-fields.php +++ b/tests/phpunit/integration/api/term-meta/fixtures/test-fields.php @@ -7,32 +7,32 @@ * @since 1.5.0 */ -return array( - 'fields' => array( - array( +return [ + 'fields' => [ + [ 'id' => 'beans_layout_test', 'label' => 'Layout', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', 'c' => BEANS_THEME_URL . 'lib/admin/assets/images/layouts/c.png', 'c_sp' => BEANS_THEME_URL . 'lib/admin/assets/images/layouts/c_sp.png', 'sp_c' => BEANS_THEME_URL . 'lib/admin/assets/images/layouts/sp_c.png', - ), - ), - array( + ], + ], + [ 'id' => 'beans_checkbox_test', 'label' => 'Checkbox Test Field Label', 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_text_test', 'description' => 'Sample Text Field Description', 'type' => 'text', 'default' => 'Testing the text field.', - ), - ), -); + ], + ], +]; diff --git a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php index 31570bf7..32aa8d55 100644 --- a/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php +++ b/tests/phpunit/unit/api/term-meta/beansGetTermMeta.php @@ -29,7 +29,7 @@ class Tests_BeansGetTermMeta extends Beans_Term_Meta_Test_Case { public function test_should_return_false_when_no_default_given_and_term_meta_not_set() { Monkey\Functions\expect( 'get_queried_object' ) ->once() - ->andReturn( (object) array( 'post_id' => 1 ) ); // return an object with no term_id. + ->andReturn( (object) [ 'post_id' => 1 ] ); // return an object with no term_id. Monkey\Functions\expect( 'get_option' )->never(); $this->assertFalse( beans_get_term_meta( 'beans_layout' ) ); @@ -42,7 +42,7 @@ public function test_should_return_false_when_no_default_given_and_term_meta_not public function test_should_return_default_when_default_given_and_queried_obj_has_term_id_but_term_meta_not_set() { Monkey\Functions\expect( 'get_queried_object' ) ->once() - ->andReturn( (object) array( 'term_id' => 1 ) ); + ->andReturn( (object) [ 'term_id' => 1 ] ); Monkey\Functions\expect( 'get_option' ) ->with( 'beans_term_1_beans_layout', 'default_fallback' ) ->twice() @@ -59,7 +59,7 @@ public function test_should_return_default_when_default_given_and_queried_obj_ha public function test_should_return_term_meta_when_queried_object_has_term_id_and_meta_is_set() { Monkey\Functions\expect( 'get_queried_object' ) ->once() - ->andReturn( (object) array( 'term_id' => 1 ) ); + ->andReturn( (object) [ 'term_id' => 1 ] ); Monkey\Functions\expect( 'get_option' ) ->with( 'beans_term_1_beans_layout', 'default_fallback' ) ->twice() @@ -75,7 +75,7 @@ public function test_should_return_term_meta_when_queried_object_has_term_id_and public function test_should_return_default_when_default_given_and_term_id_is_tag_id_but_term_meta_not_set() { Monkey\Functions\expect( 'get_queried_object' ) ->once() - ->andReturn( (object) array( 'post_id' => 1 ) ); + ->andReturn( (object) [ 'post_id' => 1 ] ); Monkey\Functions\expect( 'beans_get' )->once()->with( 'tag_ID' )->andReturn( 1 ); Monkey\Functions\expect( 'get_option' ) ->with( 'beans_term_1_beans_layout', 'default_fallback' ) @@ -92,7 +92,7 @@ public function test_should_return_default_when_default_given_and_term_id_is_tag public function test_should_return_term_meta_when_default_given_and_term_id_is_tag_id_and_term_meta_exists() { Monkey\Functions\expect( 'get_queried_object' ) ->once() - ->andReturn( (object) array( 'post_id' => 1 ) ); + ->andReturn( (object) [ 'post_id' => 1 ] ); Monkey\Functions\expect( 'beans_get' )->once()->with( 'tag_ID' )->andReturn( 1 ); Monkey\Functions\expect( 'get_option' ) ->with( 'beans_term_1_beans_layout', 'default_fallback' ) diff --git a/tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php b/tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php index 09fc4075..4097e731 100644 --- a/tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php +++ b/tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php @@ -51,7 +51,7 @@ public function tests_should_return_true_when_current_taxonomy_in_taxonomy_array ->with( 'taxonomy' ) ->andReturn( 'selected-taxonomy' ); - $this->assertTrue( _beans_is_admin_term( array( 'selected-taxonomy', 'other-taxonomy' ) ) ); + $this->assertTrue( _beans_is_admin_term( [ 'selected-taxonomy', 'other-taxonomy' ] ) ); } /** @@ -63,7 +63,7 @@ public function tests_should_return_false_when_current_taxonomy_not_in_taxonomy_ ->with( 'taxonomy' ) ->andReturn( 'selected-taxonomy' ); - $this->assertFalse( _beans_is_admin_term( array( 'sample-taxonomy', 'other-taxonomy' ) ) ); + $this->assertFalse( _beans_is_admin_term( [ 'sample-taxonomy', 'other-taxonomy' ] ) ); } } diff --git a/tests/phpunit/unit/api/term-meta/beansRegisterTermMeta.php b/tests/phpunit/unit/api/term-meta/beansRegisterTermMeta.php index cc8d2b14..af83d58e 100644 --- a/tests/phpunit/unit/api/term-meta/beansRegisterTermMeta.php +++ b/tests/phpunit/unit/api/term-meta/beansRegisterTermMeta.php @@ -29,9 +29,9 @@ class Tests_BeansRegisterTermMeta extends Beans_Term_Meta_Test_Case { public function test_should_return_false_when_current_taxonomy_not_concerned() { Monkey\Functions\expect( '_beans_is_admin_term' ) ->once() - ->with( array( 'sample-taxonomy' ) ) + ->with( [ 'sample-taxonomy' ] ) ->andReturn( false ); - $this->assertFalse( beans_register_term_meta( static::$test_data, array( 'sample-taxonomy' ), 'tm-beans' ) ); + $this->assertFalse( beans_register_term_meta( static::$test_data, [ 'sample-taxonomy' ], 'tm-beans' ) ); } /** @@ -40,7 +40,7 @@ public function test_should_return_false_when_current_taxonomy_not_concerned() { public function test_should_return_false_when_not_is_admin() { Monkey\Functions\expect( '_beans_is_admin_term' ) ->once() - ->with( array( 'sample-taxonomy' ) ) + ->with( [ 'sample-taxonomy' ] ) ->andReturn( true ); Monkey\Functions\expect( 'is_admin' )->once()->andReturn( false ); @@ -59,7 +59,7 @@ public function test_should_return_false_when_not_is_admin() { public function test_should_return_false_when_fields_cannot_be_registered() { Monkey\Functions\expect( '_beans_is_admin_term' ) ->once() - ->with( array( 'sample-taxonomy' ) ) + ->with( [ 'sample-taxonomy' ] ) ->andReturn( true ); Monkey\Functions\expect( 'is_admin' )->once()->andReturn( true ); Monkey\Functions\expect( 'beans_register_fields' ) @@ -82,7 +82,7 @@ public function test_should_return_false_when_fields_cannot_be_registered() { public function test_should_return_true_when_fields_are_successfully_registered() { Monkey\Functions\expect( '_beans_is_admin_term' ) ->once() - ->with( array( 'sample-taxonomy' ) ) + ->with( [ 'sample-taxonomy' ] ) ->andReturn( true ); Monkey\Functions\expect( 'is_admin' )->once()->andReturn( true ); Monkey\Functions\expect( 'beans_register_fields' ) diff --git a/tests/phpunit/unit/api/term-meta/fixtures/test-fields.php b/tests/phpunit/unit/api/term-meta/fixtures/test-fields.php index f9d83507..e70dac6e 100644 --- a/tests/phpunit/unit/api/term-meta/fixtures/test-fields.php +++ b/tests/phpunit/unit/api/term-meta/fixtures/test-fields.php @@ -7,11 +7,11 @@ * @since 1.5.0 */ -return array( - 'sample-field' => array( +return [ + 'sample-field' => [ 'id' => 'field_id', 'context' => 'term_meta', 'type' => 'radio', 'label' => 'Field Label', - ), -); + ], +]; From ea494a01f44eb6234996ad05006a00a328842630 Mon Sep 17 00:00:00 2001 From: ibes Date: Sat, 23 Jun 2018 17:50:39 +0200 Subject: [PATCH 784/800] Updated array syntax for Template API tests. (PR #282) --- .../api/template/beansLoadFragmentFile.php | 2 +- .../unit/api/template/beansLoadFragmentFile.php | 4 ++-- .../includes/class-template-test-case.php | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/integration/api/template/beansLoadFragmentFile.php b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php index dcd01eaf..bfde3a11 100644 --- a/tests/phpunit/integration/api/template/beansLoadFragmentFile.php +++ b/tests/phpunit/integration/api/template/beansLoadFragmentFile.php @@ -26,7 +26,7 @@ class Tests_BeansLoadFragmentFile extends Test_Case { */ public function test_should_return_false_when_short_circuiting() { - foreach ( array( 'branding', 'post-body' ) as $fragment ) { + foreach ( [ 'branding', 'post-body' ] as $fragment ) { Monkey\Functions\expect( 'beans_test_fragment_short_circuit' ) ->with( false ) ->once() diff --git a/tests/phpunit/unit/api/template/beansLoadFragmentFile.php b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php index 0639e0e0..89fada22 100644 --- a/tests/phpunit/unit/api/template/beansLoadFragmentFile.php +++ b/tests/phpunit/unit/api/template/beansLoadFragmentFile.php @@ -28,7 +28,7 @@ class Tests_BeansLoadFragmentFile extends Template_Test_Case { */ public function test_should_return_false_when_short_circuiting() { - foreach ( array( 'branding', 'post-body' ) as $fragment ) { + foreach ( [ 'branding', 'post-body' ] as $fragment ) { Monkey\Filters\expectApplied( "beans_pre_load_fragment_{$fragment}" ) ->with( false ) ->once() @@ -56,7 +56,7 @@ public function test_should_return_false_when_fragment_does_not_exist() { */ public function test_should_return_true_after_loading_fragment() { - foreach ( array( 'branding', 'post-body' ) as $fragment ) { + foreach ( [ 'branding', 'post-body' ] as $fragment ) { Monkey\Filters\expectApplied( "beans_pre_load_fragment_{$fragment}" ) ->with( false ) ->once() diff --git a/tests/phpunit/unit/api/template/includes/class-template-test-case.php b/tests/phpunit/unit/api/template/includes/class-template-test-case.php index fcfb93b8..c7fee182 100644 --- a/tests/phpunit/unit/api/template/includes/class-template-test-case.php +++ b/tests/phpunit/unit/api/template/includes/class-template-test-case.php @@ -39,10 +39,10 @@ abstract class Template_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/template/functions.php', 'api/utilities/functions.php', - ) ); + ] ); $this->set_up_virtual_filesystem(); @@ -60,16 +60,16 @@ protected function setUp() { */ private function set_up_virtual_filesystem() { // Create the file structure and load each file's content. - $file_structure = array( - 'fragments' => array( + $file_structure = [ + 'fragments' => [ 'branding.php' => '', 'post-body.php' => '

                Nulla in orci condimentum, facilisis ex et, blandit augue.

                ', - ), - 'structure' => array( + ], + 'structure' => [ 'content.php' => '', 'header.php' => '', - ), - ); + ], + ]; $file_structure['structure']['content.php'] = '
                ' . $file_structure['fragments']['post-body.php'] . '
                '; $file_structure['structure']['header.php'] = '
                ' . $file_structure['fragments']['branding.php'] . '
                '; From e67b8ae49a7b4a51105c14d317d3ac2325b5242e Mon Sep 17 00:00:00 2001 From: ibes Date: Sat, 23 Jun 2018 18:03:24 +0200 Subject: [PATCH 785/800] Updated array syntax for HTML API tests. (PR #283) --- .../api/html/beans-attribute/init.php | 6 +- .../api/html/beansAddAttribute.php | 8 +-- .../api/html/beansAddAttributes.php | 4 +- .../api/html/beansModifyMarkup.php | 10 +-- .../integration/api/html/beansOpenMarkup.php | 34 ++++----- .../integration/api/html/beansOpenMarkupE.php | 8 +-- .../integration/api/html/beansOutputE.php | 4 +- .../api/html/beansRemoveAttribute.php | 20 +++--- .../api/html/beansRemoveMarkup.php | 8 +-- .../api/html/beansRemoveOutput.php | 4 +- .../api/html/beansReplaceAttribute.php | 26 +++---- .../integration/api/html/beansResetMarkup.php | 6 +- .../api/html/beansWrapInnerMarkup.php | 58 +++++++-------- .../integration/api/html/beansWrapMarkup.php | 58 +++++++-------- .../api/html/fixtures/test-attachment.php | 28 ++++---- .../api/html/fixtures/test-markup.php | 56 +++++++-------- .../unit/api/html/beans-attribute/add.php | 4 +- .../unit/api/html/beans-attribute/init.php | 2 +- .../unit/api/html/beans-attribute/remove.php | 8 +-- .../unit/api/html/beans-attribute/replace.php | 8 +-- .../unit/api/html/beansAddAttributes.php | 6 +- .../phpunit/unit/api/html/beansOpenMarkup.php | 28 ++++---- .../unit/api/html/beansOpenMarkupE.php | 8 +-- tests/phpunit/unit/api/html/beansOutputE.php | 4 +- .../unit/api/html/beansRemoveOutput.php | 4 +- .../unit/api/html/beansWrapInnerMarkup.php | 70 +++++++++---------- .../phpunit/unit/api/html/beansWrapMarkup.php | 70 +++++++++---------- .../fixtures/class-anonymous-action-stub.php | 2 +- .../fixtures/class-anonymous-filter-stub.php | 2 +- .../api/html/fixtures/test-attachment.php | 28 ++++---- .../unit/api/html/fixtures/test-markup.php | 56 +++++++-------- .../html/includes/class-html-test-case.php | 6 +- 32 files changed, 322 insertions(+), 322 deletions(-) diff --git a/tests/phpunit/integration/api/html/beans-attribute/init.php b/tests/phpunit/integration/api/html/beans-attribute/init.php index c4d72836..c5f9a2b2 100644 --- a/tests/phpunit/integration/api/html/beans-attribute/init.php +++ b/tests/phpunit/integration/api/html/beans-attribute/init.php @@ -29,7 +29,7 @@ class Tests_BeansAttribute_Init extends HTML_Test_Case { public function test_should_return_null_when_method_does_not_exist() { $instance = new _Beans_Attribute( 'foo', 'data-test' ); $this->assertNull( $instance->init( 'does_not_exist' ) ); - $this->assertFalse( has_filter( 'foo_attributes', array( $instance, 'does_not_exist' ), 10 ) ); + $this->assertFalse( has_filter( 'foo_attributes', [ $instance, 'does_not_exist' ], 10 ) ); } /** @@ -39,9 +39,9 @@ public function test_should_register_the_callback_when_method_exists() { $instance = new _Beans_Attribute( 'foo', 'data-test' ); $this->assertSame( $instance, $instance->init( 'add' ) ); - $this->assertSame( 10, has_filter( 'foo_attributes', array( $instance, 'add' ), 10 ) ); + $this->assertSame( 10, has_filter( 'foo_attributes', [ $instance, 'add' ], 10 ) ); // Clean up. - remove_filter( 'foo_attributes', array( $instance, 'add' ) ); + remove_filter( 'foo_attributes', [ $instance, 'add' ] ); } } diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php index 6f680da2..fb86c649 100644 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ b/tests/phpunit/integration/api/html/beansAddAttribute.php @@ -34,10 +34,10 @@ public function test_should_return_instance_and_register_callback_to_given_id() $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); // Check that the object's "add" method is registered to the filter event for the given ID. - $this->assertSame( 10, has_filter( "{$beans_id}_attributes", array( $instance, 'add' ), 10 ) ); + $this->assertSame( 10, has_filter( "{$beans_id}_attributes", [ $instance, 'add' ], 10 ) ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'add' ) ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'add' ] ); } } @@ -62,7 +62,7 @@ public function test_should_add_the_attribute_when_does_not_exist() { $this->assertSame( $expected, $actual ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'add' ), 10 ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'add' ], 10 ); } } @@ -84,7 +84,7 @@ public function test_should_add_value_to_existing_attribute_values() { $this->assertSame( $expected, $actual ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'add' ), 10 ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'add' ], 10 ); } } } diff --git a/tests/phpunit/integration/api/html/beansAddAttributes.php b/tests/phpunit/integration/api/html/beansAddAttributes.php index 5b245117..7f3b30f0 100644 --- a/tests/phpunit/integration/api/html/beansAddAttributes.php +++ b/tests/phpunit/integration/api/html/beansAddAttributes.php @@ -59,12 +59,12 @@ public function test_should_return_empty_string_when_no_attributes() { */ public function test_should_return_filtered_attributes_when_registered_callback() { // Set up the test. - $attributes = array( 'class' => 'foo' ); + $attributes = [ 'class' => 'foo' ]; Monkey\Functions\expect( 'foo_attributes_callback' ) ->with( $attributes ) ->once() ->andReturnUsing( function ( $attributes ) { - return array( 'class' => 'changed-me' ); + return [ 'class' => 'changed-me' ]; } ); add_action( 'foo_attributes', 'foo_attributes_callback' ); diff --git a/tests/phpunit/integration/api/html/beansModifyMarkup.php b/tests/phpunit/integration/api/html/beansModifyMarkup.php index 18393021..885e529d 100644 --- a/tests/phpunit/integration/api/html/beansModifyMarkup.php +++ b/tests/phpunit/integration/api/html/beansModifyMarkup.php @@ -36,10 +36,10 @@ public function test_should_return_anonymous_filter_instance() { public function test_should_register_callback_to_id_markup_filter() { $anonymous_filter = beans_modify_markup( 'beans_archive_title', 'h2' ); - $this->assertSame( 10, has_filter( 'beans_archive_title_markup', array( + $this->assertSame( 10, has_filter( 'beans_archive_title_markup', [ $anonymous_filter, 'callback', - ) ) ); + ] ) ); } /** @@ -60,7 +60,7 @@ public function test_should_modify_html_markup_tag() { } ); // Check the opening markup. - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertSame( $expected, $actual ); // Check the closing markup. @@ -75,13 +75,13 @@ public function test_should_modify_html_markup_self_closing_tag() { $expected = << EOB; - $actual = beans_selfclose_markup( 'beans_post_image_item', 'img', array( + $actual = beans_selfclose_markup( 'beans_post_image_item', 'img', [ 'width' => 800, 'height' => 500, 'src' => 'http://example.com/image.png', 'alt' => 'Some image', 'itemprop' => 'image', - ) ); + ] ); $this->assertSame( $expected, $actual ); } } diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php index 0743e415..04600d3e 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkup.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkup.php @@ -27,7 +27,7 @@ class Tests_BeansOpenMarkup extends HTML_Test_Case { * Test beans_open_markup() should return null when the tag is set to null. */ public function test_should_return_null_when_tag_set_to_null() { - $this->assertNull( beans_open_markup( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) ); + $this->assertNull( beans_open_markup( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ) ); } /** @@ -43,7 +43,7 @@ public function test_should_fire_before_markup_hooks_and_include_content_in_retu add_action( 'beans_archive_title_before_markup', '__beans_render_title_before_markup' ); // Run the tests. - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertEquals( 1, did_action( 'beans_archive_title_before_markup' ) ); $this->assertStringStartsWith( '', $actual ); } @@ -61,7 +61,7 @@ public function test_should_fire_prepend_markup_hooks_and_include_content_in_ret add_action( 'beans_archive_title_prepend_markup', '__beans_render_title_prepend_markup' ); // Run the tests. - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertEquals( 1, did_action( 'beans_archive_title_prepend_markup' ) ); $this->assertStringEndsWith( '', $actual ); } @@ -83,7 +83,7 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { $_beans_is_selfclose_markup = true; // Run the tests. - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); $this->assertStringEndsWith( '', $actual ); @@ -95,7 +95,7 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { * Test beans_open_markup() should return the built HTML element when before or prepend hooks are not registered. */ public function test_should_return_built_html_when_before_or_prepend_hooks_not_registered() { - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertSame( '

                ', $actual ); $this->assertEquals( 0, did_action( 'beans_archive_title_before_markup' ) ); $this->assertEquals( 0, did_action( 'beans_archive_title_prepend_markup' ) ); @@ -108,7 +108,7 @@ public function test_should_return_built_html_when_before_or_prepend_hooks_not_r public function test_should_return_built_html_with_data_markup_id_when_in_dev_mode() { add_option( 'beans_dev_mode', 1 ); - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertSame( '

                ', $actual ); } @@ -124,7 +124,7 @@ public function test_should_return_built_html_when_before_or_prepend_hooks() { } ); // Run the tests. - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $expected = <<

                EOB; @@ -140,13 +140,13 @@ public function test_should_return_built_html_when_before_or_prepend_hooks() { * $_beans_is_selfclose_markup is set to true. */ public function test_should_return_built_self_closing_html_when_selfclose_markup_is_true() { - $args = array( + $args = [ 'width' => 800, 'height' => 500, 'src' => 'http://example.com/image.png', 'alt' => 'Some image', 'itemprop' => 'image', - ); + ]; // Run it with development mode off. global $_beans_is_selfclose_markup; @@ -186,11 +186,11 @@ public function test_should_return_only_hooked_callbacks_output_and_no_html_elem } ); // Check with an empty string. - $actual = beans_open_markup( 'beans_archive_title', '', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', '', [ 'class' => 'uk-article-title' ] ); $this->assertSame( '', $actual ); // Check with false. - $actual = beans_open_markup( 'beans_archive_title', false, array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', false, [ 'class' => 'uk-article-title' ] ); $this->assertSame( '', $actual ); // Check the hooks. @@ -207,30 +207,30 @@ public function test_should_escape_built_html_tag() { <<script>alert("Should escape me.")</script> class="uk-article-title" itemprop="headline"> EOB; // Check when given as the tag. - $actual = beans_open_markup( 'beans_post_title', '', array( + $actual = beans_open_markup( 'beans_post_title', '', [ 'class' => 'uk-article-title', 'itemprop' => 'headline', - ) ); + ] ); $this->assertSame( $expected, $actual ); // Check when tag is filtered. add_filter( 'beans_post_title_markup', function() { return ''; } ); - $actual = beans_open_markup( 'beans_post_title', 'h1', array( + $actual = beans_open_markup( 'beans_post_title', 'h1', [ 'class' => 'uk-article-title', 'itemprop' => 'headline', - ) ); + ] ); $this->assertSame( $expected, $actual ); // Check the attributes too. $expected = << EOB; - $this->assertSame( $expected, beans_open_markup( 'beans_post_title_link', 'a', array( + $this->assertSame( $expected, beans_open_markup( 'beans_post_title_link', 'a', [ 'href' => 'http://example.com/testing-ensure-safe?val=', 'title' => 'Testing to ensure safe.', 'rel' => 'bookmark', - ) ) ); + ] ) ); } } diff --git a/tests/phpunit/integration/api/html/beansOpenMarkupE.php b/tests/phpunit/integration/api/html/beansOpenMarkupE.php index 93e8ed6f..11572b57 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkupE.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkupE.php @@ -27,7 +27,7 @@ class Tests_BeansOpenMarkupE extends HTML_Test_Case { */ public function test_should_echo_empty_string_when_tag_set_to_null() { ob_start(); - beans_open_markup_e( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ); + beans_open_markup_e( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ); $this->assertEquals( '', ob_get_clean() ); } @@ -37,7 +37,7 @@ public function test_should_echo_empty_string_when_tag_set_to_null() { */ public function test_should_echo_html_element_when_hooks_not_registered() { ob_start(); - beans_open_markup_e( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + beans_open_markup_e( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $actual = ob_get_clean(); $this->assertSame( '

                ', $actual ); @@ -53,7 +53,7 @@ public function test_should_echo_html_element_with_data_markup_id_when_in_dev_mo add_option( 'beans_dev_mode', 1 ); ob_start(); - beans_open_markup_e( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + beans_open_markup_e( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertSame( '

                ', ob_get_clean() ); } @@ -70,7 +70,7 @@ public function test_should_echo_before_element_prepend_html_when_before_or_prep } ); ob_start(); - beans_open_markup_e( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + beans_open_markup_e( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $actual = ob_get_clean(); $expected = << null, 'beans_post_meta_item_author' => '', 'beans_post_meta_item_comments' => false, - ); + ]; foreach ( $ids as $id => $output ) { ob_start(); diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php index 6ff7b4ab..69fa2d07 100644 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -34,10 +34,10 @@ public function test_should_return_instance_and_register_callback_to_given_id() $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); // Check that the object's "remove" method is registered to the filter event for the given ID. - $this->assertSame( 10, has_filter( "{$beans_id}_attributes", array( $instance, 'remove' ), 10 ) ); + $this->assertSame( 10, has_filter( "{$beans_id}_attributes", [ $instance, 'remove' ], 10 ) ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ) ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'remove' ] ); } } @@ -61,7 +61,7 @@ public function test_should_return_original_attributes_when_target_attribute_doe $this->assertSame( $markup['attributes'], $actual ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ) ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'remove' ] ); } } @@ -87,7 +87,7 @@ public function test_should_remove_attribute_when_value_is_null() { $this->assertSame( $expected, $actual ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ), 10 ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'remove' ], 10 ); } } @@ -96,13 +96,13 @@ public function test_should_remove_attribute_when_value_is_null() { * should remove the given value from the attribute. */ public function test_should_remove_the_given_value_from_attribute() { - $attributes = array( + $attributes = [ 'id' => 47, 'class' => 'uk-article uk-panel-box category-beans', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/blogPost', 'itemprop' => 'beans_post', - ); + ]; $instance = beans_remove_attribute( 'beans_test', 'class', 'uk-panel-box' ); @@ -119,7 +119,7 @@ public function test_should_remove_the_given_value_from_attribute() { $this->assertSame( $expected, $actual ); // Clean up. - remove_filter( 'beans_test_attributes', array( $instance, 'remove' ), 10 ); + remove_filter( 'beans_test_attributes', [ $instance, 'remove' ], 10 ); } /** @@ -135,13 +135,13 @@ public function test_should_return_empty_array_when_empty_array_given() { $instance = beans_remove_attribute( $beans_id, $name, $value ); // Fire the event to run the remove. - $actual = apply_filters( "{$beans_id}_attributes", array() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $actual = apply_filters( "{$beans_id}_attributes", [] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Check that an empty array is returned. - $this->assertSame( array(), $actual ); + $this->assertSame( [], $actual ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'remove' ), 10 ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'remove' ], 10 ); } } } diff --git a/tests/phpunit/integration/api/html/beansRemoveMarkup.php b/tests/phpunit/integration/api/html/beansRemoveMarkup.php index 1fc5c6e4..7605ea25 100644 --- a/tests/phpunit/integration/api/html/beansRemoveMarkup.php +++ b/tests/phpunit/integration/api/html/beansRemoveMarkup.php @@ -36,10 +36,10 @@ public function test_should_return_anonymous_filter_instance() { public function test_should_register_callback_to_id_markup_filter() { $anonymous_filter = beans_remove_markup( 'beans_archive_title' ); - $this->assertSame( 10, has_filter( 'beans_archive_title_markup', array( + $this->assertSame( 10, has_filter( 'beans_archive_title_markup', [ $anonymous_filter, 'callback', - ) ) ); + ] ) ); } /** @@ -55,7 +55,7 @@ public function test_should_remove_only_element_when_remove_actions_is_false() { add_action( 'beans_archive_title_prepend_markup', function() { echo ''; } ); - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertSame( '', $actual ); $this->assertSame( '', beans_close_markup( 'beans_archive_title', 'h1' ) ); } @@ -67,7 +67,7 @@ public function test_should_remove_html_markup_when_remove_actions_is_true() { beans_remove_markup( 'beans_archive_title' ); // Let's test it out by running the markup for this ID. - $this->assertSame( '', beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ) ); + $this->assertSame( '', beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ) ); $this->assertSame( '', beans_close_markup( 'beans_archive_title', 'h1' ) ); } } diff --git a/tests/phpunit/integration/api/html/beansRemoveOutput.php b/tests/phpunit/integration/api/html/beansRemoveOutput.php index 57fc99d2..50f45169 100644 --- a/tests/phpunit/integration/api/html/beansRemoveOutput.php +++ b/tests/phpunit/integration/api/html/beansRemoveOutput.php @@ -36,10 +36,10 @@ public function test_should_return_anonymous_filter_instance() { public function test_should_return_register_callback_to_id_output_filter() { $anonymous_filter = beans_remove_output( 'beans_post_meta_item_date' ); - $this->assertSame( 99999999, has_filter( 'beans_post_meta_item_date_output', array( + $this->assertSame( 99999999, has_filter( 'beans_post_meta_item_date_output', [ $anonymous_filter, 'callback', - ) ) ); + ] ) ); } /** diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index 8dbb90e2..5c471cc9 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -34,10 +34,10 @@ public function test_should_return_instance_and_register_callback_to_given_id() $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); // Check that the object's "replace" method is registered to the filter event for the given ID. - $this->assertSame( 10, has_filter( "{$beans_id}_attributes", array( $instance, 'replace' ), 10 ) ); + $this->assertSame( 10, has_filter( "{$beans_id}_attributes", [ $instance, 'replace' ], 10 ) ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'replace' ) ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'replace' ] ); } } @@ -46,13 +46,13 @@ public function test_should_return_instance_and_register_callback_to_given_id() * an existing attribute value. */ public function test_should_replace_existing_attribute_value() { - $attributes = array( + $attributes = [ 'id' => 47, 'class' => 'uk-article uk-panel-box category-beans', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/blogPost', 'itemprop' => 'beans_post', - ); + ]; $instance = beans_replace_attribute( 'beans_post', 'class', 'uk-panel-box', 'beans-test' ); @@ -67,7 +67,7 @@ public function test_should_replace_existing_attribute_value() { $this->assertNotContains( 'uk-panel-box', $actual['class'] ); // Clean up. - remove_filter( 'beans_post_attributes', array( $instance, 'replace' ), 10 ); + remove_filter( 'beans_post_attributes', [ $instance, 'replace' ], 10 ); } /** @@ -84,25 +84,25 @@ public function test_should_overwrite_attribute_values_when_target_value_is_empt $instance = beans_replace_attribute( $beans_id, $name, null ); $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertNull( $actual[ $name ] ); - remove_filter( $hook, array( $instance, 'replace' ), 10 ); + remove_filter( $hook, [ $instance, 'replace' ], 10 ); // Check when the target value is null. $instance = beans_replace_attribute( $beans_id, $name, null, '' ); $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( '', $actual[ $name ] ); - remove_filter( $hook, array( $instance, 'replace' ), 10 ); + remove_filter( $hook, [ $instance, 'replace' ], 10 ); // Check when the target value is an empty string. $instance = beans_replace_attribute( $beans_id, $name, '', 'foo' ); $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( 'foo', $actual[ $name ] ); - remove_filter( $hook, array( $instance, 'replace' ), 10 ); + remove_filter( $hook, [ $instance, 'replace' ], 10 ); // Check when the target value is false. $instance = beans_replace_attribute( $beans_id, $name, false, 'foo' ); $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. $this->assertSame( 'foo', $actual[ $name ] ); - remove_filter( $hook, array( $instance, 'replace' ), 10 ); + remove_filter( $hook, [ $instance, 'replace' ], 10 ); } } @@ -131,7 +131,7 @@ public function test_should_add_attribute_when_it_does_not_exist() { $this->assertSame( $expected, $actual ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'replace' ), 10 ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'replace' ], 10 ); } } @@ -147,14 +147,14 @@ public function test_should_add_attribute_when_an_empty_array_given() { $instance = beans_replace_attribute( $beans_id, $name, $value, 'beans-test' ); // Fire the event to run the replace. - $actual = apply_filters( "{$beans_id}_attributes", array() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. + $actual = apply_filters( "{$beans_id}_attributes", [] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. // Check that it did add the attribute. $this->assertArrayHasKey( $name, $actual ); - $this->assertSame( array( $name => 'beans-test' ), $actual ); + $this->assertSame( [ $name => 'beans-test' ], $actual ); // Clean up. - remove_filter( "{$beans_id}_attributes", array( $instance, 'replace' ), 10 ); + remove_filter( "{$beans_id}_attributes", [ $instance, 'replace' ], 10 ); } } } diff --git a/tests/phpunit/integration/api/html/beansResetMarkup.php b/tests/phpunit/integration/api/html/beansResetMarkup.php index e3103492..2b4b4158 100644 --- a/tests/phpunit/integration/api/html/beansResetMarkup.php +++ b/tests/phpunit/integration/api/html/beansResetMarkup.php @@ -29,7 +29,7 @@ class Tests_BeansResetMarkup extends HTML_Test_Case { public function test_should_reset_html_markup_opening_and_closing_tag() { // First, register to modify the tag. $anonymous_filter = beans_modify_markup( 'beans_archive_title', 'h2', 20 ); - $this->assertEquals( 20, has_filter( 'beans_archive_title_markup', array( $anonymous_filter, 'callback' ) ) ); + $this->assertEquals( 20, has_filter( 'beans_archive_title_markup', [ $anonymous_filter, 'callback' ] ) ); // Reset it. beans_reset_markup( 'beans_archive_title' ); @@ -49,7 +49,7 @@ public function test_should_reset_html_markup_opening_and_closing_tag() { public function test_should_reset_html_markup_self_closing_tag() { // First, register to modify the tag. $anonymous_filter = beans_modify_markup( 'beans_post_image_item', 'foo', 20 ); - $this->assertEquals( 20, has_filter( 'beans_post_image_item_markup', array( $anonymous_filter, 'callback' ) ) ); + $this->assertEquals( 20, has_filter( 'beans_post_image_item_markup', [ $anonymous_filter, 'callback' ] ) ); // Reset it. beans_reset_markup( 'beans_post_image_item' ); @@ -68,7 +68,7 @@ public function test_should_reset_html_markup_self_closing_tag() { public function test_should_reset_sub_hooks() { // First, register to modify the tag. $anonymous_filter = beans_modify_markup( 'beans_title[_foo]', 'p', 20 ); - $this->assertEquals( 20, has_filter( 'beans_title[_foo]_markup', array( $anonymous_filter, 'callback' ) ) ); + $this->assertEquals( 20, has_filter( 'beans_title[_foo]_markup', [ $anonymous_filter, 'callback' ] ) ); // Reset it. beans_reset_markup( 'beans_title[_foo]' ); diff --git a/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php b/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php index 0855fa39..3cd1b22d 100644 --- a/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php +++ b/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php @@ -42,7 +42,7 @@ protected function get_instance_from_wp( $hook, $priority ) { * Test beans_wrap_inner_markup() should register beans_open_markup() to the given ID's '_prepend_markup' hook. */ public function test_should_register_beans_open_markup_to_given_id_prepend_markup_hook() { - $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); // Check that it did register a callback to the hook. $this->assertTrue( has_action( 'foo_prepend_markup' ) ); @@ -53,26 +53,26 @@ public function test_should_register_beans_open_markup_to_given_id_prepend_marku // Check that the correct arguments were stored in the instance. $anonymous_action = $this->get_instance_from_wp( 'foo_prepend_markup', 1 ); $this->assertSame( - array( + [ 'beans_open_markup', - array( + [ 1 => 'new_foo', 2 => 'div', - 3 => array( 'class' => 'test-wrap' ), - ), - ), + 3 => [ 'class' => 'test-wrap' ], + ], + ], $anonymous_action->callback ); // Clean up. - remove_action( 'foo_prepend_markup', array( $anonymous_action, 'callback' ), 1 ); + remove_action( 'foo_prepend_markup', [ $anonymous_action, 'callback' ], 1 ); } /** * Test beans_wrap_inner_markup() should register beans_close_markup() to the given ID's '_append_markup' hook. */ public function test_should_register_beans_close_markup_to_given_id_append_markup_hook() { - $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); // Check that it did register a callback to the hook. $this->assertTrue( has_action( 'foo_append_markup' ) ); @@ -83,32 +83,32 @@ public function test_should_register_beans_close_markup_to_given_id_append_marku // Check that the correct arguments were stored in the instance. $anonymous_action = $this->get_instance_from_wp( 'foo_append_markup', 9999 ); $this->assertSame( - array( + [ 'beans_close_markup', - array( + [ 1 => 'new_foo', 2 => 'div', - ), - ), + ], + ], $anonymous_action->callback ); // Clean up. - remove_action( 'foo_append_markup', array( $anonymous_action, 'callback' ), 9999 ); + remove_action( 'foo_append_markup', [ $anonymous_action, 'callback' ], 9999 ); } /** * Test beans_wrap_inner_markup() should not pass the given attributes to anonymous action. */ public function test_should_not_pass_attributes_for_append_markup_hook() { - beans_wrap_inner_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ); + beans_wrap_inner_markup( 'no_atts', '', 'div', [ 'class' => 'test-wrap' ] ); // Check that the attributes do not exist. $anonymous_action = $this->get_instance_from_wp( 'no_atts_append_markup', 9999 ); - $this->assertNotContains( array( 'class' => 'test-wrap' ), $anonymous_action->callback[1] ); + $this->assertNotContains( [ 'class' => 'test-wrap' ], $anonymous_action->callback[1] ); // Clean up. - remove_action( 'no_atts_append_markup', array( $anonymous_action, 'callback' ), 9999 ); + remove_action( 'no_atts_append_markup', [ $anonymous_action, 'callback' ], 9999 ); } /** @@ -116,26 +116,26 @@ public function test_should_not_pass_attributes_for_append_markup_hook() { * '_prepend_markup' hook. */ public function test_should_pass_extra_arguments_for_prepend_markup_hook() { - beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ); + beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', [ 'class' => 'test-wrap' ], 47, 'Beans Rocks!' ); // Check that the correct arguments were stored in the instance. $anonymous_action = $this->get_instance_from_wp( 'extra_args_prepend_markup', 1 ); $this->assertSame( - array( + [ 'beans_open_markup', - array( + [ 1 => 'new_extra_args', 2 => 'div', - 3 => array( 'class' => 'test-wrap' ), + 3 => [ 'class' => 'test-wrap' ], 4 => 47, 5 => 'Beans Rocks!', - ), - ), + ], + ], $anonymous_action->callback ); // Clean up. - remove_action( 'extra_args_prepend_markup', array( $anonymous_action, 'callback' ), 1 ); + remove_action( 'extra_args_prepend_markup', [ $anonymous_action, 'callback' ], 1 ); } /** @@ -143,24 +143,24 @@ public function test_should_pass_extra_arguments_for_prepend_markup_hook() { * '_append_markup' hook. */ public function test_should_pass_extra_arguments_for_append_markup_hook() { - beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 'and so does WordPress!' ); + beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', [ 'class' => 'test-wrap' ], 'Beans Rocks!', 'and so does WordPress!' ); // Check that the correct arguments were stored in the instance. $anonymous_action = $this->get_instance_from_wp( 'extra_args_append_markup', 9999 ); $this->assertSame( - array( + [ 'beans_close_markup', - array( + [ 1 => 'new_extra_args', 2 => 'div', 4 => 'Beans Rocks!', 5 => 'and so does WordPress!', - ), - ), + ], + ], $anonymous_action->callback ); // Clean up. - remove_action( 'extra_args_append_markup', array( $anonymous_action, 'callback' ), 9999 ); + remove_action( 'extra_args_append_markup', [ $anonymous_action, 'callback' ], 9999 ); } } diff --git a/tests/phpunit/integration/api/html/beansWrapMarkup.php b/tests/phpunit/integration/api/html/beansWrapMarkup.php index 9bfd019e..0ab3dd9b 100644 --- a/tests/phpunit/integration/api/html/beansWrapMarkup.php +++ b/tests/phpunit/integration/api/html/beansWrapMarkup.php @@ -42,7 +42,7 @@ protected function get_instance_from_wp( $hook, $priority ) { * Test beans_wrap_markup() should register beans_open_markup() to the given ID's '_before_markup' hook. */ public function test_should_register_beans_open_markup_to_given_id_before_markup_hook() { - $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); // Check that it did register a callback to the hook. $this->assertTrue( has_action( 'foo_before_markup' ) ); @@ -53,26 +53,26 @@ public function test_should_register_beans_open_markup_to_given_id_before_markup // Check that the correct arguments were stored in the instance. $anonymous_action = $this->get_instance_from_wp( 'foo_before_markup', 9999 ); $this->assertSame( - array( + [ 'beans_open_markup', - array( + [ 1 => 'new_foo', 2 => 'div', - 3 => array( 'class' => 'test-wrap' ), - ), - ), + 3 => [ 'class' => 'test-wrap' ], + ], + ], $anonymous_action->callback ); // Clean up. - remove_action( 'foo_before_markup', array( $anonymous_action, 'callback' ), 9999 ); + remove_action( 'foo_before_markup', [ $anonymous_action, 'callback' ], 9999 ); } /** * Test beans_wrap_markup() should register beans_close_markup() to the given ID's '_after_markup' hook. */ public function test_should_register_beans_close_markup_to_given_id_after_markup_hook() { - $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); // Check that it did register a callback to the hook. $this->assertTrue( has_action( 'foo_after_markup' ) ); @@ -83,32 +83,32 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup // Check that the correct arguments were stored in the instance. $anonymous_action = $this->get_instance_from_wp( 'foo_after_markup', 1 ); $this->assertSame( - array( + [ 'beans_close_markup', - array( + [ 1 => 'new_foo', 2 => 'div', - ), - ), + ], + ], $anonymous_action->callback ); // Clean up. - remove_action( 'foo_after_markup', array( $anonymous_action, 'callback' ), 1 ); + remove_action( 'foo_after_markup', [ $anonymous_action, 'callback' ], 1 ); } /** * Test beans_wrap_markup() should not pass the given attributes to anonymous action. */ public function test_should_not_pass_attributes_for_after_markup_hook() { - beans_wrap_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ); + beans_wrap_markup( 'no_atts', '', 'div', [ 'class' => 'test-wrap' ] ); // Check that the attributes do not exist. $anonymous_action = $this->get_instance_from_wp( 'no_atts_after_markup', 1 ); - $this->assertNotContains( array( 'class' => 'test-wrap' ), $anonymous_action->callback[1] ); + $this->assertNotContains( [ 'class' => 'test-wrap' ], $anonymous_action->callback[1] ); // Clean up. - remove_action( 'no_atts_after_markup', array( $anonymous_action, 'callback' ), 1 ); + remove_action( 'no_atts_after_markup', [ $anonymous_action, 'callback' ], 1 ); } /** @@ -116,26 +116,26 @@ public function test_should_not_pass_attributes_for_after_markup_hook() { * '_before_markup' hook. */ public function test_should_pass_extra_arguments_for_before_markup_hook() { - beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ); + beans_wrap_markup( 'extra_args', '', 'div', [ 'class' => 'test-wrap' ], 47, 'Beans Rocks!' ); // Check that the correct arguments were stored in the instance. $anonymous_action = $this->get_instance_from_wp( 'extra_args_before_markup', 9999 ); $this->assertSame( - array( + [ 'beans_open_markup', - array( + [ 1 => '', 2 => 'div', - 3 => array( 'class' => 'test-wrap' ), + 3 => [ 'class' => 'test-wrap' ], 4 => 47, 5 => 'Beans Rocks!', - ), - ), + ], + ], $anonymous_action->callback ); // Clean up. - remove_action( 'extra_args_before_markup', array( $anonymous_action, 'callback' ), 9999 ); + remove_action( 'extra_args_before_markup', [ $anonymous_action, 'callback' ], 9999 ); } /** @@ -143,24 +143,24 @@ public function test_should_pass_extra_arguments_for_before_markup_hook() { * '_after_markup' hook. */ public function test_should_pass_extra_arguments_for_after_markup_hook() { - beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 47 ); + beans_wrap_markup( 'extra_args', '', 'div', [ 'class' => 'test-wrap' ], 'Beans Rocks!', 47 ); // Check that the correct arguments were stored in the instance. $anonymous_action = $this->get_instance_from_wp( 'extra_args_after_markup', 1 ); $this->assertSame( - array( + [ 'beans_close_markup', - array( + [ 1 => '', 2 => 'div', 4 => 'Beans Rocks!', 5 => 47, - ), - ), + ], + ], $anonymous_action->callback ); // Clean up. - remove_action( 'extra_args_after_markup', array( $anonymous_action, 'callback' ), 1 ); + remove_action( 'extra_args_after_markup', [ $anonymous_action, 'callback' ], 1 ); } } diff --git a/tests/phpunit/integration/api/html/fixtures/test-attachment.php b/tests/phpunit/integration/api/html/fixtures/test-attachment.php index 00a0e571..ab98f0a4 100644 --- a/tests/phpunit/integration/api/html/fixtures/test-attachment.php +++ b/tests/phpunit/integration/api/html/fixtures/test-attachment.php @@ -7,15 +7,15 @@ * @since 1.5.0 */ -return array( - array( +return [ + [ 'id' => 'beans_post_image_small_item', 'tag' => 'source', - 'attributes' => array( + 'attributes' => [ 'media' => '(max-width: 200px)', 'srcset' => 'https://example.com/small-image.png', - ), - 'attachment' => (object) array( + ], + 'attachment' => (object) [ 'id' => 47, 'src' => 'https://example.com/small-image.png', 'width' => 200, @@ -24,19 +24,19 @@ 'title' => 'This is a post title.', 'caption' => 'This is the caption.', 'description' => 'This is the description.', - ), - ), - array( + ], + ], + [ 'id' => 'beans_post_image_item', 'tag' => 'img', - 'attributes' => array( + 'attributes' => [ 'width' => 1200, 'height' => 600, 'src' => 'https://example.com/image.png', 'alt' => 'A background image.', 'itemprop' => 'image', - ), - 'attachment' => (object) array( + ], + 'attachment' => (object) [ 'id' => 1047, 'src' => 'https://example.com/image.png', 'width' => 1200, @@ -45,6 +45,6 @@ 'title' => 'This is a post title.', 'caption' => 'This is the caption.', 'description' => 'This is the description.', - ), - ), -); + ], + ], +]; diff --git a/tests/phpunit/integration/api/html/fixtures/test-markup.php b/tests/phpunit/integration/api/html/fixtures/test-markup.php index 872ab7ae..ed54f805 100644 --- a/tests/phpunit/integration/api/html/fixtures/test-markup.php +++ b/tests/phpunit/integration/api/html/fixtures/test-markup.php @@ -7,58 +7,58 @@ * @since 1.5.0 */ -return array( - 'beans_post' => array( +return [ + 'beans_post' => [ 'id' => 'beans_post', 'tag' => 'article', - 'attributes' => array( + 'attributes' => [ 'id' => 47, 'class' => 'uk-article uk-panel-box post-47 post type-post status-publish format-standard has-post-thumbnail hentry category-beans', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/blogPost', 'itemprop' => 'beans_post', - ), - ), - 'beans_post_header' => array( + ], + ], + 'beans_post_header' => [ 'id' => 'beans_post_header', 'tag' => 'header', - ), - 'beans_post_body' => array( + ], + 'beans_post_body' => [ 'id' => 'beans_post_body', 'tag' => 'div', - 'attributes' => array( + 'attributes' => [ 'itemprop' => 'articleBody', - ), - ), - 'beans_post_title' => array( + ], + ], + 'beans_post_title' => [ 'id' => 'beans_post_title', 'tag' => 'h1', - 'attributes' => array( + 'attributes' => [ 'class' => 'uk-article-title', 'itemprop' => 'headline', - ), - ), - 'beans_post_meta' => array( + ], + ], + 'beans_post_meta' => [ 'id' => 'beans_post_meta', 'tag' => 'ul', - 'attributes' => array( + 'attributes' => [ 'class' => 'uk-article-meta uk-subnav uk-subnav-line', - ), - ), - 'beans_post_meta_item[_date]' => array( + ], + ], + 'beans_post_meta_item[_date]' => [ 'id' => 'beans_post_meta_item[_date]', 'tag' => 'li', - ), - 'beans_post_meta_item[_author]' => array( + ], + 'beans_post_meta_item[_author]' => [ 'id' => 'beans_post_meta_item[_author]', 'tag' => 'li', - ), - 'beans_post_image_link' => array( + ], + 'beans_post_image_link' => [ 'id' => 'beans_post_image_link', 'tag' => 'a', - 'attributes' => array( + 'attributes' => [ 'href' => 'http://example.com/image.png', 'title' => 'Some cool image', - ), - ), -); + ], + ], +]; diff --git a/tests/phpunit/unit/api/html/beans-attribute/add.php b/tests/phpunit/unit/api/html/beans-attribute/add.php index 9bb4535e..163705b6 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/add.php +++ b/tests/phpunit/unit/api/html/beans-attribute/add.php @@ -47,9 +47,9 @@ public function test_should_add_the_attribute_when_does_not_exist() { public function test_should_add_the_attribute_when_empty_array_given() { foreach ( array_keys( static::$test_attributes ) as $beans_id ) { - $actual = ( new _Beans_Attribute( $beans_id, 'data-test', 'foo' ) )->add( array() ); + $actual = ( new _Beans_Attribute( $beans_id, 'data-test', 'foo' ) )->add( [] ); - $this->assertSame( array( 'data-test' => 'foo' ), $actual ); + $this->assertSame( [ 'data-test' => 'foo' ], $actual ); } } diff --git a/tests/phpunit/unit/api/html/beans-attribute/init.php b/tests/phpunit/unit/api/html/beans-attribute/init.php index 948a45a6..bfaa5f98 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/init.php +++ b/tests/phpunit/unit/api/html/beans-attribute/init.php @@ -39,7 +39,7 @@ public function test_should_register_the_callback_when_method_exists() { $instance = new _Beans_Attribute( 'foo', 'data-test' ); Monkey\Functions\expect( 'beans_add_filter' ) - ->with( 'foo_attributes', array( $instance, 'add' ) ) + ->with( 'foo_attributes', [ $instance, 'add' ] ) ->once(); $this->assertSame( $instance, $instance->init( 'add' ) ); diff --git a/tests/phpunit/unit/api/html/beans-attribute/remove.php b/tests/phpunit/unit/api/html/beans-attribute/remove.php index 7ce4fda6..95b4eaea 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/remove.php +++ b/tests/phpunit/unit/api/html/beans-attribute/remove.php @@ -67,13 +67,13 @@ public function test_should_remove_attribute_when_value_is_null() { * Test _Beans_Attribute::remove() should remove the given value from the attribute. */ public function test_should_remove_the_given_value_from_attribute() { - $attributes = array( + $attributes = [ 'id' => 47, 'class' => 'uk-article uk-panel-box category-beans', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/blogPost', 'itemprop' => 'beans_post', - ); + ]; // Run the remove. $actual = ( new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box' ) )->remove( $attributes ); @@ -99,10 +99,10 @@ public function test_should_return_empty_array_when_empty_array_given() { $value = current( $markup['attributes'] ); // Run the remove. - $actual = ( new _Beans_Attribute( $beans_id, $name, $value ) )->remove( array() ); + $actual = ( new _Beans_Attribute( $beans_id, $name, $value ) )->remove( [] ); // Check that an empty array is returned. - $this->assertSame( array(), $actual ); + $this->assertSame( [], $actual ); } } } diff --git a/tests/phpunit/unit/api/html/beans-attribute/replace.php b/tests/phpunit/unit/api/html/beans-attribute/replace.php index 9daaea37..51ea0d99 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/replace.php +++ b/tests/phpunit/unit/api/html/beans-attribute/replace.php @@ -28,13 +28,13 @@ class Tests_BeansAttribute_Replace extends HTML_Test_Case { * Test _Beans_Attribute::replace() should replace an existing attribute value. */ public function test_should_replace_existing_attribute_value() { - $attributes = array( + $attributes = [ 'id' => 47, 'class' => 'uk-article uk-panel-box category-beans', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/blogPost', 'itemprop' => 'beans_post', - ); + ]; $instance = new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box', 'beans-test' ); @@ -110,11 +110,11 @@ public function test_should_add_attribute_when_an_empty_array_given() { foreach ( static::$test_attributes as $beans_id => $markup ) { $name = key( $markup['attributes'] ); $value = current( $markup['attributes'] ); - $actual = ( new _Beans_Attribute( $beans_id, $name, $value, 'beans-test' ) )->replace( array() ); + $actual = ( new _Beans_Attribute( $beans_id, $name, $value, 'beans-test' ) )->replace( [] ); // Check that it did add the attribute. $this->assertArrayHasKey( $name, $actual ); - $this->assertSame( array( $name => 'beans-test' ), $actual ); + $this->assertSame( [ $name => 'beans-test' ], $actual ); } } } diff --git a/tests/phpunit/unit/api/html/beansAddAttributes.php b/tests/phpunit/unit/api/html/beansAddAttributes.php index 47f37a52..4a22ae4f 100644 --- a/tests/phpunit/unit/api/html/beansAddAttributes.php +++ b/tests/phpunit/unit/api/html/beansAddAttributes.php @@ -68,9 +68,9 @@ public function test_should_return_built_attributes_string() { */ public function test_should_return_empty_string_when_no_attributes() { Monkey\Functions\expect( 'beans_apply_filters' ) - ->with( 'foo_attributes', array() ) + ->with( 'foo_attributes', [] ) ->times( 4 ) - ->andReturn( array() ); + ->andReturn( [] ); $this->assertSame( '', beans_add_attributes( 'foo' ) ); $this->assertSame( '', beans_add_attributes( 'foo', null ) ); @@ -82,7 +82,7 @@ public function test_should_return_empty_string_when_no_attributes() { * Test beans_add_attributes() should pass additional arguments when given. */ public function test_should_pass_additional_arguments_when_given() { - $attributes = array( 'class' => 'foo' ); + $attributes = [ 'class' => 'foo' ]; Monkey\Functions\expect( 'beans_apply_filters' ) ->with( 'foo_attributes', $attributes, 14, 'hi' ) ->once() diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php index b77c761e..2fad6d00 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkup.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkup.php @@ -32,7 +32,7 @@ public function test_should_return_null_when_tag_set_to_null() { ->with( 'beans_archive_title_markup', null ) ->andReturnNull(); - $this->assertNull( beans_open_markup( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) ); + $this->assertNull( beans_open_markup( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ) ); } /** @@ -46,7 +46,7 @@ public function test_should_fire_before_markup_hooks_and_include_content_in_retu ->with( 'beans_archive_title_before_markup' ) ->andReturn( '' ); - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertStringStartsWith( '', $actual ); } @@ -61,7 +61,7 @@ public function test_should_fire_prepend_markup_hooks_and_include_content_in_ret ->with( 'beans_archive_title_prepend_markup' ) ->andReturn( '' ); - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertStringEndsWith( '', $actual ); } @@ -80,7 +80,7 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { global $_beans_is_selfclose_markup; $_beans_is_selfclose_markup = true; - $this->assertContains( 'Worked!', beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ) ); + $this->assertContains( 'Worked!', beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ) ); // Check that the global was unset. $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); @@ -93,11 +93,11 @@ public function test_should_return_built_html_when_before_or_prepend_hooks_not_r Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); Monkey\Functions\expect( 'beans_add_attributes' ) ->once() - ->with( 'beans_archive_title', array( 'class' => 'uk-article-title' ) ) + ->with( 'beans_archive_title', [ 'class' => 'uk-article-title' ] ) ->andReturn( 'class="uk-article-title"' ); Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertSame( '

                ', $actual ); } @@ -108,11 +108,11 @@ public function test_should_return_built_html_with_data_markup_id_when_in_dev_mo Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); Monkey\Functions\expect( 'beans_add_attributes' ) ->once() - ->with( 'beans_archive_title', array( 'class' => 'uk-article-title' ) ) + ->with( 'beans_archive_title', [ 'class' => 'uk-article-title' ] ) ->andReturn( 'class="uk-article-title"' ); Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( true ); - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertSame( '

                ', $actual ); } @@ -122,7 +122,7 @@ public function test_should_return_built_html_with_data_markup_id_when_in_dev_mo public function test_should_return_built_html_when_before_or_prepend_hooks() { Monkey\Functions\expect( 'beans_add_attributes' ) ->once() - ->with( 'beans_archive_title', array( 'class' => 'uk-article-title' ) ) + ->with( 'beans_archive_title', [ 'class' => 'uk-article-title' ] ) ->andReturn( 'class="uk-article-title"' ); Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); Monkey\Functions\expect( '_beans_render_action' ) @@ -134,7 +134,7 @@ public function test_should_return_built_html_when_before_or_prepend_hooks() { ->with( 'beans_archive_title_prepend_markup' ) ->andReturn( '' ); - $actual = beans_open_markup( 'beans_archive_title', 'h1', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $expected = <<

                EOB; @@ -146,13 +146,13 @@ public function test_should_return_built_html_when_before_or_prepend_hooks() { * $_beans_is_selfclose_markup is set to true. */ public function test_should_return_built_self_closing_html_when_selfclose_markup_is_true() { - $args = array( + $args = [ 'width' => 800, 'height' => 500, 'src' => 'http://example.com/image.png', 'alt' => 'Some image', 'itemprop' => 'image', - ); + ]; Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); Monkey\Functions\expect( 'beans_add_attributes' ) @@ -202,11 +202,11 @@ public function test_should_return_only_hooked_callbacks_output_and_no_html_elem ->andReturn( '' ); // Check with an empty string. - $actual = beans_open_markup( 'beans_archive_title', '', array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', '', [ 'class' => 'uk-article-title' ] ); $this->assertSame( '', $actual ); // Check with false. - $actual = beans_open_markup( 'beans_archive_title', false, array( 'class' => 'uk-article-title' ) ); + $actual = beans_open_markup( 'beans_archive_title', false, [ 'class' => 'uk-article-title' ] ); $this->assertSame( '', $actual ); } } diff --git a/tests/phpunit/unit/api/html/beansOpenMarkupE.php b/tests/phpunit/unit/api/html/beansOpenMarkupE.php index c8160dd0..cceedfa3 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkupE.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkupE.php @@ -29,11 +29,11 @@ class Tests_BeansOpenMarkupE extends HTML_Test_Case { public function test_should_echo_empty_string_when_tag_set_to_null() { Monkey\Functions\expect( 'beans_open_markup' ) ->once() - ->with( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) + ->with( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ) ->andReturn( null ); ob_start(); - beans_open_markup_e( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ); + beans_open_markup_e( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ); $this->assertEquals( '', ob_get_clean() ); } @@ -43,12 +43,12 @@ public function test_should_echo_empty_string_when_tag_set_to_null() { public function test_should_echo_html_element_when_hooks_not_registered() { Monkey\Functions\expect( 'beans_open_markup' ) ->once() - ->with( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ) + ->with( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ) ->andReturn( '

                ' ); // Run the tests. ob_start(); - beans_open_markup_e( 'beans_archive_title', null, array( 'class' => 'uk-article-title' ) ); + beans_open_markup_e( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ); $this->assertEquals( '

                ', ob_get_clean() ); } } diff --git a/tests/phpunit/unit/api/html/beansOutputE.php b/tests/phpunit/unit/api/html/beansOutputE.php index a49deb7c..230bf1e1 100644 --- a/tests/phpunit/unit/api/html/beansOutputE.php +++ b/tests/phpunit/unit/api/html/beansOutputE.php @@ -31,11 +31,11 @@ public function test_should_echo_empty_string_when_output_is_empty() { return $output; } ); - $ids = array( + $ids = [ 'beans_post_meta_item_date' => null, 'beans_post_meta_item_author' => '', 'beans_post_meta_item_comments' => false, - ); + ]; foreach ( $ids as $id => $output ) { ob_start(); diff --git a/tests/phpunit/unit/api/html/beansRemoveOutput.php b/tests/phpunit/unit/api/html/beansRemoveOutput.php index 50367398..df03be4e 100644 --- a/tests/phpunit/unit/api/html/beansRemoveOutput.php +++ b/tests/phpunit/unit/api/html/beansRemoveOutput.php @@ -48,11 +48,11 @@ public function test_should_return_anonymous_filter_instance() { * Test beans_remove_output() should call beans_add_filter() to register the callback for the remove process. */ public function test_should_call_beans_add_filter_to_register_callback() { - $ids = array( + $ids = [ 'beans_post_meta_item_date', 'beans_post_meta_item_author', 'beans_post_meta_item_comments', - ); + ]; foreach ( $ids as $id ) { Monkey\Functions\expect( 'beans_add_filter' ) diff --git a/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php b/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php index d6c4cc4f..c6d30169 100644 --- a/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php +++ b/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php @@ -39,7 +39,7 @@ protected function setUp() { public function test_should_return_false_when_empty_tag_is_given() { $this->assertFalse( beans_wrap_inner_markup( 'foo', 'new_foo', null ) ); $this->assertFalse( beans_wrap_inner_markup( 'bar', 'new_bar', '' ) ); - $this->assertFalse( beans_wrap_inner_markup( 'baz', 'new_baz', false, array( 'class' => 'test-wrap' ) ) ); + $this->assertFalse( beans_wrap_inner_markup( 'baz', 'new_baz', false, [ 'class' => 'test-wrap' ] ) ); } /** @@ -47,14 +47,14 @@ public function test_should_return_false_when_empty_tag_is_given() { */ public function test_should_register_beans_open_markup_to_given_id_prepend_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_open_markup', - array( + [ 1 => 'new_foo', 2 => 'div', - 3 => array( 'class' => 'test-wrap' ), - ), - ); + 3 => [ 'class' => 'test-wrap' ], + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_prepend_markup', $args, 1 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -62,11 +62,11 @@ public function test_should_register_beans_open_markup_to_given_id_prepend_marku ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); - $this->assertTrue( has_action( 'foo_prepend_markup', array( $anonymous_action_mock, 'callback' ) ) ); + $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); + $this->assertTrue( has_action( 'foo_prepend_markup', [ $anonymous_action_mock, 'callback' ] ) ); // Clean up. - remove_action( 'foo_prepend_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + remove_action( 'foo_prepend_markup', [ $anonymous_action_mock, 'callback' ], 1 ); } /** @@ -74,13 +74,13 @@ public function test_should_register_beans_open_markup_to_given_id_prepend_marku */ public function test_should_register_beans_close_markup_to_given_id_append_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_close_markup', - array( + [ 1 => 'new_foo', 2 => 'div', - ), - ); + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_append_markup', $args, 9999 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -88,11 +88,11 @@ public function test_should_register_beans_close_markup_to_given_id_append_marku ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); - $this->assertTrue( has_action( 'foo_append_markup', array( $anonymous_action_mock, 'callback' ) ) ); + $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); + $this->assertTrue( has_action( 'foo_append_markup', [ $anonymous_action_mock, 'callback' ] ) ); // Clean up. - remove_action( 'foo_append_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + remove_action( 'foo_append_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); } /** @@ -100,13 +100,13 @@ public function test_should_register_beans_close_markup_to_given_id_append_marku */ public function test_should_not_pass_attributes_for_append_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_close_markup', - array( + [ 1 => 'new_no_atts', 2 => 'div', - ), - ); + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'no_atts_append_markup', $args, 9999 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -114,11 +114,11 @@ public function test_should_not_pass_attributes_for_append_markup_hook() { ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'no_atts', 'new_no_atts', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( beans_wrap_inner_markup( 'no_atts', 'new_no_atts', 'div', [ 'class' => 'test-wrap' ] ) ); $this->assertSame( $args, $anonymous_action_mock->callback ); // Clean up. - remove_action( 'no_atts_append_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + remove_action( 'no_atts_append_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); } /** @@ -126,16 +126,16 @@ public function test_should_not_pass_attributes_for_append_markup_hook() { */ public function test_should_pass_extra_arguments_for_prepend_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_open_markup', - array( + [ 1 => 'new_extra_args', 2 => 'div', - 3 => array( 'class' => 'test-wrap' ), + 3 => [ 'class' => 'test-wrap' ], 4 => 47, 5 => 'Beans Rocks!', - ), - ); + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_prepend_markup', $args, 1 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -143,11 +143,11 @@ public function test_should_pass_extra_arguments_for_prepend_markup_hook() { ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ) ); + $this->assertTrue( beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', [ 'class' => 'test-wrap' ], 47, 'Beans Rocks!' ) ); $this->assertSame( $args, $anonymous_action_mock->callback ); // Clean up. - remove_action( 'extra_args_prepend_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + remove_action( 'extra_args_prepend_markup', [ $anonymous_action_mock, 'callback' ], 1 ); } /** @@ -155,15 +155,15 @@ public function test_should_pass_extra_arguments_for_prepend_markup_hook() { */ public function test_should_pass_extra_arguments_for_append_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_close_markup', - array( + [ 1 => 'new_extra_args', 2 => 'div', 4 => 'Beans Rocks!', 5 => 47, - ), - ); + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_append_markup', $args, 9999 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -171,10 +171,10 @@ public function test_should_pass_extra_arguments_for_append_markup_hook() { ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 47 ) ); + $this->assertTrue( beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', [ 'class' => 'test-wrap' ], 'Beans Rocks!', 47 ) ); $this->assertSame( $args, $anonymous_action_mock->callback ); // Clean up. - remove_action( 'extra_args_append_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + remove_action( 'extra_args_append_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); } } diff --git a/tests/phpunit/unit/api/html/beansWrapMarkup.php b/tests/phpunit/unit/api/html/beansWrapMarkup.php index 17f562e1..65b59634 100644 --- a/tests/phpunit/unit/api/html/beansWrapMarkup.php +++ b/tests/phpunit/unit/api/html/beansWrapMarkup.php @@ -39,7 +39,7 @@ protected function setUp() { public function test_should_return_false_when_empty_tag_is_given() { $this->assertFalse( beans_wrap_markup( 'foo', '', null ) ); $this->assertFalse( beans_wrap_markup( 'foo', '', '' ) ); - $this->assertFalse( beans_wrap_markup( 'foo', '', false, array( 'class' => 'test-wrap' ) ) ); + $this->assertFalse( beans_wrap_markup( 'foo', '', false, [ 'class' => 'test-wrap' ] ) ); } /** @@ -47,14 +47,14 @@ public function test_should_return_false_when_empty_tag_is_given() { */ public function test_should_register_beans_open_markup_to_given_id_before_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_open_markup', - array( + [ 1 => 'new_foo', 2 => 'div', - 3 => array( 'class' => 'test-wrap' ), - ), - ); + 3 => [ 'class' => 'test-wrap' ], + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_before_markup', $args, 9999 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -62,11 +62,11 @@ public function test_should_register_beans_open_markup_to_given_id_before_markup ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); - $this->assertTrue( has_action( 'foo_before_markup', array( $anonymous_action_mock, 'callback' ) ) ); + $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); + $this->assertTrue( has_action( 'foo_before_markup', [ $anonymous_action_mock, 'callback' ] ) ); // Clean up. - remove_action( 'foo_before_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + remove_action( 'foo_before_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); } /** @@ -74,13 +74,13 @@ public function test_should_register_beans_open_markup_to_given_id_before_markup */ public function test_should_register_beans_close_markup_to_given_id_after_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_close_markup', - array( + [ 1 => 'new_foo', 2 => 'div', - ), - ); + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_after_markup', $args, 1 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -88,11 +88,11 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', array( 'class' => 'test-wrap' ) ) ); - $this->assertTrue( has_action( 'foo_after_markup', array( $anonymous_action_mock, 'callback' ) ) ); + $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); + $this->assertTrue( has_action( 'foo_after_markup', [ $anonymous_action_mock, 'callback' ] ) ); // Clean up. - remove_action( 'foo_after_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + remove_action( 'foo_after_markup', [ $anonymous_action_mock, 'callback' ], 1 ); } /** @@ -100,13 +100,13 @@ public function test_should_register_beans_close_markup_to_given_id_after_markup */ public function test_should_not_pass_attributes_for_after_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_close_markup', - array( + [ 1 => '', 2 => 'div', - ), - ); + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'no_atts_after_markup', $args, 1 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -114,11 +114,11 @@ public function test_should_not_pass_attributes_for_after_markup_hook() { ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_markup( 'no_atts', '', 'div', array( 'class' => 'test-wrap' ) ) ); + $this->assertTrue( beans_wrap_markup( 'no_atts', '', 'div', [ 'class' => 'test-wrap' ] ) ); $this->assertSame( $args, $anonymous_action_mock->callback ); // Clean up. - remove_action( 'no_atts_after_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + remove_action( 'no_atts_after_markup', [ $anonymous_action_mock, 'callback' ], 1 ); } /** @@ -126,16 +126,16 @@ public function test_should_not_pass_attributes_for_after_markup_hook() { */ public function test_should_pass_extra_arguments_for_before_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_open_markup', - array( + [ 1 => '', 2 => 'div', - 3 => array( 'class' => 'test-wrap' ), + 3 => [ 'class' => 'test-wrap' ], 4 => 47, 5 => 'Beans Rocks!', - ), - ); + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_before_markup', $args, 9999 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -143,11 +143,11 @@ public function test_should_pass_extra_arguments_for_before_markup_hook() { ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 47, 'Beans Rocks!' ) ); + $this->assertTrue( beans_wrap_markup( 'extra_args', '', 'div', [ 'class' => 'test-wrap' ], 47, 'Beans Rocks!' ) ); $this->assertSame( $args, $anonymous_action_mock->callback ); // Clean up. - remove_action( 'extra_args_before_markup', array( $anonymous_action_mock, 'callback' ), 9999 ); + remove_action( 'extra_args_before_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); } /** @@ -155,15 +155,15 @@ public function test_should_pass_extra_arguments_for_before_markup_hook() { */ public function test_should_pass_extra_arguments_for_after_markup_hook() { // Set up the tests. - $args = array( + $args = [ 'beans_close_markup', - array( + [ 1 => '', 2 => 'div', 4 => 'Beans Rocks!', 5 => 47, - ), - ); + ], + ]; $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_after_markup', $args, 1 ); Monkey\Functions\expect( '_beans_add_anonymous_action' ) ->once() @@ -171,10 +171,10 @@ public function test_should_pass_extra_arguments_for_after_markup_hook() { ->andReturn( $anonymous_action_mock ); // Run the tests. - $this->assertTrue( beans_wrap_markup( 'extra_args', '', 'div', array( 'class' => 'test-wrap' ), 'Beans Rocks!', 47 ) ); + $this->assertTrue( beans_wrap_markup( 'extra_args', '', 'div', [ 'class' => 'test-wrap' ], 'Beans Rocks!', 47 ) ); $this->assertSame( $args, $anonymous_action_mock->callback ); // Clean up. - remove_action( 'extra_args_after_markup', array( $anonymous_action_mock, 'callback' ), 1 ); + remove_action( 'extra_args_after_markup', [ $anonymous_action_mock, 'callback' ], 1 ); } } diff --git a/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php b/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php index d165a35e..3349ffb4 100644 --- a/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php +++ b/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php @@ -33,7 +33,7 @@ class Anonymous_Action_Stub { public function __construct( $hook, array $callback, $priority ) { $this->callback = $callback; - add_action( $hook, array( $this, 'callback' ), $priority ); + add_action( $hook, [ $this, 'callback' ], $priority ); } /** diff --git a/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php b/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php index c76f185f..03b5e77c 100644 --- a/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php +++ b/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php @@ -33,7 +33,7 @@ class Anonymous_Filter_Stub { public function __construct( $hook, $value_to_return, $priority ) { $this->value_to_return = $value_to_return; - add_filter( $hook, array( $this, 'callback' ), $priority ); + add_filter( $hook, [ $this, 'callback' ], $priority ); } /** diff --git a/tests/phpunit/unit/api/html/fixtures/test-attachment.php b/tests/phpunit/unit/api/html/fixtures/test-attachment.php index 6e25b454..967b2fbc 100644 --- a/tests/phpunit/unit/api/html/fixtures/test-attachment.php +++ b/tests/phpunit/unit/api/html/fixtures/test-attachment.php @@ -7,15 +7,15 @@ * @since 1.5.0 */ -return array( - array( +return [ + [ 'id' => 'beans_post_image_small_item', 'tag' => 'source', - 'attributes' => array( + 'attributes' => [ 'media' => '(max-width: 200px)', 'srcset' => 'https://example.com/small-image.png', - ), - 'attachment' => (object) array( + ], + 'attachment' => (object) [ 'id' => 47, 'src' => 'https://example.com/small-image.png', 'width' => 200, @@ -24,19 +24,19 @@ 'title' => 'This is a post title.', 'caption' => 'This is the caption.', 'description' => 'This is the description.', - ), - ), - array( + ], + ], + [ 'id' => 'beans_post_image_item', 'tag' => 'img', - 'attributes' => array( + 'attributes' => [ 'width' => 1200, 'height' => 600, 'src' => 'https://example.com/image.png', 'alt' => 'A background image.', 'itemprop' => 'image', - ), - 'attachment' => (object) array( + ], + 'attachment' => (object) [ 'id' => 1047, 'src' => 'https://example.com/image.png', 'width' => 1200, @@ -45,6 +45,6 @@ 'title' => 'This is a post title.', 'caption' => 'This is the caption.', 'description' => 'This is the description.', - ), - ), -); + ], + ], +]; diff --git a/tests/phpunit/unit/api/html/fixtures/test-markup.php b/tests/phpunit/unit/api/html/fixtures/test-markup.php index 06660ac8..08870409 100644 --- a/tests/phpunit/unit/api/html/fixtures/test-markup.php +++ b/tests/phpunit/unit/api/html/fixtures/test-markup.php @@ -7,58 +7,58 @@ * @since 1.5.0 */ -return array( - 'beans_post' => array( +return [ + 'beans_post' => [ 'id' => 'beans_post', 'tag' => 'article', - 'attributes' => array( + 'attributes' => [ 'id' => 47, 'class' => 'uk-article uk-panel-box post-47 post type-post status-publish format-standard has-post-thumbnail hentry category-beans', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/blogPost', 'itemprop' => 'beans_post', - ), - ), - 'beans_post_header' => array( + ], + ], + 'beans_post_header' => [ 'id' => 'beans_post_header', 'tag' => 'header', - ), - 'beans_post_body' => array( + ], + 'beans_post_body' => [ 'id' => 'beans_post_body', 'tag' => 'div', - 'attributes' => array( + 'attributes' => [ 'itemprop' => 'articleBody', - ), - ), - 'beans_post_title' => array( + ], + ], + 'beans_post_title' => [ 'id' => 'beans_post_title', 'tag' => 'h1', - 'attributes' => array( + 'attributes' => [ 'class' => 'uk-article-title', 'itemprop' => 'headline', - ), - ), - 'beans_post_meta' => array( + ], + ], + 'beans_post_meta' => [ 'id' => 'beans_post_meta', 'tag' => 'ul', - 'attributes' => array( + 'attributes' => [ 'class' => 'uk-article-meta uk-subnav uk-subnav-line', - ), - ), - 'beans_post_meta_item[_date]' => array( + ], + ], + 'beans_post_meta_item[_date]' => [ 'id' => 'beans_post_meta_item[_date]', 'tag' => 'li', - ), - 'beans_post_meta_item[_author]' => array( + ], + 'beans_post_meta_item[_author]' => [ 'id' => 'beans_post_meta_item[_author]', 'tag' => 'li', - ), - 'beans_post_image_link' => array( + ], + 'beans_post_image_link' => [ 'id' => 'beans_post_image_link', 'tag' => 'a', - 'attributes' => array( + 'attributes' => [ 'href' => 'http://example.com/image.png', 'title' => 'Some cool image', - ), - ), -); + ], + ], +]; diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index 6ba66148..05b70c4b 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -62,14 +62,14 @@ protected function setUp() { $this->setup_function_mocks(); $this->setup_common_wp_stubs(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/html/class-beans-attribute.php', 'api/html/functions.php', 'api/html/accessibility.php', 'api/filters/functions.php', 'api/layout/functions.php', 'api/widget/functions.php', - ) ); + ] ); // Reset the test fixtures. reset( static::$test_markup ); @@ -81,7 +81,7 @@ protected function setUp() { * Setup dependency function mocks. */ protected function setup_function_mocks() { - Monkey\Functions\when( 'beans_esc_attributes' )->alias( array( $this, 'convert_attributes_into_html' ) ); + Monkey\Functions\when( 'beans_esc_attributes' )->alias( [ $this, 'convert_attributes_into_html' ] ); Monkey\Functions\when( 'beans_add_smart_action' )->justReturn(); } From 1fcef5d16381f281f326d208ea054c9073d510fd Mon Sep 17 00:00:00 2001 From: ibes Date: Sat, 23 Jun 2018 18:04:53 +0200 Subject: [PATCH 786/800] Updated array syntax for Post Meta API tests. (PR #284) --- .../post-meta/beans-post-meta/construct.php | 20 ++++++------- .../post-meta/beans-post-meta/okToSave.php | 22 +++++++-------- .../beans-post-meta/registerMetabox.php | 2 +- .../beans-post-meta/renderMetaboxContent.php | 2 +- .../post-meta/beans-post-meta/renderNonce.php | 2 +- .../api/post-meta/beans-post-meta/save.php | 8 +++--- .../beans-post-meta/saveAttachment.php | 6 ++-- .../api/post-meta/beansGetPostMeta.php | 6 ++-- .../post-meta/beansIsPostMetaConditions.php | 28 +++++++++---------- .../beansPostMetaPageTemplateReload.php | 4 +-- .../api/post-meta/beansRegisterPostMeta.php | 26 ++++++++--------- .../api/post-meta/fixtures/test-fields.php | 24 ++++++++-------- .../post-meta/beans-post-meta/okToSave.php | 16 +++++------ .../beans-post-meta/registerMetabox.php | 16 +++++------ .../beans-post-meta/renderMetaboxContent.php | 8 +++--- .../post-meta/beans-post-meta/renderNonce.php | 2 +- .../api/post-meta/beans-post-meta/save.php | 8 +++--- .../beans-post-meta/saveAttachment.php | 10 +++---- .../unit/api/post-meta/beansGetPostMeta.php | 12 ++++---- .../post-meta/beansIsPostMetaConditions.php | 22 +++++++-------- .../beansPostMetaPageTemplateReload.php | 4 +-- .../api/post-meta/beansRegisterPostMeta.php | 26 ++++++++--------- .../class-beans-post-meta-test-case.php | 4 +-- 23 files changed, 139 insertions(+), 139 deletions(-) diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php index 449544f0..74bf136b 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php @@ -29,19 +29,19 @@ class Tests_BeansPostMeta_Construct extends Beans_Post_Meta_Test_Case { */ public function test_should_set_correct_hooks_when_instantiated() { // First instantiation sets all hooks. - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - $this->assertEquals( 10, has_action( 'edit_form_top', array( $post_meta, 'render_nonce' ) ) ); - $this->assertEquals( 10, has_action( 'save_post', array( $post_meta, 'save' ) ) ); - $this->assertEquals( 10, has_filter( 'attachment_fields_to_save', array( $post_meta, 'save_attachment' ) ) ); - $this->assertEquals( 10, has_action( 'add_meta_boxes', array( $post_meta, 'register_metabox' ) ) ); + $this->assertEquals( 10, has_action( 'edit_form_top', [ $post_meta, 'render_nonce' ] ) ); + $this->assertEquals( 10, has_action( 'save_post', [ $post_meta, 'save' ] ) ); + $this->assertEquals( 10, has_filter( 'attachment_fields_to_save', [ $post_meta, 'save_attachment' ] ) ); + $this->assertEquals( 10, has_action( 'add_meta_boxes', [ $post_meta, 'register_metabox' ] ) ); // Subsequent instantiation sets 'add_meta_boxes' hook only. - $post_meta_2 = new _Beans_Post_Meta( 'tm-beans-custom-post-meta', array( 'title' => 'Custom Options' ) ); + $post_meta_2 = new _Beans_Post_Meta( 'tm-beans-custom-post-meta', [ 'title' => 'Custom Options' ] ); - $this->assertFalse( has_action( 'edit_form_top', array( $post_meta_2, 'render_nonce' ) ) ); - $this->assertFalse( has_action( 'save_post', array( $post_meta_2, 'save' ) ) ); - $this->assertFalse( has_filter( 'attachment_fields_to_save', array( $post_meta_2, 'save_attachment' ) ) ); - $this->assertEquals( 10, has_action( 'add_meta_boxes', array( $post_meta_2, 'register_metabox' ) ) ); + $this->assertFalse( has_action( 'edit_form_top', [ $post_meta_2, 'render_nonce' ] ) ); + $this->assertFalse( has_action( 'save_post', [ $post_meta_2, 'save' ] ) ); + $this->assertFalse( has_filter( 'attachment_fields_to_save', [ $post_meta_2, 'save_attachment' ] ) ); + $this->assertEquals( 10, has_action( 'add_meta_boxes', [ $post_meta_2, 'register_metabox' ] ) ); } } diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php index 8418b94d..b300d663 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php @@ -28,60 +28,60 @@ class Tests_BeansPostMeta_OkToSave extends Beans_Post_Meta_Test_Case { * Test _Beans_Post_Meta::ok_to_save() should return false when nonce check fails. */ public function test_ok_to_save_should_return_false_when_nonce_check_fails() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); $post_id = $this->factory()->post->create(); - $this->assertFalse( $post_meta->ok_to_save( $post_id, array( array( 'id' => 'beans_test_slider' ) ) ) ); + $this->assertFalse( $post_meta->ok_to_save( $post_id, [ [ 'id' => 'beans_test_slider' ] ] ) ); } /** * Test _Beans_Post_Meta::ok_to_save() should return false when `edit_post` user permissions are not met. */ public function test_ok_to_save_should_return_false_when_user_permissions_not_met() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); $post_id = $this->factory()->post->create(); // Run without permission to save. - $user_id = $this->factory()->user->create( array( 'role' => 'subscriber' ) ); + $user_id = $this->factory()->user->create( [ 'role' => 'subscriber' ] ); wp_set_current_user( $user_id ); // Set a nonce to return. $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); - $this->assertFalse( $post_meta->ok_to_save( $post_id, array( array( 'id' => 'beans_test_slider' ) ) ) ); + $this->assertFalse( $post_meta->ok_to_save( $post_id, [ [ 'id' => 'beans_test_slider' ] ] ) ); } /** * Test _Beans_Post_Meta::ok_to_save() should return false when post meta has no fields. */ public function test_ok_to_save_should_return_false_when_no_fields() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); $post_id = $this->factory()->post->create(); // Run with permission to save. - $user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) ); + $user_id = $this->factory()->user->create( [ 'role' => 'administrator' ] ); wp_set_current_user( $user_id ); // Set a nonce to return. $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); - $this->assertFalse( $post_meta->ok_to_save( $post_id, array() ) ); + $this->assertFalse( $post_meta->ok_to_save( $post_id, [] ) ); } /** * Test _Beans_Post_Meta::ok_to_save() should return true when all conditions for saving are met. */ public function test_ok_to_save_should_return_true_when_all_conditions_met() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); $post_id = $this->factory()->post->create(); // Run with permission to save. - $user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) ); + $user_id = $this->factory()->user->create( [ 'role' => 'administrator' ] ); wp_set_current_user( $user_id ); // Set a nonce to return. $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); - $this->assertTrue( $post_meta->ok_to_save( $post_id, array( array( 'id' => 'beans_test_slider' ) ) ) ); + $this->assertTrue( $post_meta->ok_to_save( $post_id, [ [ 'id' => 'beans_test_slider' ] ] ) ); } } diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php index 4a4452b3..916c3b06 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php @@ -30,7 +30,7 @@ class Tests_BeansPostMeta_RegisterMetabox extends Beans_Post_Meta_Test_Case { public function test_register_metabox_should_register_metabox() { global $wp_meta_boxes; - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); $post_meta->register_metabox( 'post' ); $this->assertArrayHasKey( 'tm-beans', $wp_meta_boxes['post']['normal']['high'] ); diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php index 249879c5..368f92b5 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php @@ -29,7 +29,7 @@ class Tests_BeansPostMeta_RenderMetaboxContent extends Beans_Post_Meta_Test_Case */ public function test_should_output_fields_markup() { $test_data = require dirname( ( __DIR__ ) ) . DIRECTORY_SEPARATOR . 'fixtures/test-fields.php'; - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); beans_register_fields( $test_data['fields'], 'post_meta', $test_data['section'] ); diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php index 54bd2104..26e9d2c4 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php @@ -28,7 +28,7 @@ class Tests_BeansPostMeta_RenderNonce extends Beans_Post_Meta_Test_Case { * Test _Beans_Post_Meta::render_nonce() should echo correct nonce input HTML when called. */ public function test_should_echo_nonce_input_html() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); $expected_html_output = ''; diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php index b9dcf27d..ff2b6332 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php @@ -28,7 +28,7 @@ class Tests_BeansPostMeta_Save extends Beans_Post_Meta_Test_Case { * Test _Beans_Post_Meta::save() should return the post_ID when ok_to_save() is false. */ public function test_should_return_post_id_when_ok_to_save_is_false() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); $post_id = $this->factory()->post->create(); $this->assertEquals( $post_id, $post_meta->save( $post_id ) ); @@ -38,15 +38,15 @@ public function test_should_return_post_id_when_ok_to_save_is_false() { * Test _Beans_Post_Meta::save() should run update_post_meta() and return null when ok_to_save() is true. */ public function test_should_run_update_post_meta_and_return_null_when_ok_to_save() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); $post_id = $this->factory()->post->create(); // Run with permission to save. - $user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) ); + $user_id = $this->factory()->user->create( [ 'role' => 'administrator' ] ); wp_set_current_user( $user_id ); // Give beans_post() a field to find and set a nonce to return. - $_POST['beans_fields'] = array( 'beans_post_test_field' => 'beans_post_test_field_value' ); + $_POST['beans_fields'] = [ 'beans_post_test_field' => 'beans_post_test_field_value' ]; $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); $this->assertnull( $post_meta->save( $post_id ) ); diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php index b342b236..a96f41f4 100644 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php +++ b/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php @@ -28,16 +28,16 @@ class Tests_BeansPostMeta_SaveAttachment extends Beans_Post_Meta_Test_Case { * Test _Beans_Post_Meta::save_attachment() should run update_post_meta() and return attachment when ok_to_save() is true. */ public function test_should_run_update_post_meta_and_return_attachment_when_ok_to_save() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); $attachment_id = $this->factory()->attachment->create(); $attachment_data = get_post( $attachment_id, ARRAY_A ); // Run with permission to save. - $user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) ); + $user_id = $this->factory()->user->create( [ 'role' => 'administrator' ] ); wp_set_current_user( $user_id ); // Give beans_post() a field to find and set a nonce to return. - $_POST['beans_fields'] = array( 'beans_post_test_field' => 'beans_post_test_field_value' ); + $_POST['beans_fields'] = [ 'beans_post_test_field' => 'beans_post_test_field_value' ]; $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); $this->assertSame( $attachment_data, $post_meta->save_attachment( $attachment_data ) ); diff --git a/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php b/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php index 866fa2b2..5d105f8b 100644 --- a/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php +++ b/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php @@ -34,7 +34,7 @@ public function test_should_return_default_when_post_id_cannot_be_resolved() { * Test beans_get_post_meta() should return the default when the post meta does not exist. */ public function test_should_return_default_when_post_meta_does_not_exist() { - $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); + $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); update_post_meta( $post_id, 'foo', 'foo' ); $this->assertFalse( beans_get_post_meta( 'beans_layout', false, $post_id ) ); @@ -46,7 +46,7 @@ public function test_should_return_default_when_post_meta_does_not_exist() { * Test beans_get_post_meta() should get the post ID when none is provided. */ public function test_should_get_post_id_when_none_is_provided() { - $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); + $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); $_GET['post'] = $post_id; $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); unset( $_GET['post'] ); @@ -59,7 +59,7 @@ public function test_should_get_post_id_when_none_is_provided() { * Test beans_get_post_meta() should return the post's meta value when all conditions are met. */ public function test_should_return_post_meta_value() { - $post_id = self::factory()->post->create( array( 'post_title' => 'Hello Beans' ) ); + $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); update_post_meta( $post_id, 'beans_layout', 'c_sp' ); $this->assertSame( 'c_sp', beans_get_post_meta( 'beans_layout', false, $post_id ) ); diff --git a/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php b/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php index 255529bc..a65129e5 100644 --- a/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php +++ b/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php @@ -37,7 +37,7 @@ public function test_should_return_true_when_new_post_and_conditions_include_pos set_current_screen( 'post' ); $_SERVER['REQUEST_URI'] = 'post-new.php'; - $this->assertTrue( _beans_is_post_meta_conditions( array( 'post' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'post' ] ) ); // Clean up server globals. $_SERVER['REQUEST_URI'] = ''; @@ -50,7 +50,7 @@ public function test_should_return_false_when_new_post_and_conditions_do_not_inc set_current_screen( 'post' ); $_SERVER['REQUEST_URI'] = 'post-new.php'; - $this->assertFalse( _beans_is_post_meta_conditions( array( 'page' ) ) ); + $this->assertFalse( _beans_is_post_meta_conditions( [ 'page' ] ) ); // Clean up server globals. $_SERVER['REQUEST_URI'] = ''; @@ -62,20 +62,20 @@ public function test_should_return_false_when_new_post_and_conditions_do_not_inc public function test_should_return_false_when_post_id_not_found() { set_current_screen( 'edit' ); - $this->assertFalse( _beans_is_post_meta_conditions( array( 'post' ) ) ); + $this->assertFalse( _beans_is_post_meta_conditions( [ 'post' ] ) ); } /** * Test _beans_is_post_meta_conditions() should return true when $conditions match post type. */ public function test_should_return_true_when_conditions_match_post_type() { - $post_id = $this->factory()->post->create( array( 'post_type' => 'cpt' ) ); + $post_id = $this->factory()->post->create( [ 'post_type' => 'cpt' ] ); set_current_screen( 'cpt' ); // Setup for when post_ID is in GET. $_GET['post'] = $post_id; - $this->assertTrue( _beans_is_post_meta_conditions( array( 'cpt' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'cpt' ] ) ); // Clear Global GET. $_GET['post'] = null; @@ -83,7 +83,7 @@ public function test_should_return_true_when_conditions_match_post_type() { // Setup for when post_ID is in POST. $_POST['post_ID'] = $post_id; - $this->assertTrue( _beans_is_post_meta_conditions( array( 'cpt' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'cpt' ] ) ); // Clear Global POST. $_POST['post_ID'] = null; @@ -99,7 +99,7 @@ public function test_should_return_true_when_conditions_match_post_id() { // Setup for when post_ID is in GET. $_GET['post'] = $post_id; - $this->assertTrue( _beans_is_post_meta_conditions( array( $post_id ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ $post_id ] ) ); // Clear Global GET. $_GET['post'] = null; @@ -107,7 +107,7 @@ public function test_should_return_true_when_conditions_match_post_id() { // Setup for when post_ID is in POST. $_POST['post_ID'] = $post_id; - $this->assertTrue( _beans_is_post_meta_conditions( array( $post_id ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ $post_id ] ) ); // Clear Global POST. $_POST['post_ID'] = null; @@ -117,14 +117,14 @@ public function test_should_return_true_when_conditions_match_post_id() { * Test _beans_is_post_meta_conditions() should return true when conditions match a page template name. */ public function test_should_return_true_when_conditions_match_page_template_name() { - $page_id = $this->factory()->post->create( array( 'post_type' => 'page' ) ); + $page_id = $this->factory()->post->create( [ 'post_type' => 'page' ] ); set_current_screen( 'edit' ); add_post_meta( $page_id, '_wp_page_template', 'page-template-name' ); // Setup for when post_ID is in GET. $_GET['post'] = $page_id; - $this->assertTrue( _beans_is_post_meta_conditions( array( 'page-template-name' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'page-template-name' ] ) ); // Clear Global GET. $_GET['post'] = null; @@ -132,7 +132,7 @@ public function test_should_return_true_when_conditions_match_page_template_name // Setup for when post_ID is in POST. $_POST['post_ID'] = $page_id; - $this->assertTrue( _beans_is_post_meta_conditions( array( 'page-template-name' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'page-template-name' ] ) ); // Clear Global POST. $_POST['post_ID'] = null; @@ -143,14 +143,14 @@ public function test_should_return_true_when_conditions_match_page_template_name */ public function test_should_return_false_when_no_conditions_match() { - $page_id = $this->factory()->post->create( array( 'post_type' => 'page' ) ); + $page_id = $this->factory()->post->create( [ 'post_type' => 'page' ] ); set_current_screen( 'edit' ); add_post_meta( $page_id, '_wp_page_template', 'page-template-name' ); // Setup for when post_ID is in GET. $_GET['post'] = $page_id; - $this->assertFalse( _beans_is_post_meta_conditions( array( 'some-other-conditions' ) ) ); + $this->assertFalse( _beans_is_post_meta_conditions( [ 'some-other-conditions' ] ) ); // Clear Global GET. $_GET['post'] = null; @@ -158,7 +158,7 @@ public function test_should_return_false_when_no_conditions_match() { // Setup for when post_ID is in POST. $_POST['post_ID'] = $page_id; - $this->assertFalse( _beans_is_post_meta_conditions( array( 'some-other-conditions' ) ) ); + $this->assertFalse( _beans_is_post_meta_conditions( [ 'some-other-conditions' ] ) ); // Clear Global POST. $_POST['post_ID'] = null; diff --git a/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php b/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php index aad59112..859f4abd 100644 --- a/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php +++ b/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php @@ -43,7 +43,7 @@ public function test_should_do_nothing_when_not_editing_post_object() { public function test_should_do_nothing_when_post_meta_not_assigned_to_page_templates() { global $_beans_post_meta_conditions, $pagenow; - $_beans_post_meta_conditions = array(); + $_beans_post_meta_conditions = []; $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. ob_start(); @@ -59,7 +59,7 @@ public function test_should_do_nothing_when_post_meta_not_assigned_to_page_templ public function test_should_output_script_html_when_post_meta_assigned_to_page_templates() { global $_beans_post_meta_conditions, $pagenow; - $_beans_post_meta_conditions = array( 'page-template-name.php' ); + $_beans_post_meta_conditions = [ 'page-template-name.php' ]; $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. ob_start(); diff --git a/tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php b/tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php index 1c139ee7..5382383c 100644 --- a/tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php +++ b/tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php @@ -28,13 +28,13 @@ class Tests_BeansRegisterPostMeta extends Beans_Post_Meta_Test_Case { */ public function test_should_return_false_when_not_is_admin() { - $this->assertFalse( beans_register_post_meta( array( - array( + $this->assertFalse( beans_register_post_meta( [ + [ 'id' => 'field_id', 'type' => 'radio', 'label' => 'Field Label', - ), - ), true, 'tm-beans' ) ); + ], + ], true, 'tm-beans' ) ); } /** @@ -43,13 +43,13 @@ public function test_should_return_false_when_not_is_admin() { public function test_should_return_false_when_conditions_are_false() { set_current_screen( 'edit' ); - $this->assertFalse( beans_register_post_meta( array( - array( + $this->assertFalse( beans_register_post_meta( [ + [ 'id' => 'field_id', 'type' => 'radio', 'label' => 'Field Label', - ), - ), false, 'tm-beans' ) ); + ], + ], false, 'tm-beans' ) ); } /** @@ -58,7 +58,7 @@ public function test_should_return_false_when_conditions_are_false() { public function test_should_return_false_when_fields_cannot_be_registered() { set_current_screen( 'edit' ); - $this->assertFalse( beans_register_post_meta( array(), true, 'tm-beans' ) ); + $this->assertFalse( beans_register_post_meta( [], true, 'tm-beans' ) ); } /** @@ -67,12 +67,12 @@ public function test_should_return_false_when_fields_cannot_be_registered() { public function test_should_return_true_when_post_meta_is_registered() { set_current_screen( 'edit' ); - $this->assertTrue( beans_register_post_meta( array( - array( + $this->assertTrue( beans_register_post_meta( [ + [ 'id' => 'field_id', 'type' => 'radio', 'label' => 'Field Label', - ), - ), true, 'tm-beans' ) ); + ], + ], true, 'tm-beans' ) ); } } diff --git a/tests/phpunit/integration/api/post-meta/fixtures/test-fields.php b/tests/phpunit/integration/api/post-meta/fixtures/test-fields.php index 79335d71..a499cc15 100644 --- a/tests/phpunit/integration/api/post-meta/fixtures/test-fields.php +++ b/tests/phpunit/integration/api/post-meta/fixtures/test-fields.php @@ -7,33 +7,33 @@ * @since 1.5.0 */ -return array( - 'fields' => array( - array( +return [ + 'fields' => [ + [ 'id' => 'beans_layout_test', 'label' => 'Layout', 'type' => 'radio', 'default' => 'default_fallback', - 'options' => array( + 'options' => [ 'default_fallback' => 'Use Default Layout', 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', - ), - ), - array( + ], + ], + [ 'id' => 'beans_checkbox_test', 'label' => false, 'checkbox_label' => 'Enable the checkbox test', 'type' => 'checkbox', 'default' => false, - ), - array( + ], + [ 'id' => 'beans_text_test', 'type' => 'text', 'default' => 'Testing the text field.', - ), - ), + ], + ], 'context' => 'tests', 'section' => 'tm-beans', -); +]; diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/okToSave.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/okToSave.php index 41fa305e..88c67987 100644 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/okToSave.php +++ b/tests/phpunit/unit/api/post-meta/beans-post-meta/okToSave.php @@ -28,45 +28,45 @@ class Tests_BeansPostMeta_OkToSave extends Beans_Post_Meta_Test_Case { * Test _Beans_Post_Meta::ok_to_save() should return false when nonce check fails. */ public function test_ok_to_save_should_return_false_when_nonce_check_fails() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( false ); - $this->assertFalse( $post_meta->ok_to_save( 456, array( array( 'id' => 'beans_test_slider' ) ) ) ); + $this->assertFalse( $post_meta->ok_to_save( 456, [ [ 'id' => 'beans_test_slider' ] ] ) ); } /** * Test _Beans_Post_Meta::ok_to_save() should return false when `edit post` user permissions are not met. */ public function test_ok_to_save_should_return_false_when_user_permissions_not_met() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); Monkey\Functions\expect( 'current_user_can' ) ->once() ->with( 'edit_post', 456 ) ->andReturn( false ); - $this->assertFalse( $post_meta->ok_to_save( 456, array( array( 'id' => 'beans_test_slider' ) ) ) ); + $this->assertFalse( $post_meta->ok_to_save( 456, [ [ 'id' => 'beans_test_slider' ] ] ) ); } /** * Test _Beans_Post_Meta::ok_to_save() should return false when post meta has no fields. */ public function test_ok_to_save_should_return_false_when_no_fields() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); Monkey\Functions\expect( 'current_user_can' )->once()->andReturn( true ); - $this->assertFalse( $post_meta->ok_to_save( 456, array() ) ); + $this->assertFalse( $post_meta->ok_to_save( 456, [] ) ); } /** * Test _Beans_Post_Meta::ok_to_save() should return true when all conditions for saving are met. */ public function test_ok_to_save_should_return_true_when_all_conditions_met() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); Monkey\Functions\expect( 'current_user_can' )->once()->andReturn( true ); - $this->assertTrue( $post_meta->ok_to_save( 456, array( array( 'id' => 'beans_test_slider' ) ) ) ); + $this->assertTrue( $post_meta->ok_to_save( 456, [ [ 'id' => 'beans_test_slider' ] ] ) ); } } diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/registerMetabox.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/registerMetabox.php index 8742ac94..b656e3fe 100644 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/registerMetabox.php +++ b/tests/phpunit/unit/api/post-meta/beans-post-meta/registerMetabox.php @@ -28,30 +28,30 @@ class Tests_BeansPostMeta_RegisterMetabox extends Beans_Post_Meta_Test_Case { * Test _Beans_Post_Meta::register_metabox() should register an appropriate metabox. */ public function test_register_metabox_should_register_metabox() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - $wp_meta_boxes['post']['normal']['high']['1'] = array( + $wp_meta_boxes['post']['normal']['high']['1'] = [ 'id' => 1, 'title' => 'Post Options', - 'callback' => array( $this, 'render_metabox_content' ), + 'callback' => [ $this, 'render_metabox_content' ], 'callback_args' => null, - ); + ]; Monkey\Functions\expect( 'add_meta_box' ) ->once() - ->with( 'tm-beans', 'Post Options', array( $post_meta, 'render_metabox_content' ), 'post', 'normal', 'high' ) + ->with( 'tm-beans', 'Post Options', [ $post_meta, 'render_metabox_content' ], 'post', 'normal', 'high' ) ->andReturn( $wp_meta_boxes['post']['normal']['high']['1'] ); $post_meta->register_metabox( 'post' ); $this->assertEquals( $wp_meta_boxes['post']['normal']['high'][1], - array( + [ 'id' => 1, 'title' => 'Post Options', - 'callback' => array( $this, 'render_metabox_content' ), + 'callback' => [ $this, 'render_metabox_content' ], 'callback_args' => null, - ) + ] ); } } diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php index a3186b12..5aae1384 100644 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php +++ b/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php @@ -28,21 +28,21 @@ class Tests_BeansPostMeta_RenderMetaboxContent extends Beans_Post_Meta_Test_Case * Test _Beans_Post_Meta::render_metabox_content() should output post meta fields markup. */ public function test_metabox_content_should_output_fields_markup() { - $field = array( + $field = [ 'id' => 'beans_layout', 'label' => 'Layout', 'type' => 'radio', 'context' => 'tm-beams', 'default' => 'default_fallback', 'options' => 'options html from layout options callback', - ); + ]; - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); Monkey\Functions\expect( 'beans_get_fields' ) ->once() ->with( 'post_meta', 'tm-beans' ) - ->andReturn( array( $field ) ); + ->andReturn( [ $field ] ); Monkey\Functions\expect( 'beans_field' )->once()->with( $field )->andReturnUsing( function () { echo 'beans_field_html'; } ); diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderNonce.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/renderNonce.php index 1f96f90b..134f797f 100644 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderNonce.php +++ b/tests/phpunit/unit/api/post-meta/beans-post-meta/renderNonce.php @@ -31,7 +31,7 @@ public function test_should_echo_nonce_input_html() { Monkey\Functions\expect( 'wp_create_nonce' )->once()->with( 'beans_post_meta_nonce' )->andReturn( '123456' ); $expected_html_output = ''; - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); ob_start(); $post_meta->render_nonce(); $actual_output = ob_get_clean(); diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php index 1398949c..67af1733 100644 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php +++ b/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php @@ -28,7 +28,7 @@ class Tests_BeansPostMeta_Save extends Beans_Post_Meta_Test_Case { * Test _Beans_Post_Meta::save() should return false when doing autosave. */ public function test_should_return_false_when_doing_autosave() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( true ); $this->assertFalse( $post_meta->save( 256 ) ); @@ -38,7 +38,7 @@ public function test_should_return_false_when_doing_autosave() { * Test _Beans_Post_Meta::save() should return the post_ID when ok_to_save() is false. */ public function test_should_return_post_id_when_ok_to_save_false() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( false ); Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( false ); @@ -49,8 +49,8 @@ public function test_should_return_post_id_when_ok_to_save_false() { * Test _Beans_Post_Meta::save() should run update_post_meta() and return null when ok_to_save() is true. */ public function test_should_run_update_post_meta_and_return_null_when_ok_to_save() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); - $fields = array( 'beans_post_test_field' => 'beans_test_post_field_value' ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); + $fields = [ 'beans_post_test_field' => 'beans_test_post_field_value' ]; Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( false ); Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php index 64d140fa..0f9c458c 100644 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php +++ b/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php @@ -28,8 +28,8 @@ class Tests_BeansPostMeta_SaveAttachment extends Beans_Post_Meta_Test_Case { * Test _Beans_Post_Meta::save_attachment() should not update post meta when _beans_doing_autosave() is true. */ public function test_should_not_update_post_meta_when_doing_autosave() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); - $attachment = array( 'ID' => 543 ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); + $attachment = [ 'ID' => 543 ]; Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( true ); Monkey\Functions\expect( 'update_post_meta' )->never(); @@ -40,9 +40,9 @@ public function test_should_not_update_post_meta_when_doing_autosave() { * Test _Beans_Post_Meta::save_attachment() should run update_post_meta() and return attachment when ok_to_save() is true. */ public function test_should_run_update_post_meta_and_return_attachment_when_ok_to_save() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', array( 'title' => 'Post Options' ) ); - $attachment = array( 'ID' => 543 ); - $fields = array( 'beans_post_test_field' => 'beans_test_post_field_value' ); + $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); + $attachment = [ 'ID' => 543 ]; + $fields = [ 'beans_post_test_field' => 'beans_test_post_field_value' ]; Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( false ); Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); diff --git a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php index a0f1ec1a..a64a79c0 100644 --- a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php +++ b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php @@ -42,7 +42,7 @@ public function test_should_return_default_when_post_meta_does_not_exist() { Monkey\Functions\expect( 'get_post_meta' ) ->with( 1 ) ->times( 3 ) - ->andReturn( array() ); + ->andReturn( [] ); $this->assertFalse( beans_get_post_meta( 'beans_layout', false, 1 ) ); $this->assertSame( '', beans_get_post_meta( 'beans_layout', '', 1 ) ); @@ -57,7 +57,7 @@ public function test_should_get_post_id_when_none_is_provided() { Monkey\Functions\expect( 'get_post_meta' ) ->with( 47 ) ->once() - ->andReturn( array() ); + ->andReturn( [] ); $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 0 ); @@ -68,7 +68,7 @@ public function test_should_get_post_id_when_none_is_provided() { Monkey\Functions\expect( 'get_post_meta' ) ->with( '18' ) ->once() - ->andReturn( array() ); + ->andReturn( [] ); $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); } @@ -80,7 +80,7 @@ public function test_should_return_post_meta_value() { ->with( 521 ) ->once() ->ordered() - ->andReturn( array( 'beans_layout' => 'c_sp' ) ) + ->andReturn( [ 'beans_layout' => 'c_sp' ] ) ->andAlsoExpectIt() ->with( 521, 'beans_layout', true ) ->once() @@ -93,7 +93,7 @@ public function test_should_return_post_meta_value() { ->with( 47 ) ->once() ->ordered() - ->andReturn( array( 'beans_layout' => 'sp_c' ) ) + ->andReturn( [ 'beans_layout' => 'sp_c' ] ) ->andAlsoExpectIt() ->with( 47, 'beans_layout', true ) ->once() @@ -110,7 +110,7 @@ public function test_should_return_post_meta_value() { ->with( '18' ) ->once() ->ordered() - ->andReturn( array( 'beans_layout' => 'default_fallback' ) ) + ->andReturn( [ 'beans_layout' => 'default_fallback' ] ) ->andAlsoExpectIt() ->with( '18', 'beans_layout', true ) ->once() diff --git a/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php b/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php index 0af5e62e..784d9ac8 100644 --- a/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php +++ b/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php @@ -35,7 +35,7 @@ public function test_shold_return_true_when_new_post_and_conditions_include_post $_SERVER['REQUEST_URI'] = 'post-new.php'; Monkey\Functions\expect( 'beans_get' )->once()->with( 'post_type' )->andReturn( 'post' ); - $this->assertTrue( _beans_is_post_meta_conditions( array( 'post' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'post' ] ) ); // Clean up server globals. $_SERVER['REQUEST_URI'] = ''; @@ -48,7 +48,7 @@ public function test_should_return_false_when_new_post_and_conditions_do_not_inc $_SERVER['REQUEST_URI'] = 'post-new.php'; Monkey\Functions\expect( 'beans_get' )->once()->with( 'post_type' )->andReturn( 'page' ); - $this->assertFalse( _beans_is_post_meta_conditions( array( 'post' ) ) ); + $this->assertFalse( _beans_is_post_meta_conditions( [ 'post' ] ) ); // Clean up server globals. $_SERVER['REQUEST_URI'] = ''; @@ -62,7 +62,7 @@ public function test_should_return_false_when_post_id_not_found() { Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); - $this->assertFalse( _beans_is_post_meta_conditions( array( 'post' ) ) ); + $this->assertFalse( _beans_is_post_meta_conditions( [ 'post' ] ) ); } /** @@ -76,7 +76,7 @@ public function test_should_return_true_when_conditions_match_post_type() { Monkey\Functions\expect( 'get_post_type' )->once()->with( 25 )->andReturn( 'cpt' ); Monkey\Functions\expect( 'get_post_meta' )->once()->andReturn( false ); - $this->assertTrue( _beans_is_post_meta_conditions( array( 'cpt' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'cpt' ] ) ); // Setup for when post_ID is in POST. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); @@ -84,7 +84,7 @@ public function test_should_return_true_when_conditions_match_post_type() { Monkey\Functions\expect( 'get_post_type' )->once()->with( 25 )->andReturn( 'cpt' ); Monkey\Functions\expect( 'get_post_meta' )->once()->andReturn( false ); - $this->assertTrue( _beans_is_post_meta_conditions( array( 'cpt' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'cpt' ] ) ); } /** @@ -98,7 +98,7 @@ public function test_should_return_true_when_conditions_match_post_id() { Monkey\Functions\expect( 'get_post_type' )->once()->with( 1 )->andReturn( 'cpt' ); Monkey\Functions\expect( 'get_post_meta' )->once()->andReturn( false ); - $this->assertTrue( _beans_is_post_meta_conditions( array( 1 ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 1 ] ) ); // Setup for when post_ID is in POST. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); @@ -106,7 +106,7 @@ public function test_should_return_true_when_conditions_match_post_id() { Monkey\Functions\expect( 'get_post_type' )->once()->with( 2 )->andReturn( 'cpt' ); Monkey\Functions\expect( 'get_post_meta' )->once()->andReturn( false ); - $this->assertTrue( _beans_is_post_meta_conditions( array( 2 ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 2 ] ) ); } /** @@ -123,7 +123,7 @@ public function test_should_return_true_when_conditions_match_page_template_name ->with( '345', '_wp_page_template', true ) ->andReturn( 'page-template-name' ); - $this->assertTrue( _beans_is_post_meta_conditions( array( 'page-template-name' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'page-template-name' ] ) ); // Setup for when post_ID is in POST. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); @@ -134,7 +134,7 @@ public function test_should_return_true_when_conditions_match_page_template_name ->with( '543', '_wp_page_template', true ) ->andReturn( 'page-template-name' ); - $this->assertTrue( _beans_is_post_meta_conditions( array( 'page-template-name' ) ) ); + $this->assertTrue( _beans_is_post_meta_conditions( [ 'page-template-name' ] ) ); } /** @@ -151,7 +151,7 @@ public function test_should_return_false_when_no_conditions_match() { ->with( '345', '_wp_page_template', true ) ->andReturn( 'page-template-name' ); - $this->assertFalse( _beans_is_post_meta_conditions( array( 'some-other-conditions' ) ) ); + $this->assertFalse( _beans_is_post_meta_conditions( [ 'some-other-conditions' ] ) ); // Setup for when post_ID is in POST. Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); @@ -162,6 +162,6 @@ public function test_should_return_false_when_no_conditions_match() { ->with( '543', '_wp_page_template', true ) ->andReturn( 'page-template-name' ); - $this->assertFalse( _beans_is_post_meta_conditions( array( 'some-other-conditions' ) ) ); + $this->assertFalse( _beans_is_post_meta_conditions( [ 'some-other-conditions' ] ) ); } } diff --git a/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php b/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php index 87d84225..72a959c1 100644 --- a/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php +++ b/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php @@ -41,7 +41,7 @@ public function test_should_do_nothing_when_not_editing_post_object() { public function test_should_do_nothing_when_post_meta_not_assigned_to_page_templates() { global $_beans_post_meta_conditions, $pagenow; - $_beans_post_meta_conditions = array(); + $_beans_post_meta_conditions = []; $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. ob_start(); @@ -57,7 +57,7 @@ public function test_should_do_nothing_when_post_meta_not_assigned_to_page_templ public function test_should_output_script_html_when_post_meta_assigned_to_page_templates() { global $_beans_post_meta_conditions, $pagenow; - $_beans_post_meta_conditions = array( 'page-template-name.php' ); + $_beans_post_meta_conditions = [ 'page-template-name.php' ]; $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. ob_start(); diff --git a/tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php b/tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php index 8ac67365..ce124ad1 100644 --- a/tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php +++ b/tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php @@ -27,7 +27,7 @@ class Tests_BeansRegisterPostMeta extends Beans_Post_Meta_Test_Case { * Test beans_register_post_meta() should return false when no fields. */ public function test_should_return_false_when_no_fields() { - $this->assertFalse( beans_register_post_meta( array(), true, 'tm-beans' ) ); + $this->assertFalse( beans_register_post_meta( [], true, 'tm-beans' ) ); } /** @@ -37,13 +37,13 @@ public function test_should_return_false_when_conditions_are_false() { Monkey\Functions\when( '_beans_pre_standardize_fields' )->returnArg(); Monkey\Functions\expect( '_beans_is_post_meta_conditions' )->once()->andReturn( false ); - $this->assertFalse( beans_register_post_meta( array( - array( + $this->assertFalse( beans_register_post_meta( [ + [ 'id' => 'field_id', 'type' => 'radio', 'label' => 'Field Label', - ), - ), false, 'tm-beans' ) ); + ], + ], false, 'tm-beans' ) ); } /** @@ -54,13 +54,13 @@ public function test_should_return_false_when_not_is_admin() { Monkey\Functions\expect( '_beans_is_post_meta_conditions' )->once()->andReturn( true ); Monkey\Functions\expect( 'is_admin' )->once()->andReturn( false ); - $this->assertFalse( beans_register_post_meta( array( - array( + $this->assertFalse( beans_register_post_meta( [ + [ 'id' => 'field_id', 'type' => 'radio', 'label' => 'Field Label', - ), - ), true, 'tm-beans' ) ); + ], + ], true, 'tm-beans' ) ); } /** @@ -72,10 +72,10 @@ public function test_should_return_false_when_fields_cannot_be_registered() { Monkey\Functions\expect( 'is_admin' )->once()->andReturn( true ); Monkey\Functions\expect( 'beans_register_fields' ) ->once() - ->with( array( 'unregisterable' ), 'post_meta', 'tm-beans' ) + ->with( [ 'unregisterable' ], 'post_meta', 'tm-beans' ) ->andReturn( false ); - $this->assertFalse( beans_register_post_meta( array( 'unregisterable' ), true, 'tm-beans' ) ); + $this->assertFalse( beans_register_post_meta( [ 'unregisterable' ], true, 'tm-beans' ) ); } /** @@ -87,9 +87,9 @@ public function test_should_return_true_when_fields_successfully_registered() { Monkey\Functions\expect( 'is_admin' )->once()->andReturn( true ); Monkey\Functions\expect( 'beans_register_fields' ) ->once() - ->with( array( 'field_id', 'radio', 'Field Label' ), 'post_meta', 'tm-beans' ) + ->with( [ 'field_id', 'radio', 'Field Label' ], 'post_meta', 'tm-beans' ) ->andReturn( true ); - $this->assertTrue( beans_register_post_meta( array( 'field_id', 'radio', 'Field Label' ), true, 'tm-beans' ) ); + $this->assertTrue( beans_register_post_meta( [ 'field_id', 'radio', 'Field Label' ], true, 'tm-beans' ) ); } } diff --git a/tests/phpunit/unit/api/post-meta/includes/class-beans-post-meta-test-case.php b/tests/phpunit/unit/api/post-meta/includes/class-beans-post-meta-test-case.php index 185bc855..09daddbd 100644 --- a/tests/phpunit/unit/api/post-meta/includes/class-beans-post-meta-test-case.php +++ b/tests/phpunit/unit/api/post-meta/includes/class-beans-post-meta-test-case.php @@ -24,13 +24,13 @@ abstract class Beans_Post_Meta_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( + $this->load_original_functions( [ 'api/post-meta/class-beans-post-meta.php', 'api/post-meta/functions.php', 'api/post-meta/functions-admin.php', 'api/fields/functions.php', 'api/utilities/functions.php', - ) ); + ] ); $this->setup_common_wp_stubs(); } From c4f105b7c04dfd011d72c9513d38390a8d7befdf Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 24 Jun 2018 18:44:16 -0400 Subject: [PATCH 787/800] Changed beans_updater to call the getbeans.io API using https (PR #286) Closes #285 --- lib/admin/updater.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/admin/updater.php b/lib/admin/updater.php index b780283a..9b1b5fb6 100644 --- a/lib/admin/updater.php +++ b/lib/admin/updater.php @@ -40,7 +40,7 @@ function beans_updater( $value ) { // Query the Beans REST API if the transient is expired. if ( empty( $data ) ) { - $response = wp_remote_get( 'http://www.getbeans.io/rest-api/', array( 'sslverify' => false ) ); + $response = wp_remote_get( 'https://www.getbeans.io/rest-api/' ); // Retrieve data from the body and decode json format. $data = json_decode( wp_remote_retrieve_body( $response ), true ); From d07a196621dd415a0cb58eed644ccaa4beddfd29 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Sun, 24 Jun 2018 21:21:32 -0400 Subject: [PATCH 788/800] Improved consistency of test suite. (PR #287) --- .../integration/api/actions/beansAddAnonymousAction.php | 4 ++-- .../api/actions/includes/class-actions-test-case.php | 4 ++-- .../actions/includes/class-replace-action-test-case.php | 2 -- .../compiler/beans-page-compiler/compilePageStyles.php | 2 +- .../api/compiler/beans-page-compiler/dequeueScripts.php | 2 +- .../integration/api/filters/beansAddAnonymousFilter.php | 6 ++++-- .../api/post-meta/beans-post-meta/construct.php | 6 +++--- .../api/post-meta/beans-post-meta/okToSave.php | 6 +++--- .../api/post-meta/beans-post-meta/registerMetabox.php | 6 +++--- .../post-meta/beans-post-meta/renderMetaboxContent.php | 6 +++--- .../api/post-meta/beans-post-meta/renderNonce.php | 6 +++--- .../integration/api/post-meta/beans-post-meta/save.php | 6 +++--- .../api/post-meta/beans-post-meta/saveAttachment.php | 6 +++--- .../integration/api/post-meta/beansGetPostMeta.php | 6 +++--- .../api/post-meta/beansIsPostMetaConditions.php | 6 +++--- .../api/post-meta/beansPostMetaPageTemplateReload.php | 6 +++--- .../integration/api/post-meta/beansRegisterPostMeta.php | 6 +++--- ...t-meta-test-case.php => class-post-meta-test-case.php} | 4 ++-- .../api/term-meta/beans-term-meta/construct.php | 6 +++--- .../integration/api/term-meta/beans-term-meta/delete.php | 6 +++--- .../api/term-meta/beans-term-meta/renderFields.php | 6 +++--- .../api/term-meta/beans-term-meta/renderNonce.php | 6 +++--- .../integration/api/term-meta/beans-term-meta/save.php | 6 +++--- .../integration/api/term-meta/beansGetTermMeta.php | 6 ++++-- .../integration/api/term-meta/beansRegisterTermMeta.php | 7 +++---- ...m-meta-test-case.php => class-term-meta-test-case.php} | 4 ++-- .../phpunit/integration/api/uikit/beans-uikit/compile.php | 2 +- tests/phpunit/unit/api/compiler/beans-compiler/get.php | 2 +- .../unit/api/post-meta/beans-post-meta/okToSave.php | 6 +++--- .../api/post-meta/beans-post-meta/registerMetabox.php | 6 +++--- .../post-meta/beans-post-meta/renderMetaboxContent.php | 6 +++--- .../unit/api/post-meta/beans-post-meta/renderNonce.php | 6 +++--- tests/phpunit/unit/api/post-meta/beans-post-meta/save.php | 6 +++--- .../unit/api/post-meta/beans-post-meta/saveAttachment.php | 8 ++++---- tests/phpunit/unit/api/post-meta/beansGetPostMeta.php | 6 +++--- .../unit/api/post-meta/beansIsPostMetaConditions.php | 6 ++++-- .../api/post-meta/beansPostMetaPageTemplateReload.php | 6 ++++-- .../phpunit/unit/api/post-meta/beansRegisterPostMeta.php | 6 +++--- ...t-meta-test-case.php => class-post-meta-test-case.php} | 4 ++-- .../unit/api/term-meta/beans-term-meta/renderFields.php | 6 +++--- .../unit/api/term-meta/beans-term-meta/renderNonce.php | 6 +++--- tests/phpunit/unit/api/term-meta/beans-term-meta/save.php | 6 +++--- tests/phpunit/unit/api/term-meta/beansGetTermMeta.php | 6 +++--- tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php | 6 +++--- .../phpunit/unit/api/term-meta/beansRegisterTermMeta.php | 6 +++--- ...m-meta-test-case.php => class-term-meta-test-case.php} | 4 ++-- tests/phpunit/unit/api/uikit/beans-uikit/compile.php | 2 +- .../unit/api/uikit/beans-uikit/getAllComponents.php | 2 +- .../unit/api/uikit/beans-uikit/getAutoloadComponents.php | 2 +- .../api/uikit/beans-uikit/getComponentsFromDirectory.php | 2 +- .../unit/api/uikit/beans-uikit/getJsDirectories.php | 2 +- .../unit/api/uikit/beans-uikit/getLessDirectories.php | 2 +- .../unit/api/uikit/beans-uikit/registerJsComponents.php | 2 +- .../unit/api/uikit/beans-uikit/registerLessComponents.php | 2 +- tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php | 2 +- 55 files changed, 135 insertions(+), 130 deletions(-) rename tests/phpunit/integration/api/post-meta/includes/{class-beans-post-meta-test-case.php => class-post-meta-test-case.php} (83%) rename tests/phpunit/integration/api/term-meta/includes/{class-beans-term-meta-test-case.php => class-term-meta-test-case.php} (86%) rename tests/phpunit/unit/api/post-meta/includes/{class-beans-post-meta-test-case.php => class-post-meta-test-case.php} (87%) rename tests/phpunit/unit/api/term-meta/includes/{class-beans-term-meta-test-case.php => class-term-meta-test-case.php} (91%) diff --git a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php index 1012a2f9..43f86d83 100644 --- a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php +++ b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php @@ -9,8 +9,8 @@ namespace Beans\Framework\Tests\Integration\API\Actions; +use Beans\Framework\Tests\Integration\API\Actions\Includes\Actions_Test_Case; use Brain\Monkey\Functions; -use WP_UnitTestCase; /** * Class Tests_BeansAddAnonymousAction @@ -19,7 +19,7 @@ * @group api * @group api-actions */ -class Tests_BeansAddAnonymousAction extends WP_UnitTestCase { +class Tests_BeansAddAnonymousAction extends Actions_Test_Case { /** * Test _beans_add_anonymous_action() should register callback to the given hook. diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php index 78a815c1..5476b0f6 100644 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php @@ -9,14 +9,14 @@ namespace Beans\Framework\Tests\Integration\API\Actions\Includes; -use WP_UnitTestCase; +use Beans\Framework\Tests\Integration\Test_Case; /** * Abstract Class Actions_Test_Case * * @package Beans\Framework\Tests\Unit\API\Actions\Includes */ -abstract class Actions_Test_Case extends WP_UnitTestCase { +abstract class Actions_Test_Case extends Test_Case { /** * When true, reset $_beans_registered_actions at tear down. diff --git a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php index 0b4658db..f7ed7194 100644 --- a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php +++ b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php @@ -9,8 +9,6 @@ namespace Beans\Framework\Tests\Integration\API\Actions\Includes; -use WP_UnitTestCase; - /** * Abstract Class Replace_Actions_Test_Case * diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php index 5622b07d..8dedcf2e 100644 --- a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php +++ b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php @@ -1,6 +1,6 @@ Date: Mon, 25 Jun 2018 03:23:18 +0200 Subject: [PATCH 789/800] Updated DocBlocks from http:// to https://. (PR #289) Part of #288 --- 404.php | 2 +- comments.php | 2 +- footer.php | 2 +- functions.php | 4 ++-- header.php | 2 +- index.php | 2 +- lib/api/actions/functions.php | 2 +- lib/api/compiler/functions.php | 8 ++++---- lib/api/compiler/vendors/lessc.php | 2 +- lib/api/filters/functions.php | 6 +++--- lib/api/post-meta/functions.php | 2 +- lib/api/utilities/functions.php | 2 +- lib/api/utilities/polyfills.php | 2 +- lib/api/widget/functions.php | 6 +++--- lib/templates/fragments/post.php | 2 +- page.php | 2 +- search.php | 2 +- sidebar-primary.php | 2 +- sidebar-secondary.php | 2 +- sidebar.php | 2 +- single.php | 2 +- 21 files changed, 29 insertions(+), 29 deletions(-) diff --git a/404.php b/404.php index 2cdf219d..2c7be533 100644 --- a/404.php +++ b/404.php @@ -6,7 +6,7 @@ * how to customize the Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/comments.php b/comments.php index d6b8f8f1..789921b5 100644 --- a/comments.php +++ b/comments.php @@ -7,7 +7,7 @@ * how to customize the Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/footer.php b/footer.php index 698a444a..b15b2bdc 100644 --- a/footer.php +++ b/footer.php @@ -7,7 +7,7 @@ * how to customize the Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/functions.php b/functions.php index d3e54a99..76f83270 100644 --- a/functions.php +++ b/functions.php @@ -7,7 +7,7 @@ * how to customize the Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ @@ -15,7 +15,7 @@ * Initialize Beans theme framework. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io */ require_once dirname( __FILE__ ) . '/lib/init.php'; diff --git a/header.php b/header.php index 37bbdb5d..2c8d2d0b 100644 --- a/header.php +++ b/header.php @@ -7,7 +7,7 @@ * how to customize Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/index.php b/index.php index 0bff2f0c..3a5ebabf 100644 --- a/index.php +++ b/index.php @@ -6,7 +6,7 @@ * how to customize Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index a79508be..379ffd88 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -13,7 +13,7 @@ /** * Hooks a callback (function or method) to a specific action event. * - * This function is similar to {@link http://codex.wordpress.org/Function_Reference/add_action add_action()} + * This function is similar to {@link https://codex.wordpress.org/Function_Reference/add_action add_action()} * with the exception of being registered by ID within Beans in order to be manipulated by the other Beans * Actions functions. * diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index f5523cd5..9c3ffb27 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -15,7 +15,7 @@ * Compile CSS fragments and enqueue compiled file. * * This function should be used in a similar fashion to - * {@link http://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. + * {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. * * Fragments can be added to the compiler using {@see beans_compiler_add_fragment()}. * @@ -46,7 +46,7 @@ function beans_compile_css_fragments( $id, $fragments, $args = array() ) { * Compile LESS fragments, convert to CSS and enqueue compiled file. * * This function should be used in a similar fashion to - * {@link http://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. + * {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. * * Fragments can be added to the compiler using {@see beans_compiler_add_fragment()}. * @@ -76,7 +76,7 @@ function beans_compile_less_fragments( $id, $fragments, $args = array() ) { * Compile JS fragments and enqueue compiled file. * * This function should be used in a similar fashion to - * {@link http://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. + * {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. * * Fragments can be added to the compiler using {@see beans_compiler_add_fragment()}. * @@ -136,7 +136,7 @@ function _beans_compile_fragments( $id, $format, $fragments, array $args = array * Add CSS, LESS or JS fragments to a compiler. * * This function should be used in a similar fashion to - * {@link http://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. + * {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. * * @since 1.0.0 * diff --git a/lib/api/compiler/vendors/lessc.php b/lib/api/compiler/vendors/lessc.php index 68ee6fd7..aac854b6 100644 --- a/lib/api/compiler/vendors/lessc.php +++ b/lib/api/compiler/vendors/lessc.php @@ -2509,7 +2509,7 @@ protected function expressionList(&$exps) { /** * Attempt to consume an expression. - * @link http://en.wikipedia.org/wiki/Operator-precedence_parser#Pseudo-code + * @link https://en.wikipedia.org/wiki/Operator-precedence_parser#Pseudo-code */ protected function expression(&$out) { if ($this->value($lhs)) { diff --git a/lib/api/filters/functions.php b/lib/api/filters/functions.php index 8af1d600..c5ae6278 100644 --- a/lib/api/filters/functions.php +++ b/lib/api/filters/functions.php @@ -8,7 +8,7 @@ /** * Hooks a callback (function or method) to a specific filter event. * - * This function is similar to {@link http://codex.wordpress.org/Function_Reference/add_filter add_filter()} + * This function is similar to {@link https://codex.wordpress.org/Function_Reference/add_filter add_filter()} * with the exception that it accepts a $callback_or_value argument which is used to automatically create an * anonymous function. * @@ -39,7 +39,7 @@ function beans_add_filter( $hook, $callback_or_value, $priority = 10, $args = 1 /** * Call the functions added to a filter hook. * - * This function is similar to {@link http://codex.wordpress.org/Function_Reference/apply_filters apply_filters()} + * This function is similar to {@link https://codex.wordpress.org/Function_Reference/apply_filters apply_filters()} * with the exception of creating sub-hooks if it is told to do so. * * Sub-hooks must be set in square brackets as part of the filter id argument. Sub-hooks are cascaded @@ -111,7 +111,7 @@ function beans_apply_filters( $id, $value ) { /** * Check if any filter has been registered for a hook. * - * This function is similar to {@link http://codex.wordpress.org/Function_Reference/has_filters has_filters()} + * This function is similar to {@link https://codex.wordpress.org/Function_Reference/has_filters has_filters()} * with the exception of checking sub-hooks if it is told to do so. * * @since 1.0.0 diff --git a/lib/api/post-meta/functions.php b/lib/api/post-meta/functions.php index 7b57ca6f..33659a84 100644 --- a/lib/api/post-meta/functions.php +++ b/lib/api/post-meta/functions.php @@ -10,7 +10,7 @@ /** * Get the post's meta value. When no post ID is given, get the current post's meta value. * - * This function is a shortcut of {@link http://codex.wordpress.org/Function_Reference/get_post_meta get_post_meta()}. + * This function is a shortcut of {@link https://codex.wordpress.org/Function_Reference/get_post_meta get_post_meta()}. * * @since 1.0.0 * diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 4722ac81..3a1644ea 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -559,7 +559,7 @@ function beans_esc_attributes( $attributes ) { * Filter attributes escaping methods. * * For all unspecified selectors, values are automatically escaped using - * {@link http://codex.wordpress.org/Function_Reference/esc_attr esc_attr()}. + * {@link https://codex.wordpress.org/Function_Reference/esc_attr esc_attr()}. * * @since 1.3.1 * diff --git a/lib/api/utilities/polyfills.php b/lib/api/utilities/polyfills.php index 8017ad05..00d78dba 100644 --- a/lib/api/utilities/polyfills.php +++ b/lib/api/utilities/polyfills.php @@ -25,7 +25,7 @@ * value recursively. * * @see PHP Manual - * @link http://php.net/manual/en/function.array-replace-recursive.php + * @link https://php.net/manual/en/function.array-replace-recursive.php * * Note: This function became available in PHP 5.3.0. * diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 0b30c822..35d2e517 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -13,7 +13,7 @@ * Register a widget area. * * Since a Beans widget area is using the WordPress sidebar, this function registers a WordPress sidebar using - * {@link http://codex.wordpress.org/Function_Reference/register_sidebar register_sidebar()}, with additional + * {@link https://codex.wordpress.org/Function_Reference/register_sidebar register_sidebar()}, with additional * arguments. * * Note that the 'class', before_widget', 'after_widget', 'before_title' and 'after_title' arguments are not @@ -79,7 +79,7 @@ function beans_register_widget_area( $args = array() ) { * * Since a Beans widget area is using the WordPress sidebar, this function deregisters the defined * WordPress sidebar using - * {@link http://codex.wordpress.org/Function_Reference/unregister_sidebar unregister_sidebar()}. + * {@link https://codex.wordpress.org/Function_Reference/unregister_sidebar unregister_sidebar()}. * * @since 1.0.0 * @@ -95,7 +95,7 @@ function beans_deregister_widget_area( $id ) { * Check whether a widget area is in use. * * Since a Beans widget area is using the WordPress sidebar, this function checks if the defined sidebar - * is in use using {@link http://codex.wordpress.org/Function_Reference/is_active_sidebar is_active_sidebar()}. + * is in use using {@link https://codex.wordpress.org/Function_Reference/is_active_sidebar is_active_sidebar()}. * * @since 1.0.0 * diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 894b59c3..ee9bd15c 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -181,7 +181,7 @@ function beans_post_image() { * * @since 1.2.5 * - * @param bool $edit True to use Beans Image API to handle the image edition (resize), false to let {@link http://codex.wordpress.org/Function_Reference/the_post_thumbnail the_post_thumbnail()} taking care of it. Default true. + * @param bool $edit True to use Beans Image API to handle the image edition (resize), false to let {@link https://codex.wordpress.org/Function_Reference/the_post_thumbnail the_post_thumbnail()} taking care of it. Default true. */ $edit = apply_filters( 'beans_post_image_edit', true ); diff --git a/page.php b/page.php index 2cdf219d..2c7be533 100644 --- a/page.php +++ b/page.php @@ -6,7 +6,7 @@ * how to customize the Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/search.php b/search.php index 2cdf219d..2c7be533 100644 --- a/search.php +++ b/search.php @@ -6,7 +6,7 @@ * how to customize the Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/sidebar-primary.php b/sidebar-primary.php index 46df712f..d2e52d67 100644 --- a/sidebar-primary.php +++ b/sidebar-primary.php @@ -7,7 +7,7 @@ * how to customize the Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/sidebar-secondary.php b/sidebar-secondary.php index 133ffbbb..764cbd0f 100644 --- a/sidebar-secondary.php +++ b/sidebar-secondary.php @@ -7,7 +7,7 @@ * how to customize the Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/sidebar.php b/sidebar.php index 3271142b..88b9b0ad 100644 --- a/sidebar.php +++ b/sidebar.php @@ -4,7 +4,7 @@ * not overwrite this file. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ diff --git a/single.php b/single.php index 2cdf219d..2c7be533 100644 --- a/single.php +++ b/single.php @@ -6,7 +6,7 @@ * how to customize the Beans theme. * * @author Beans - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @package Beans\Framework */ From d9cdd9faaa4eb9f390d32f7f3ee5e9540bf533b0 Mon Sep 17 00:00:00 2001 From: ibes Date: Mon, 25 Jun 2018 03:24:40 +0200 Subject: [PATCH 790/800] Updated Schema.org from http:// to https:// (PR #290) Part of #288 --- lib/templates/fragments/comments.php | 2 +- lib/templates/fragments/menu.php | 2 +- lib/templates/fragments/post-shortcodes.php | 2 +- lib/templates/structure/comment.php | 2 +- lib/templates/structure/content.php | 4 ++-- lib/templates/structure/footer-partial.php | 2 +- lib/templates/structure/header-partial.php | 2 +- lib/templates/structure/header.php | 2 +- lib/templates/structure/loop.php | 4 ++-- lib/templates/structure/sidebar-primary.php | 2 +- lib/templates/structure/sidebar-secondary.php | 2 +- tests/phpunit/integration/api/html/beansRemoveAttribute.php | 2 +- tests/phpunit/integration/api/html/beansReplaceAttribute.php | 2 +- tests/phpunit/integration/api/html/fixtures/test-markup.php | 2 +- .../integration/api/template/beansLoadDefaultTemplate.php | 2 +- tests/phpunit/unit/api/html/beans-attribute/remove.php | 2 +- tests/phpunit/unit/api/html/beans-attribute/replace.php | 2 +- tests/phpunit/unit/api/html/fixtures/test-markup.php | 2 +- 18 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index 7488ff87..fb73b35a 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -71,7 +71,7 @@ function beans_comment_author() { 'class' => 'uk-comment-title', 'itemprop' => 'author', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/Person', + 'itemtype' => 'https://schema.org/Person', ) ); diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index 2b83a0a4..bbdb9018 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -27,7 +27,7 @@ function beans_primary_menu() { 'id' => 'beans-primary-navigation', 'role' => 'navigation', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/SiteNavigationElement', + 'itemtype' => 'https://schema.org/SiteNavigationElement', 'aria-label' => esc_attr__( 'Primary Navigation Menu', 'tm-beans' ), 'tabindex' => '-1', ) diff --git a/lib/templates/fragments/post-shortcodes.php b/lib/templates/fragments/post-shortcodes.php index d6426b2d..9b9eaf51 100644 --- a/lib/templates/fragments/post-shortcodes.php +++ b/lib/templates/fragments/post-shortcodes.php @@ -51,7 +51,7 @@ function beans_post_meta_author_shortcode() { 'rel' => 'author', 'itemprop' => 'author', 'itemscope' => '', - 'itemtype' => 'http://schema.org/Person', + 'itemtype' => 'https://schema.org/Person', ) ); diff --git a/lib/templates/structure/comment.php b/lib/templates/structure/comment.php index 74910ec6..c4c4d388 100644 --- a/lib/templates/structure/comment.php +++ b/lib/templates/structure/comment.php @@ -15,7 +15,7 @@ 'class' => 'uk-comment', 'itemprop' => 'comment', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/Comment', + 'itemtype' => 'https://schema.org/Comment', ) ); diff --git a/lib/templates/structure/content.php b/lib/templates/structure/content.php index 8c2927d5..10fc575a 100644 --- a/lib/templates/structure/content.php +++ b/lib/templates/structure/content.php @@ -21,7 +21,7 @@ if ( is_home() || is_page_template( 'page_blog.php' ) || is_singular( 'post' ) || is_archive() ) { $content_attributes['itemscope'] = 'itemscope'; // Automatically escaped. - $content_attributes['itemtype'] = 'http://schema.org/Blog'; // Automatically escaped. + $content_attributes['itemtype'] = 'https://schema.org/Blog'; // Automatically escaped. } @@ -29,7 +29,7 @@ if ( is_search() ) { $content_attributes['itemscope'] = 'itemscope'; // Automatically escaped. - $content_attributes['itemtype'] = 'http://schema.org/SearchResultsPage'; // Automatically escaped. + $content_attributes['itemtype'] = 'https://schema.org/SearchResultsPage'; // Automatically escaped. } // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound diff --git a/lib/templates/structure/footer-partial.php b/lib/templates/structure/footer-partial.php index dba6d54b..67a31b8f 100644 --- a/lib/templates/structure/footer-partial.php +++ b/lib/templates/structure/footer-partial.php @@ -14,7 +14,7 @@ 'class' => 'tm-footer uk-block', 'role' => 'contentinfo', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPFooter', + 'itemtype' => 'https://schema.org/WPFooter', ) ); diff --git a/lib/templates/structure/header-partial.php b/lib/templates/structure/header-partial.php index 9deda11d..cfa3793d 100644 --- a/lib/templates/structure/header-partial.php +++ b/lib/templates/structure/header-partial.php @@ -14,7 +14,7 @@ 'class' => 'tm-header uk-block', 'role' => 'banner', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPHeader', + 'itemtype' => 'https://schema.org/WPHeader', ) ); diff --git a/lib/templates/structure/header.php b/lib/templates/structure/header.php index aee6c649..3027ced5 100644 --- a/lib/templates/structure/header.php +++ b/lib/templates/structure/header.php @@ -34,7 +34,7 @@ array( 'class' => implode( ' ', get_body_class( 'uk-form no-js' ) ), 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WebPage', + 'itemtype' => 'https://schema.org/WebPage', ) ); diff --git a/lib/templates/structure/loop.php b/lib/templates/structure/loop.php index a21515f1..aed3aa32 100644 --- a/lib/templates/structure/loop.php +++ b/lib/templates/structure/loop.php @@ -35,13 +35,13 @@ 'id' => get_the_ID(), // Automatically escaped. 'class' => implode( ' ', get_post_class( array( 'uk-article', ( current_theme_supports( 'beans-default-styling' ) ? 'uk-panel-box' : null ) ) ) ), // Automatically escaped. 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/CreativeWork', + 'itemtype' => 'https://schema.org/CreativeWork', ); // Blog specifc attributes. if ( 'post' === get_post_type() ) { - $article_attributes['itemtype'] = 'http://schema.org/BlogPosting'; + $article_attributes['itemtype'] = 'https://schema.org/BlogPosting'; // Only add to blogPost attribute to the main query. if ( is_main_query() && ! is_search() ) { diff --git a/lib/templates/structure/sidebar-primary.php b/lib/templates/structure/sidebar-primary.php index 252468c1..c7acb251 100644 --- a/lib/templates/structure/sidebar-primary.php +++ b/lib/templates/structure/sidebar-primary.php @@ -16,7 +16,7 @@ 'id' => 'beans-primary-sidebar', 'role' => 'complementary', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPSideBar', + 'itemtype' => 'https://schema.org/WPSideBar', 'tabindex' => '-1', ) ); diff --git a/lib/templates/structure/sidebar-secondary.php b/lib/templates/structure/sidebar-secondary.php index 4c2cea07..118ca771 100644 --- a/lib/templates/structure/sidebar-secondary.php +++ b/lib/templates/structure/sidebar-secondary.php @@ -16,7 +16,7 @@ 'id' => 'beans-secondary-sidebar', 'role' => 'complementary', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPSideBar', + 'itemtype' => 'https://schema.org/WPSideBar', 'tabindex' => '-1', ) ); diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php index 69fa2d07..9fac5c6d 100644 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ b/tests/phpunit/integration/api/html/beansRemoveAttribute.php @@ -100,7 +100,7 @@ public function test_should_remove_the_given_value_from_attribute() { 'id' => 47, 'class' => 'uk-article uk-panel-box category-beans', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', + 'itemtype' => 'https://schema.org/blogPost', 'itemprop' => 'beans_post', ]; diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php index 5c471cc9..35e3c36a 100644 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ b/tests/phpunit/integration/api/html/beansReplaceAttribute.php @@ -50,7 +50,7 @@ public function test_should_replace_existing_attribute_value() { 'id' => 47, 'class' => 'uk-article uk-panel-box category-beans', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', + 'itemtype' => 'https://schema.org/blogPost', 'itemprop' => 'beans_post', ]; diff --git a/tests/phpunit/integration/api/html/fixtures/test-markup.php b/tests/phpunit/integration/api/html/fixtures/test-markup.php index ed54f805..954725ba 100644 --- a/tests/phpunit/integration/api/html/fixtures/test-markup.php +++ b/tests/phpunit/integration/api/html/fixtures/test-markup.php @@ -15,7 +15,7 @@ 'id' => 47, 'class' => 'uk-article uk-panel-box post-47 post type-post status-publish format-standard has-post-thumbnail hentry category-beans', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', + 'itemtype' => 'https://schema.org/blogPost', 'itemprop' => 'beans_post', ], ], diff --git a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php index 4682b496..cb5f616e 100644 --- a/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php +++ b/tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php @@ -54,7 +54,7 @@ public function test_should_load_default_structure_when_given_file_does_not_exis $html = ob_get_clean(); $expected = << +
                EOB; $this->assertStringStartsWith( $expected, trim( $html ) ); diff --git a/tests/phpunit/unit/api/html/beans-attribute/remove.php b/tests/phpunit/unit/api/html/beans-attribute/remove.php index 95b4eaea..939679da 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/remove.php +++ b/tests/phpunit/unit/api/html/beans-attribute/remove.php @@ -71,7 +71,7 @@ public function test_should_remove_the_given_value_from_attribute() { 'id' => 47, 'class' => 'uk-article uk-panel-box category-beans', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', + 'itemtype' => 'https://schema.org/blogPost', 'itemprop' => 'beans_post', ]; diff --git a/tests/phpunit/unit/api/html/beans-attribute/replace.php b/tests/phpunit/unit/api/html/beans-attribute/replace.php index 51ea0d99..cb1f1186 100644 --- a/tests/phpunit/unit/api/html/beans-attribute/replace.php +++ b/tests/phpunit/unit/api/html/beans-attribute/replace.php @@ -32,7 +32,7 @@ public function test_should_replace_existing_attribute_value() { 'id' => 47, 'class' => 'uk-article uk-panel-box category-beans', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', + 'itemtype' => 'https://schema.org/blogPost', 'itemprop' => 'beans_post', ]; diff --git a/tests/phpunit/unit/api/html/fixtures/test-markup.php b/tests/phpunit/unit/api/html/fixtures/test-markup.php index 08870409..ebd2d582 100644 --- a/tests/phpunit/unit/api/html/fixtures/test-markup.php +++ b/tests/phpunit/unit/api/html/fixtures/test-markup.php @@ -15,7 +15,7 @@ 'id' => 47, 'class' => 'uk-article uk-panel-box post-47 post type-post status-publish format-standard has-post-thumbnail hentry category-beans', 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/blogPost', + 'itemtype' => 'https://schema.org/blogPost', 'itemprop' => 'beans_post', ], ], From 20182877c4e0decff2714baae7196e37a39d5d81 Mon Sep 17 00:00:00 2001 From: ibes Date: Mon, 25 Jun 2018 03:25:24 +0200 Subject: [PATCH 791/800] Update some URLs from http:// to https:// (PR #291) Part of #288 --- README.md | 8 ++++---- lib/api/compiler/class-beans-compiler.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 980c6b17..ab906e58 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ [![Build Status](https://travis-ci.org/Getbeans/Beans.svg?branch=development)](https://travis-ci.org/Getbeans/Beans) -[Beans](http://www.getbeans.io/) is an incredibly powerful and flexible WordPress theme, yet light weight and unbelievably fast. Whether you are a pro or a beginner, you will enjoy the simplicity of it. The magic is under the hood! +[Beans](https://www.getbeans.io/) is an incredibly powerful and flexible WordPress theme, yet light weight and unbelievably fast. Whether you are a pro or a beginner, you will enjoy the simplicity of it. The magic is under the hood! # Documentation -Whether you are looking how to get started or how to use Beans API, you will find your answers in the [documentation](http://www.getbeans.io/documentation/). If your don't find what your are looking for, don't hesitate to [contact us](http://getbeans.io/contact/). +Whether you are looking how to get started or how to use Beans API, you will find your answers in the [documentation](https://www.getbeans.io/documentation/). If your don't find what your are looking for, don't hesitate to [contact us](https://getbeans.io/contact/). # Code snippets -[Code snippets](http://www.getbeans.io/code-snippets/) are ready to be pasted straight into your child theme functions.php. +[Code snippets](https://www.getbeans.io/code-snippets/) are ready to be pasted straight into your child theme functions.php. # Code reference -Developers this is made for you! You will find all the hooks and functions available in Beans under the [Code reference](http://www.getbeans.io/code-reference/). +Developers this is made for you! You will find all the hooks and functions available in Beans under the [Code reference](https://www.getbeans.io/code-reference/). # Community Beans is the achievement of two years of work and was launched the 26th of August 2015. The response has been incredible so far and we hope the community will grow around Beans. We just opened the [Twitter account](https://twitter.com/BeansPress) so if you would like to say hello, use twitter @BeansPress handle. diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index cf41a138..cb3a6d08 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -854,7 +854,7 @@ private function kill() { ) ); $html .= beans_output( 'beans_compiler_error_contact_text', sprintf( - '%s', + '%s', __( 'Contact Beans Support', 'tm-beans' ) ) ); From 9ec62e6beae1e87f0908b6d1a35eed2ec41da41c Mon Sep 17 00:00:00 2001 From: ibes Date: Mon, 25 Jun 2018 18:07:36 +0200 Subject: [PATCH 792/800] Updated URLs in code to agreed writing style. (PR #292) Made sure that Beans URL is https://www.getbeans.io Closes #288 --- README.md | 2 +- lib/templates/fragments/footer.php | 2 +- tests/phpunit/integration/bootstrap.php | 2 +- tests/phpunit/unit/bootstrap.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ab906e58..c6400e21 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [Beans](https://www.getbeans.io/) is an incredibly powerful and flexible WordPress theme, yet light weight and unbelievably fast. Whether you are a pro or a beginner, you will enjoy the simplicity of it. The magic is under the hood! # Documentation -Whether you are looking how to get started or how to use Beans API, you will find your answers in the [documentation](https://www.getbeans.io/documentation/). If your don't find what your are looking for, don't hesitate to [contact us](https://getbeans.io/contact/). +Whether you are looking how to get started or how to use Beans API, you will find your answers in the [documentation](https://www.getbeans.io/documentation/). If your don't find what your are looking for, don't hesitate to [contact us](https://www.getbeans.io/contact/). # Code snippets [Code snippets](https://www.getbeans.io/code-snippets/) are ready to be pasted straight into your child theme functions.php. # Code reference diff --git a/lib/templates/fragments/footer.php b/lib/templates/fragments/footer.php index 35f43d52..11685252 100644 --- a/lib/templates/fragments/footer.php +++ b/lib/templates/fragments/footer.php @@ -36,7 +36,7 @@ function beans_footer_content() { 'beans_footer_credit_framework_link', 'a', array( - 'href' => 'http://www.getbeans.io', // Automatically escaped. + 'href' => 'https://www.getbeans.io', // Automatically escaped. 'rel' => 'nofollow', ) ); diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index 48fc288c..ca50847c 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -4,7 +4,7 @@ * * @package Beans\Framework\Tests\Integration * @since 1.5.0 - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @license GNU-2.0+ */ diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php index 126edab5..e4fdc6c3 100644 --- a/tests/phpunit/unit/bootstrap.php +++ b/tests/phpunit/unit/bootstrap.php @@ -4,7 +4,7 @@ * * @package Beans\Framework\Tests\Unit * @since 1.5.0 - * @link http://www.getbeans.io + * @link https://www.getbeans.io * @license GNU-2.0+ */ From eddec173a434b930df980c8fa2129adf4a887f70 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 26 Jun 2018 14:52:23 -0400 Subject: [PATCH 793/800] Fixed regression in Customizer preventing the logo to refresh. (PR #294) --- lib/admin/wp-customize.php | 2 ++ lib/api/wp-customize/class-beans-wp-customize.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index d0322b88..7cd1fba0 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -72,6 +72,7 @@ function beans_do_register_wp_customize_options() { 'label' => __( 'Viewport Width - for Previewing Only', 'tm-beans' ), 'description' => __( 'Slide left or right to change the viewport width. Publishing will not change the width of your website.', 'tm-beans' ), 'type' => 'group', + 'transport' => 'postMessage', 'fields' => array( array( 'id' => 'beans_enable_viewport_width', @@ -95,6 +96,7 @@ function beans_do_register_wp_customize_options() { 'label' => __( 'Viewport Height - for Previewing Only', 'tm-beans' ), 'description' => __( 'Slide left or right to change the viewport height. Publishing will not change the height of your website.', 'tm-beans' ), 'type' => 'group', + 'transport' => 'postMessage', 'fields' => array( array( 'id' => 'beans_enable_viewport_height', diff --git a/lib/api/wp-customize/class-beans-wp-customize.php b/lib/api/wp-customize/class-beans-wp-customize.php index 62de34e6..2fa9a15d 100644 --- a/lib/api/wp-customize/class-beans-wp-customize.php +++ b/lib/api/wp-customize/class-beans-wp-customize.php @@ -143,7 +143,7 @@ private function add_setting( WP_Customize_Manager $wp_customize, array $field ) $defaults = array( 'db_type' => 'theme_mod', 'capability' => 'edit_theme_options', - 'transport' => 'postMessage', + 'transport' => 'refresh', ); $field = array_merge( $defaults, $field ); From 61b4fdc9eaf6baed719fab810a281844dfc3cc60 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 3 Jul 2018 10:40:13 -0500 Subject: [PATCH 794/800] Escaped translation. Fixed phpcs:ignore message. --- lib/templates/fragments/post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index ee9bd15c..51ad2745 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -71,7 +71,7 @@ function beans_post_search_title() { beans_open_markup_e( 'beans_search_title', 'h1', array( 'class' => 'uk-article-title' ) ); - printf( '%1$s%2$s', beans_output( 'beans_search_title_text', __( 'Search results for: ', 'tm-beans' ) ), get_search_query() ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + printf( '%1$s%2$s', beans_output( 'beans_search_title_text', esc_html__( 'Search results for: ', 'tm-beans' ) ), get_search_query() ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Each placeholder is escaped. beans_close_markup_e( 'beans_search_title', 'h1' ); } From c8d74368412f7bf77908400a4d53c7bd764bd385 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 3 Jul 2018 10:45:33 -0500 Subject: [PATCH 795/800] Escaped translations that are not an attribute. Translations that are an attribute are automatically escaped in Beans. Removed the escaping in the templates. Added escaping for translations when not an attribute. Fixed the phpcs:ignore messages. --- lib/templates/fragments/comments.php | 26 +++++++------- lib/templates/fragments/menu.php | 4 +-- lib/templates/fragments/post-shortcodes.php | 21 ++++++----- lib/templates/fragments/post.php | 40 ++++++++++----------- lib/templates/fragments/widget.php | 5 ++- 5 files changed, 47 insertions(+), 49 deletions(-) diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index fb73b35a..22019660 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -95,7 +95,7 @@ function beans_comment_badges() { if ( 'trackback' === $comment->comment_type ) { beans_open_markup_e( 'beans_trackback_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left' ) ); - beans_output_e( 'beans_trackback_text', __( 'Trackback', 'tm-beans' ) ); + beans_output_e( 'beans_trackback_text', esc_html__( 'Trackback', 'tm-beans' ) ); beans_close_markup_e( 'beans_trackback_badge', 'span' ); } @@ -104,7 +104,7 @@ function beans_comment_badges() { if ( 'pingback' === $comment->comment_type ) { beans_open_markup_e( 'beans_pingback_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left' ) ); - beans_output_e( 'beans_pingback_text', __( 'Pingback', 'tm-beans' ) ); + beans_output_e( 'beans_pingback_text', esc_html__( 'Pingback', 'tm-beans' ) ); beans_close_markup_e( 'beans_pingback_badge', 'span' ); } @@ -113,7 +113,7 @@ function beans_comment_badges() { if ( '0' === $comment->comment_approved ) { beans_open_markup_e( 'beans_moderation_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left uk-badge-warning' ) ); - beans_output_e( 'beans_moderation_text', __( 'Awaiting Moderation', 'tm-beans' ) ); + beans_output_e( 'beans_moderation_text', esc_html__( 'Awaiting Moderation', 'tm-beans' ) ); beans_close_markup_e( 'beans_moderation_badge', 'span' ); } @@ -122,7 +122,7 @@ function beans_comment_badges() { if ( user_can( $comment->user_id, 'moderate_comments' ) ) { beans_open_markup_e( 'beans_moderator_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left' ) ); - beans_output_e( 'beans_moderator_text', __( 'Moderator', 'tm-beans' ) ); + beans_output_e( 'beans_moderator_text', esc_html__( 'Moderator', 'tm-beans' ) ); beans_close_markup_e( 'beans_moderator_badge', 'span' ); } @@ -212,7 +212,7 @@ function beans_comment_links() { ) ); - beans_output_e( 'beans_comment_edit_text', __( 'Edit', 'tm-beans' ) ); + beans_output_e( 'beans_comment_edit_text', esc_html__( 'Edit', 'tm-beans' ) ); beans_close_markup_e( 'beans_comment_item_link[_edit]', 'a' ); @@ -230,7 +230,7 @@ function beans_comment_links() { ) ); - beans_output_e( 'beans_comment_link_text', __( 'Link', 'tm-beans' ) ); + beans_output_e( 'beans_comment_link_text', esc_html__( 'Link', 'tm-beans' ) ); beans_close_markup_e( 'beans_comment_item_link[_link]', 'a' ); @@ -250,7 +250,7 @@ function beans_comment_links() { function beans_no_comment() { beans_open_markup_e( 'beans_no_comment', 'p', 'class=uk-text-muted' ); - beans_output_e( 'beans_no_comment_text', __( 'No comment yet, add your voice below!', 'tm-beans' ) ); + beans_output_e( 'beans_no_comment_text', esc_html__( 'No comment yet, add your voice below!', 'tm-beans' ) ); beans_close_markup_e( 'beans_no_comment', 'p' ); } @@ -266,7 +266,7 @@ function beans_no_comment() { function beans_comments_closed() { beans_open_markup_e( 'beans_comments_closed', 'p', array( 'class' => 'uk-alert uk-alert-warning uk-margin-bottom-remove' ) ); - beans_output_e( 'beans_comments_closed_text', __( 'Comments are closed for this article!', 'tm-beans' ) ); + beans_output_e( 'beans_comments_closed_text', esc_html__( 'Comments are closed for this article!', 'tm-beans' ) ); beans_close_markup_e( 'beans_comments_closed', 'p' ); } @@ -387,12 +387,12 @@ function beans_comment_form() { ) ); - $submit .= beans_output( 'beans_comment_form_submit_text', __( 'Post Comment', 'tm-beans' ) ); + $submit .= beans_output( 'beans_comment_form_submit_text', esc_html__( 'Post Comment', 'tm-beans' ) ); $submit .= beans_close_markup( 'beans_comment_form_submit', 'button' ); // WordPress, please make it easier for us. - echo preg_replace( '#]+type="submit"[^>]+>#', $submit, $output ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + echo preg_replace( '#]+type="submit"[^>]+>#', $submit, $output ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped above or as an attribute. } // Filter. @@ -455,7 +455,7 @@ function beans_comment_form_comment() { $output .= beans_open_markup( 'beans_comment_form_legend[_comment]', 'legend' ); - $output .= beans_output( 'beans_comment_form_legend_text[_comment]', __( 'Comment *', 'tm-beans' ) ); + $output .= beans_output( 'beans_comment_form_legend_text[_comment]', esc_html__( 'Comment *', 'tm-beans' ) ); $output .= beans_close_markup( 'beans_comment_form_legend[_comment]', 'legend' ); } @@ -530,7 +530,7 @@ function beans_comment_form_fields( $fields ) { if ( beans_apply_filters( 'beans_comment_form_legend[_name]', true ) ) { $author .= beans_open_markup( 'beans_comment_form_legend[_name]', 'legend' ); - $author .= beans_output( 'beans_comment_form_legend_text[_name]', __( 'Name *', 'tm-beans' ) ); + $author .= beans_output( 'beans_comment_form_legend_text[_name]', esc_html__( 'Name *', 'tm-beans' ) ); $author .= beans_close_markup( 'beans_comment_form_legend[_name]', 'legend' ); } @@ -599,7 +599,7 @@ function beans_comment_form_fields( $fields ) { if ( beans_apply_filters( 'beans_comment_form_legend[_url]', true ) ) { $url .= beans_open_markup( 'beans_comment_form_legend', 'legend' ); - $url .= beans_output( 'beans_comment_form_legend_text[_url]', __( 'Website', 'tm-beans' ) ); + $url .= beans_output( 'beans_comment_form_legend_text[_url]', esc_html__( 'Website', 'tm-beans' ) ); $url .= beans_close_markup( 'beans_comment_form_legend[_url]', 'legend' ); } diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index bbdb9018..1c49b17e 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -93,7 +93,7 @@ function beans_primary_menu_offcanvas_button() { beans_close_markup_e( 'beans_primary_menu_offcanvas_button_icon', 'span' ); - beans_output_e( 'beans_offcanvas_menu_button', __( 'Menu', 'tm-beans' ) ); + beans_output_e( 'beans_offcanvas_menu_button', esc_html__( 'Menu', 'tm-beans' ) ); beans_close_markup_e( 'beans_primary_menu_offcanvas_button', 'a' ); } @@ -155,7 +155,7 @@ function beans_primary_offcanvas_menu() { function beans_no_menu_notice() { beans_open_markup_e( 'beans_no_menu_notice', 'p', array( 'class' => 'uk-alert uk-alert-warning' ) ); - beans_output_e( 'beans_no_menu_notice_text', __( 'Whoops, your site does not have a menu!', 'tm-beans' ) ); + beans_output_e( 'beans_no_menu_notice_text', esc_html__( 'Whoops, your site does not have a menu!', 'tm-beans' ) ); beans_close_markup_e( 'beans_no_menu_notice', 'p' ); } diff --git a/lib/templates/fragments/post-shortcodes.php b/lib/templates/fragments/post-shortcodes.php index 9b9eaf51..20ab6fa7 100644 --- a/lib/templates/fragments/post-shortcodes.php +++ b/lib/templates/fragments/post-shortcodes.php @@ -16,7 +16,7 @@ * @return void */ function beans_post_meta_date_shortcode() { - beans_output_e( 'beans_post_meta_date_prefix', __( 'Posted on ', 'tm-beans' ) ); + beans_output_e( 'beans_post_meta_date_prefix', esc_html__( 'Posted on ', 'tm-beans' ) ); beans_open_markup_e( 'beans_post_meta_date', @@ -41,7 +41,7 @@ function beans_post_meta_date_shortcode() { * @return void */ function beans_post_meta_author_shortcode() { - beans_output_e( 'beans_post_meta_author_prefix', __( 'By ', 'tm-beans' ) ); + beans_output_e( 'beans_post_meta_author_prefix', esc_html__( 'By ', 'tm-beans' ) ); beans_open_markup_e( 'beans_post_meta_author', @@ -78,29 +78,29 @@ function beans_post_meta_author_shortcode() { * @return void */ function beans_post_meta_comments_shortcode() { - global $post; if ( post_password_required() || ! comments_open() ) { return; } + global $post; $comments_number = (int) get_comments_number( $post->ID ); if ( $comments_number < 1 ) { - $comment_text = beans_output( 'beans_post_meta_empty_comment_text', __( 'Leave a comment', 'tm-beans' ) ); + $comment_text = beans_output( 'beans_post_meta_empty_comment_text', esc_html__( 'Leave a comment', 'tm-beans' ) ); } elseif ( 1 === $comments_number ) { - $comment_text = beans_output( 'beans_post_meta_comments_text_singular', __( '1 comment', 'tm-beans' ) ); + $comment_text = beans_output( 'beans_post_meta_comments_text_singular', esc_html__( '1 comment', 'tm-beans' ) ); } else { $comment_text = beans_output( 'beans_post_meta_comments_text_plural', - // translators: Number of comments. Plural. - __( '%s comments', 'tm-beans' ) + // translators: %s: Number of comments. Plural. + esc_html__( '%s comments', 'tm-beans' ) ); } beans_open_markup_e( 'beans_post_meta_comments', 'a', array( 'href' => get_comments_link() ) ); // Automatically escaped. - printf( $comment_text, (int) get_comments_number( $post->ID ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + printf( $comment_text, (int) get_comments_number( $post->ID ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaping handled prior to this printf. beans_close_markup_e( 'beans_post_meta_comments', 'a' ); } @@ -114,14 +114,13 @@ function beans_post_meta_comments_shortcode() { * @return void */ function beans_post_meta_tags_shortcode() { - $tags = get_the_tag_list( null, ', ' ); if ( ! $tags || is_wp_error( $tags ) ) { return; } - printf( '%1$s%2$s', beans_output( 'beans_post_meta_tags_prefix', __( 'Tagged with: ', 'tm-beans' ) ), $tags ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + printf( '%1$s%2$s', beans_output( 'beans_post_meta_tags_prefix', esc_html__( 'Tagged with: ', 'tm-beans' ) ), $tags ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Tags are escaped by WordPress. } beans_add_smart_action( 'beans_post_meta_categories', 'beans_post_meta_categories_shortcode' ); @@ -139,5 +138,5 @@ function beans_post_meta_categories_shortcode() { return; } - printf( '%1$s%2$s', beans_output( 'beans_post_meta_categories_prefix', __( 'Filed under: ', 'tm-beans' ) ), $categories ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + printf( '%1$s%2$s', beans_output( 'beans_post_meta_categories_prefix', esc_html__( 'Filed under: ', 'tm-beans' ) ), $categories ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Categories are escaped by WordPress. } diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 51ad2745..1dfe5447 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -336,7 +336,7 @@ function beans_post_more_link() { ) ); - $output .= beans_output( 'beans_post_more_link_text', __( 'Continue reading', 'tm-beans' ) ); + $output .= beans_output( 'beans_post_more_link_text', esc_html__( 'Continue reading', 'tm-beans' ) ); $output .= beans_open_markup( 'beans_next_icon[_more_link]', @@ -388,7 +388,7 @@ function beans_post_meta_categories() { beans_open_markup_e( 'beans_post_meta_categories', 'span', array( 'class' => 'uk-text-small uk-text-muted uk-clearfix' ) ); - echo $categories; // // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + echo $categories; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Shortcode's callback handles the escaping. See beans_post_meta_categories_shortcode(). beans_close_markup_e( 'beans_post_meta_categories', 'span' ); } @@ -408,7 +408,7 @@ function beans_post_meta_tags() { beans_open_markup_e( 'beans_post_meta_tags', 'span', array( 'class' => 'uk-text-small uk-text-muted uk-clearfix' ) ); - echo $tags; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Pending security audit. + echo $tags; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Shortcode's callback handles the escaping. See beans_post_meta_tags_shortcode(). beans_close_markup_e( 'beans_post_meta_tags', 'span' ); } @@ -540,7 +540,7 @@ function beans_post_navigation() { 'nav', array( 'role' => 'navigation', - 'aria-label' => esc_attr__( 'Pagination Navigation', 'tm-beans' ), + 'aria-label' => __( 'Pagination Navigation', 'tm-beans' ), // Attributes are automatically escaped. ) ); @@ -616,7 +616,7 @@ function beans_posts_pagination() { 'nav', array( 'role' => 'navigation', - 'aria-label' => esc_attr__( 'Posts Pagination Navigation', 'tm-beans' ), + 'aria-label' => __( 'Posts Pagination Navigation', 'tm-beans' ), // Attributes are automatically escaped. ) ); @@ -636,7 +636,7 @@ function beans_posts_pagination() { 'beans_previous_link[_posts_pagination]', 'a', array( - 'href' => previous_posts( false ), // Automatically escaped. + 'href' => previous_posts( false ), // Attributes are automatically escaped. ), $current ); @@ -652,7 +652,7 @@ function beans_posts_pagination() { beans_close_markup_e( 'beans_previous_icon[_posts_pagination]', 'span' ); - beans_output_e( 'beans_previous_text[_posts_pagination]', __( 'Previous Page', 'tm-beans' ) ); + beans_output_e( 'beans_previous_text[_posts_pagination]', esc_html__( 'Previous Page', 'tm-beans' ) ); beans_close_markup_e( 'beans_previous_link[_posts_pagination]', 'a' ); @@ -715,7 +715,7 @@ function beans_posts_pagination() { 'beans_posts_pagination_item_link', 'a', array( - 'href' => get_pagenum_link( $link ), // Automatically escaped. + 'href' => get_pagenum_link( $link ), // Attributes are automatically escaped. ), $link ); @@ -736,12 +736,12 @@ function beans_posts_pagination() { 'beans_next_link[_posts_pagination]', 'a', array( - 'href' => next_posts( $count, false ), // Automatically escaped. + 'href' => next_posts( $count, false ), // Attributes are automatically escaped. ), $current ); - beans_output_e( 'beans_next_text[_posts_pagination]', __( 'Next Page', 'tm-beans' ) ); + beans_output_e( 'beans_next_text[_posts_pagination]', esc_html__( 'Next Page', 'tm-beans' ) ); beans_open_markup_e( 'beans_next_icon[_posts_pagination]', @@ -779,7 +779,7 @@ function beans_no_post() { beans_open_markup_e( 'beans_post_title', 'h1', array( 'class' => 'uk-article-title' ) ); - beans_output_e( 'beans_no_post_article_title_text', __( 'Whoops, no result found!', 'tm-beans' ) ); + beans_output_e( 'beans_no_post_article_title_text', esc_html__( 'Whoops, no result found!', 'tm-beans' ) ); beans_close_markup_e( 'beans_post_title', 'h1' ); @@ -791,7 +791,7 @@ function beans_no_post() { beans_open_markup_e( 'beans_no_post_article_content', 'p', array( 'class' => 'uk-alert uk-alert-warning' ) ); - beans_output_e( 'beans_no_post_article_content_text', __( 'It looks like nothing was found at this location. Maybe try a search?', 'tm-beans' ) ); + beans_output_e( 'beans_no_post_article_content_text', esc_html__( 'It looks like nothing was found at this location. Maybe try a search?', 'tm-beans' ) ); beans_close_markup_e( 'beans_no_post_article_content', 'p' ); @@ -821,7 +821,7 @@ function beans_post_password_form() { // Notice. $output = beans_open_markup( 'beans_password_form_notice', 'p', array( 'class' => 'uk-alert uk-alert-warning' ) ); - $output .= beans_output( 'beans_password_form_notice_text', __( 'This post is protected. To view it, enter the password below!', 'tm-beans' ) ); + $output .= beans_output( 'beans_password_form_notice_text', esc_html__( 'This post is protected. To view it, enter the password below!', 'tm-beans' ) ); $output .= beans_close_markup( 'beans_password_form_notice', 'p' ); @@ -832,7 +832,7 @@ function beans_post_password_form() { array( 'class' => 'uk-form uk-margin-bottom', 'method' => 'post', - 'action' => site_url( 'wp-login.php?action=postpass', 'login_post' ), // Automatically escaped. + 'action' => site_url( 'wp-login.php?action=postpass', 'login_post' ), // Attributes are automatically escaped. ) ); @@ -842,7 +842,7 @@ function beans_post_password_form() { array( 'class' => 'uk-margin-small-top uk-margin-small-right', 'type' => 'password', - 'placeholder' => apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ), // Automatically escaped. + 'placeholder' => apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ), // Attributes are automatically escaped. 'name' => 'post_password', ) ); @@ -854,7 +854,7 @@ function beans_post_password_form() { 'class' => 'uk-button uk-margin-small-top', 'type' => 'submit', 'name' => 'submit', - 'value' => esc_attr( apply_filters( 'beans_password_form_submit_text', __( 'Submit', 'tm-beans' ) ) ), + 'value' => apply_filters( 'beans_password_form_submit_text', __( 'Submit', 'tm-beans' ) ), // Attributes are automatically escaped. ) ); @@ -897,7 +897,7 @@ function beans_post_gallery( $output, $attr, $instance ) { $atts = shortcode_atts( $defaults, $attr, 'gallery' ); $id = intval( $atts['id'] ); - // Set attachements. + // Set attachments. if ( ! empty( $atts['include'] ) ) { $_attachments = get_posts( array( @@ -979,7 +979,7 @@ function beans_post_gallery( $output, $attr, $instance ) { "beans_post_gallery[_{$id}]", 'div', array( - 'class' => "uk-grid uk-grid-width-small-1-{$columns} gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}", // Automatically escaped. + 'class' => "uk-grid uk-grid-width-small-1-{$columns} gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}", // Attributes are automatically escaped. 'data-uk-grid-margin' => false, ), $id, @@ -1005,7 +1005,7 @@ function beans_post_gallery( $output, $attr, $instance ) { $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; } - // Set the image output. + // Set the image output. if ( 'none' === $atts['link'] ) { $image_output = wp_get_attachment_image( $attachment_id, $atts['size'], false, $attr ); } else { @@ -1014,7 +1014,7 @@ function beans_post_gallery( $output, $attr, $instance ) { $output .= beans_open_markup( "beans_post_gallery_item[_{$attachment_id}]", $atts['itemtag'], array( 'class' => 'gallery-item' ) ); - $output .= beans_open_markup( "beans_post_gallery_icon[_{$attachment_id}]", $atts['icontag'], array( 'class' => "gallery-icon {$orientation}" ) ); // Automatically escaped. + $output .= beans_open_markup( "beans_post_gallery_icon[_{$attachment_id}]", $atts['icontag'], array( 'class' => "gallery-icon {$orientation}" ) ); // Attributes are automatically escaped. $output .= beans_output( "beans_post_gallery_icon[_{$attachment_id}]", $image_output, $attachment_id, $atts ); diff --git a/lib/templates/fragments/widget.php b/lib/templates/fragments/widget.php index 49806bce..61daaf03 100644 --- a/lib/templates/fragments/widget.php +++ b/lib/templates/fragments/widget.php @@ -86,7 +86,7 @@ function beans_no_widget() { beans_output_e( 'beans_no_widget_notice_text', // translators: Name of the widget area. - sprintf( __( '%s does not have any widget assigned!', 'tm-beans' ), beans_get_widget_area( 'name' ) ) + sprintf( esc_html__( '%s does not have any widget assigned!', 'tm-beans' ), beans_get_widget_area( 'name' ) ) ); beans_close_markup_e( 'beans_no_widget_notice', 'p' ); @@ -101,10 +101,9 @@ function beans_no_widget() { * @return string The RSS widget content. */ function beans_widget_rss_content() { - $options = beans_get_widget( 'options' ); - return '

                ' . __( 'Read feed', 'tm-beans' ) . '

                '; + return '

                ' . esc_html__( 'Read feed', 'tm-beans' ) . '

                '; } beans_add_filter( 'beans_widget_content_attributes', 'beans_modify_widget_content_attributes' ); From da57ed10e2eca4acd55a4881e8822ccbf0b29de4 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 3 Jul 2018 17:03:05 -0400 Subject: [PATCH 796/800] Adjusted styling for comment fieldset and cookie consent. --- lib/assets/less/style.less | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/assets/less/style.less b/lib/assets/less/style.less index 82f15172..51d8f7e4 100644 --- a/lib/assets/less/style.less +++ b/lib/assets/less/style.less @@ -80,6 +80,14 @@ article header > .tm-article-image:first-child { margin-top: @grid-gutter-vertical; } +.comment-respond fieldset { + margin-bottom: @grid-gutter-vertical; +} + +#wp-comment-cookies-consent { + margin-right: 15px; +} + .comment-reply-title > small a { margin-top: -3px; } From 95b175b44e1649aa062919d42e1763b0742fbaf3 Mon Sep 17 00:00:00 2001 From: Christoph Herr Date: Tue, 3 Jul 2018 18:23:36 -0400 Subject: [PATCH 797/800] Styled class instead of id. --- lib/assets/less/style.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/assets/less/style.less b/lib/assets/less/style.less index 51d8f7e4..a22a7d8c 100644 --- a/lib/assets/less/style.less +++ b/lib/assets/less/style.less @@ -84,7 +84,7 @@ article header > .tm-article-image:first-child { margin-bottom: @grid-gutter-vertical; } -#wp-comment-cookies-consent { +.comment-form-cookies-consent input { margin-right: 15px; } From 346856b998a4a04a0460bbac14f5c15b78ca6639 Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Thu, 5 Jul 2018 08:37:01 -0500 Subject: [PATCH 798/800] Updated to v.1.5.0-rc. --- CHANGELOG.md | 4 ++-- lib/init.php | 2 +- lib/languages/tm-beans.pot | 2 +- style.css | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8de8b49a..12f2f66e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Beans Changelog -## 2018.06.21 - version 1.5.0-beta +## 2018.07.05 - version 1.5.0-rc -This pre-release includes security, web accessibility, code quality improvements, performance improvements, and bug fixes. The entire framework is now WPCS compliant. The APIs are now fully and thoroughly well-tested. All found issues are resolved. New functionality is added. +This release candidate includes security, web accessibility, code quality improvements, performance improvements, and bug fixes. The entire framework is now WPCS compliant. The APIs are now fully and thoroughly well-tested. All found issues are resolved. New functionality is added. ### Improved * Improved web accessibility by adding skip links, ARIA, labels, tabs, and more. diff --git a/lib/init.php b/lib/init.php index 548ba217..908691b9 100644 --- a/lib/init.php +++ b/lib/init.php @@ -18,7 +18,7 @@ */ function beans_define_constants() { // Define version. - define( 'BEANS_VERSION', '1.5.0-beta' ); + define( 'BEANS_VERSION', '1.5.0-rc' ); // Define paths. if ( ! defined( 'BEANS_THEME_PATH' ) ) { diff --git a/lib/languages/tm-beans.pot b/lib/languages/tm-beans.pot index 54cc9f88..7c16b595 100644 --- a/lib/languages/tm-beans.pot +++ b/lib/languages/tm-beans.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -"Project-Id-Version: Beans v.1.5.0-beta\n" +"Project-Id-Version: Beans v.1.5.0-rc\n" "POT-Creation-Date: 2018-06-20 20:46-0500\n" "PO-Revision-Date: 2018-06-20 08:10-0500\n" "Last-Translator: \n" diff --git a/style.css b/style.css index 051bb0fc..24b1422b 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Theme URI: https://www.getbeans.io/themes/beans/ Author: Beans Author URI: https://www.getbeans.io Description: The most innovative theme for WordPress. The real magic is under the hood. -Version: 1.5.0-beta +Version: 1.5.0-rc Text Domain: tm-beans Tags: white, light, one-column, two-columns, three-columns, right-sidebar, left-sidebar, responsive-layout, fluid-layout, fixed-layout, custom-header, custom-background, custom-menu, editor-style, featured-images, microformats, post-formats, translation-ready License: GNU General Public License v2 or later From d13badaeb4bb3e019f67b99ac22310cc7e7d82c1 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Tue, 10 Jul 2018 17:44:17 -0500 Subject: [PATCH 799/800] Changed version from 1.5.0-rc to 1.5.0. (PR #302) --- CHANGELOG.md | 2 +- lib/init.php | 2 +- lib/languages/tm-beans.pot | 2 +- style.css | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f2f66e..126e6979 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Beans Changelog -## 2018.07.05 - version 1.5.0-rc +## 2018.07.10 - version 1.5.0 This release candidate includes security, web accessibility, code quality improvements, performance improvements, and bug fixes. The entire framework is now WPCS compliant. The APIs are now fully and thoroughly well-tested. All found issues are resolved. New functionality is added. diff --git a/lib/init.php b/lib/init.php index 908691b9..80aa26bc 100644 --- a/lib/init.php +++ b/lib/init.php @@ -18,7 +18,7 @@ */ function beans_define_constants() { // Define version. - define( 'BEANS_VERSION', '1.5.0-rc' ); + define( 'BEANS_VERSION', '1.5.0' ); // Define paths. if ( ! defined( 'BEANS_THEME_PATH' ) ) { diff --git a/lib/languages/tm-beans.pot b/lib/languages/tm-beans.pot index 7c16b595..e1b09a10 100644 --- a/lib/languages/tm-beans.pot +++ b/lib/languages/tm-beans.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -"Project-Id-Version: Beans v.1.5.0-rc\n" +"Project-Id-Version: Beans v.1.5.0\n" "POT-Creation-Date: 2018-06-20 20:46-0500\n" "PO-Revision-Date: 2018-06-20 08:10-0500\n" "Last-Translator: \n" diff --git a/style.css b/style.css index 24b1422b..5f810d0e 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Theme URI: https://www.getbeans.io/themes/beans/ Author: Beans Author URI: https://www.getbeans.io Description: The most innovative theme for WordPress. The real magic is under the hood. -Version: 1.5.0-rc +Version: 1.5.0 Text Domain: tm-beans Tags: white, light, one-column, two-columns, three-columns, right-sidebar, left-sidebar, responsive-layout, fluid-layout, fixed-layout, custom-header, custom-background, custom-menu, editor-style, featured-images, microformats, post-formats, translation-ready License: GNU General Public License v2 or later From dd21ca3d3b015958bb262c1f1c50878301b23d5a Mon Sep 17 00:00:00 2001 From: hellofromtonya Date: Tue, 10 Jul 2018 18:55:54 -0500 Subject: [PATCH 800/800] Release 1.5.0. --- .dev-lib | 10 - .editorconfig | 21 - .gitattributes | 11 - .travis.yml | 28 - bin/install-pre-commit-hook.sh | 46 -- bin/pre-commit | 17 - bin/travis.sh | 27 - phpcs.xml.dist | 73 --- phpunit.xml.dist | 29 - tests/phpunit/class-beans-resetter.php | 109 ---- tests/phpunit/functions.php | 99 ---- .../api/actions/beansAddAction.php | 145 ----- .../api/actions/beansAddAnonymousAction.php | 46 -- .../api/actions/beansGetAction.php | 127 ----- .../api/actions/beansGetCurrentAction.php | 96 ---- .../api/actions/beansMergeAction.php | 68 --- .../api/actions/beansModifyAction.php | 204 ------- .../actions/beansModifyActionArguments.php | 149 ----- .../api/actions/beansModifyActionCallback.php | 103 ---- .../api/actions/beansModifyActionHook.php | 107 ---- .../api/actions/beansModifyActionPriority.php | 187 ------- .../api/actions/beansRemoveAction.php | 103 ---- .../api/actions/beansReplaceAction.php | 265 --------- .../actions/beansReplaceActionArguments.php | 131 ----- .../actions/beansReplaceActionCallback.php | 130 ----- .../api/actions/beansReplaceActionHook.php | 132 ----- .../actions/beansReplaceActionPriority.php | 130 ----- .../api/actions/beansResetAction.php | 513 ------------------ .../api/actions/beansSetAction.php | 108 ---- .../api/actions/beansUnsetAction.php | 91 ---- .../api/actions/fixtures/test-actions.php | 29 - .../includes/class-actions-test-case.php | 215 -------- .../class-replace-action-test-case.php | 105 ---- .../compiler/beans-compiler-options/flush.php | 58 -- .../beans-compiler-options/register.php | 193 ------- .../renderFlushButton.php | 55 -- .../renderScriptsNotCompiledNotice.php | 68 --- .../renderStylesNotCompiledNotice.php | 68 --- .../renderSuccessNotice.php | 58 -- .../beans-compiler/addContentMediaQuery.php | 108 ---- .../api/compiler/beans-compiler/cacheFile.php | 135 ----- .../beans-compiler/combineFragments.php | 309 ----------- .../api/compiler/beans-compiler/fileystem.php | 103 ---- .../compiler/beans-compiler/formatContent.php | 237 -------- .../beans-compiler/getInternalContent.php | 76 --- .../beans-compiler/getRemoteContent.php | 106 ---- .../compiler/beans-compiler/replaceCssUrl.php | 210 ------- .../compiler/beans-compiler/runCompiler.php | 324 ----------- .../compiler/beans-compiler/setFilename.php | 163 ------ .../compilePageScripts.php | 209 ------- .../beans-page-compiler/compilePageStyles.php | 244 --------- .../beans-page-compiler/dequeueScripts.php | 130 ----- .../api/compiler/beansCompileCssFragments.php | 44 -- .../api/compiler/beansCompileJsFragments.php | 99 ---- .../compiler/beansCompileLessFragments.php | 47 -- .../api/compiler/beansFlushCompiler.php | 112 ---- .../api/compiler/beansGetCompilerDir.php | 45 -- .../api/compiler/beansGetCompilerUrl.php | 44 -- .../api/compiler/fixtures/jquery.test.js | 29 - .../api/compiler/fixtures/my-game-clock.js | 21 - .../api/compiler/fixtures/style.css | 16 - .../api/compiler/fixtures/test.less | 7 - .../api/compiler/fixtures/variables.less | 8 - .../includes/class-base-test-case.php | 104 ---- .../class-compiler-options-test-case.php | 48 -- .../includes/class-compiler-test-case.php | 327 ----------- .../class-page-compiler-test-case.php | 31 -- .../integration/api/fields/beansField.php | 309 ----------- .../integration/api/fields/beansGetFields.php | 44 -- .../api/fields/beansPreStandardizeFields.php | 55 -- .../api/fields/beansRegisterFields.php | 54 -- .../api/fields/fixtures/test-fields.php | 80 --- .../includes/class-fields-test-case.php | 93 ---- .../api/fields/types/beansFieldActivation.php | 85 --- .../api/fields/types/beansFieldCheckbox.php | 112 ---- .../fields/types/beansFieldDescription.php | 100 ---- .../api/fields/types/beansFieldImage.php | 205 ------- .../api/fields/types/beansFieldLabel.php | 174 ------ .../api/fields/types/beansFieldRadio.php | 144 ----- .../api/fields/types/beansFieldSelect.php | 95 ---- .../api/fields/types/beansFieldSlider.php | 162 ------ .../api/fields/types/beansFieldText.php | 83 --- .../api/fields/types/beansFieldTextarea.php | 83 --- .../api/fields/types/beansGetImageAlt.php | 74 --- .../api/fields/types/beansGetImageUrl.php | 65 --- .../api/fields/types/beansIsRadioImage.php | 90 --- .../types/beansStandardizeRadioImage.php | 136 ----- .../api/filters/beansAddAnonymousFilter.php | 62 --- .../api/filters/beansAddFilter.php | 77 --- .../api/filters/beansApplyFilters.php | 98 ---- .../api/filters/beansHasFilters.php | 57 -- .../api/filters/fixtures/test-filters.php | 41 -- .../includes/class-filters-test-case.php | 111 ---- .../api/html/beans-attribute/init.php | 47 -- .../api/html/beansAddAttribute.php | 90 --- .../api/html/beansAddAttributes.php | 77 --- .../api/html/beansBuildSkipLinks.php | 247 --------- .../integration/api/html/beansCloseMarkup.php | 152 ------ .../api/html/beansCloseMarkupE.php | 72 --- .../api/html/beansIsHtmlDevMode.php | 49 -- .../api/html/beansModifyMarkup.php | 87 --- .../integration/api/html/beansOpenMarkup.php | 236 -------- .../integration/api/html/beansOpenMarkupE.php | 86 --- .../integration/api/html/beansOutput.php | 97 ---- .../integration/api/html/beansOutputE.php | 114 ---- .../api/html/beansRemoveAttribute.php | 147 ----- .../api/html/beansRemoveMarkup.php | 73 --- .../api/html/beansRemoveOutput.php | 63 --- .../api/html/beansReplaceAttribute.php | 160 ------ .../integration/api/html/beansResetMarkup.php | 84 --- .../api/html/beansSelfcloseMarkup.php | 70 --- .../api/html/beansSelfcloseMarkupE.php | 60 -- .../api/html/beansWrapInnerMarkup.php | 166 ------ .../integration/api/html/beansWrapMarkup.php | 166 ------ .../api/html/fixtures/test-attachment.php | 50 -- .../api/html/fixtures/test-markup.php | 64 --- .../html/includes/class-html-test-case.php | 85 --- .../beans-image-editor/createEditedImage.php | 87 --- .../api/image/beans-image-editor/run.php | 339 ------------ .../api/image/beans-image-options/flush.php | 58 -- .../image/beans-image-options/register.php | 104 ---- .../beans-image-options/renderFlushButton.php | 48 -- .../renderSuccessNotice.php | 59 -- .../integration/api/image/beansEditImage.php | 98 ---- .../api/image/beansGetImagesDir.php | 49 -- .../integration/api/image/fixtures/image1.jpg | Bin 31016 -> 0 bytes .../integration/api/image/fixtures/image2.jpg | Bin 31429 -> 0 bytes .../image/includes/class-base-test-case.php | 100 ---- .../image/includes/class-image-test-case.php | 61 --- .../includes/class-options-test-case.php | 57 -- .../api/layout/beansGetDefaultLayout.php | 52 -- .../integration/api/layout/beansGetLayout.php | 177 ------ .../api/layout/beansGetLayoutClass.php | 382 ------------- .../api/layout/beansHasPrimarySidebar.php | 79 --- .../api/layout/beansHasSecondarySidebar.php | 78 --- .../options/beans-options/processActions.php | 200 ------- .../api/options/beans-options/register.php | 72 --- .../options/beans-options/renderMetabox.php | 77 --- .../api/options/beans-options/renderPage.php | 164 ------ .../api/options/fixtures/test-options.php | 91 ---- .../includes/class-options-test-case.php | 70 --- .../post-meta/beans-post-meta/construct.php | 47 -- .../post-meta/beans-post-meta/okToSave.php | 87 --- .../beans-post-meta/registerMetabox.php | 38 -- .../beans-post-meta/renderMetaboxContent.php | 46 -- .../post-meta/beans-post-meta/renderNonce.php | 41 -- .../api/post-meta/beans-post-meta/save.php | 55 -- .../beans-post-meta/saveAttachment.php | 46 -- .../api/post-meta/beansGetPostMeta.php | 75 --- .../post-meta/beansIsPostMetaConditions.php | 166 ------ .../beansPostMetaPageTemplateReload.php | 71 --- .../api/post-meta/beansRegisterPostMeta.php | 78 --- .../api/post-meta/fixtures/test-fields.php | 39 -- .../includes/class-post-meta-test-case.php | 31 -- .../api/template/beansLoadDefaultTemplate.php | 77 --- .../api/template/beansLoadFragmentFile.php | 61 --- .../term-meta/beans-term-meta/construct.php | 48 -- .../api/term-meta/beans-term-meta/delete.php | 42 -- .../beans-term-meta/renderFields.php | 118 ---- .../term-meta/beans-term-meta/renderNonce.php | 41 -- .../api/term-meta/beans-term-meta/save.php | 63 --- .../api/term-meta/beansGetTermMeta.php | 84 --- .../api/term-meta/beansRegisterTermMeta.php | 73 --- .../fixtures/test-field-output-html.php | 55 -- .../api/term-meta/fixtures/test-fields.php | 38 -- .../includes/class-term-meta-test-case.php | 36 -- .../api/uikit/beans-uikit/compile.php | 280 ---------- .../uikit/beansUikitAutoloadDependencies.php | 67 --- .../api/uikit/beansUikitEnqueueAssets.php | 118 ---- .../api/uikit/beansUikitEnqueueComponents.php | 173 ------ .../api/uikit/beansUikitEnqueueTheme.php | 75 --- .../api/uikit/beansUikitRegisterTheme.php | 43 -- .../api/uikit/fixtures/less/alert.less | 20 - .../api/uikit/fixtures/less/close.less | 17 - .../api/uikit/fixtures/less/panel.less | 25 - .../api/uikit/fixtures/less/uikit.less | 5 - .../api/uikit/fixtures/less/variables.less | 68 --- .../uikit/includes/class-uikit-test-case.php | 171 ------ .../api/widget/beansDeregisterWidgetArea.php | 39 -- .../api/widget/beansForceTheWidget.php | 62 --- .../integration/api/widget/beansGetWidget.php | 49 -- .../api/widget/beansGetWidgetArea.php | 68 --- .../api/widget/beansGetWidgetAreaOutput.php | 55 -- .../api/widget/beansHasWidgetArea.php | 49 -- .../api/widget/beansHaveWidgets.php | 63 --- .../api/widget/beansIsActiveWidgetArea.php | 46 -- .../api/widget/beansPrepareWidgetData.php | 44 -- .../api/widget/beansRegisterWidgetArea.php | 53 -- .../api/widget/beansSetupWidget.php | 63 --- .../api/widget/beansSetupWidgetArea.php | 48 -- .../api/widget/beansSetupWidgets.php | 61 --- .../api/widget/beansWidgetAreaShortcodes.php | 47 -- .../api/widget/beansWidgetAreaSubfilters.php | 35 -- .../api/widget/beansWidgetShortcodes.php | 47 -- .../api/widget/beansWidgetSubfilters.php | 36 -- .../includes/class-beans-widget-test-case.php | 70 --- .../wp-customize/beans-wp-customize/add.php | 67 --- .../beansRegisterWPCustomizeOptions.php | 103 ---- .../api/wp-customize/fixtures/test-fields.php | 90 --- .../includes/class-wp-customize-test-case.php | 104 ---- tests/phpunit/integration/bootstrap.php | 76 --- tests/phpunit/integration/class-test-case.php | 52 -- tests/phpunit/integration/phpunit.xml.dist | 22 - tests/phpunit/test-case-trait.php | 118 ---- .../beans-anonymous-action/__construct.php | 59 -- .../beans-anonymous-action/callback.php | 76 --- .../unit/api/actions/beansAddAction.php | 263 --------- .../api/actions/beansBuildActionArray.php | 143 ----- .../unit/api/actions/beansGetAction.php | 137 ----- .../api/actions/beansGetCurrentAction.php | 128 ----- .../unit/api/actions/beansMergeAction.php | 87 --- .../unit/api/actions/beansModifyAction.php | 214 -------- .../actions/beansModifyActionArguments.php | 40 -- .../api/actions/beansModifyActionCallback.php | 52 -- .../api/actions/beansModifyActionHook.php | 53 -- .../api/actions/beansModifyActionPriority.php | 40 -- .../unit/api/actions/beansRemoveAction.php | 87 --- .../unit/api/actions/beansRenderAction.php | 219 -------- .../unit/api/actions/beansReplaceAction.php | 188 ------- .../actions/beansReplaceActionArguments.php | 40 -- .../actions/beansReplaceActionCallback.php | 52 -- .../api/actions/beansReplaceActionHook.php | 53 -- .../actions/beansReplaceActionPriority.php | 40 -- .../unit/api/actions/beansResetAction.php | 153 ------ .../unit/api/actions/beansSetAction.php | 127 ----- .../unit/api/actions/beansSmartAddAction.php | 40 -- .../unit/api/actions/beansUniqueActionId.php | 116 ---- .../unit/api/actions/beansUnsetAction.php | 103 ---- .../api/actions/fixtures/test-actions.php | 29 - .../includes/class-actions-test-case.php | 119 ---- .../class-replace-action-test-case.php | 33 -- .../api/actions/stubs/class-action-stub.php | 41 -- .../compiler/beans-compiler-options/flush.php | 74 --- .../beans-compiler-options/register.php | 162 ------ .../renderFlushButton.php | 52 -- .../renderScriptsNotCompiledNotice.php | 81 --- .../renderStylesNotCompiledNotice.php | 81 --- .../renderSuccessNotice.php | 62 --- .../beans-compiler/addContentMediaQuery.php | 131 ----- .../api/compiler/beans-compiler/cacheFile.php | 188 ------- .../beans-compiler/cacheFileExist.php | 83 --- .../beans-compiler/combineFragments.php | 315 ----------- .../compiler/beans-compiler/filesystem.php | 44 -- .../compiler/beans-compiler/formatContent.php | 260 --------- .../unit/api/compiler/beans-compiler/get.php | 119 ---- .../compiler/beans-compiler/getExtension.php | 59 -- .../beans-compiler/getFunctionContent.php | 74 --- .../beans-compiler/getInternalContent.php | 83 --- .../beans-compiler/getRemoteContent.php | 243 --------- .../compiler/beans-compiler/replaceCssUrl.php | 199 ------- .../compiler/beans-compiler/runCompiler.php | 427 --------------- .../compiler/beans-compiler/setFilename.php | 140 ----- .../compiler/beans-compiler/setFragments.php | 127 ----- .../compilePageScripts.php | 387 ------------- .../beans-page-compiler/compilePageStyles.php | 406 -------------- .../beans-page-compiler/dequeueScripts.php | 216 -------- .../beansAddCompilerOptionsToSettings.php | 32 -- .../api/compiler/beansCompileCssFragments.php | 33 -- .../api/compiler/beansCompileJsFragments.php | 36 -- .../compiler/beansCompileLessFragments.php | 33 -- .../api/compiler/beansCompilerAddFragment.php | 92 ---- .../unit/api/compiler/beansFlushCompiler.php | 165 ------ .../unit/api/compiler/beansGetCompilerDir.php | 45 -- .../unit/api/compiler/beansGetCompilerUrl.php | 44 -- .../unit/api/compiler/fixtures/jquery.test.js | 29 - .../api/compiler/fixtures/my-game-clock.js | 21 - .../unit/api/compiler/fixtures/style.css | 16 - .../unit/api/compiler/fixtures/test.less | 7 - .../unit/api/compiler/fixtures/variables.less | 8 - .../includes/class-base-test-case.php | 101 ---- .../class-compiler-options-test-case.php | 34 -- .../includes/class-compiler-test-case.php | 333 ------------ .../class-page-compiler-test-case.php | 54 -- .../unit/api/fields/beansGetFields.php | 44 -- .../api/fields/beansPreStandardizeFields.php | 55 -- .../unit/api/fields/beansRegisterFields.php | 56 -- .../unit/api/fields/fixtures/test-fields.php | 80 --- .../includes/class-fields-test-case.php | 130 ----- .../api/fields/types/beansFieldActivation.php | 85 --- .../api/fields/types/beansFieldCheckbox.php | 112 ---- .../unit/api/fields/types/beansFieldImage.php | 203 ------- .../unit/api/fields/types/beansFieldRadio.php | 144 ----- .../api/fields/types/beansFieldSelect.php | 95 ---- .../api/fields/types/beansFieldSlider.php | 162 ------ .../unit/api/fields/types/beansFieldText.php | 83 --- .../api/fields/types/beansFieldTextarea.php | 83 --- .../api/fields/types/beansGetImageAlt.php | 71 --- .../api/fields/types/beansGetImageUrl.php | 76 --- .../api/fields/types/beansIsRadioImage.php | 90 --- .../types/beansStandardizeRadioImage.php | 136 ----- .../beans-anonymous-filters/_construct.php | 56 -- .../unit/api/filters/beansAddFilter.php | 74 --- .../unit/api/filters/beansApplyFilters.php | 148 ----- .../unit/api/filters/beansHasFilters.php | 57 -- .../api/filters/fixtures/test-filters.php | 41 -- .../includes/class-filters-test-case.php | 82 --- .../unit/api/html/beans-attribute/add.php | 75 --- .../unit/api/html/beans-attribute/init.php | 47 -- .../unit/api/html/beans-attribute/remove.php | 108 ---- .../unit/api/html/beans-attribute/replace.php | 120 ---- .../unit/api/html/beansAddAttributes.php | 93 ---- .../unit/api/html/beansBuildSkipLinks.php | 69 --- .../unit/api/html/beansCloseMarkup.php | 135 ----- .../unit/api/html/beansCloseMarkupE.php | 80 --- .../unit/api/html/beansIsHtmlDevMode.php | 68 --- .../unit/api/html/beansModifyMarkup.php | 59 -- .../phpunit/unit/api/html/beansOpenMarkup.php | 212 -------- .../unit/api/html/beansOpenMarkupE.php | 54 -- tests/phpunit/unit/api/html/beansOutput.php | 118 ---- tests/phpunit/unit/api/html/beansOutputE.php | 114 ---- .../unit/api/html/beansRemoveMarkup.php | 64 --- .../unit/api/html/beansRemoveOutput.php | 69 --- .../unit/api/html/beansSelfcloseMarkup.php | 60 -- .../unit/api/html/beansSelfcloseMarkupE.php | 45 -- .../unit/api/html/beansWrapInnerMarkup.php | 180 ------ .../phpunit/unit/api/html/beansWrapMarkup.php | 180 ------ .../fixtures/class-anonymous-action-stub.php | 45 -- .../fixtures/class-anonymous-filter-stub.php | 45 -- .../api/html/fixtures/test-attachment.php | 50 -- .../unit/api/html/fixtures/test-markup.php | 64 --- .../html/includes/class-html-test-case.php | 106 ---- .../beans-image-editor/createEditedImage.php | 101 ---- .../unit/api/image/beans-image-editor/run.php | 355 ------------ .../api/image/beans-image-options/flush.php | 74 --- .../image/beans-image-options/register.php | 94 ---- .../beans-image-options/renderFlushButton.php | 51 -- .../renderSuccessNotice.php | 61 --- .../unit/api/image/beansGetImagesDir.php | 45 -- .../unit/api/image/fixtures/image1.jpg | Bin 31016 -> 0 bytes .../unit/api/image/fixtures/image2.jpg | Bin 31429 -> 0 bytes .../image/includes/class-base-test-case.php | 84 --- .../image/includes/class-image-test-case.php | 139 ----- .../includes/class-options-test-case.php | 32 -- .../unit/api/layout/beansGetDefaultLayout.php | 67 --- .../unit/api/layout/beansGetLayout.php | 196 ------- .../unit/api/layout/beansGetLayoutClass.php | 377 ------------- .../api/layout/beansHasPrimarySidebar.php | 66 --- .../api/layout/beansHasSecondarySidebar.php | 66 --- .../api/options/beans-options/register.php | 87 --- .../options/beans-options/renderMetabox.php | 64 --- .../api/options/beans-options/renderPage.php | 120 ---- .../beans-options/renderRenderNotice.php | 66 --- .../beans-options/renderSaveNotice.php | 66 --- .../api/options/fixtures/test-options.php | 91 ---- .../includes/class-options-test-case.php | 93 ---- .../post-meta/beans-post-meta/okToSave.php | 72 --- .../beans-post-meta/registerMetabox.php | 57 -- .../beans-post-meta/renderMetaboxContent.php | 56 -- .../post-meta/beans-post-meta/renderNonce.php | 41 -- .../api/post-meta/beans-post-meta/save.php | 65 --- .../beans-post-meta/saveAttachment.php | 57 -- .../unit/api/post-meta/beansGetPostMeta.php | 121 ----- .../post-meta/beansIsPostMetaConditions.php | 169 ------ .../beansPostMetaPageTemplateReload.php | 71 --- .../api/post-meta/beansRegisterPostMeta.php | 95 ---- .../includes/class-post-meta-test-case.php | 38 -- .../api/template/beansLoadDefaultTemplate.php | 73 --- .../api/template/beansLoadFragmentFile.php | 71 --- .../includes/class-template-test-case.php | 79 --- .../beans-term-meta/renderFields.php | 73 --- .../term-meta/beans-term-meta/renderNonce.php | 44 -- .../api/term-meta/beans-term-meta/save.php | 107 ---- .../unit/api/term-meta/beansGetTermMeta.php | 104 ---- .../unit/api/term-meta/beansIsAdminTerm.php | 69 --- .../api/term-meta/beansRegisterTermMeta.php | 101 ---- .../api/term-meta/fixtures/test-fields.php | 17 - .../includes/class-term-meta-test-case.php | 56 -- .../unit/api/uikit/beans-uikit/compile.php | 150 ----- .../uikit/beans-uikit/getAllComponents.php | 138 ----- .../beans-uikit/getAutoloadComponents.php | 288 ---------- .../getComponentsFromDirectory.php | 224 -------- .../uikit/beans-uikit/getJsDirectories.php | 55 -- .../uikit/beans-uikit/getLessDirectories.php | 94 ---- .../beans-uikit/registerJsComponents.php | 135 ----- .../beans-uikit/registerLessComponents.php | 142 ----- .../unit/api/uikit/beans-uikit/toFilename.php | 100 ---- .../api/uikit/beansUikitDequeueComponents.php | 176 ------ .../unit/api/uikit/beansUikitDequeueTheme.php | 59 -- .../api/uikit/beansUikitEnqueueComponents.php | 254 --------- .../unit/api/uikit/beansUikitEnqueueTheme.php | 102 ---- .../api/uikit/beansUikitGetAllComponents.php | 137 ----- .../uikit/beansUikitGetAllDependencies.php | 261 --------- .../uikit/beansUikitGetRegisteredTheme.php | 55 -- .../api/uikit/beansUikitRegisterTheme.php | 101 ---- .../uikit/includes/class-uikit-test-case.php | 149 ----- .../unit/api/utilities/beansArrayUnique.php | 95 ---- tests/phpunit/unit/api/utilities/beansGet.php | 119 ---- .../phpunit/unit/api/utilities/beansIsUri.php | 74 --- .../phpunit/unit/api/utilities/beansIsUrl.php | 74 --- .../unit/api/utilities/beansJoinArrays.php | 123 ----- .../api/utilities/beansJoinArraysClean.php | 123 ----- .../utilities/beansMultiArrayKeyExists.php | 134 ----- .../unit/api/utilities/beansPathToUrl.php | 375 ------------- .../unit/api/utilities/beansRemoveDir.php | 118 ---- .../api/utilities/beansRenderFunction.php | 80 --- .../utilities/beansRenderFunctionArray.php | 91 ---- .../unit/api/utilities/beansSanitizePath.php | 110 ---- .../unit/api/utilities/beansScandir.php | 60 -- .../unit/api/utilities/beansStrEndsWith.php | 124 ----- .../unit/api/utilities/beansStrStartsWith.php | 144 ----- .../unit/api/utilities/beansUrlToPath.php | 377 ------------- .../api/widget/beansDeregisterWidgetArea.php | 37 -- .../unit/api/widget/beansForceTheWidget.php | 78 --- .../unit/api/widget/beansGetWidget.php | 77 --- .../unit/api/widget/beansGetWidgetArea.php | 81 --- .../api/widget/beansGetWidgetAreaOutput.php | 62 --- .../unit/api/widget/beansHasWidgetArea.php | 49 -- .../unit/api/widget/beansHaveWidgets.php | 88 --- .../api/widget/beansIsActiveWidgetArea.php | 49 -- .../api/widget/beansPrepareWidgetData.php | 50 -- .../api/widget/beansRegisterWidgetArea.php | 83 --- .../unit/api/widget/beansResetWidget.php | 51 -- .../unit/api/widget/beansResetWidgetArea.php | 45 -- .../unit/api/widget/beansSetupWidget.php | 77 --- .../unit/api/widget/beansSetupWidgetArea.php | 68 --- .../unit/api/widget/beansSetupWidgets.php | 110 ---- .../api/widget/beansWidgetAreaShortcodes.php | 82 --- .../api/widget/beansWidgetAreaSubfilters.php | 36 -- .../unit/api/widget/beansWidgetShortcodes.php | 82 --- .../unit/api/widget/beansWidgetSubfilters.php | 40 -- .../includes/class-beans-widget-test-case.php | 35 -- .../wp-customize/beans-wp-customize/add.php | 57 -- .../beans-wp-customize/add_control.php | 54 -- .../beans-wp-customize/add_group_setting.php | 81 --- .../beans-wp-customize/add_section.php | 52 -- .../beans-wp-customize/add_setting.php | 56 -- .../beansRegisterWPCustomizeOptions.php | 127 ----- .../api/wp-customize/fixtures/test-fields.php | 96 ---- .../includes/class-wp-customize-test-case.php | 94 ---- tests/phpunit/unit/bootstrap.php | 26 - tests/phpunit/unit/class-test-case.php | 97 ---- 431 files changed, 42551 deletions(-) delete mode 100644 .dev-lib delete mode 100644 .editorconfig delete mode 100644 .gitattributes delete mode 100644 .travis.yml delete mode 100755 bin/install-pre-commit-hook.sh delete mode 100755 bin/pre-commit delete mode 100644 bin/travis.sh delete mode 100644 phpcs.xml.dist delete mode 100644 phpunit.xml.dist delete mode 100644 tests/phpunit/class-beans-resetter.php delete mode 100644 tests/phpunit/functions.php delete mode 100644 tests/phpunit/integration/api/actions/beansAddAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansAddAnonymousAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansGetAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansGetCurrentAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansMergeAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansModifyAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansModifyActionArguments.php delete mode 100644 tests/phpunit/integration/api/actions/beansModifyActionCallback.php delete mode 100644 tests/phpunit/integration/api/actions/beansModifyActionHook.php delete mode 100644 tests/phpunit/integration/api/actions/beansModifyActionPriority.php delete mode 100644 tests/phpunit/integration/api/actions/beansRemoveAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansReplaceAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansReplaceActionArguments.php delete mode 100644 tests/phpunit/integration/api/actions/beansReplaceActionCallback.php delete mode 100644 tests/phpunit/integration/api/actions/beansReplaceActionHook.php delete mode 100644 tests/phpunit/integration/api/actions/beansReplaceActionPriority.php delete mode 100644 tests/phpunit/integration/api/actions/beansResetAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansSetAction.php delete mode 100644 tests/phpunit/integration/api/actions/beansUnsetAction.php delete mode 100644 tests/phpunit/integration/api/actions/fixtures/test-actions.php delete mode 100644 tests/phpunit/integration/api/actions/includes/class-actions-test-case.php delete mode 100644 tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler-options/flush.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler-options/register.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler-options/renderFlushButton.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler-options/renderScriptsNotCompiledNotice.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler-options/renderSuccessNotice.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php delete mode 100644 tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php delete mode 100644 tests/phpunit/integration/api/compiler/beansCompileCssFragments.php delete mode 100644 tests/phpunit/integration/api/compiler/beansCompileJsFragments.php delete mode 100644 tests/phpunit/integration/api/compiler/beansCompileLessFragments.php delete mode 100644 tests/phpunit/integration/api/compiler/beansFlushCompiler.php delete mode 100644 tests/phpunit/integration/api/compiler/beansGetCompilerDir.php delete mode 100644 tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php delete mode 100644 tests/phpunit/integration/api/compiler/fixtures/jquery.test.js delete mode 100644 tests/phpunit/integration/api/compiler/fixtures/my-game-clock.js delete mode 100644 tests/phpunit/integration/api/compiler/fixtures/style.css delete mode 100644 tests/phpunit/integration/api/compiler/fixtures/test.less delete mode 100644 tests/phpunit/integration/api/compiler/fixtures/variables.less delete mode 100644 tests/phpunit/integration/api/compiler/includes/class-base-test-case.php delete mode 100644 tests/phpunit/integration/api/compiler/includes/class-compiler-options-test-case.php delete mode 100644 tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php delete mode 100644 tests/phpunit/integration/api/compiler/includes/class-page-compiler-test-case.php delete mode 100644 tests/phpunit/integration/api/fields/beansField.php delete mode 100644 tests/phpunit/integration/api/fields/beansGetFields.php delete mode 100644 tests/phpunit/integration/api/fields/beansPreStandardizeFields.php delete mode 100644 tests/phpunit/integration/api/fields/beansRegisterFields.php delete mode 100644 tests/phpunit/integration/api/fields/fixtures/test-fields.php delete mode 100644 tests/phpunit/integration/api/fields/includes/class-fields-test-case.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldActivation.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldDescription.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldImage.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldLabel.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldRadio.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldSelect.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldSlider.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldText.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansFieldTextarea.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansGetImageAlt.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansGetImageUrl.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansIsRadioImage.php delete mode 100644 tests/phpunit/integration/api/fields/types/beansStandardizeRadioImage.php delete mode 100644 tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php delete mode 100644 tests/phpunit/integration/api/filters/beansAddFilter.php delete mode 100644 tests/phpunit/integration/api/filters/beansApplyFilters.php delete mode 100644 tests/phpunit/integration/api/filters/beansHasFilters.php delete mode 100644 tests/phpunit/integration/api/filters/fixtures/test-filters.php delete mode 100644 tests/phpunit/integration/api/filters/includes/class-filters-test-case.php delete mode 100644 tests/phpunit/integration/api/html/beans-attribute/init.php delete mode 100644 tests/phpunit/integration/api/html/beansAddAttribute.php delete mode 100644 tests/phpunit/integration/api/html/beansAddAttributes.php delete mode 100644 tests/phpunit/integration/api/html/beansBuildSkipLinks.php delete mode 100644 tests/phpunit/integration/api/html/beansCloseMarkup.php delete mode 100644 tests/phpunit/integration/api/html/beansCloseMarkupE.php delete mode 100644 tests/phpunit/integration/api/html/beansIsHtmlDevMode.php delete mode 100644 tests/phpunit/integration/api/html/beansModifyMarkup.php delete mode 100644 tests/phpunit/integration/api/html/beansOpenMarkup.php delete mode 100644 tests/phpunit/integration/api/html/beansOpenMarkupE.php delete mode 100644 tests/phpunit/integration/api/html/beansOutput.php delete mode 100644 tests/phpunit/integration/api/html/beansOutputE.php delete mode 100644 tests/phpunit/integration/api/html/beansRemoveAttribute.php delete mode 100644 tests/phpunit/integration/api/html/beansRemoveMarkup.php delete mode 100644 tests/phpunit/integration/api/html/beansRemoveOutput.php delete mode 100644 tests/phpunit/integration/api/html/beansReplaceAttribute.php delete mode 100644 tests/phpunit/integration/api/html/beansResetMarkup.php delete mode 100644 tests/phpunit/integration/api/html/beansSelfcloseMarkup.php delete mode 100644 tests/phpunit/integration/api/html/beansSelfcloseMarkupE.php delete mode 100644 tests/phpunit/integration/api/html/beansWrapInnerMarkup.php delete mode 100644 tests/phpunit/integration/api/html/beansWrapMarkup.php delete mode 100644 tests/phpunit/integration/api/html/fixtures/test-attachment.php delete mode 100644 tests/phpunit/integration/api/html/fixtures/test-markup.php delete mode 100644 tests/phpunit/integration/api/html/includes/class-html-test-case.php delete mode 100644 tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php delete mode 100644 tests/phpunit/integration/api/image/beans-image-editor/run.php delete mode 100644 tests/phpunit/integration/api/image/beans-image-options/flush.php delete mode 100644 tests/phpunit/integration/api/image/beans-image-options/register.php delete mode 100644 tests/phpunit/integration/api/image/beans-image-options/renderFlushButton.php delete mode 100644 tests/phpunit/integration/api/image/beans-image-options/renderSuccessNotice.php delete mode 100644 tests/phpunit/integration/api/image/beansEditImage.php delete mode 100644 tests/phpunit/integration/api/image/beansGetImagesDir.php delete mode 100644 tests/phpunit/integration/api/image/fixtures/image1.jpg delete mode 100644 tests/phpunit/integration/api/image/fixtures/image2.jpg delete mode 100644 tests/phpunit/integration/api/image/includes/class-base-test-case.php delete mode 100644 tests/phpunit/integration/api/image/includes/class-image-test-case.php delete mode 100644 tests/phpunit/integration/api/image/includes/class-options-test-case.php delete mode 100644 tests/phpunit/integration/api/layout/beansGetDefaultLayout.php delete mode 100644 tests/phpunit/integration/api/layout/beansGetLayout.php delete mode 100644 tests/phpunit/integration/api/layout/beansGetLayoutClass.php delete mode 100644 tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php delete mode 100644 tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php delete mode 100644 tests/phpunit/integration/api/options/beans-options/processActions.php delete mode 100644 tests/phpunit/integration/api/options/beans-options/register.php delete mode 100644 tests/phpunit/integration/api/options/beans-options/renderMetabox.php delete mode 100644 tests/phpunit/integration/api/options/beans-options/renderPage.php delete mode 100644 tests/phpunit/integration/api/options/fixtures/test-options.php delete mode 100644 tests/phpunit/integration/api/options/includes/class-options-test-case.php delete mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php delete mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php delete mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php delete mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php delete mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php delete mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/save.php delete mode 100644 tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php delete mode 100644 tests/phpunit/integration/api/post-meta/beansGetPostMeta.php delete mode 100644 tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php delete mode 100644 tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php delete mode 100644 tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php delete mode 100644 tests/phpunit/integration/api/post-meta/fixtures/test-fields.php delete mode 100644 tests/phpunit/integration/api/post-meta/includes/class-post-meta-test-case.php delete mode 100644 tests/phpunit/integration/api/template/beansLoadDefaultTemplate.php delete mode 100644 tests/phpunit/integration/api/template/beansLoadFragmentFile.php delete mode 100644 tests/phpunit/integration/api/term-meta/beans-term-meta/construct.php delete mode 100644 tests/phpunit/integration/api/term-meta/beans-term-meta/delete.php delete mode 100644 tests/phpunit/integration/api/term-meta/beans-term-meta/renderFields.php delete mode 100644 tests/phpunit/integration/api/term-meta/beans-term-meta/renderNonce.php delete mode 100644 tests/phpunit/integration/api/term-meta/beans-term-meta/save.php delete mode 100644 tests/phpunit/integration/api/term-meta/beansGetTermMeta.php delete mode 100644 tests/phpunit/integration/api/term-meta/beansRegisterTermMeta.php delete mode 100644 tests/phpunit/integration/api/term-meta/fixtures/test-field-output-html.php delete mode 100644 tests/phpunit/integration/api/term-meta/fixtures/test-fields.php delete mode 100644 tests/phpunit/integration/api/term-meta/includes/class-term-meta-test-case.php delete mode 100644 tests/phpunit/integration/api/uikit/beans-uikit/compile.php delete mode 100644 tests/phpunit/integration/api/uikit/beansUikitAutoloadDependencies.php delete mode 100644 tests/phpunit/integration/api/uikit/beansUikitEnqueueAssets.php delete mode 100644 tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php delete mode 100644 tests/phpunit/integration/api/uikit/beansUikitEnqueueTheme.php delete mode 100644 tests/phpunit/integration/api/uikit/beansUikitRegisterTheme.php delete mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/alert.less delete mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/close.less delete mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/panel.less delete mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/uikit.less delete mode 100755 tests/phpunit/integration/api/uikit/fixtures/less/variables.less delete mode 100644 tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php delete mode 100644 tests/phpunit/integration/api/widget/beansDeregisterWidgetArea.php delete mode 100644 tests/phpunit/integration/api/widget/beansForceTheWidget.php delete mode 100644 tests/phpunit/integration/api/widget/beansGetWidget.php delete mode 100644 tests/phpunit/integration/api/widget/beansGetWidgetArea.php delete mode 100644 tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php delete mode 100644 tests/phpunit/integration/api/widget/beansHasWidgetArea.php delete mode 100644 tests/phpunit/integration/api/widget/beansHaveWidgets.php delete mode 100644 tests/phpunit/integration/api/widget/beansIsActiveWidgetArea.php delete mode 100644 tests/phpunit/integration/api/widget/beansPrepareWidgetData.php delete mode 100644 tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php delete mode 100644 tests/phpunit/integration/api/widget/beansSetupWidget.php delete mode 100644 tests/phpunit/integration/api/widget/beansSetupWidgetArea.php delete mode 100644 tests/phpunit/integration/api/widget/beansSetupWidgets.php delete mode 100644 tests/phpunit/integration/api/widget/beansWidgetAreaShortcodes.php delete mode 100644 tests/phpunit/integration/api/widget/beansWidgetAreaSubfilters.php delete mode 100644 tests/phpunit/integration/api/widget/beansWidgetShortcodes.php delete mode 100644 tests/phpunit/integration/api/widget/beansWidgetSubfilters.php delete mode 100644 tests/phpunit/integration/api/widget/includes/class-beans-widget-test-case.php delete mode 100644 tests/phpunit/integration/api/wp-customize/beans-wp-customize/add.php delete mode 100644 tests/phpunit/integration/api/wp-customize/beansRegisterWPCustomizeOptions.php delete mode 100644 tests/phpunit/integration/api/wp-customize/fixtures/test-fields.php delete mode 100644 tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php delete mode 100644 tests/phpunit/integration/bootstrap.php delete mode 100644 tests/phpunit/integration/class-test-case.php delete mode 100644 tests/phpunit/integration/phpunit.xml.dist delete mode 100644 tests/phpunit/test-case-trait.php delete mode 100644 tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php delete mode 100644 tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php delete mode 100644 tests/phpunit/unit/api/actions/beansAddAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansBuildActionArray.php delete mode 100644 tests/phpunit/unit/api/actions/beansGetAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansGetCurrentAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansMergeAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansModifyAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansModifyActionArguments.php delete mode 100644 tests/phpunit/unit/api/actions/beansModifyActionCallback.php delete mode 100644 tests/phpunit/unit/api/actions/beansModifyActionHook.php delete mode 100644 tests/phpunit/unit/api/actions/beansModifyActionPriority.php delete mode 100644 tests/phpunit/unit/api/actions/beansRemoveAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansRenderAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansReplaceAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansReplaceActionArguments.php delete mode 100644 tests/phpunit/unit/api/actions/beansReplaceActionCallback.php delete mode 100644 tests/phpunit/unit/api/actions/beansReplaceActionHook.php delete mode 100644 tests/phpunit/unit/api/actions/beansReplaceActionPriority.php delete mode 100644 tests/phpunit/unit/api/actions/beansResetAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansSetAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansSmartAddAction.php delete mode 100644 tests/phpunit/unit/api/actions/beansUniqueActionId.php delete mode 100644 tests/phpunit/unit/api/actions/beansUnsetAction.php delete mode 100644 tests/phpunit/unit/api/actions/fixtures/test-actions.php delete mode 100644 tests/phpunit/unit/api/actions/includes/class-actions-test-case.php delete mode 100644 tests/phpunit/unit/api/actions/includes/class-replace-action-test-case.php delete mode 100644 tests/phpunit/unit/api/actions/stubs/class-action-stub.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler-options/flush.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler-options/register.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler-options/renderFlushButton.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler-options/renderScriptsNotCompiledNotice.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler-options/renderSuccessNotice.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/filesystem.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/get.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/getExtension.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/getFunctionContent.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/replaceCssUrl.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/setFilename.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-compiler/setFragments.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php delete mode 100644 tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php delete mode 100644 tests/phpunit/unit/api/compiler/beansAddCompilerOptionsToSettings.php delete mode 100644 tests/phpunit/unit/api/compiler/beansCompileCssFragments.php delete mode 100644 tests/phpunit/unit/api/compiler/beansCompileJsFragments.php delete mode 100644 tests/phpunit/unit/api/compiler/beansCompileLessFragments.php delete mode 100644 tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php delete mode 100644 tests/phpunit/unit/api/compiler/beansFlushCompiler.php delete mode 100644 tests/phpunit/unit/api/compiler/beansGetCompilerDir.php delete mode 100644 tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php delete mode 100644 tests/phpunit/unit/api/compiler/fixtures/jquery.test.js delete mode 100644 tests/phpunit/unit/api/compiler/fixtures/my-game-clock.js delete mode 100644 tests/phpunit/unit/api/compiler/fixtures/style.css delete mode 100644 tests/phpunit/unit/api/compiler/fixtures/test.less delete mode 100644 tests/phpunit/unit/api/compiler/fixtures/variables.less delete mode 100644 tests/phpunit/unit/api/compiler/includes/class-base-test-case.php delete mode 100644 tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php delete mode 100644 tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php delete mode 100644 tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php delete mode 100644 tests/phpunit/unit/api/fields/beansGetFields.php delete mode 100644 tests/phpunit/unit/api/fields/beansPreStandardizeFields.php delete mode 100644 tests/phpunit/unit/api/fields/beansRegisterFields.php delete mode 100644 tests/phpunit/unit/api/fields/fixtures/test-fields.php delete mode 100644 tests/phpunit/unit/api/fields/includes/class-fields-test-case.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansFieldActivation.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansFieldImage.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansFieldRadio.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansFieldSelect.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansFieldSlider.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansFieldText.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansFieldTextarea.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansGetImageAlt.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansGetImageUrl.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansIsRadioImage.php delete mode 100644 tests/phpunit/unit/api/fields/types/beansStandardizeRadioImage.php delete mode 100644 tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php delete mode 100644 tests/phpunit/unit/api/filters/beansAddFilter.php delete mode 100644 tests/phpunit/unit/api/filters/beansApplyFilters.php delete mode 100644 tests/phpunit/unit/api/filters/beansHasFilters.php delete mode 100644 tests/phpunit/unit/api/filters/fixtures/test-filters.php delete mode 100644 tests/phpunit/unit/api/filters/includes/class-filters-test-case.php delete mode 100644 tests/phpunit/unit/api/html/beans-attribute/add.php delete mode 100644 tests/phpunit/unit/api/html/beans-attribute/init.php delete mode 100644 tests/phpunit/unit/api/html/beans-attribute/remove.php delete mode 100644 tests/phpunit/unit/api/html/beans-attribute/replace.php delete mode 100644 tests/phpunit/unit/api/html/beansAddAttributes.php delete mode 100644 tests/phpunit/unit/api/html/beansBuildSkipLinks.php delete mode 100644 tests/phpunit/unit/api/html/beansCloseMarkup.php delete mode 100644 tests/phpunit/unit/api/html/beansCloseMarkupE.php delete mode 100644 tests/phpunit/unit/api/html/beansIsHtmlDevMode.php delete mode 100644 tests/phpunit/unit/api/html/beansModifyMarkup.php delete mode 100644 tests/phpunit/unit/api/html/beansOpenMarkup.php delete mode 100644 tests/phpunit/unit/api/html/beansOpenMarkupE.php delete mode 100644 tests/phpunit/unit/api/html/beansOutput.php delete mode 100644 tests/phpunit/unit/api/html/beansOutputE.php delete mode 100644 tests/phpunit/unit/api/html/beansRemoveMarkup.php delete mode 100644 tests/phpunit/unit/api/html/beansRemoveOutput.php delete mode 100644 tests/phpunit/unit/api/html/beansSelfcloseMarkup.php delete mode 100644 tests/phpunit/unit/api/html/beansSelfcloseMarkupE.php delete mode 100644 tests/phpunit/unit/api/html/beansWrapInnerMarkup.php delete mode 100644 tests/phpunit/unit/api/html/beansWrapMarkup.php delete mode 100644 tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php delete mode 100644 tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php delete mode 100644 tests/phpunit/unit/api/html/fixtures/test-attachment.php delete mode 100644 tests/phpunit/unit/api/html/fixtures/test-markup.php delete mode 100644 tests/phpunit/unit/api/html/includes/class-html-test-case.php delete mode 100644 tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php delete mode 100644 tests/phpunit/unit/api/image/beans-image-editor/run.php delete mode 100644 tests/phpunit/unit/api/image/beans-image-options/flush.php delete mode 100644 tests/phpunit/unit/api/image/beans-image-options/register.php delete mode 100644 tests/phpunit/unit/api/image/beans-image-options/renderFlushButton.php delete mode 100644 tests/phpunit/unit/api/image/beans-image-options/renderSuccessNotice.php delete mode 100644 tests/phpunit/unit/api/image/beansGetImagesDir.php delete mode 100644 tests/phpunit/unit/api/image/fixtures/image1.jpg delete mode 100644 tests/phpunit/unit/api/image/fixtures/image2.jpg delete mode 100644 tests/phpunit/unit/api/image/includes/class-base-test-case.php delete mode 100644 tests/phpunit/unit/api/image/includes/class-image-test-case.php delete mode 100644 tests/phpunit/unit/api/image/includes/class-options-test-case.php delete mode 100644 tests/phpunit/unit/api/layout/beansGetDefaultLayout.php delete mode 100644 tests/phpunit/unit/api/layout/beansGetLayout.php delete mode 100644 tests/phpunit/unit/api/layout/beansGetLayoutClass.php delete mode 100644 tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php delete mode 100644 tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php delete mode 100644 tests/phpunit/unit/api/options/beans-options/register.php delete mode 100644 tests/phpunit/unit/api/options/beans-options/renderMetabox.php delete mode 100644 tests/phpunit/unit/api/options/beans-options/renderPage.php delete mode 100644 tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php delete mode 100644 tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php delete mode 100644 tests/phpunit/unit/api/options/fixtures/test-options.php delete mode 100644 tests/phpunit/unit/api/options/includes/class-options-test-case.php delete mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/okToSave.php delete mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/registerMetabox.php delete mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php delete mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/renderNonce.php delete mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/save.php delete mode 100644 tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php delete mode 100644 tests/phpunit/unit/api/post-meta/beansGetPostMeta.php delete mode 100644 tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php delete mode 100644 tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php delete mode 100644 tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php delete mode 100644 tests/phpunit/unit/api/post-meta/includes/class-post-meta-test-case.php delete mode 100644 tests/phpunit/unit/api/template/beansLoadDefaultTemplate.php delete mode 100644 tests/phpunit/unit/api/template/beansLoadFragmentFile.php delete mode 100644 tests/phpunit/unit/api/template/includes/class-template-test-case.php delete mode 100644 tests/phpunit/unit/api/term-meta/beans-term-meta/renderFields.php delete mode 100644 tests/phpunit/unit/api/term-meta/beans-term-meta/renderNonce.php delete mode 100644 tests/phpunit/unit/api/term-meta/beans-term-meta/save.php delete mode 100644 tests/phpunit/unit/api/term-meta/beansGetTermMeta.php delete mode 100644 tests/phpunit/unit/api/term-meta/beansIsAdminTerm.php delete mode 100644 tests/phpunit/unit/api/term-meta/beansRegisterTermMeta.php delete mode 100644 tests/phpunit/unit/api/term-meta/fixtures/test-fields.php delete mode 100644 tests/phpunit/unit/api/term-meta/includes/class-term-meta-test-case.php delete mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/compile.php delete mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getAllComponents.php delete mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getAutoloadComponents.php delete mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getComponentsFromDirectory.php delete mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getJsDirectories.php delete mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/getLessDirectories.php delete mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php delete mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php delete mode 100644 tests/phpunit/unit/api/uikit/beans-uikit/toFilename.php delete mode 100644 tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php delete mode 100644 tests/phpunit/unit/api/uikit/beansUikitDequeueTheme.php delete mode 100644 tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php delete mode 100644 tests/phpunit/unit/api/uikit/beansUikitEnqueueTheme.php delete mode 100644 tests/phpunit/unit/api/uikit/beansUikitGetAllComponents.php delete mode 100644 tests/phpunit/unit/api/uikit/beansUikitGetAllDependencies.php delete mode 100644 tests/phpunit/unit/api/uikit/beansUikitGetRegisteredTheme.php delete mode 100644 tests/phpunit/unit/api/uikit/beansUikitRegisterTheme.php delete mode 100644 tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php delete mode 100644 tests/phpunit/unit/api/utilities/beansArrayUnique.php delete mode 100644 tests/phpunit/unit/api/utilities/beansGet.php delete mode 100644 tests/phpunit/unit/api/utilities/beansIsUri.php delete mode 100644 tests/phpunit/unit/api/utilities/beansIsUrl.php delete mode 100644 tests/phpunit/unit/api/utilities/beansJoinArrays.php delete mode 100644 tests/phpunit/unit/api/utilities/beansJoinArraysClean.php delete mode 100644 tests/phpunit/unit/api/utilities/beansMultiArrayKeyExists.php delete mode 100644 tests/phpunit/unit/api/utilities/beansPathToUrl.php delete mode 100644 tests/phpunit/unit/api/utilities/beansRemoveDir.php delete mode 100644 tests/phpunit/unit/api/utilities/beansRenderFunction.php delete mode 100644 tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php delete mode 100644 tests/phpunit/unit/api/utilities/beansSanitizePath.php delete mode 100644 tests/phpunit/unit/api/utilities/beansScandir.php delete mode 100644 tests/phpunit/unit/api/utilities/beansStrEndsWith.php delete mode 100644 tests/phpunit/unit/api/utilities/beansStrStartsWith.php delete mode 100644 tests/phpunit/unit/api/utilities/beansUrlToPath.php delete mode 100644 tests/phpunit/unit/api/widget/beansDeregisterWidgetArea.php delete mode 100644 tests/phpunit/unit/api/widget/beansForceTheWidget.php delete mode 100644 tests/phpunit/unit/api/widget/beansGetWidget.php delete mode 100644 tests/phpunit/unit/api/widget/beansGetWidgetArea.php delete mode 100644 tests/phpunit/unit/api/widget/beansGetWidgetAreaOutput.php delete mode 100644 tests/phpunit/unit/api/widget/beansHasWidgetArea.php delete mode 100644 tests/phpunit/unit/api/widget/beansHaveWidgets.php delete mode 100644 tests/phpunit/unit/api/widget/beansIsActiveWidgetArea.php delete mode 100644 tests/phpunit/unit/api/widget/beansPrepareWidgetData.php delete mode 100644 tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php delete mode 100644 tests/phpunit/unit/api/widget/beansResetWidget.php delete mode 100644 tests/phpunit/unit/api/widget/beansResetWidgetArea.php delete mode 100644 tests/phpunit/unit/api/widget/beansSetupWidget.php delete mode 100644 tests/phpunit/unit/api/widget/beansSetupWidgetArea.php delete mode 100644 tests/phpunit/unit/api/widget/beansSetupWidgets.php delete mode 100644 tests/phpunit/unit/api/widget/beansWidgetAreaShortcodes.php delete mode 100644 tests/phpunit/unit/api/widget/beansWidgetAreaSubfilters.php delete mode 100644 tests/phpunit/unit/api/widget/beansWidgetShortcodes.php delete mode 100644 tests/phpunit/unit/api/widget/beansWidgetSubfilters.php delete mode 100644 tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php delete mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize/add.php delete mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_control.php delete mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_group_setting.php delete mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_section.php delete mode 100644 tests/phpunit/unit/api/wp-customize/beans-wp-customize/add_setting.php delete mode 100644 tests/phpunit/unit/api/wp-customize/beansRegisterWPCustomizeOptions.php delete mode 100644 tests/phpunit/unit/api/wp-customize/fixtures/test-fields.php delete mode 100644 tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php delete mode 100644 tests/phpunit/unit/bootstrap.php delete mode 100644 tests/phpunit/unit/class-test-case.php diff --git a/.dev-lib b/.dev-lib deleted file mode 100644 index 6ab05421..00000000 --- a/.dev-lib +++ /dev/null @@ -1,10 +0,0 @@ -PROJECT_TYPE=theme -WPCS_STANDARD=phpcs.xml.dist -PATH_EXCLUDES_PATTERN='^(.*/)?(vendors|vendor|node_modules)/.*' -DEV_LIB_SKIP=yuicompressor,codeception,grunt,jshint - -# Run integration tests when the DEV_LIB_ONLY is set to phpunit -# This is the only flag we can use to change the config file -if [ 'phpunit' == "$DEV_LIB_ONLY" ]; then - PHPUNIT_CONFIG=tests/phpunit/integration/phpunit.xml.dist -fi diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index c951f002..00000000 --- a/.editorconfig +++ /dev/null @@ -1,21 +0,0 @@ -# This file is for unifying the coding style for different editors and IDEs -# editorconfig.org - -# WordPress Coding Standards -# https://make.wordpress.org/core/handbook/coding-standards/ - -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = tab - -[{.jshintrc,*.json,*.yml}] -indent_style = space -indent_size = 2 - -[{*.txt,wp-config-sample.php}] -end_of_line = crlf \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 77324a07..00000000 --- a/.gitattributes +++ /dev/null @@ -1,11 +0,0 @@ -# Default behaviour -* text=auto - -# Text files -*.php eol=lf - -# Binary files -*.png binary -*.jpg binary -*.gif binary -*.ico binary diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9f650cdf..00000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: php -sudo: false - -cache: - directories: - node_modules - vendor - -php: - - 5.6 - - 7.2 - -env: - - WP_VERSION=latest WP_MULTISITE=0 - - WP_VERSION=latest WP_MULTISITE=1 - - WP_VERSION=trunk WP_MULTISITE=0 - - WP_VERSION=trunk WP_MULTISITE=1 - -install: - - composer install - - export DEV_LIB_PATH=vendor/xwp/wp-dev-lib - - source $DEV_LIB_PATH/travis.install.sh - -script: - - source bin/travis.sh - -after_script: - - source $DEV_LIB_PATH/travis.after_script.sh diff --git a/bin/install-pre-commit-hook.sh b/bin/install-pre-commit-hook.sh deleted file mode 100755 index d517cb30..00000000 --- a/bin/install-pre-commit-hook.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# Link pre-commit hook for a repo in the directory supplied as an argument, or the parent repo of this file. -# -# USAGES: -# $ /path/to/install-pre-commit-hook.sh -# $ /path/to/install-pre-commit-hook.sh wp-content/themes/my-theme - -set -e - -# Check if Perl is installed -command -v perl >/dev/null 2>&1 || { echo >&2 "Perl is not installed, and is required by this script. See how to install it on http://learn.perl.org/installing"; exit 1; } - -# Store the initial directory to return back to it later -OLDPWD=$(pwd) - -# Navigate to the script directory -cd "$(dirname $0)" - -# Get full path of the script directory -BINDIR=$(pwd) - -# Get back to the calling directory -cd - &> /dev/null - -# If passed a destination, switch to it to get the full path and then .git/hooks directory -if [ ! -z "$1" ]; then - cd $1 - DEST=$(pwd) -fi - -# Get the hooks directory of the current git repo -cd "$(git rev-parse --git-dir)/hooks" - -# Get relative path to the original file from within the hooks directory -RELPATH=$( perl -e 'use File::Spec; print File::Spec->abs2rel(@ARGV)' "$BINDIR/pre-commit" "$(pwd)" ) - -if [ -z "$RELPATH" ]; then - echo 'Could not determine the relative path, Sorry. Try symlinking the file manually.' - exit 1 -fi - -echo "## Placing pre-commit file in $(pwd) from $RELPATH" -ln -s "$RELPATH" . - -# Return back to the calling directory -cd "$OLDPWD" &> /dev/null diff --git a/bin/pre-commit b/bin/pre-commit deleted file mode 100755 index 0c7be46e..00000000 --- a/bin/pre-commit +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -DEV_LIB_HOOK_PATH='./vendor/xwp/wp-dev-lib/pre-commit' - -# Exit if the dev lib isn't installed -if [ ! -f $DEV_LIB_HOOK_PATH ]; then - echo "Oops, the Dev Library is not install, please run composer install!" -else - # Run sniffers and unit tests. - export PATH="./vendor/bin:$PATH" - export WP_TESTS_DIR='exclude' - $DEV_LIB_HOOK_PATH - - # Run integration tests. - export WP_TESTS_DIR='' - export DEV_LIB_ONLY=phpunit - $DEV_LIB_HOOK_PATH -fi diff --git a/bin/travis.sh b/bin/travis.sh deleted file mode 100644 index b7346ada..00000000 --- a/bin/travis.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -set -e - -export PATH="./vendor/bin:$PATH" - -# Exit if the dev lib isn't installed -if [ ! -f $DEV_LIB_TRAVIS_PATH ]; then - echo "Oops, the Dev Library is not install, please run composer install!" -else - echo "## Checking files, scope $CHECK_SCOPE:" - if [[ $CHECK_SCOPE != "all" ]]; then - cat "$TEMP_DIRECTORY/paths-scope" - fi - - # Run sniffers. - lint_js_files - lint_php_files - - # Run unit tests. - echo '## Running unit tests:' - phpunit --testsuite unit - - # Run integration tests. - echo '## Running integration tests:' - export PHPUNIT_CONFIG=tests/phpunit/integration/phpunit.xml.dist - run_phpunit_travisci -fi diff --git a/phpcs.xml.dist b/phpcs.xml.dist deleted file mode 100644 index fb049156..00000000 --- a/phpcs.xml.dist +++ /dev/null @@ -1,73 +0,0 @@ - - - The code standard for Beans. - - . - - - */dist/* - node_modules/* - */vendor/* - */vendors/* - - - - - - - - - - - - - - - */tests/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index 8ba026d7..00000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - ./tests/phpunit/unit/ - ./tests/phpunit/unit/*/*/fixtures/ - - - - - - . - ./tests/TestCase.php - - - diff --git a/tests/phpunit/class-beans-resetter.php b/tests/phpunit/class-beans-resetter.php deleted file mode 100644 index 3f189cbb..00000000 --- a/tests/phpunit/class-beans-resetter.php +++ /dev/null @@ -1,109 +0,0 @@ -reset_global_state(); - - // Reset APIs. - $this->reset_components(); - $this->reset_actions_api(); - $this->reset_compiler_api(); - $this->reset_fields_api(); - } - - /** - * Reset the global state. - */ - protected function reset_global_state() { - $_GET = []; - $_POST = []; - unset( $GLOBALS['current_screen'] ); - } - - /** - * Resets the Beans' API Components. - */ - protected function reset_components() { - - if ( ! function_exists( 'beans_get_component_support' ) ) { - return; - } - - global $_beans_api_components_support; - $_beans_api_components_support = []; - } - - /** - * Reset the Actions API. - */ - protected function reset_actions_api() { - global $_beans_registered_actions; - $_beans_registered_actions = [ - 'added' => [], - 'modified' => [], - 'removed' => [], - 'replaced' => [], - ]; - } - - /** - * Reset the Compiler API. - */ - protected function reset_compiler_api() { - global $_beans_compiler_added_fragments; - $_beans_compiler_added_fragments = [ - 'css' => [], - 'less' => [], - 'js' => [], - ]; - - unset( $GLOBALS['wp_filesystem'] ); - } - - /** - * Reset the Fields API. - */ - protected function reset_fields_api() { - - if ( ! class_exists( '_Beans_Fields' ) ) { - return; - } - - // Reset the "registered" container. - $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); - $registered->setValue( new _Beans_Fields(), [ - 'option' => [], - 'post_meta' => [], - 'term_meta' => [], - 'wp_customize' => [], - ] ); - - // Reset the other static properties. - foreach ( [ 'field_types_loaded', 'field_assets_hook_loaded' ] as $property_name ) { - $property = $this->get_reflective_property( $property_name, '_Beans_Fields' ); - $property->setValue( new _Beans_Fields(), [] ); - } - } -} diff --git a/tests/phpunit/functions.php b/tests/phpunit/functions.php deleted file mode 100644 index f7a839cf..00000000 --- a/tests/phpunit/functions.php +++ /dev/null @@ -1,99 +0,0 @@ -reset(); -} - -/** - * Gets the Bean's Resetter. - * - * @since 1.5.0 - * - * @return Beans_Resetter - */ -function get_beans_resetter() { - static $resetter; - - if ( is_null( $resetter ) ) { - require_once __DIR__ . '/class-beans-resetter.php'; - $resetter = new Beans_Resetter(); - } - - return $resetter; -} diff --git a/tests/phpunit/integration/api/actions/beansAddAction.php b/tests/phpunit/integration/api/actions/beansAddAction.php deleted file mode 100644 index 86ffda41..00000000 --- a/tests/phpunit/integration/api/actions/beansAddAction.php +++ /dev/null @@ -1,145 +0,0 @@ - $action ) { - // Test that the action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - - // Let's add it. - $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); - - // Now check that it was registered in Beans and WordPress. - $this->assertEquals( $action, _beans_get_action( $beans_id, 'added' ) ); - $this->check_registered_in_wp( $action['hook'], $action ); - } - } - - /** - * Test beans_add_action() should overwrite the action in both Beans and WordPress. - * - * This test makes sure nothing breaks if beans_add_action() is called more than once - * with the exact same set of conditions. - */ - public function test_should_overwrite_add_action_in_beans_and_wordpress() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Let's add it the first time. - $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); - - // Add it again. - $this->assertTrue( beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); - - // Now check that it's still registered in both Beans and WordPress. - $this->assertEquals( $action, _beans_get_action( $beans_id, 'added' ) ); - $this->check_registered_in_wp( $action['hook'], $action ); - } - } - - /** - * Test beans_add_action() should use the action configuration in "replaced" status, when it's available. - */ - public function test_should_use_replaced_action_when_available() { - $replaced_action = [ - 'callback' => 'my_new_callback', - 'priority' => 47, - ]; - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // We want to store the "replaced" action first, before we add the original action. - _beans_set_action( $beans_id, $replaced_action, 'replaced', true ); - - // Next, add the original action. - beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); - - // Get the newly created action. - $new_action = _beans_get_action( $beans_id, 'added' ); - - // Check if the callback and priority were replaced. - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); - $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Now check that the action was replaced in WordPress. - $this->check_registered_in_wp( $new_action['hook'], $new_action ); - } - } - - /** - * Test beans_add_action() should return false when the ID is registered to the "removed" status. - */ - public function test_should_return_false_when_removed() { - $empty_action = [ - 'hook' => null, - 'callback' => null, - 'priority' => null, - 'args' => null, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Store the "removed" action before we call beans_add_action(). - _beans_set_action( $beans_id, $empty_action, 'removed', true ); - - // Next, add the action. - beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ); - - // Check if the action is stored as "added". - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - - // Check that the action is not registered in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_add_action() should merge the "modified" action configuration parameters. - */ - public function test_should_merge_modified_action_parameters() { - $modified_action = [ - 'callback' => 'foo', - 'priority' => 17, - ]; - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // We want to store the "modified" action first, before we add the original action. - _beans_set_action( $beans_id, $modified_action, 'modified', true ); - - // Next, add the original action. - beans_add_action( $beans_id, $original_action['hook'], $original_action['callback'], $original_action['priority'], $original_action['args'] ); - - // Test that the original action is stored away, which allows us to reset it (if we want). - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Now check that the action was modified in WordPress. - $new_action = array_merge( $original_action, $modified_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php b/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php deleted file mode 100644 index 43f86d83..00000000 --- a/tests/phpunit/integration/api/actions/beansAddAnonymousAction.php +++ /dev/null @@ -1,46 +0,0 @@ -assertTrue( has_action( 'do_foo' ) ); - } - - /** - * Test _beans_add_anonymous_action() should call callback on the given hook. - */ - public function test_should_call_callback() { - _beans_add_anonymous_action( 'beans_test_do_foo', [ 'foo_test_callback', [ 'foo' ] ] ); - - Functions\when( 'foo_test_callback' ) - ->justReturn( 'foo' ); - - ob_start(); - do_action( 'beans_test_do_foo' ); - $this->assertEquals( 'foo', ob_get_clean() ); - } -} diff --git a/tests/phpunit/integration/api/actions/beansGetAction.php b/tests/phpunit/integration/api/actions/beansGetAction.php deleted file mode 100644 index 91e42196..00000000 --- a/tests/phpunit/integration/api/actions/beansGetAction.php +++ /dev/null @@ -1,127 +0,0 @@ -assertEmpty( $_beans_registered_actions[ $status ] ); - $this->assertFalse( _beans_get_action( 'foo', $status ) ); - } - } - - /** - * Test _beans_get_action() should return false when the action is not registered. - */ - public function test_should_return_false_when_action_is_not_registered() { - - foreach ( static::$test_ids as $beans_id ) { - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); - } - } - - /** - * Test _beans_get_action() should return the "added" action. - */ - public function test_should_return_added_action() { - global $_beans_registered_actions; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['added'][ $beans_id ] = $action; - - // Test that we get the "added" action. - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - - // Make sure that it is not stored in the other registries. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); - } - } - - /** - * Test _beans_get_action() should return the "modified" action. - */ - public function test_should_return_modified_action() { - global $_beans_registered_actions; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['modified'][ $beans_id ] = $action; - - // Test that we get the "modified" action. - $this->assertSame( $action, _beans_get_action( $beans_id, 'modified' ) ); - - // Make sure that it is not stored in the other registries. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); - } - } - - /** - * Test _beans_get_action() should return the "removed" action. - */ - public function test_should_return_removed_action() { - global $_beans_registered_actions; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['removed'][ $beans_id ] = $action; - - // Test that we get the "removed" action. - $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); - - // Make sure that it is not stored in the other registries. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'replaced' ) ); - } - } - - /** - * Test _beans_get_action() should return the "replaced" action. - */ - public function test_should_return_replaced_action() { - global $_beans_registered_actions; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['replaced'][ $beans_id ] = $action; - - // Test that we get the "replaced" action. - $this->assertSame( $action, _beans_get_action( $beans_id, 'replaced' ) ); - - // Make sure that it is not stored in the other registries. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansGetCurrentAction.php b/tests/phpunit/integration/api/actions/beansGetCurrentAction.php deleted file mode 100644 index eec30ff8..00000000 --- a/tests/phpunit/integration/api/actions/beansGetCurrentAction.php +++ /dev/null @@ -1,96 +0,0 @@ - $action ) { - // Store the action in the registry. - $_beans_registered_actions['removed'][ $beans_id ] = $action; - - // Test that it returns false. - $this->assertFalse( _beans_get_current_action( $beans_id ) ); - } - } - - /** - * Test _beans_get_current_action() should return the "added" action. - */ - public function test_should_return_added_action() { - global $_beans_registered_actions; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['added'][ $beans_id ] = $action; - - // Test that we get the "added" action. - $this->assertSame( $action, _beans_get_current_action( $beans_id ) ); - } - } - - /** - * Test _beans_get_current_action() should return false when there's a "modified" action but no "added" action. - */ - public function test_should_return_false_when_modified_but_no_added_action() { - global $_beans_registered_actions; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['modified'][ $beans_id ] = $action; - - // Run the tests. - $this->assertFalse( _beans_get_current_action( $beans_id ) ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['added'] ); - $this->assertSame( $action, $_beans_registered_actions['modified'][ $beans_id ] ); - } - } - - /** - * Test _beans_get_current_action() should return the merged "added" and "modified" action. - */ - public function test_should_return_merged_added_and_modified_action() { - global $_beans_registered_actions; - - $modified_action = [ - 'callback' => 'callback', - 'priority' => 27, - 'args' => 14, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Store the action in the registry. - $_beans_registered_actions['added'][ $beans_id ] = $action; - $_beans_registered_actions['modified'][ $beans_id ] = $modified_action; - - // Test that it merges the action. - $this->assertSame( - array_merge( $action, $modified_action ), - _beans_get_current_action( $beans_id ) - ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansMergeAction.php b/tests/phpunit/integration/api/actions/beansMergeAction.php deleted file mode 100644 index bb4330a9..00000000 --- a/tests/phpunit/integration/api/actions/beansMergeAction.php +++ /dev/null @@ -1,68 +0,0 @@ - 29, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - $merged_action = array_merge( $action, $modified_action ); - - // Test each status. - foreach ( $this->statuses as $status ) { - $_beans_registered_actions[ $status ][ $beans_id ] = $action; - $this->assertSame( $merged_action, _beans_merge_action( $beans_id, $modified_action, $status ) ); - } - } - } - - /** - * Test _beans_merge_action() should store an unregistered action. - */ - public function test_should_store_new_action() { - global $_beans_registered_actions; - - foreach ( static::$test_actions as $beans_id => $action ) { - - // Test each status. - foreach ( $this->statuses as $status ) { - $this->assertSame( $action, _beans_merge_action( $beans_id, $action, $status ) ); - $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); - } - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansModifyAction.php b/tests/phpunit/integration/api/actions/beansModifyAction.php deleted file mode 100644 index 18d844e8..00000000 --- a/tests/phpunit/integration/api/actions/beansModifyAction.php +++ /dev/null @@ -1,204 +0,0 @@ -go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that it returns false. - $this->assertFalse( beans_modify_action( $beans_id ) ); - - // Verify that the action was not stored as "modified". - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action was not replaced. - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_modify_action() should register with Beans as "modified", but not add the action. - */ - public function test_should_register_as_modified_but_not_add_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check the starting state. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that it returns false. - $this->assertFalse( beans_modify_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ) ); - - // Check that it did register as "modified" in Beans. - $this->assertEquals( $action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action was not added in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_modify_action() should modify the registered action's hook. - */ - public function test_should_modify_the_action_hook() { - $modified_action = [ - 'hook' => 'foo', - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action is registered in WordPress and in Beans as "added". - $this->check_registered_in_wp( $original_action['hook'], $original_action ); - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Modify the action's hook. - $this->assertTrue( beans_modify_action( $beans_id, $modified_action['hook'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - - // Check that the modified action was added in WordPress. - $this->assertTrue( has_action( $modified_action['hook'], $original_action['callback'] ) !== false ); - } - } - - /** - * Test beans_modify_action() should modify the registered action's callback. - */ - public function test_should_modify_the_action_callback() { - $modified_action = [ - 'callback' => 'my_callback', - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action is registered in WordPress and in Beans as "added". - $this->check_registered_in_wp( $original_action['hook'], $original_action ); - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Modify the action's callback. - $this->assertTrue( beans_modify_action( $beans_id, null, $modified_action['callback'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - - // Check that the modified action was added in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); - } - } - - /** - * Test beans_modify_action() should modify the registered action's priority level. - */ - public function test_should_modify_the_action_priority() { - global $wp_filter; - - $modified_action = [ - 'priority' => 20, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check the starting state. - $this->assertEquals( - [ - 'function' => $original_action['callback'], - 'accepted_args' => $original_action['args'], - ], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] - ); - - // Modify the action's priority. - $this->assertTrue( beans_modify_action( $beans_id, null, null, $modified_action['priority'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the original action was removed from WordPress. - $callbacks_in_wp = $wp_filter[ $original_action['hook'] ]->callbacks; - if ( isset( $callbacks_in_wp[ $original_action['priority'] ] ) ) { - $this->assertArrayNotHasKey( $original_action['callback'], $callbacks_in_wp[ $original_action['priority'] ] ); - } else { - $this->assertArrayNotHasKey( $original_action['priority'], $callbacks_in_wp ); - } - - // Check that the action's priority was modified in WordPress. - $this->assertEquals( - [ - 'function' => $original_action['callback'], - 'accepted_args' => $original_action['args'], - ], - $callbacks_in_wp[ $modified_action['priority'] ][ $original_action['callback'] ] - ); - } - } - - /** - * Test beans_modify_action() should modify the registered action's number of arguments. - */ - public function test_should_modify_the_action_args() { - global $wp_filter; - - $modified_action = [ - 'args' => 7, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check the starting state. - $this->assertEquals( - $original_action['args'], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] - ); - - // Modify the action's number of arguments. - $this->assertTrue( beans_modify_action( $beans_id, null, null, null, $modified_action['args'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action's number of arguments was modified in WordPress. - $this->assertEquals( - $modified_action['args'], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] - ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansModifyActionArguments.php b/tests/phpunit/integration/api/actions/beansModifyActionArguments.php deleted file mode 100644 index 0676f24c..00000000 --- a/tests/phpunit/integration/api/actions/beansModifyActionArguments.php +++ /dev/null @@ -1,149 +0,0 @@ -go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check the starting state. - $this->assertEquals( - $original_action['args'], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] - ); - - foreach ( $arguments as $number_of_args ) { - // Check that it returns false. - $this->assertFalse( beans_modify_action_arguments( $beans_id, $number_of_args ) ); - - // Check that the modification was not stored in Beans. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the number of arguments did not change in WordPress. - $this->assertEquals( - $original_action['args'], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] - ); - } - } - } - - /** - * Test beans_modify_action_arguments() should modify the action's "args" when the new one is zero. - */ - public function test_should_modify_action_when_args_is_zero() { - global $wp_filter; - - $arguments = [ 0, 0.0, '0', '0.0' ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check the starting state. - $this->assertEquals( - $original_action['args'], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] - ); - - foreach ( $arguments as $number_of_args ) { - // Modify the action's callback. - $this->assertTrue( beans_modify_action_arguments( $beans_id, $number_of_args ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( [ 'args' => (int) $number_of_args ], _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action's number of arguments was modified in WordPress. - $this->assertEquals( - $number_of_args, - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] - ); - } - } - } - - /** - * Test beans_modify_action_arguments() should register with Beans as "modified", but not add the action. - */ - public function test_should_register_as_modified_but_not_add_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check the starting state. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that it returns false. - $this->assertFalse( beans_modify_action_arguments( $beans_id, $action['args'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( [ 'args' => $action['args'] ], _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action was not added in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_modify_action_arguments() should modify the registered action's number of arguments. - */ - public function test_should_modify_the_action_args() { - global $wp_filter; - - $modified_action = [ - 'args' => 7, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Test the action before we start. - $this->assertEquals( - $original_action['args'], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] - ); - - // Modify the action's number of arguments. - $this->assertTrue( beans_modify_action_arguments( $beans_id, $modified_action['args'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action's number of arguments was modified in WordPress. - $this->assertEquals( - $modified_action['args'], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]['accepted_args'] - ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansModifyActionCallback.php b/tests/phpunit/integration/api/actions/beansModifyActionCallback.php deleted file mode 100644 index 137cdf40..00000000 --- a/tests/phpunit/integration/api/actions/beansModifyActionCallback.php +++ /dev/null @@ -1,103 +0,0 @@ -go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check the starting state. - $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); - - foreach ( $callbacks as $callback ) { - // Check that it returns false. - $this->assertFalse( beans_modify_action_callback( $beans_id, $callback ) ); - - // Check that the callback did not get stored as "modified" in Beans. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the callback did not change in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); - } - } - } - - /** - * Test beans_modify_action_callback() should register with Beans as "modified", but not add the action. - */ - public function test_should_register_as_modified_but_not_add_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check the starting state. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that it returns false. - $this->assertFalse( beans_modify_action_callback( $beans_id, $action['callback'] ) ); - - // Check that it did register as "modified" in Beans. - $this->assertEquals( [ 'callback' => $action['callback'] ], _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action was not added in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_modify_action_callback() should modify the registered action's callback. - */ - public function test_should_modify_the_action_callback() { - $modified_action = [ - 'callback' => 'my_callback', - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action is registered in WordPress and in Beans as "added". - $this->check_registered_in_wp( $original_action['hook'], $original_action ); - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Modify the callback. - $this->assertTrue( beans_modify_action_callback( $beans_id, $modified_action['callback'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - - // Check that the modified action was added in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $modified_action['callback'] ) !== false ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansModifyActionHook.php b/tests/phpunit/integration/api/actions/beansModifyActionHook.php deleted file mode 100644 index 45a691a8..00000000 --- a/tests/phpunit/integration/api/actions/beansModifyActionHook.php +++ /dev/null @@ -1,107 +0,0 @@ -go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check the starting state. - $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); - - foreach ( $hooks as $hook ) { - // Check that it returns false. - $this->assertFalse( beans_modify_action_hook( $beans_id, $hook ) ); - - // Check that the hook did not get stored as "modified" in Beans. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the hook did not change in WordPress. - $this->assertTrue( has_action( $original_action['hook'], $original_action['callback'] ) !== false ); - } - } - } - - /** - * Test beans_modify_action_hook() should register with Beans as "modified", but not add the action. - */ - public function test_should_register_as_modified_but_not_add_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check the starting state. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that it returns false. - $this->assertFalse( beans_modify_action_hook( $beans_id, $action['hook'] ) ); - - // Check that it did register as "modified" in Beans. - $this->assertEquals( [ 'hook' => $action['hook'] ], _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action was not added in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_modify_action_hook() should modify the registered action's hook. - */ - public function test_should_modify_the_action_hook() { - $modified_action = [ - 'hook' => 'foo', - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action is registered in WordPress and in Beans as "added". - $this->check_registered_in_wp( $original_action['hook'], $original_action ); - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Modify the action's hook. - $this->assertTrue( beans_modify_action_hook( $beans_id, $modified_action['hook'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - - // Check that the modified action was added in WordPress. - $this->assertTrue( has_action( $modified_action['hook'], $original_action['callback'] ) !== false ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansModifyActionPriority.php b/tests/phpunit/integration/api/actions/beansModifyActionPriority.php deleted file mode 100644 index 334219cd..00000000 --- a/tests/phpunit/integration/api/actions/beansModifyActionPriority.php +++ /dev/null @@ -1,187 +0,0 @@ -go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check the starting state. - $this->assertEquals( - [ - 'function' => $original_action['callback'], - 'accepted_args' => $original_action['args'], - ], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] - ); - - foreach ( $priorities as $priority ) { - // Check that it returns false. - $this->assertFalse( beans_modify_action_priority( $beans_id, $priority ) ); - - // Check that the priority did not get stored as "modified" in Beans. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the priority did not change in WordPress. - $this->assertEquals( - [ - 'function' => $original_action['callback'], - 'accepted_args' => $original_action['args'], - ], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] - ); - } - } - } - - /** - * Test beans_modify_action_priority() should modify the action's priority when the new one is zero. - */ - public function test_should_modify_action_when_priority_is_zero() { - global $wp_filter; - - $priorities = [ 0, 0.0, '0', '0.0' ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check the starting state. - $this->assertEquals( - [ - 'function' => $original_action['callback'], - 'accepted_args' => $original_action['args'], - ], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] - ); - - foreach ( $priorities as $priority ) { - // Modify the priority. - $this->assertTrue( beans_modify_action_priority( $beans_id, $priority ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( [ 'priority' => (int) $priority ], _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the priority did change in WordPress. - $this->check_modified_in_wp( $original_action, (int) $priority ); - } - } - } - - /** - * Test beans_modify_action_priority() should register with Beans as "modified", but not add the action. - */ - public function test_should_register_as_modified_but_not_add_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check the starting state. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - - // Check that it returns false. - $this->assertFalse( beans_modify_action_priority( $beans_id, $action['priority'] ) ); - - // Check that it did register as "modified" in Beans. - $this->assertEquals( [ 'priority' => $action['priority'] ], _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the action was not added in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_modify_action_priority() should modify the registered action's priority level. - */ - public function test_should_modify_the_action_priority() { - global $wp_filter; - - $modified_action = [ - 'priority' => 20, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check the starting state. - $this->assertEquals( - [ - 'function' => $original_action['callback'], - 'accepted_args' => $original_action['args'], - ], - $wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ] - ); - - // Modify the action's priority. - $this->assertTrue( beans_modify_action_priority( $beans_id, $modified_action['priority'] ) ); - - // Check that the modified action is registered as "modified" in Beans. - $this->assertEquals( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the priority did change in WordPress. - $this->check_modified_in_wp( $original_action, $modified_action['priority'] ); - } - } - - /** - * Check that the priority was modified in WordPress. - * - * @since 1.5.0 - * - * @param array $original_action The original action. - * @param int $new_priority The new priority. - * - * @return void - */ - protected function check_modified_in_wp( $original_action, $new_priority ) { - global $wp_filter; - - $callbacks_in_wp = $wp_filter[ $original_action['hook'] ]->callbacks; - - // Check that the original action was removed from WordPress. - if ( isset( $callbacks_in_wp[ $original_action['priority'] ] ) ) { - $this->assertArrayNotHasKey( $original_action['callback'], $callbacks_in_wp[ $original_action['priority'] ] ); - } else { - $this->assertArrayNotHasKey( $original_action['priority'], $callbacks_in_wp ); - } - - // Check that the action's priority was modified in WordPress. - $this->assertEquals( - [ - 'function' => $original_action['callback'], - 'accepted_args' => $original_action['args'], - ], - $callbacks_in_wp[ $new_priority ][ $original_action['callback'] ] - ); - } -} diff --git a/tests/phpunit/integration/api/actions/beansRemoveAction.php b/tests/phpunit/integration/api/actions/beansRemoveAction.php deleted file mode 100644 index 1f7ba3cb..00000000 --- a/tests/phpunit/integration/api/actions/beansRemoveAction.php +++ /dev/null @@ -1,103 +0,0 @@ - null, - 'callback' => null, - 'priority' => null, - 'args' => null, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - $this->assertFalse( _beans_get_current_action( $beans_id ) ); - - // Remove the action. Test that an empty action is returned. - $this->assertSame( $empty_action, beans_remove_action( $beans_id ) ); - - // Check that the "empty" action is registered as "removed". - $this->assertSame( $empty_action, _beans_get_action( $beans_id, 'removed' ) ); - - // Check that the original action is not registered in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_remove_action() should store the "removed" action before the original action is "added". - * Once the original action is registered, then it should be removed. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_remove_action() { - - // Remove the actions. - foreach ( static::$test_actions as $beans_id => $action ) { - beans_remove_action( $beans_id ); - } - - // Load the post, which runs beans_add_action for each of our test actions. - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check that the action is registered as "added". - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - - // Check that the action is not registered in WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } - - /** - * Test beans_remove_action() should remove a registered action. - */ - public function test_should_remove_a_registered_action() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Check that the action is registered with Beans. - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - - // Check that the action is registered with WordPress. - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); - - // Remove it. - $this->assertSame( $action, beans_remove_action( $beans_id ) ); - - // Check that the action is registered as "removed". - $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); - - // Check that the action is no longer registered with WordPress. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansReplaceAction.php b/tests/phpunit/integration/api/actions/beansReplaceAction.php deleted file mode 100644 index 9c15f413..00000000 --- a/tests/phpunit/integration/api/actions/beansReplaceAction.php +++ /dev/null @@ -1,265 +0,0 @@ - $replaced_callback ]; - - foreach ( static::$test_ids as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - - // Now store away the "replace" hook. - $this->assertFalse( beans_replace_action( $beans_id, null, $replaced_callback ) ); - - // Check that it was stored as "replaced". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); - - // Check that it did not store as "added". - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_replace_action() should store the "replaced" action when the original action - * has not yet been registered. Once the original action is registered, then it should be replaced. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_replace_action() { - $replaced_callback = 'my_replaced_callback'; - $replaced_action = [ 'callback' => $replaced_callback ]; - - // Store the "replaced" action. - foreach ( static::$test_ids as $beans_id ) { - beans_replace_action( $beans_id, null, $replaced_callback ); - } - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action's callback was replaced in Beans. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_callback, $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); - } - } - - /** - * Test beans_replace_action() should return false when there's nothing to replace, - * i.e. no arguments passed. - */ - public function test_should_return_false_when_nothing_to_replace() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check it returns false. - $this->assertFalse( beans_replace_action( $beans_id ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action has not been replaced. - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_replace_action() should replace the registered action's hook. - */ - public function test_should_replace_the_action_hook() { - $replaced_action = [ - 'hook' => 'foo', - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action is registered in WordPress and in Beans as "added". - $this->check_registered_in_wp( $original_action['hook'], $original_action ); - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, $replaced_action['hook'] ) ); - - // Check that only the hook was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); - } - } - - /** - * Test beans_replace_action() should replace the registered action's callback. - */ - public function test_should_replace_the_action_callback() { - $replaced_action = [ - 'callback' => 'foo', - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action is registered in WordPress and in Beans as "added". - $this->check_registered_in_wp( $original_action['hook'], $original_action ); - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, null, $replaced_action['callback'] ) ); - - // Check that only the callback was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); - } - } - - /** - * Test beans_replace_action() should replace the registered action's priority level. - */ - public function test_should_replace_the_action_priority() { - $replaced_action = [ - 'priority' => 52, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action is registered in WordPress and in Beans as "added". - $this->check_registered_in_wp( $original_action['hook'], $original_action ); - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, null, null, $replaced_action['priority'] ) ); - - // Check that only the priority was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); - } - } - - /** - * Test beans_replace_action() should replace the registered action's number of arguments. - */ - public function test_should_replace_the_action_args() { - $replaced_action = [ - 'args' => 6, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action is registered in WordPress and in Beans as "added". - $this->check_registered_in_wp( $original_action['hook'], $original_action ); - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Run the replace. - $this->assertTrue( beans_replace_action( $beans_id, null, null, null, $replaced_action['args'] ) ); - - // Check that only the number of arguments was replaced. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $replaced_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); - } - } - - /** - * Test beans_replace_action() should replace the original registered action. - */ - public function test_should_replace_the_action() { - $replaced_action = [ - 'hook' => 'new_hook', - 'callback' => 'new_callback', - 'priority' => 99, - 'args' => 10, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check that the original action is registered in WordPress and in Beans as "added". - $this->check_registered_in_wp( $original_action['hook'], $original_action ); - $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); - - // Run the replace. - $this->assertTrue( beans_replace_action( - $beans_id, - $replaced_action['hook'], - $replaced_action['callback'], - $replaced_action['priority'], - $replaced_action['args'] - ) ); - - // Check that the "replaced" action has been stored in Beans. - $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); - $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); - $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - - // Check that the original action was removed from WordPress. - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - - // Check that the new action is now registered in WordPress. - $this->check_registered_in_wp( $replaced_action['hook'], $replaced_action ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php b/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php deleted file mode 100644 index 9241ec27..00000000 --- a/tests/phpunit/integration/api/actions/beansReplaceActionArguments.php +++ /dev/null @@ -1,131 +0,0 @@ - 10, - ]; - - // Store the "replaced" action. - foreach ( static::$test_ids as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - - // Now store away the "replace" args. - $this->assertFalse( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); - - // Check that it was stored as "modified". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - } - } - - /** - * Test beans_replace_action_arguments() should store the "replaced" action when the original action - * has not yet been registered. Once the original action is registered, then the arguments should be replaced. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_replace_the_args() { - $replaced_action = [ - 'args' => 10, - ]; - - // Now replace the actions. - foreach ( static::$test_ids as $beans_id ) { - beans_replace_action_arguments( $beans_id, $replaced_action['args'] ); - } - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the args. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $replaced_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); - } - } - - /** - * Test beans_replace_action_arguments() should return false when "args" is not passed. - */ - public function test_should_return_false_when_no_args() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $this->assertFalse( beans_replace_action_arguments( $beans_id, '' ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_replace_action_arguments() should replace the registered action's args. - */ - public function test_should_replace_the_action_args() { - $replaced_action = [ - 'args' => 14, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); - - // Make sure the args is what we think before we get rolling. - $this->assertEquals( $action_config['args'], $original_action['args'] ); - - // Run the replace. - $this->assertTrue( beans_replace_action_arguments( $beans_id, $replaced_action['args'] ) ); - - // Check if it replaced only the args. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $replaced_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php b/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php deleted file mode 100644 index 3610c0ab..00000000 --- a/tests/phpunit/integration/api/actions/beansReplaceActionCallback.php +++ /dev/null @@ -1,130 +0,0 @@ - 'my_new_callback', - ]; - - foreach ( static::$test_ids as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - - // Now store away the "replace" callback. - $this->assertFalse( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); - - // Check that it was stored as "modified". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - } - } - - /** - * Test beans_replace_action_callback() should store the "replaced" action when the original action - * has not yet been registered. Once the original action is registered, then the callback should be replaced. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_replace_the_callback() { - $replaced_action = [ - 'callback' => 'foo', - ]; - - // Now replace the actions. - foreach ( static::$test_ids as $beans_id ) { - beans_replace_action_callback( $beans_id, $replaced_action['callback'] ); - } - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the hook. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); - } - } - - /** - * Test beans_replace_action_callback() should return false when no hook was passed. - */ - public function test_should_return_false_when_no_hook() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $this->assertFalse( beans_replace_action_callback( $beans_id, '' ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_replace_action_callback() should replace the registered action's callback. - */ - public function test_should_replace_the_action_callback() { - $replaced_action = [ - 'callback' => 'beans_foo', - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); - - // Make sure the callback is what we think before we get rolling. - $this->assertEquals( $action_config['callback'], $original_action['callback'] ); - - // Run the replace. - $this->assertTrue( beans_replace_action_callback( $beans_id, $replaced_action['callback'] ) ); - - // Check if it replaced only the callback. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $replaced_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionHook.php b/tests/phpunit/integration/api/actions/beansReplaceActionHook.php deleted file mode 100644 index 51431c24..00000000 --- a/tests/phpunit/integration/api/actions/beansReplaceActionHook.php +++ /dev/null @@ -1,132 +0,0 @@ - 'my_new_hook', - ]; - - foreach ( static::$test_ids as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - - // Now store away the "replace" hook. - $this->assertFalse( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); - - // Check that it was stored as "modified". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - } - } - - /** - * Test beans_replace_action_hook() should store the "replaced" action when the original action - * has not yet been registered. Once the original action is registered, then the hook should be replaced. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_replace_the_hook() { - $replaced_action = [ - 'hook' => 'foo', - ]; - - // Now replace the actions. - foreach ( static::$test_ids as $beans_id ) { - beans_replace_action_hook( $beans_id, $replaced_action['hook'] ); - } - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the hook. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->assertFalse( has_action( $original_action['hook'], $original_action['callback'] ) ); - $this->check_registered_in_wp( $replaced_action['hook'], $new_action ); - } - } - - /** - * Test beans_replace_action_hook() should return false when no hook was passed. - */ - public function test_should_return_false_when_no_hook() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $this->assertFalse( beans_replace_action_hook( $beans_id, '' ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_replace_action_hook() should replace the registered action's hook. - */ - public function test_should_replace_the_action_hook() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); - - // Make sure the callback is what we think before we get rolling. - $this->assertEquals( $action_config['hook'], $original_action['hook'] ); - - // Set up what will get stored in Beans. - $replaced_action = [ - 'hook' => 'beans_foo', - ]; - - // Run the replace. - $this->assertTrue( beans_replace_action_hook( $beans_id, $replaced_action['hook'] ) ); - - // Check if it replaced only the hook. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $replaced_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $original_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php b/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php deleted file mode 100644 index 0e10b3f6..00000000 --- a/tests/phpunit/integration/api/actions/beansReplaceActionPriority.php +++ /dev/null @@ -1,130 +0,0 @@ - 99, - ]; - - foreach ( static::$test_ids as $beans_id ) { - // Test that the original action has not yet been added. - $this->assertFalse( _beans_get_action( $beans_id, 'added' ) ); - - // Now store away the "replace" priority. - $this->assertFalse( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); - - // Check that it was stored as "modified". - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - } - } - - /** - * Test beans_replace_action_priority() should store the "replaced" action when the original action - * has not yet been registered. Once the original action is registered, then the priority should be replaced. - * - * Intent: We are testing to ensure Beans is "load order" agnostic. - */ - public function test_should_store_and_then_replace_the_priority() { - $replaced_action = [ - 'priority' => 10000, - ]; - - // Now replace the actions. - foreach ( static::$test_ids as $beans_id ) { - beans_replace_action_priority( $beans_id, $replaced_action['priority'] ); - } - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $original_action ) { - // Check if it replaced the hook. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $original_action['hook'], $new_action ); - } - } - - /** - * Test beans_replace_action_priority() should return false when no priority is passed. - */ - public function test_should_return_false_when_no_hook() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $this->assertFalse( beans_replace_action_priority( $beans_id, '' ) ); - - // Verify that it did not get stored in "replaced" or "modified". - global $_beans_registered_actions; - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['replaced'] ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions['modified'] ); - - // Check that the original action has not been replaced. - $this->assertSame( $action_config, _beans_get_action( $beans_id, 'added' ) ); - } - } - - /** - * Test beans_replace_action_priority() should replace the registered action's priority. - */ - public function test_should_replace_the_action_priority() { - $replaced_action = [ - 'priority' => 999, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action_config ) { - $original_action = _beans_get_action( $beans_id, 'added' ); - - // Make sure the priority is what we think before we get rolling. - $this->assertEquals( $action_config['priority'], $original_action['priority'] ); - - // Run the replace. - $this->assertTrue( beans_replace_action_priority( $beans_id, $replaced_action['priority'] ) ); - - // Check if it replaced only the priority. - $new_action = _beans_get_action( $beans_id, 'added' ); - $this->assertEquals( $original_action['hook'], $new_action['hook'] ); - $this->assertEquals( $original_action['callback'], $new_action['callback'] ); - $this->assertEquals( $replaced_action['priority'], $new_action['priority'] ); - $this->assertEquals( $original_action['args'], $new_action['args'] ); - - // Check that the "replaced" action has been stored in Beans and WordPress. - $this->check_stored_in_beans( $beans_id, $replaced_action ); - $this->check_registered_in_wp( $new_action['hook'], $new_action ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansResetAction.php b/tests/phpunit/integration/api/actions/beansResetAction.php deleted file mode 100644 index 6f014de5..00000000 --- a/tests/phpunit/integration/api/actions/beansResetAction.php +++ /dev/null @@ -1,513 +0,0 @@ - $action ) { - $this->assertFalse( beans_reset_action( $beans_id ) ); - } - } - - /** - * Test beans_reset_action() should reset the original action after it was "removed" via beans_remove_action(). - */ - public function test_should_reset_after_remove() { - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); - - // Remove it. - beans_remove_action( $beans_id ); - - // Check that the action did get removed. - $this->assertSame( $action, _beans_get_action( $beans_id, 'removed' ) ); - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - - // Let's reset the action. - $this->assertSame( $action, beans_reset_action( $beans_id ) ); - - // Check that the action was reset. - $this->assertFalse( _beans_get_action( $beans_id, 'removed' ) ); - $this->check_the_action( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's hook after it was "modified". - */ - public function test_should_reset_after_modifying_the_hook() { - $modified_action = [ - 'hook' => 'foo', - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); - - // Now modify the hook. - beans_modify_action_hook( $beans_id, $modified_action['hook'] ); - - // Check that the hook was modified. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertTrue( has_action( $modified_action['hook'], $action['callback'] ) !== false ); - - // Let's reset the action. - $this->assertSame( $action, beans_reset_action( $beans_id ) ); - - // Check that the action was reset. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->check_the_action( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's callback after it was "modified". - */ - public function test_should_reset_after_modifying_the_callback() { - global $wp_filter; - - $modified_action = [ - 'callback' => 'my_callback', - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); - - // Grab what's registered in WordPress. - $action_in_wp = $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ]; - - // Modify the callback. - beans_modify_action_callback( $beans_id, $modified_action['callback'] ); - - // Check that the action's callback was modified. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertEquals( $action['callback'], $action_in_wp[ $action['callback'] ]['function'] ); - - // Let's reset the action. - $this->assertSame( $action, beans_reset_action( $beans_id ) ); - - // Check that the action was reset. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->check_the_action( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's priority after it was "modified". - */ - public function test_should_reset_after_modifying_the_priority() { - global $wp_filter; - - $modified_action = [ - 'priority' => 9999, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, do a hard check to ensure the original priority is registered. - $this->assertEquals( - $action['callback'], - $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['function'] - ); - - // Modify the priority. - beans_modify_action_priority( $beans_id, $modified_action['priority'] ); - - // Check that the priority was modified. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertEquals( - $action['callback'], - $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $action['callback'] ]['function'] - ); - - // Let's reset the action. - $this->assertSame( $action, beans_reset_action( $beans_id ) ); - - // Check that the action was reset. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->check_the_action( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's args after it was "modified". - */ - public function test_should_reset_after_modifying_the_args() { - global $wp_filter; - - $modified_action = [ - 'args' => 14, - ]; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, do a hard check to ensure the original number of args is registered. - $this->assertEquals( - $action['args'], - $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['accepted_args'] - ); - - // Modify the number of arguments. - beans_modify_action_arguments( $beans_id, $modified_action['args'] ); - - // Check that the number of arguments was modified. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertEquals( - $modified_action['args'], - $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['accepted_args'] - ); - - // Let's reset the action. - $this->assertSame( $action, beans_reset_action( $beans_id ) ); - - // Check that the action was reset. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->check_the_action( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's callback and args after they were "modified". - */ - public function test_should_reset_after_modifying_callback_and_args() { - global $wp_filter; - - $this->go_to_post(); - - $modified_action = [ - 'callback' => 'my_callback', - 'args' => 14, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->check_the_action( $beans_id, $action ); - - // Modify the action. - beans_modify_action( $beans_id, null, $modified_action['callback'], null, $modified_action['args'] ); - - // Check that the action was modified. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertTrue( has_action( $action['hook'], $modified_action['callback'] ) !== false ); - $this->assertEquals( - [ - 'function' => $modified_action['callback'], - 'accepted_args' => $modified_action['args'], - ], - $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $modified_action['callback'] ] - ); - - // Let's reset the action. - $this->assertSame( $action, beans_reset_action( $beans_id ) ); - - // Check that the action was reset. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->check_the_action( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's priority and args after they were "modified". - */ - public function test_should_reset_after_modifying_priority_and_args() { - global $wp_filter; - - $this->go_to_post(); - - $modified_action = [ - 'priority' => 79, - 'args' => 14, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->check_the_action( $beans_id, $action ); - - // Modify the action. - beans_modify_action( $beans_id, null, null, $modified_action['priority'], $modified_action['args'] ); - - // Check that the action was modified. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertEquals( - [ - 'function' => $action['callback'], - 'accepted_args' => $modified_action['args'], - ], - $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $action['callback'] ] - ); - - // Let's reset the action. - $this->assertSame( $action, beans_reset_action( $beans_id ) ); - - // Check that the action was reset. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->check_the_action( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's callback and priority after they were "modified". - */ - public function test_should_reset_after_modifying_callback_and_priority() { - global $wp_filter; - - $this->go_to_post(); - - $modified_action = [ - 'callback' => 'foo', - 'priority' => 39, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->check_the_action( $beans_id, $action ); - - // Modify the action. - beans_modify_action( $beans_id, null, $modified_action['callback'], $modified_action['priority'] ); - - // Check that the action was modified. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertEquals( - [ - 'function' => $modified_action['callback'], - 'accepted_args' => $action['args'], - ], - $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $modified_action['callback'] ] - ); - - // Let's reset the action. - $this->assertSame( $action, beans_reset_action( $beans_id ) ); - - // Check that the action was reset. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->check_the_action( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should reset the original action's callback, priority, and args after they were - * "modified". - */ - public function test_should_reset_after_modifying_all_but_hook() { - global $wp_filter; - - $this->go_to_post(); - - $modified_action = [ - 'callback' => 'foo', - 'priority' => 39, - 'args' => 24, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->check_the_action( $beans_id, $action ); - - // Modify the action. - beans_modify_action( $beans_id, null, $modified_action['callback'], $modified_action['priority'], $modified_action['args'] ); - - // Check that the action was modified. - $this->assertSame( $modified_action, _beans_get_action( $beans_id, 'modified' ) ); - $this->assertEquals( - [ - 'function' => $modified_action['callback'], - 'accepted_args' => $modified_action['args'], - ], - $wp_filter[ $action['hook'] ]->callbacks[ $modified_action['priority'] ][ $modified_action['callback'] ] - ); - - // Let's reset the action. - $this->assertSame( $action, beans_reset_action( $beans_id ) ); - - // Check that the action was reset. - $this->assertFalse( _beans_get_action( $beans_id, 'modified' ) ); - $this->check_the_action( $beans_id, $action ); - } - } - - /** - * Test beans_reset_action() should not reset after replacing the action's hook. - * - * Why? "Replace" overwrites and is not resettable. - */ - public function test_should_not_reset_after_replacing_hook() { - $hook = 'foo'; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); - - // Run the replace. - beans_replace_action_hook( $beans_id, $hook ); - - // Let's try to reset the action. - $this->assertSame( $hook, beans_reset_action( $beans_id )['hook'] ); - - // Check that the action was not reset. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertTrue( has_action( $hook, $action['callback'] ) !== false ); - } - } - - /** - * Test beans_reset_action() should not reset after replacing the action's callback. - * - * Why? "Replace" overwrites and is not resettable. - */ - public function test_should_not_reset_after_replacing_callback() { - $callback = 'foo_cb'; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, check that the action is registered. - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); - - // Run the replace. - beans_replace_action_callback( $beans_id, $callback ); - - // Let's try to reset the action. - $this->assertSame( $callback, beans_reset_action( $beans_id )['callback'] ); - - // Check that the action was not reset. - $this->assertFalse( has_action( $action['hook'], $action['callback'] ) ); - $this->assertTrue( has_action( $action['hook'], $callback ) !== false ); - } - } - - /** - * Test beans_reset_action() should not reset after replacing the action's priority. - * - * Why? "Replace" overwrites and is not resettable. - */ - public function test_should_not_reset_after_replacing_priority() { - global $wp_filter; - - $priority = 17; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, do a hard check to ensure the original priority is registered. - $this->assertEquals( - [ - 'function' => $action['callback'], - 'accepted_args' => $action['args'], - ], - $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ] - ); - - // Run the replace. - beans_replace_action_priority( $beans_id, $priority ); - - // Let's try to reset the action. - $this->assertSame( $priority, beans_reset_action( $beans_id )['priority'] ); - - // Check that the action was not reset. - $this->assertEquals( - [ - 'function' => $action['callback'], - 'accepted_args' => $action['args'], - ], - $wp_filter[ $action['hook'] ]->callbacks[ $priority ][ $action['callback'] ] - ); - } - } - - /** - * Test beans_reset_action() should not reset after replacing the action's args. - * - * Why? "Replace" overwrites and is not resettable. - */ - public function test_should_not_reset_after_replacing_args() { - global $wp_filter; - - $args = 29; - - $this->go_to_post(); - - foreach ( static::$test_actions as $beans_id => $action ) { - // Before we start, do a hard check to ensure the original number of args is registered. - $this->assertEquals( - $action['args'], - $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['accepted_args'] - ); - - // Run the replace. - beans_replace_action_arguments( $beans_id, $args ); - - // Let's try to reset the action. - $this->assertSame( $args, beans_reset_action( $beans_id )['args'] ); - - // Check that the action was not reset. - $this->assertEquals( - $args, - $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ]['accepted_args'] - ); - } - } - - /** - * Check that the action was reset. - * - * @since 1.5.0 - * - * @param string $beans_id The action's Beans ID, a unique ID tracked within Beans for this action. - * @param array $action The action to check. - * - * @return void - */ - protected function check_the_action( $beans_id, array $action ) { - global $wp_filter; - - $this->assertSame( $action, _beans_get_action( $beans_id, 'added' ) ); - $this->assertTrue( has_action( $action['hook'], $action['callback'] ) !== false ); - - $this->assertEquals( - [ - 'function' => $action['callback'], - 'accepted_args' => $action['args'], - ], - $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ][ $action['callback'] ] - ); - } -} diff --git a/tests/phpunit/integration/api/actions/beansSetAction.php b/tests/phpunit/integration/api/actions/beansSetAction.php deleted file mode 100644 index b9254c9f..00000000 --- a/tests/phpunit/integration/api/actions/beansSetAction.php +++ /dev/null @@ -1,108 +0,0 @@ - $action ) { - - // Test each status. - foreach ( $this->statuses as $status ) { - // Before we start, check that the action is not set. - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); - - // Now do the tests. - $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); - $this->assertArrayHasKey( $beans_id, $_beans_registered_actions[ $status ] ); - $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); - } - } - } - - /** - * Test _beans_set_action() should not overwrite an existing registered action. - */ - public function test_should_not_overwrite_existing_registered_action() { - global $_beans_registered_actions; - - $new_action = [ - 'hook' => 'bar', - 'callback' => 'callback_bar', - 'priority' => 20, - 'args' => 2, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - - // Test each status. - foreach ( $this->statuses as $status ) { - // Register the original action. - $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); - - // Now test that it does not overwrite the previously registered action. - $this->assertSame( $action, _beans_set_action( $beans_id, $new_action, $status ) ); - $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); - } - } - } - - /** - * Test _beans_set_action() should overwrite the existing registered action when the "overwrite" - * argument is set to true. - */ - public function test_should_overwrite_existing_registered_action() { - global $_beans_registered_actions; - - $new_action = [ - 'hook' => 'bar', - 'callback' => 'callback_bar', - 'priority' => 20, - 'args' => 2, - ]; - - foreach ( static::$test_actions as $beans_id => $action ) { - - // Test each status. - foreach ( $this->statuses as $status ) { - // Register the original action. - $this->assertSame( $action, _beans_set_action( $beans_id, $action, $status ) ); - $this->assertSame( $action, $_beans_registered_actions[ $status ][ $beans_id ] ); - - // Now test that it does overwrite the previously registered action. - $this->assertSame( $new_action, _beans_set_action( $beans_id, $new_action, $status, true ) ); - $this->assertSame( $new_action, $_beans_registered_actions[ $status ][ $beans_id ] ); - } - } - } -} diff --git a/tests/phpunit/integration/api/actions/beansUnsetAction.php b/tests/phpunit/integration/api/actions/beansUnsetAction.php deleted file mode 100644 index d70eec53..00000000 --- a/tests/phpunit/integration/api/actions/beansUnsetAction.php +++ /dev/null @@ -1,91 +0,0 @@ - $action ) { - - // Test each status. - foreach ( $this->statuses as $status ) { - $this->assertFalse( _beans_unset_action( $beans_id, $status ) ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); - } - } - } - - /** - * Test _beans_unset_action() should unset the registered action. - */ - public function test_should_unset_registered_action() { - global $_beans_registered_actions; - - foreach ( static::$test_actions as $beans_id => $action ) { - - // Test each status. - foreach ( $this->statuses as $status ) { - // Register the action first. - _beans_set_action( $beans_id, $action, $status ); - $this->assertArrayHasKey( $beans_id, $_beans_registered_actions[ $status ] ); - - // Test that it unsets the action. - $this->assertTrue( _beans_unset_action( $beans_id, $status ) ); - $this->assertArrayNotHasKey( $beans_id, $_beans_registered_actions[ $status ] ); - } - } - } - - /** - * Test _beans_unset_action() should return false when the status is invalid. - */ - public function test_should_return_false_when_status_is_invalid() { - - foreach ( static::$test_actions as $beans_id => $action ) { - - $this->assertFalse( _beans_unset_action( $beans_id, 'invalid_status' ) ); - $this->assertFalse( _beans_unset_action( $beans_id, 'foo' ) ); - $this->assertFalse( _beans_unset_action( $beans_id, 'not_valid_either' ) ); - - // Now store the action in each status. - foreach ( $this->statuses as $status ) { - _beans_set_action( $beans_id, $action, $status ); - } - - // Run the tests again. - $this->assertFalse( _beans_unset_action( $beans_id, 'invalid_status' ) ); - $this->assertFalse( _beans_unset_action( $beans_id, 'foo' ) ); - $this->assertFalse( _beans_unset_action( $beans_id, 'not_valid_either' ) ); - } - } -} diff --git a/tests/phpunit/integration/api/actions/fixtures/test-actions.php b/tests/phpunit/integration/api/actions/fixtures/test-actions.php deleted file mode 100644 index 291530a8..00000000 --- a/tests/phpunit/integration/api/actions/fixtures/test-actions.php +++ /dev/null @@ -1,29 +0,0 @@ - [ - 'hook' => 'beans_post_header', - 'callback' => 'beans_post_meta', - 'priority' => 15, - 'args' => 1, - ], - 'beans_post_image' => [ - 'hook' => 'beans_post_body', - 'callback' => 'beans_post_image', - 'priority' => 5, - 'args' => 1, - ], - 'beans_previous_post_link' => [ - 'hook' => 'previous_post_link', - 'callback' => 'beans_previous_post_link', - 'priority' => 10, - 'args' => 4, - ], -]; diff --git a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php b/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php deleted file mode 100644 index 5476b0f6..00000000 --- a/tests/phpunit/integration/api/actions/includes/class-actions-test-case.php +++ /dev/null @@ -1,215 +0,0 @@ - [], - 'modified' => [], - 'removed' => [], - 'replaced' => [], - ]; - - // Remove the test actions. - foreach ( static::$test_actions as $beans_id => $action ) { - remove_action( $action['hook'], $action['callback'], $action['priority'] ); - } - - static::$test_actions = null; - static::$test_ids = null; - } - - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - - if ( false === $this->reset_beans_registry ) { - return; - } - - global $_beans_registered_actions; - $_beans_registered_actions = [ - 'added' => [], - 'modified' => [], - 'removed' => [], - 'replaced' => [], - ]; - - parent::tearDown(); - } - - /** - * Restore the original action. - * - * @since 1.5.0 - * - * @param string $beans_id The Beans unique ID. - * - * @return void - */ - protected function restore_original( $beans_id ) { - $action = static::$test_actions[ $beans_id ]; - - _beans_unset_action( $beans_id, 'added' ); - - beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ); - } - - /** - * Check that it is not registered first. - * - * @since 1.5.0 - * - * @param string $id The ID to check. - * @param string $hook The hook (event name) to check. - * - * @return void - */ - protected function check_not_added( $id, $hook ) { - $this->assertFalse( _beans_get_action( $id, 'added' ) ); - $this->assertFalse( has_action( $hook ) ); - } - - /** - * Check that the action has been registered in WordPress. - * - * @since 1.5.0 - * - * @param string $hook The event's name (hook) that is registered in WordPress. - * @param array $action The action to be checked. - * @param bool $remove_action When true, it removes the action automatically to clean up this test. - * - * @return void - */ - protected function check_registered_in_wp( $hook, array $action, $remove_action = true ) { - $this->assertTrue( has_action( $hook, $action['callback'] ) !== false ); - $this->check_parameters_registered_in_wp( $action, $remove_action ); - } - - /** - * Check that the right parameters are registered in WordPress. - * - * @since 1.5.0 - * - * @param array $action The action that should be registered. - * @param bool $remove_action When true, it removes the action automatically to clean up this test. - * - * @return void - */ - protected function check_parameters_registered_in_wp( array $action, $remove_action = true ) { - global $wp_filter; - $registered_action = $wp_filter[ $action['hook'] ]->callbacks[ $action['priority'] ]; - - $this->assertArrayHasKey( $action['callback'], $registered_action ); - $this->assertEquals( $action['callback'], $registered_action[ $action['callback'] ]['function'] ); - $this->assertEquals( $action['args'], $registered_action[ $action['callback'] ]['accepted_args'] ); - - // Then remove the action. - if ( $remove_action ) { - remove_action( $action['hook'], $action['callback'], $action['priority'] ); - } - } - - /** - * Set up the original action. - * - * @since 1.5.0 - * - * @param string $id Optional. Beans ID to register. Default is 'foo'. - * - * @return array - */ - protected function setup_original_action( $id = 'foo' ) { - $action = [ - 'hook' => "{$id}_hook", - 'callback' => "callback_{$id}", - 'priority' => 10, - 'args' => 1, - ]; - - $this->check_not_added( $id, $action['hook'] ); - - // Add the original action to get us rolling. - beans_add_action( $id, $action['hook'], $action['callback'] ); - $this->assertTrue( has_action( $action['hook'] ) ); - $this->check_parameters_registered_in_wp( $action, false ); - - return $action; - } - - /** - * Simulate going to the post and loading in the template and fragments. - * - * @since 1.5.0 - * - * @return void - */ - protected function go_to_post() { - - /** - * Restore the actions. Why? The file loads once and initially adds the actions. But then we remove them - * during our tests. - */ - foreach ( static::$test_ids as $beans_id ) { - $this->restore_original( $beans_id ); - } - - $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); - $this->go_to( get_permalink( $post_id ) ); - do_action( 'template_redirect' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Valid use case as we need to fire this action as part of our tests. - } -} diff --git a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php b/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php deleted file mode 100644 index f7ed7194..00000000 --- a/tests/phpunit/integration/api/actions/includes/class-replace-action-test-case.php +++ /dev/null @@ -1,105 +0,0 @@ -reset_beans_registry = false; - - parent::setUp(); - - // Just in case the original action is already registered, remove it. - $this->remove_original_action(); - } - - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - - // Reset and restore. - foreach ( static::$test_actions as $beans_id => $action ) { - // Reset Beans. - _beans_unset_action( $beans_id, 'modified' ); - _beans_unset_action( $beans_id, 'replaced' ); - _beans_unset_action( $beans_id, 'added' ); - - // Restore the original action. - beans_add_smart_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); - } - - parent::tearDown(); - } - - /** - * Store the original action and then remove it. These steps allow us to set up an - * initial test where the action is not registered. Then when we're doing testing, we can - * restore it. - * - * @since 1.5.0 - * - * @return void - */ - private function remove_original_action() { - - foreach ( static::$test_actions as $beans_id => $action ) { - _beans_unset_action( $beans_id, 'added' ); - - if ( has_action( $action['hook'], $action['callback'] ) ) { - remove_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); - } - } - } - - /** - * Merge the action's configuration with the defaults. - * - * @since 1.5.0 - * - * @param array $action The action to merge. - * - * @return array - */ - protected function merge_action_with_defaults( array $action ) { - return array_merge( - [ - 'hook' => null, - 'callback' => null, - 'priority' => null, - 'args' => null, - ], - $action - ); - } - - /** - * Check that the "replaced" action has been stored in Beans. - * - * @since 1.5.0 - * - * @param string $beans_id The Beans unique ID. - * @param array $replaced_action The "replaced" action's configuration. - * - * @return void - */ - protected function check_stored_in_beans( $beans_id, array $replaced_action ) { - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'replaced' ) ); - $this->assertEquals( $replaced_action, _beans_get_action( $beans_id, 'modified' ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/flush.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/flush.php deleted file mode 100644 index da805f17..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/flush.php +++ /dev/null @@ -1,58 +0,0 @@ -directoryExists( vfsStream::url( 'compiled/beans/compiler/' ) ); - - $this->assertNull( ( new _Beans_Compiler_Options() )->flush() ); - - // Check that it still exists and was not removed. - $this->directoryExists( vfsStream::url( 'compiled/beans/compiler/' ) ); - } - - /** - * Test _Beans_Compiler_Options::flush() should should remove the cached directory. - */ - public function test_should_remove_cached_dir() { - // Check that the cached directory exists before we start. - $this->directoryExists( vfsStream::url( 'compiled/beans/compiler/' ) ); - - $this->go_to_settings_page(); - $_POST['beans_flush_compiler_cache'] = 1; - - // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. - Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); - - $this->assertNull( ( new _Beans_Compiler_Options() )->flush() ); - $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/' ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/register.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/register.php deleted file mode 100644 index 1a6dbf8f..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/register.php +++ /dev/null @@ -1,193 +0,0 @@ -assertNull( ( new _Beans_Compiler_Options() )->register() ); - } - - /** - * Test _Beans_Compiler_Options::register() should not register when not is_admin(), i.e. not in the backend. - */ - public function test_should_not_register_when_not_is_admin() { - set_current_screen( 'front' ); - $_GET['page'] = 'beans_settings'; - $this->assertFalse( is_admin() ); - $this->assertNull( ( new _Beans_Compiler_Options() )->register() ); - } - - /** - * Test _Beans_Compiler_Options::register() should register only the flush button when the styles and scripts are - * not supported. - */ - public function test_should_only_register_only_flush_button_when_styles_scripts_not_supported() { - $this->go_to_settings_page(); - - // Set up the tests by removing these API components. - beans_remove_api_component_support( 'wp_styles_compiler' ); - beans_remove_api_component_support( 'wp_scripts_compiler' ); - $this->assertFalse( beans_get_component_support( 'wp_styles_compiler' ) ); - $this->assertFalse( beans_get_component_support( 'wp_scripts_compiler' ) ); - - // Run the registration. - $this->assertTrue( ( new _Beans_Compiler_Options() )->register() ); - - // Check that the fields did get registered. - $registered_fields = beans_get_fields( 'option', 'compiler_options' ); - $this->assertNotEmpty( $registered_fields ); - $this->assertCount( 1, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - ], current( $registered_fields ) ); - - // Check that the metabox did get registered. - global $wp_meta_boxes; - $this->assertArrayHasKey( 'compiler_options', $wp_meta_boxes['beans_settings']['normal']['default'] ); - $this->assertEquals( 'Compiler options', $wp_meta_boxes['beans_settings']['normal']['default']['compiler_options']['title'] ); - } - - /** - * Test _Beans_Compiler_Options::register() should not register the styles options when not supported. - */ - public function test_should_not_register_styles_options_when_not_supported() { - $this->go_to_settings_page(); - - // Set up API components. - beans_remove_api_component_support( 'wp_styles_compiler' ); - beans_add_api_component_support( 'wp_scripts_compiler' ); - $this->assertFalse( beans_get_component_support( 'wp_styles_compiler' ) ); - $this->assertNotEmpty( beans_get_component_support( 'wp_scripts_compiler' ) ); - - // Run the registration. - $this->assertTrue( ( new _Beans_Compiler_Options() )->register() ); - - // Check that the right fields did get registered. - $registered_fields = beans_get_fields( 'option', 'compiler_options' ); - $this->assertCount( 2, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - ], current( $registered_fields ) ); - $this->assertArraySubset( [ - 'id' => 'beans_compile_all_scripts_group', - 'label' => 'Compile all WordPress scripts', - 'type' => 'group', - ], next( $registered_fields ) ); - - // Check that the metabox did get registered. - global $wp_meta_boxes; - $this->assertArrayHasKey( 'compiler_options', $wp_meta_boxes['beans_settings']['normal']['default'] ); - $this->assertEquals( 'Compiler options', $wp_meta_boxes['beans_settings']['normal']['default']['compiler_options']['title'] ); - } - - /** - * Test _Beans_Compiler_Options::register() should not register the scripts options when not supported. - */ - public function test_should_not_register_scripts_options_when_not_supported() { - $this->go_to_settings_page(); - - // Set up API components. - beans_add_api_component_support( 'wp_styles_compiler' ); - beans_remove_api_component_support( 'wp_scripts_compiler' ); - $this->assertNotEmpty( beans_get_component_support( 'wp_styles_compiler' ) ); - $this->assertFalse( beans_get_component_support( 'wp_scripts_compiler' ) ); - - // Run the registration. - $this->assertTrue( ( new _Beans_Compiler_Options() )->register() ); - - // Check that the right fields did get registered. - $registered_fields = beans_get_fields( 'option', 'compiler_options' ); - $this->assertCount( 2, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - ], current( $registered_fields ) ); - $this->assertArraySubset( [ - 'id' => 'beans_compile_all_styles', - 'label' => 'Compile all WordPress styles', - 'checkbox_label' => 'Select to compile styles.', - 'type' => 'checkbox', - 'default' => false, - ], next( $registered_fields ) ); - - // Check that the metabox did get registered. - global $wp_meta_boxes; - $this->assertArrayHasKey( 'compiler_options', $wp_meta_boxes['beans_settings']['normal']['default'] ); - $this->assertEquals( 'Compiler options', $wp_meta_boxes['beans_settings']['normal']['default']['compiler_options']['title'] ); - } - - /** - * Test _Beans_Compiler_Options::register() should register all options when styles and scripts are supported. - */ - public function test_should_register_all_options_when_styles_scripts_supported() { - $this->go_to_settings_page(); - - // Set up API components. - beans_add_api_component_support( 'wp_styles_compiler' ); - beans_add_api_component_support( 'wp_scripts_compiler' ); - $this->assertNotEmpty( beans_get_component_support( 'wp_styles_compiler' ) ); - $this->assertNotEmpty( beans_get_component_support( 'wp_scripts_compiler' ) ); - - // Run the registration. - $this->assertTrue( ( new _Beans_Compiler_Options() )->register() ); - - // Check that the right fields did get registered. - $registered_fields = beans_get_fields( 'option', 'compiler_options' ); - $this->assertCount( 3, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - ], current( $registered_fields ) ); - $this->assertArraySubset( [ - 'id' => 'beans_compile_all_styles', - 'label' => 'Compile all WordPress styles', - 'checkbox_label' => 'Select to compile styles.', - 'type' => 'checkbox', - 'default' => false, - ], next( $registered_fields ) ); - $this->assertArraySubset( [ - 'id' => 'beans_compile_all_scripts_group', - 'label' => 'Compile all WordPress scripts', - 'type' => 'group', - ], next( $registered_fields ) ); - - // Check that the metabox did get registered. - global $wp_meta_boxes; - $this->assertArrayHasKey( 'compiler_options', $wp_meta_boxes['beans_settings']['normal']['default'] ); - $this->assertEquals( 'Compiler options', $wp_meta_boxes['beans_settings']['normal']['default']['compiler_options']['title'] ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderFlushButton.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/renderFlushButton.php deleted file mode 100644 index 57ebf3c0..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderFlushButton.php +++ /dev/null @@ -1,55 +0,0 @@ -render_flush_button( [ 'id' => 'foo' ] ); - - $this->assertEmpty( ob_get_clean() ); - } - - /** - * Test _Beans_Compiler_Options::render_flush_button() should render when the field is for compiler options. - */ - public function test_should_render_when_field_is_compiler_items_options() { - $this->go_to_settings_page(); - $_POST = [ 'beans_flush_compiler_cache' => 1 ]; - - ob_start(); - ( new _Beans_Compiler_Options() )->render_flush_button( [ 'id' => 'beans_compiler_items' ] ); - $actual = ob_get_clean(); - - $expected = << -EOB; - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderScriptsNotCompiledNotice.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/renderScriptsNotCompiledNotice.php deleted file mode 100644 index 1a3d79d1..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderScriptsNotCompiledNotice.php +++ /dev/null @@ -1,68 +0,0 @@ -assertFalse( _beans_is_compiler_dev_mode() ); - - $this->assertNull( ( new _Beans_Compiler_Options() )->render_scripts_not_compiled_notice() ); - } - - /** - * Test _Beans_Compiler_Options::render_scripts_not_compiled_notice() should not render when compile scripts is not - * an option. - */ - public function test_should_not_render_when_compile_scripts_not_an_option() { - add_option( 'beans_dev_mode', 1 ); - $this->assertTrue( _beans_is_compiler_dev_mode() ); - $this->assertEmpty( get_option( 'beans_compile_all_scripts' ) ); - - $this->assertNull( ( new _Beans_Compiler_Options() )->render_scripts_not_compiled_notice() ); - } - - /** - * Test _Beans_Compiler_Options::render_scripts_not_compiled_notice() should render when compile scripts is - * selected and Compiler is in dev mode. - */ - public function test_should_render_when_compile_scripts_selected_and_compiler_in_dev_mode() { - add_option( 'beans_dev_mode', 1 ); - add_option( 'beans_compile_all_scripts', 1 ); - $this->assertTrue( _beans_is_compiler_dev_mode() ); - $this->assertEquals( 1, get_option( 'beans_compile_all_scripts' ) ); - - ob_start(); - ( new _Beans_Compiler_Options() )->render_scripts_not_compiled_notice(); - $actual = ob_get_clean(); - - $expected = << -Scripts are not compiled in development mode. -EOB; - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php deleted file mode 100644 index b0c9f31c..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderStylesNotCompiledNotice.php +++ /dev/null @@ -1,68 +0,0 @@ -assertFalse( _beans_is_compiler_dev_mode() ); - - $this->assertNull( ( new _Beans_Compiler_Options() )->render_styles_not_compiled_notice() ); - } - - /** - * Test _Beans_Compiler_Options::render_styles_not_compiled_notice() should not render when compile styles is not - * an option. - */ - public function test_should_not_render_when_compile_styles_not_an_option() { - add_option( 'beans_dev_mode', 1 ); - $this->assertTrue( _beans_is_compiler_dev_mode() ); - $this->assertEmpty( get_option( 'beans_compile_all_styles' ) ); - - $this->assertNull( ( new _Beans_Compiler_Options() )->render_styles_not_compiled_notice() ); - } - - /** - * Test _Beans_Compiler_Options::render_styles_not_compiled_notice() should render when compile styles is selected - * and Compiler is in dev mode. - */ - public function test_should_render_when_compile_styles_selected_and_compiler_in_dev_mode() { - add_option( 'beans_dev_mode', 1 ); - add_option( 'beans_compile_all_styles', 1 ); - $this->assertEquals( 1, get_option( 'beans_compile_all_styles' ) ); - $this->assertTrue( _beans_is_compiler_dev_mode() ); - - ob_start(); - ( new _Beans_Compiler_Options() )->render_styles_not_compiled_notice(); - $actual = ob_get_clean(); - - $expected = << -Styles are not compiled in development mode. -EOB; - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderSuccessNotice.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/renderSuccessNotice.php deleted file mode 100644 index ab75fd2d..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/renderSuccessNotice.php +++ /dev/null @@ -1,58 +0,0 @@ -go_to_settings_page(); - $this->assertArrayNotHasKey( 'beans_flush_compiler_cache', $_POST ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- No need for nonce in this test. - - ob_start(); - ( new _Beans_Compiler_Options() )->render_success_notice(); - - $this->assertEmpty( ob_get_clean() ); - } - - /** - * Test _Beans_Compiler_Options::render_success_notice() should render when flushing compiler cache. - */ - public function test_should_render_when_flushing_compiler_cache() { - $this->go_to_settings_page(); - $_POST['beans_flush_compiler_cache'] = 1; - - ob_start(); - ( new _Beans_Compiler_Options() )->render_success_notice(); - $actual = ob_get_clean(); - - $expected = << -

                Cache flushed successfully!

                -
                -EOB; - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php deleted file mode 100644 index 085359ea..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/addContentMediaQuery.php +++ /dev/null @@ -1,108 +0,0 @@ -set_current_fragment( $compiler, [ $this, __METHOD__ ] ); - $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); - } - - /** - * Test _Beans_Compiler::add_content_media_query() should return original content when there are no query args. - */ - public function test_should_return_content_when_no_query_args() { - $compiler = new _Beans_Compiler( [] ); - $css = <<set_current_fragment( $compiler, 'http://foo.com/foo.css' ); - $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); - - $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/foo.less' ); - $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); - } - - /** - * Test _Beans_Compiler::add_content_media_query() should return original content when the - * 'beans_compiler_media_query' query arg is not present in the current fragment. - */ - public function test_should_return_content_when_no_media_query() { - $compiler = new _Beans_Compiler( [] ); - $css = <<set_current_fragment( $compiler, 'http://foo.com/base.css?beans=rocks' ); - $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); - - $this->set_current_fragment( $compiler, 'http://foo.com/style.css?beans=rocks&beans_compiler=media_query' ); - $this->assertSame( $css, $compiler->add_content_media_query( $css ) ); - } - - /** - * Test _Beans_Compiler::add_content_media_query() should wrap the content in the specified media query. - */ - public function test_should_wrap_content_in_media_query() { - $compiler = new _Beans_Compiler( [] ); - $css = <<set_current_fragment( $compiler, 'http://foo.com/base.css?beans_compiler_media_query=' . $media_query ); - $this->assertSame( - "@media {$media_query} {\n{$css}\n}\n", - $compiler->add_content_media_query( $css ) - ); - } - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php deleted file mode 100644 index ece67172..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/cacheFile.php +++ /dev/null @@ -1,135 +0,0 @@ - 'test-jquery', - 'type' => 'script', - 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - ]; - $compiler = $this->initialize_compiler( $config ); - - // Run the tests. - $this->assertTrue( $compiler->cache_file() ); - $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); - - // Clean Up. - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } - - /** - * Test _Beans_Compiler::cache_file() should create the compiled JavaScript file. - */ - public function test_should_create_compiled_javascript_file() { - $config = [ - 'id' => 'test-js', - 'type' => 'script', - 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ], - 'in_footer' => true, - 'minify_js' => true, - ]; - $compiler = $this->initialize_compiler( $config ); - - // Run the tests. - $this->assertTrue( $compiler->cache_file() ); - $this->assertSame( $this->get_compiled_js(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); - - // Clean Up. - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } - - /** - * Test _Beans_Compiler::cache_file() should create the compiled CSS file. - */ - public function test_should_create_compiled_css_file() { - $config = [ - 'id' => 'test-css', - 'type' => 'style', - 'fragments' => [ vfsStream::url( 'compiled/fixtures/style.css' ) ], - ]; - $compiler = $this->initialize_compiler( $config ); - - // Run the tests. - $this->assertTrue( $compiler->cache_file() ); - $this->assertSame( $this->get_compiled_css(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); - - // Clean Up. - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } - - /** - * Test _Beans_Compiler::cache_file() should create the compiled LESS file. - */ - public function test_should_create_compiled_less_file() { - $config = [ - 'id' => 'test-css', - 'type' => 'style', - 'format' => 'less', - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/variables.less' ), - vfsStream::url( 'compiled/fixtures/test.less' ), - ], - ]; - $compiler = $this->initialize_compiler( $config ); - - // Run the tests. - $this->assertTrue( $compiler->cache_file() ); - $this->assertSame( $this->get_compiled_less(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); - - // Clean Up. - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } - - /** - * Initialize the Compiler for the test. - * - * @since 1.0.0 - * - * @param array $config Array of runtime configuration parameters. - * - * @return _Beans_Compiler - * @throws \ReflectionException Throws an error. - */ - protected function initialize_compiler( array $config ) { - $compiler = new _Beans_Compiler( $config ); - - add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - $compiler->filesystem(); - $this->add_virtual_directory( $config['id'] ); - $this->set_current_fragment( $compiler, $config['fragments'][0] ); - $compiler->set_filename(); - $compiler->combine_fragments(); - - return $compiler; - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php deleted file mode 100644 index 462bdcf0..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php +++ /dev/null @@ -1,309 +0,0 @@ -mock_filesystem->getChild( 'fixtures' ); - $this->css = $fixtures->getChild( 'style.css' )->getContent(); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); - $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); - $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); - } - - /** - * Test _Beans_Compiler::combine_fragments() should return an empty string when there are no fragments to combine. - */ - public function test_should_return_empty_string_when_no_fragments() { - $compiler = new _Beans_Compiler( [] ); - - // Run the test. - $compiler->combine_fragments(); - $this->assertSame( '', $compiler->compiled_content ); - } - - /** - * Test _Beans_Compiler::combine_fragments() should return an empty string when the fragment does not exist. - */ - public function test_should_return_empty_string_when_fragment_does_not_exist() { - $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = new _Beans_Compiler( [] ); - $this->set_current_fragment( $compiler, $fragment ); - - // Run the test. - $compiler->combine_fragments(); - $this->assertSame( '', $compiler->compiled_content ); - } - - /** - * Test _Beans_Compiler::combine_fragments() should compile the Less fragments and return the compiled CSS. - */ - public function test_should_compile_less_and_return_css() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/variables.less' ), - vfsStream::url( 'compiled/fixtures/test.less' ), - ], - ] ); - - // Set up the test. - $this->set_up_wp_filesystem( $compiler ); - $this->set_dev_mode( true ); - - // Run the test. - $compiler->combine_fragments(); - $expected_css = <<assertSame( $expected_css, $compiler->compiled_content ); - } - - /** - * Test _Beans_Compiler::combine_fragments() should return minified, compiled Less from the Less combined fragments. - */ - public function test_should_return_minified_compiled_less() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/variables.less' ), - vfsStream::url( 'compiled/fixtures/test.less' ), - ], - ] ); - - // Set up the test. - $this->set_up_wp_filesystem( $compiler ); - $this->set_dev_mode( false ); - - // Run the test. - $compiler->combine_fragments(); - $this->assertContains( $this->get_compiled_less(), $compiler->compiled_content ); - } - - /** - * Test _Beans_Compiler::combine_fragments() should return the original jQuery when site is not in development mode, - * but "minify_js" is disabled. - */ - public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ], - 'dependencies' => [ 'jquery' ], - ] ); - - // Set up the test. - $this->set_up_wp_filesystem( $compiler ); - $this->set_dev_mode( false ); - - // Run the test. - $compiler->combine_fragments(); - $this->assertSame( $this->jquery, $compiler->compiled_content ); - } - - /** - * Test _Beans_Compiler::combine_fragments() should return the original jQuery when "minify_js" is enabled, - * but the site is in development mode. - */ - public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ], - 'dependencies' => [ 'jquery' ], - ] ); - - // Set up the test. - $this->set_up_wp_filesystem( $compiler ); - $this->set_dev_mode( true ); - - // Run the test. - $compiler->combine_fragments(); - $this->assertSame( $this->jquery, $compiler->compiled_content ); - } - - /** - * Test _Beans_Compiler::combine_fragments() should return minified jQuery. - */ - public function test_should_return_minified_jquery() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ], - 'dependencies' => [ 'jquery' ], - ] ); - - // Set up the test. - $this->set_up_wp_filesystem( $compiler ); - $this->set_dev_mode( false ); - - // Run the test. - $compiler->combine_fragments(); - $this->assertSame( $this->get_compiled_jquery(), $compiler->compiled_content ); - } - - /** - * Test _Beans_Compiler::combine_fragments() should return the original JavaScript when site is not in development - * mode, but "minify_js" is disabled. - */ - public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ], - ] ); - - // Set up the test. - $this->set_up_wp_filesystem( $compiler ); - $this->set_dev_mode( false ); - - // Run the test. - $compiler->combine_fragments(); - $this->assertSame( $this->js, $compiler->compiled_content ); - - // Clean up. - unset( $GLOBALS['wp_filesystem'] ); - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } - - /** - * Test _Beans_Compiler::combine_fragments() should return the original JavaScript when "minify_js" is enabled, - * but the site is in development mode. - */ - public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ], - ] ); - - // Set up the test. - $this->set_up_wp_filesystem( $compiler ); - $this->set_dev_mode( true ); - - // Run the test. - $compiler->combine_fragments(); - $this->assertSame( $this->js, $compiler->compiled_content ); - - // Clean up. - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } - - /** - * Test _Beans_Compiler::combine_fragments() should return minified JavaScript. - */ - public function test_should_return_minified_javascript() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ], - ] ); - - // Set up the test. - $this->set_up_wp_filesystem( $compiler ); - $this->set_dev_mode( false ); - - // Run the test. - $compiler->combine_fragments(); - $this->assertSame( $this->get_compiled_js(), $compiler->compiled_content ); - - // Clean up. - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } - - /** - * Set the WP Filesystem. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the compiler. - * - * @return void - */ - private function set_up_wp_filesystem( $compiler ) { - add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - $compiler->filesystem(); - $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php deleted file mode 100644 index 774d2a24..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php +++ /dev/null @@ -1,103 +0,0 @@ -once() - ->andReturn( 'base' ); - Functions\expect( __NAMESPACE__ . '\set_wp_die_handler' ) - ->once() - ->andReturn( __NAMESPACE__ . '\mock_wp_die_handler' ); - Functions\when( __NAMESPACE__ . '\mock_wp_die_handler' ) - ->alias( function( $message ) { - $this->assertContains( 'Beans cannot work its magic', $message ); - } ); - - add_filter( 'wp_die_handler', __NAMESPACE__ . '\set_wp_die_handler' ); - - // Initialize the WP Filesystem. - $this->assertNull( $compiler->filesystem() ); - - // Clean up. - unset( $GLOBALS['wp_filesystem'] ); - remove_filter( 'wp_die_handler', __NAMESPACE__ . '\set_wp_die_handler' ); - remove_filter( 'filesystem_method', __NAMESPACE__ . '\set_filesystem_method_to_base' ); - } - - /** - * Test _Beans_Compiler::filesystem() should initialize the WP Filesystem. - */ - public function test_should_init_wp_filesystem() { - $compiler = new _Beans_Compiler( [] ); - - add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - - // Initialize the WP Filesystem. - $this->assertTrue( $compiler->filesystem() ); - - // Check that it was initialized. - $this->assertTrue( function_exists( 'WP_Filesystem' ) ); - $this->assertTrue( class_exists( 'WP_Filesystem_Direct' ) ); - $this->assertArrayHasKey( 'wp_filesystem', $GLOBALS ); - $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); - - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } - - /** - * Test _Beans_Compiler::filesystem() should set WP_Filesystem_Direct when not set as WP_Filesystem method. - */ - public function test_should_set_wp_filesystem_direct() { - // First, set something else as the WP_Filesystem method. - Functions\expect( __NAMESPACE__ . '\set_filesystem_method_to_base' ) - ->once() - ->andReturn( 'base' ); - - add_filter( 'filesystem_method', __NAMESPACE__ . '\set_filesystem_method_to_base' ); - WP_Filesystem(); - $this->assertInstanceOf( 'WP_Filesystem_Base', $GLOBALS['wp_filesystem'] ); - remove_filter( 'filesystem_method', __NAMESPACE__ . '\set_filesystem_method_to_base' ); - - // Next, let's run our Compiler's filesystem and check that it did initialize WP_Filesystem_Direct. - $compiler = new _Beans_Compiler( [] ); - - add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - $this->assertTrue( $compiler->filesystem() ); - $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php deleted file mode 100644 index 9b3d083c..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ /dev/null @@ -1,237 +0,0 @@ -mock_filesystem->getChild( 'fixtures' ); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); - $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); - $this->js = $fixtures->getChild( 'my-game-clock.js' )->getContent(); - } - - /** - * Test _Beans_Compiler::format_content() should return original content when the "type" is not - * a style or script (per the configuration). - */ - public function test_should_return_original_content_when_type_not_style_or_script() { - $compiler = new \_Beans_Compiler( [ - 'type' => 'foo', - ] ); - - // Run the tests. - $this->assertSame( $this->less, $compiler->format_content( $this->less ) ); - $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); - $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); - } - - /** - * Test _Beans_Compiler::format_content() should return compiled CSS (not minified) from the Less combined - * fragments. - */ - public function test_should_return_compiled_css() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - ] ); - - // Turn on development mode. - update_option( 'beans_dev_mode', true ); - - // Don't remove empty line before EOB; ! - $expected_css = <<assertSame( $expected_css, $compiler->format_content( $this->less ) ); - } - - /** - * Test _Beans_Compiler::format_content() should return minified, compiled CSS from the Less combined fragments. - */ - public function test_should_return_minified_compiled_css() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - ] ); - - // Turn off development mode. - update_option( 'beans_dev_mode', false ); - - $expected_css = <<assertSame( $expected_css, $compiler->format_content( $this->less ) ); - } - - /** - * Test _Beans_Compiler::format_content() should return the original jQuery when site is not in development mode, - * but "minify_js" is disabled. - */ - public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - ] ); - - // Turn off development mode. - update_option( 'beans_dev_mode', false ); - - // Run the test. - $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); - } - - /** - * Test _Beans_Compiler::format_content() should return the original jQuery when "minify_js" is enabled, - * but the site is in development mode. - */ - public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); - - // Turn on development mode. - update_option( 'beans_dev_mode', true ); - - // Run the test. - $this->assertSame( $this->jquery, $compiler->format_content( $this->jquery ) ); - } - - /** - * Test _Beans_Compiler::format_content() should return minified jQuery when "minify_js" is enabled - * and the site is not in development mode. - */ - public function test_should_return_minified_jquery_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); - - // Turn off development mode. - update_option( 'beans_dev_mode', false ); - - $expected = <<assertSame( str_replace( '/$', '$', $expected ), $compiler->format_content( $this->jquery ) ); - } - - /** - * Test _Beans_Compiler::format_content() should return the original JavaScript when site is not in development - * mode, but "minify_js" is disabled. - */ - public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - ] ); - - // Turn off development mode. - update_option( 'beans_dev_mode', false ); - - // Run the test. - $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); - } - - /** - * Test _Beans_Compiler::format_content() should return the original JavaScript when "minify_js" is enabled, - * but the site is in development mode. - */ - public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); - - // Turn on development mode. - update_option( 'beans_dev_mode', true ); - - // Run the test. - $this->assertSame( $this->js, $compiler->format_content( $this->js ) ); - } - - /** - * Test _Beans_Compiler::format_content() should return minified JavaScript when "minify_js" is enabled - * and the site is not in development mode. - */ - public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); - - // Turn off development mode. - update_option( 'beans_dev_mode', false ); - - $expected = <<assertSame( $expected, $compiler->format_content( $this->js ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php deleted file mode 100644 index 5f7d5cec..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php +++ /dev/null @@ -1,76 +0,0 @@ -assertfalse( $compiler->get_internal_content( '' ) ); - } - - /** - * Test _Beans_Compiler::get_internal_content() should return false when the file does not exist. - */ - public function test_should_return_false_when_file_does_not_exist() { - // Set up the compiler. - $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); - $this->set_current_fragment( $compiler, $fragment ); - - // Run the test. - $this->assertfalse( $compiler->get_internal_content( $fragment ) ); - } - - /** - * Test _Beans_Compiler::get_internal_content() should return a fragment's contents. - */ - public function test_should_return_fragment_contents() { - // Set up the compiler. - $fragment = vfsStream::url( 'compiled/fixtures/test.less' ); - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); - $this->set_current_fragment( $compiler, $fragment ); - - // Set the WP Filesystem. - add_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - $compiler->filesystem(); - $this->assertInstanceOf( 'WP_Filesystem_Direct', $GLOBALS['wp_filesystem'] ); - - // Run the tests. - $contents = $compiler->get_internal_content( $fragment ); - $this->assertContains( 'body {', $contents ); - $this->assertContains( 'color: @body-color;', $contents ); - - // Clean up. - remove_filter( 'filesystem_method', [ $compiler, 'modify_filesystem_method' ] ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php deleted file mode 100644 index b36962f9..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php +++ /dev/null @@ -1,106 +0,0 @@ -assertfalse( $compiler->get_remote_content( '' ) ); - } - - /** - * Test _Beans_Compiler::get_remote_content() should return empty string when the remote site or file does not - * exist. - */ - public function test_should_return_empty_string_when_remote_does_not_exist() { - $fragment = 'http://beans.local/invalid-file.js'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); - $this->set_current_fragment( $compiler, $fragment ); - - // Run the test. - $this->assertSame( '', $compiler->get_remote_content( $fragment ) ); - } - - /** - * Test _Beans_Compiler::get_remote_content() should return the content when fragment is a relative url. - */ - public function test_should_return_content_when_fragment_is_relative_url() { - $fragment = '//fonts.googleapis.com/css?family=Lato'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); - $this->set_current_fragment( $compiler, $fragment ); - - $content = $compiler->get_remote_content( $fragment ); - - // Run the tests. - $this->assertContains( "font-family: 'Lato';", $content ); - $this->assertContains( 'font-style: normal;', $content ); - $this->assertContains( 'font-weight: 400;', $content ); - $this->assertContains( "src: local('Lato Regular')", $content ); - } - - /** - * Test _Beans_Compiler::get_remote_content() should return the content when fragment is an http URL. - */ - public function test_should_return_content_when_fragment_is_http() { - $fragment = 'http://fonts.googleapis.com/css?family=Roboto'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); - $this->set_current_fragment( $compiler, $fragment ); - - $content = $compiler->get_remote_content( $fragment ); - - // Run the tests. - $this->assertContains( "font-family: 'Roboto';", $content ); - $this->assertContains( 'font-style: normal;', $content ); - $this->assertContains( 'font-weight: 400;', $content ); - $this->assertContains( "src: local('Roboto')", $content ); - } - - /** - * Test _Beans_Compiler::get_remote_content() should return the content when fragment is an https URL. - */ - public function test_should_return_content_when_fragment_is_https() { - $fragment = 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); - $this->set_current_fragment( $compiler, $fragment ); - - $content = $compiler->get_remote_content( $fragment ); - - // Run the tests. - $this->assertContains( 'Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome', $content ); - $this->assertContains( "@font-face{font-family:'FontAwesome';", $content ); - $this->assertContains( "src:url('../fonts/fontawesome-webfont.eot?v=4.7.0');", $content ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php b/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php deleted file mode 100644 index 16e71381..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/replaceCssUrl.php +++ /dev/null @@ -1,210 +0,0 @@ -assertSame( $css, $compiler->replace_css_url( $css ) ); - } - - /** - * Test _Beans_Compiler::replace_css_url() should return original content when it has a valid URI. - */ - public function test_should_return_original_content_when_valid_uri() { - $compiler = new _Beans_Compiler( [] ); - $css = <<assertSame( $css, $compiler->replace_css_url( $css ) ); - } - - /** - * Test _Beans_Compiler::replace_css_url() should convert the relative URL when it does not have ../. - */ - public function test_should_convert_relative_url_when_no_up_levels() { - $compiler = new _Beans_Compiler( [] ); - - // Set up the mocks. - $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); - - $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); - } - - /** - * Test _Beans_Compiler::replace_css_url() should convert the relative URL. - */ - public function test_should_convert_relative_url() { - $compiler = new _Beans_Compiler( [] ); - - // Set up the mocks. - $this->set_current_fragment( $compiler, 'http://foo.com/assets/less/hero.less' ); - - // Test with no spaces, single quotes, or double quotes. - $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); - - // Test with spaces and single quotes. - $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); - - // Test with spaces and double quotes. - $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); - } - - /** - * Test _Beans_Compiler::replace_css_url() should convert a deeper relative URL. - */ - public function test_should_convert_deeper_relative_url() { - $compiler = new _Beans_Compiler( [] ); - - // Set up the mocks. - $this->set_current_fragment( $compiler, 'http://example.com/assets/less/partials/hero.less' ); - - // Test with no spaces, single quotes, or double quotes. - $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); - - // Test with spaces and single quotes. - $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); - - // Test with spaces and double quotes. - $css = <<assertSame( $expected, $compiler->replace_css_url( $css ) ); - } - - /** - * Set the protected property "current_fragment". - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler The Compiler instance. - * @param mixed $fragment The given value to set. - * - * @return void - */ - protected function set_current_fragment( $compiler, $fragment ) { - $current_fragment = ( new \ReflectionClass( $compiler ) )->getProperty( 'current_fragment' ); - $current_fragment->setAccessible( true ); - $current_fragment->setValue( $compiler, $fragment ); - $current_fragment->setAccessible( false ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php deleted file mode 100644 index 8657cd12..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/runCompiler.php +++ /dev/null @@ -1,324 +0,0 @@ -mock_filesystem->getChild( 'fixtures' ); - $this->css = $fixtures->getChild( 'style.css' )->getContent(); - $this->less = $fixtures->getChild( 'variables.less' )->getContent() . $fixtures->getChild( 'test.less' )->getContent(); - $this->jquery = $fixtures->getChild( 'jquery.test.js' )->getContent(); - } - - /** - * Test _Beans_Compiler::cache_file() should enqueue the existing cached file when no modifications (no fragments - * have changed to warrant re-compiling the file). - */ - public function test_should_enqueue_existing_cached_file_when_no_modifications() { - $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = [ - 'id' => 'test-jquery', - 'type' => 'script', - 'format' => 'js', - 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - 'version' => '1.5.0', - ]; - $compiler = new _Beans_Compiler( $config ); - - // Store the cached file into the virtual filesystem. - $this->add_virtual_directory( $config['id'] ); - $original_filename = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); - $original_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $original_filename ); - vfsStream::newFile( $original_filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) - ->setContent( $this->get_compiled_jquery() ); - $this->assertFileExists( $original_file ); - - // Run the compiler. - $compiler->run_compiler(); - $actual_filename = $compiler->get_filename(); - - // Check that the "compiled" filename did not change. - $this->assertSame( $original_file, $actual_filename ); - - // Check that the file still exists. - $this->assertFileExists( $actual_filename ); - } - - /** - * Test _Beans_Compiler::cache_file() should recompile when a fragment(s) changes. When this happens, the existing - * cached file is removed and the new file is stored in the filesystem. - */ - public function test_should_recompile_when_fragments_change() { - $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = [ - 'id' => 'test-script', - 'type' => 'script', - 'format' => 'js', - 'fragments' => [ $fragment ], - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - 'version' => null, - ]; - $compiler = new _Beans_Compiler( $config ); - - /** - * Set up the original "compiled" file. This is the file that should get removed during this - * test. We add the file into the virtual filesystem. - */ - $this->add_virtual_directory( $config['id'] ); - $original_filemtime = filemtime( $fragment ); - $original_filename = $this->get_filename( $compiler, $config, $original_filemtime ); - $original_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $original_filename ); - vfsStream::newFile( $original_filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) - ->setContent( $this->get_compiled_jquery() ); - $original_hashes = explode( '-', pathinfo( $original_filename, PATHINFO_FILENAME ) ); - $this->assertFileExists( $original_file ); - - /** - * Next step is to modify the fragment, which will change its modification time. Let's add an opening - * comment to the fragment's content and then set up the modified file for our tests. - */ - $this->mock_filesystem->getChild( 'fixtures' ) - ->getChild( 'jquery.test.js' ) - ->write( $this->jquery . "\n console.log( 'Beans rocks!' ); \n" ); - $modified_filemtime = filemtime( $fragment ); - $modified_filename = $this->get_filename( $compiler, $config, $modified_filemtime ); - $modified_hashes = explode( '-', pathinfo( $modified_filename, PATHINFO_FILENAME ) ); - $modified_file = vfsStream::url( 'compiled/beans/compiler/' . $config['id'] . '/' . $modified_filename ); - $this->assertFileNotExists( $modified_file ); - - /** - * We've now completed the setup process. Let's test that the original fragment has changed by - * testing that it is not equal to the modification time, filename, and hashes. - */ - $this->assertNotEquals( $modified_filemtime, $original_filemtime ); - $this->assertNotEquals( $modified_filename, $original_filename ); - $this->assertSame( $modified_hashes[0], $original_hashes[0] ); - $this->assertNotEquals( $modified_hashes[1], $original_hashes[1] ); - - // Run the compiler. - $compiler->run_compiler(); - $actual_filename = $compiler->get_filename(); - - // Check that the "compiled" filename is different. - $this->assertNotEquals( $original_file, $actual_filename ); - $this->assertSame( $modified_file, $actual_filename ); - - // Check that the original cached file was removed. - $this->assertFileNotExists( $original_file ); - - // Check that a new file was cached. - $this->assertFileExists( $modified_file ); - $this->assertFileExists( $actual_filename ); - } - - /** - * Test _Beans_Compiler::cache_file() should compile jQuery, saving it to the virtual filesystem and enqueuing it - * in WordPress. - */ - public function test_should_compile_save_and_enqueue_jquery() { - $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = [ - 'id' => 'test-jquery', - 'type' => 'script', - 'format' => 'js', - 'fragments' => [ $fragment ], - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - 'version' => null, - ]; - $compiler = new _Beans_Compiler( $config ); - - // Set up the virtual directory. - $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( - 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) - ); - - // Run the compiler. Test. - $compiler->run_compiler(); - $actual_filename = $compiler->get_filename(); - $this->assertFileExists( $actual_filename ); - $this->assertSame( $expected_file, $actual_filename ); - $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); - } - - /** - * Test _Beans_Compiler::cache_file() should compile JavaScript, saving it to the virtual filesystem and enqueuing - * it in WordPress. - */ - public function test_should_compile_save_and_enqueue_js() { - $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $config = [ - 'id' => 'test-js', - 'type' => 'script', - 'format' => 'js', - 'fragments' => [ $fragment ], - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - 'version' => null, - ]; - $compiler = new _Beans_Compiler( $config ); - - // Set up the virtual directory. - $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( - 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) - ); - - // Run the compiler. Test. - $compiler->run_compiler(); - $actual_filename = $compiler->get_filename(); - $this->assertFileExists( $actual_filename ); - $this->assertSame( $expected_file, $actual_filename ); - $this->assertSame( $this->get_compiled_js(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); - } - - /** - * Test _Beans_Compiler::cache_file() should compile CSS, saving it to the virtual filesystem and enqueuing it in - * WordPress. - */ - public function test_should_compile_save_and_enqueue_css() { - $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); - $config = [ - 'id' => 'test-css', - 'type' => 'style', - 'format' => 'css', - 'fragments' => [ $fragment ], - 'dependencies' => false, - 'in_footer' => false, - 'minify_js' => false, - 'version' => '1.5.0', - ]; - $compiler = new _Beans_Compiler( $config ); - - // Set up the virtual directory. - $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( - 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config, filemtime( $fragment ) ) - ); - - // Run the compiler. Test. - $compiler->run_compiler(); - $actual_filename = $compiler->get_filename(); - $this->assertFileExists( $actual_filename ); - $this->assertSame( $expected_file, $actual_filename ); - $this->assertSame( $this->get_compiled_css(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); - } - - /** - * Test _Beans_Compiler::cache_file() should compile Less, saving it to the virtual filesystem and enqueuing it in - * WordPress. - */ - public function test_should_compile_save_and_enqueue_less() { - $config = [ - 'id' => 'test-css', - 'type' => 'style', - 'format' => 'less', - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/variables.less' ), - vfsStream::url( 'compiled/fixtures/test.less' ), - ], - 'dependencies' => false, - 'in_footer' => false, - 'minify_js' => false, - 'version' => '1.5.0', - ]; - $compiler = new _Beans_Compiler( $config ); - - // Set up the virtual directory. - $this->add_virtual_directory( $config['id'] ); - $expected_file = vfsStream::url( - 'compiled/beans/compiler/' . $config['id'] . '/' . $this->get_filename( $compiler, $config ) - ); - - // Run the compiler. Test. - $compiler->run_compiler(); - $actual_filename = $compiler->get_filename(); - $this->assertFileExists( $actual_filename ); - $this->assertSame( $expected_file, $actual_filename ); - $this->assertSame( $this->get_compiled_less(), $this->get_cached_contents( $compiler->filename, $config['id'] ) ); - } - - /** - * Get the filename from the compiler. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the compiler. - * - * @return string - */ - protected function get_actual_filename( $compiler ) { - $path = $compiler->get_filename(); - - if ( substr( $path, 0, 6 ) === 'vfs://' ) { - return $path; - } - - return str_replace( 'vfs:/', 'vfs://', $path ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php b/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php deleted file mode 100644 index b3bba301..00000000 --- a/tests/phpunit/integration/api/compiler/beans-compiler/setFilename.php +++ /dev/null @@ -1,163 +0,0 @@ -returnArg(); - } - - /** - * Test _Beans_Compiler::set_filename() should return the hash created with the modification time from each of the - * fragments. - */ - public function test_should_return_hash_created_with_fragments_filemtime() { - $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = [ - 'id' => 'test-script', - 'type' => 'script', - 'format' => false, - 'fragments' => [ $fragment ], - 'dependencies' => false, - 'in_footer' => true, - 'minify_js' => true, - 'version' => null, - ]; - $compiler = new _Beans_Compiler( $config ); - - // Set up the mocks. - $this->set_dev_mode( true ); - $this->add_virtual_directory( $config['id'] ); - - // Set the filename. Test. - $compiler->set_filename(); - $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); - $this->assertSame( $expected, $compiler->filename ); - } - - /** - * Test _Beans_Compiler::set_filename() should exclude external fragments. - */ - public function test_should_exclude_external_fragments() { - $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $config = [ - 'id' => 'test-script', - 'type' => 'script', - 'format' => false, - 'fragments' => [ - $fragment, - 'http://foo.com/my-script.js', // Should skip this one. - ], - 'dependencies' => false, - 'in_footer' => true, - 'minify_js' => true, - 'version' => null, - ]; - $compiler = new _Beans_Compiler( $config ); - - // Set up the mocks. - $this->set_dev_mode( true ); - $this->add_virtual_directory( $config['id'] ); - - // Test that we are in dev mode & the directory does exist. - $this->assertTrue( _beans_is_compiler_dev_mode() ); - $this->directoryExists( vfsStream::url( 'compiled/beans/compiler/test-script' ) ); - $this->assertTrue( is_dir( $compiler->dir ) ); - - // Set the filename. Test. - $compiler->set_filename(); - $expected = $this->get_filename( $compiler, $config, filemtime( $fragment ) ); - $this->assertSame( $expected, $compiler->filename ); - } - - /** - * Test _Beans_Compiler::set_filename() should remove the old compiled file. - */ - public function test_should_remove_old_file() { - $fragment = vfsStream::url( 'compiled/fixtures/jquery.test.js' ); - $config = [ - 'id' => 'test', - 'type' => 'script', - 'format' => 'js', - 'fragments' => [ $fragment ], - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - 'version' => null, - ]; - $compiler = new _Beans_Compiler( $config ); - - // Set up the mocks. - $this->set_dev_mode( true ); - $this->add_virtual_directory( $config['id'] ); - - /** - * Set up the original "compiled" file. This is the file that should get removed during this - * test. We add the file into the virtual filesystem. - */ - $original_filemtime = filemtime( $fragment ); - $original_filename = $this->get_filename( $compiler, $config, $original_filemtime ); - vfsStream::newFile( $original_filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) - ->setContent( $this->get_compiled_jquery() ); - $original_hashes = explode( '-', pathinfo( $original_filename, PATHINFO_FILENAME ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); - - /** - * Next step is to modify the fragment, which will change its modification time. Let's add an opening - * comment to the fragment's content and then set up the modified file for our tests. - */ - $file = $this->mock_filesystem->getChild( 'fixtures' )->getChild( 'jquery.test.js' ); - $file->write( "// changed \n" . $file->getContent() ); - $modified_filemtime = filemtime( $fragment ); - $modified_filename = $this->get_filename( $compiler, $config, $modified_filemtime ); - $modified_hashes = explode( '-', pathinfo( $modified_filename, PATHINFO_FILENAME ) ); - - /** - * We've now completed the set up process. Let's test that the original fragment has changed by - * testing that it is not equal to the modification time, filename, and hashes. - */ - $this->assertNotEquals( $modified_filemtime, $original_filemtime ); - $this->assertNotEquals( $modified_filename, $original_filename ); - $this->assertSame( $modified_hashes[0], $original_hashes[0] ); - $this->assertNotEquals( $modified_hashes[1], $original_hashes[1] ); - - /** - * Now let's run the compiler's set_filename() and test that: - * - * 1. The returned filename matches our modified filename. - * 2. The original "compiled" file was removed. - */ - $compiler->set_filename(); - $this->assertSame( $modified_filename, $compiler->filename ); - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/test/' . $original_filename ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php deleted file mode 100644 index d88898f9..00000000 --- a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageScripts.php +++ /dev/null @@ -1,209 +0,0 @@ -registered[ $handle ] ); - } - - $GLOBALS['wp_scripts']->done = []; - - parent::tearDown(); - } - - /** - * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when the scripts compiler is not supported. - */ - public function test_should_not_compile_when_scripts_compiler_not_supported() { - beans_remove_api_component_support( 'wp_scripts_compiler' ); - - Monkey\Functions\expect( 'get_option' )->with( 'beans_compile_all_scripts', false )->never(); - Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); - Monkey\Functions\expect( 'beans_get' )->never(); - Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when the "compile all scripts" option is not - * set. - */ - public function test_should_not_compile_when_option_is_not_set() { - beans_add_api_component_support( 'wp_scripts_compiler' ); - delete_option( 'beans_compile_all_scripts' ); - - Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); - Monkey\Functions\expect( 'beans_get' )->never(); - Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when in dev mode. - */ - public function test_should_not_compile_when_in_dev_mode() { - beans_add_api_component_support( 'wp_scripts_compiler' ); - update_option( 'beans_compile_all_scripts', 1 ); - update_option( 'beans_dev_mode', 1 ); - - Monkey\Functions\expect( 'beans_get' )->never(); - Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when there are no scripts. - */ - public function test_should_not_compile_when_there_are_no_scripts() { - beans_add_api_component_support( 'wp_scripts_compiler' ); - update_option( 'beans_compile_all_scripts', 1 ); - delete_option( 'beans_dev_mode' ); - - Monkey\Functions\expect( 'add_query_arg' )->never(); - Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); - - // Run the tests. - $this->assertEmpty( $GLOBALS['wp_scripts']->queue ); - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when assets are admin bar only. - */ - public function test_should_not_compile_when_assets_are_admin_bar_only() { - beans_add_api_component_support( 'wp_scripts_compiler' ); - update_option( 'beans_compile_all_scripts', 1 ); - delete_option( 'beans_dev_mode' ); - Monkey\Functions\expect( 'add_query_arg' )->never(); - Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); - - // Enqueue the admin bar's script. - wp_enqueue_script( 'admin-bar' ); - $this->assertArrayHasKey( 'admin-bar', $GLOBALS['wp_scripts']->registered ); - $this->assertContains( 'admin-bar', $GLOBALS['wp_scripts']->queue ); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_scripts() should not compile when scripts are not registered. - */ - public function test_should_not_compile_when_scripts_not_registered() { - beans_add_api_component_support( 'wp_scripts_compiler' ); - update_option( 'beans_compile_all_scripts', 1 ); - delete_option( 'beans_dev_mode' ); - Monkey\Functions\expect( 'add_query_arg' )->never(); - Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); - - // Enqueue the admin bar's script. - wp_enqueue_script( 'admin-bar' ); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_scripts() should compile when the script has src but no dependencies. - */ - public function test_should_compile_when_script_has_src_but_no_deps() { - beans_add_api_component_support( 'wp_scripts_compiler' ); - update_option( 'beans_compile_all_scripts', 1 ); - delete_option( 'beans_dev_mode' ); - Monkey\Functions\expect( 'add_query_arg' )->never(); - - // Enqueue the scripts. - wp_enqueue_script( 'admin-bar' ); - wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); - wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js' ); - - // Mock how beans_compile_js_fragments() will be called. - Monkey\Functions\expect( 'beans_compile_js_fragments' ) - ->once() - ->with( - 'beans', - [ - 'test-compiler-js' => '/foo/tests/compiler.js', - 'test-uikit-js' => '/foo/tests/uikit.js', - ], - [ - 'in_footer' => true, - 'version' => null, - ] - ) - ->andReturnNull(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_scripts() should compile scripts and dependencies. - */ - public function test_should_compile_scripts_and_deps() { - beans_add_api_component_support( 'wp_scripts_compiler' ); - update_option( 'beans_compile_all_scripts', 1 ); - delete_option( 'beans_dev_mode' ); - Monkey\Functions\expect( 'add_query_arg' )->never(); - - // Enqueue the scripts. - wp_enqueue_script( 'admin-bar' ); - wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); - wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js', [ 'jquery' ] ); - - // Mock how beans_compile_js_fragments() will be called. - Monkey\Functions\expect( 'beans_compile_js_fragments' ) - ->once() - ->with( - 'beans', - [ - 'jquery-core' => $GLOBALS['wp_scripts']->registered['jquery-core']->src, - 'jquery-migrate' => $GLOBALS['wp_scripts']->registered['jquery-migrate']->src, - 'test-compiler-js' => '/foo/tests/compiler.js', - 'test-uikit-js' => '/foo/tests/uikit.js', - ], - [ - 'in_footer' => true, - 'version' => null, - ] - ) - ->andReturnNull(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_scripts() ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php deleted file mode 100644 index 8dedcf2e..00000000 --- a/tests/phpunit/integration/api/compiler/beans-page-compiler/compilePageStyles.php +++ /dev/null @@ -1,244 +0,0 @@ -registered[ $handle ] ); - } - - $GLOBALS['wp_styles']->done = []; - - parent::tearDown(); - } - - /** - * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the styles compiler is not supported. - */ - public function test_should_not_compile_when_styles_compiler_not_supported() { - beans_remove_api_component_support( 'wp_styles_compiler' ); - - Monkey\Functions\expect( 'get_option' )->with( 'beans_compile_all_styles', false )->never(); - Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); - Monkey\Functions\expect( 'beans_get' )->never(); - Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the "compile all styles" option is not - * set. - */ - public function test_should_not_compile_when_option_is_not_set() { - beans_add_api_component_support( 'wp_styles_compiler' ); - delete_option( 'beans_compile_all_styles' ); - Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); - Monkey\Functions\expect( 'beans_get' )->never(); - Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_styles() should not compile when in dev mode. - */ - public function test_should_not_compile_when_in_dev_mode() { - beans_add_api_component_support( 'wp_styles_compiler' ); - update_option( 'beans_compile_all_styles', 1 ); - update_option( 'beans_dev_mode', 1 ); - Monkey\Functions\expect( 'beans_get' )->never(); - Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_styles() should not compile when there are no styles. - */ - public function test_should_not_compile_when_there_are_no_styles() { - beans_add_api_component_support( 'wp_styles_compiler' ); - update_option( 'beans_compile_all_styles', 1 ); - delete_option( 'beans_dev_mode' ); - Monkey\Functions\expect( 'add_query_arg' )->never(); - Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); - - // Run the tests. - $this->assertEmpty( $GLOBALS['wp_styles']->queue ); - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_styles() should not compile when assets are admin bar only. - */ - public function test_should_not_compile_when_assets_are_admin_bar_only() { - beans_add_api_component_support( 'wp_styles_compiler' ); - update_option( 'beans_compile_all_styles', 1 ); - delete_option( 'beans_dev_mode' ); - Monkey\Functions\expect( 'add_query_arg' )->never(); - Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); - - // Enqueue the styles and then check that they are registered. - wp_enqueue_style( 'admin-bar' ); - wp_enqueue_style( 'open-sans' ); - wp_enqueue_style( 'dashicons' ); - $this->assertArrayHasKey( 'admin-bar', $GLOBALS['wp_styles']->registered ); - $this->assertContains( 'admin-bar', $GLOBALS['wp_styles']->queue ); - $this->assertArrayHasKey( 'open-sans', $GLOBALS['wp_styles']->registered ); - $this->assertContains( 'open-sans', $GLOBALS['wp_styles']->queue ); - $this->assertArrayHasKey( 'dashicons', $GLOBALS['wp_styles']->registered ); - $this->assertContains( 'dashicons', $GLOBALS['wp_styles']->queue ); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_styles() should not compile when the style is not registered. - */ - public function test_should_not_compile_when_style_is_not_registered() { - beans_add_api_component_support( 'wp_styles_compiler' ); - update_option( 'beans_compile_all_styles', 1 ); - delete_option( 'beans_dev_mode' ); - Monkey\Functions\expect( 'add_query_arg' )->never(); - Monkey\Functions\expect( 'beans_compile_css_fragments' )->never(); - - // Enqueue the style. - wp_enqueue_style( 'admin-bar' ); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_styles() should compile when the style has src but no dependencies. - */ - public function test_should_compile_when_style_has_src_but_no_deps() { - beans_add_api_component_support( 'wp_styles_compiler' ); - update_option( 'beans_compile_all_styles', 1 ); - delete_option( 'beans_dev_mode' ); - Monkey\Functions\expect( 'add_query_arg' )->never(); - - // Enqueue the styles. - wp_enqueue_style( 'admin-bar' ); - wp_enqueue_style( 'test-compiler-css', '/foo/tests/compiler.css' ); - wp_enqueue_style( 'test-uikit-css', '/foo/tests/uikit.css' ); - - // Mock how beans_compile_css_fragments() will be called. - Monkey\Functions\expect( 'beans_compile_css_fragments' ) - ->once() - ->with( - 'beans', - [ - 'test-compiler-css' => '/foo/tests/compiler.css', - 'test-uikit-css' => '/foo/tests/uikit.css', - ], - [ 'version' => null ] - ) - ->andReturnNull(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); - - // Check the asset's done state. - $this->assertSame( [ 'test-compiler-css', 'test-uikit-css' ], $GLOBALS['wp_styles']->done ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_styles() should add the query arg to the compiled style's src. - */ - public function test_should_add_query_arg_to_compiled_style_src() { - beans_add_api_component_support( 'wp_styles_compiler' ); - update_option( 'beans_compile_all_styles', 1 ); - - // Enqueue the styles. - wp_enqueue_style( 'admin-bar' ); - wp_enqueue_style( 'test-compiler-css', '/foo/tests/compiler.css', [], null, 'screen' ); - wp_enqueue_style( 'test-uikit-css', '/foo/tests/uikit.css', [], null, '(max-width: 640px)' ); - - // Mock how beans_compile_css_fragments() will be called. - Monkey\Functions\expect( 'beans_compile_css_fragments' ) - ->once() - ->with( - 'beans', - [ - 'test-compiler-css' => '/foo/tests/compiler.css?beans_compiler_media_query=screen', - 'test-uikit-css' => '/foo/tests/uikit.css?beans_compiler_media_query=(max-width: 640px)', - ], - [ 'version' => null ] - ) - ->andReturnNull(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); - - // Check the asset's done state. - $this->assertSame( [ 'test-compiler-css', 'test-uikit-css' ], $GLOBALS['wp_styles']->done ); - } - - /** - * Test _Beans_Page_Compiler::compile_page_styles() should compile styles and dependencies. - */ - public function test_should_compile_styles_and_deps() { - beans_add_api_component_support( 'wp_styles_compiler' ); - update_option( 'beans_compile_all_styles', 1 ); - delete_option( 'beans_dev_mode' ); - Monkey\Functions\expect( 'add_query_arg' )->never(); - - // Enqueue the styles. - wp_enqueue_style( 'admin-bar' ); - wp_enqueue_style( 'test-compiler-css', '/foo/tests/compiler.css' ); - wp_enqueue_style( 'test-uikit-css', '/foo/tests/uikit.css', [ 'test-compiler-css' ] ); - - // Mock how beans_compile_css_fragments() will be called. - Monkey\Functions\expect( 'beans_compile_css_fragments' ) - ->once() - ->with( - 'beans', - [ - 'test-compiler-css' => '/foo/tests/compiler.css', - 'test-uikit-css' => '/foo/tests/uikit.css', - ], - [ 'version' => null ] - ) - ->andReturnNull(); - - // Run the tests. - $this->assertNull( ( new _Beans_Page_Compiler() )->compile_page_styles() ); - - // Check the asset's done state. - $this->assertSame( [ 'test-compiler-css', 'test-uikit-css' ], $GLOBALS['wp_styles']->done ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php deleted file mode 100644 index ad53250f..00000000 --- a/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php +++ /dev/null @@ -1,130 +0,0 @@ -registered[ $handle ] ); - } - - $GLOBALS['wp_scripts']->done = []; - - parent::tearDown(); - } - - /** - * Test _Beans_Page_Compiler::dequeue_scripts() should not dequeue scripts when there are no scripts. - */ - public function test_should_not_dequeue_scripts_when_no_scripts() { - $this->assertNull( ( new _Beans_Page_Compiler() )->dequeue_scripts() ); - } - - /** - * Test _Beans_Page_Compiler::dequeue_scripts() should not dequeue when no scripts are registered. - */ - public function test_should_not_dequeue_when_no_scripts_registered() { - $compiler = new _Beans_Page_Compiler(); - $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ 'test-compiler-js', 'test-uikit-js' ] ); - - $this->assertNull( $compiler->dequeue_scripts() ); - } - - /** - * Test _Beans_Page_Compiler::dequeue_scripts() should dequeue scripts. - */ - public function test_should_dequeue_scripts() { - $compiler = new _Beans_Page_Compiler(); - $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ - 'test-compiler-js' => '/foo/tests/compiler.js', - 'test-uikit-js' => '/foo/tests/uikit.js', - ] ); - - // Set up the scripts. - wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); - wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js' ); - - // Run the tests. - $this->assertNull( $compiler->dequeue_scripts() ); - $this->assertSame( [ 'test-compiler-js', 'test-uikit-js' ], $GLOBALS['wp_scripts']->done ); - } - - /** - * Test _Beans_Page_Compiler::dequeue_scripts() should not print the inline localization when no scripts have - * localized data. - */ - public function test_should_not_print_inline_when_no_scripts_have_localized_data() { - $compiler = new _Beans_Page_Compiler(); - $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ - 'test-compiler-js' => '/foo/tests/compiler.js', - 'test-uikit-js' => '/foo/tests/uikit.js', - ] ); - - // Set up the scripts. - wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); - wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js' ); - - // Run the test. - ob_start(); - $compiler->dequeue_scripts(); - $this->assertSame( '', ob_get_clean() ); - } - - /** - * Test _Beans_Page_Compiler::dequeue_scripts() should print the inline localization content. - */ - public function test_should_print_inline_localization_content() { - $compiler = new _Beans_Page_Compiler(); - $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ - 'test-compiler-js' => '/foo/tests/compiler.js', - 'test-uikit-js' => '/foo/tests/uikit.js', - ] ); - - // Set up the scripts. - wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); - wp_localize_script( 'test-compiler-js', 'testParams', 'hello-beans' ); - wp_enqueue_script( 'test-uikit-js', '/foo/tests/uikit.js' ); - - // Run the tests. - ob_start(); - $compiler->dequeue_scripts(); - $inline_script = ob_get_clean(); - - $expected = << - var testParams = "hello-beans"; - - -EOB; - - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $inline_script ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php b/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php deleted file mode 100644 index 3b71aa01..00000000 --- a/tests/phpunit/integration/api/compiler/beansCompileCssFragments.php +++ /dev/null @@ -1,44 +0,0 @@ -add_virtual_directory( $id ); - $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); - - // Run the tests. - $this->assertEmpty( $this->get_compiled_filename( $path ) ); - beans_compile_css_fragments( $id, $fragment ); - $filename = $this->get_compiled_filename( $path ); - $this->assertFileExists( $path . $filename ); - $this->assertStringEndsWith( '.css', $filename ); - $this->assertSame( $this->get_compiled_css(), $this->get_cached_contents( $filename, $id ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php b/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php deleted file mode 100644 index ea83f029..00000000 --- a/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php +++ /dev/null @@ -1,99 +0,0 @@ -add_virtual_directory( $id ); - $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); - - // Run the tests. - $this->assertEmpty( $this->get_compiled_filename( $path ) ); - beans_compile_js_fragments( $id, $fragment, [ - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - ] ); - $filename = $this->get_compiled_filename( $path ); - $this->assertFileExists( $path . $filename ); - $this->assertStringEndsWith( '.js', $filename ); - $this->assertSame( $this->get_compiled_jquery(), $this->get_cached_contents( $filename, $id ) ); - } - - /** - * Test beans_compile_js_fragments() should compile the JS fragment, saving it to the virtual filesystem and - * enqueuing it in WordPress. - */ - public function test_should_compile_save_and_enqueue_js() { - $id = 'test-js'; - $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $this->add_virtual_directory( $id ); - $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); - - // Run the tests. - $this->assertEmpty( $this->get_compiled_filename( $path ) ); - beans_compile_js_fragments( $id, $fragment, [ - 'in_footer' => true, - 'minify_js' => true, - ] ); - $filename = $this->get_compiled_filename( $path ); - $this->assertFileExists( $path . $filename ); - $this->assertStringEndsWith( '.js', $filename ); - $this->assertSame( $this->get_compiled_js(), $this->get_cached_contents( $filename, $id ) ); - } - - /** - * Test beans_compile_js_fragments() should compile the combined JS fragments, saving it to the virtual filesystem - * and enqueuing it in WordPress. - */ - public function test_should_compile_save_and_enqueue_combined_js() { - $id = 'test-js'; - $fragments = [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ]; - $this->add_virtual_directory( $id ); - $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); - - // Run the tests. - $this->assertEmpty( $this->get_compiled_filename( $path ) ); - beans_compile_js_fragments( $id, $fragments, [ - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - ] ); - $filename = $this->get_compiled_filename( $path ); - $this->assertFileExists( $path . $filename ); - $this->assertStringEndsWith( '.js', $filename ); - - $contents = $this->get_cached_contents( $filename, $id ); - $this->assertContains( $this->get_compiled_js(), $contents ); - $this->assertContains( $this->get_compiled_jquery(), $contents ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php b/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php deleted file mode 100644 index 5fe9b0a1..00000000 --- a/tests/phpunit/integration/api/compiler/beansCompileLessFragments.php +++ /dev/null @@ -1,47 +0,0 @@ -add_virtual_directory( $id ); - $path = vfsStream::url( "compiled/beans/compiler/{$id}/" ); - - // Run the tests. - $this->assertEmpty( $this->get_compiled_filename( $path ) ); - beans_compile_less_fragments( $id, $fragments ); - $filename = $this->get_compiled_filename( $path ); - $this->assertFileExists( $path . $filename ); - $this->assertStringEndsWith( '.css', $filename ); - $this->assertSame( $this->get_compiled_less(), $this->get_cached_contents( $filename, $id ) ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beansFlushCompiler.php b/tests/phpunit/integration/api/compiler/beansFlushCompiler.php deleted file mode 100644 index 198c7efd..00000000 --- a/tests/phpunit/integration/api/compiler/beansFlushCompiler.php +++ /dev/null @@ -1,112 +0,0 @@ -never(); - - $this->assertNull( beans_flush_compiler( 'beans' ) ); - } - - /** - * Test beans_flush_compiler() should remove cached CSS file. - */ - public function test_should_remove_cached_css_file() { - $this->overwrite_virtual_filesystem(); - - // Check that both files exist before we start. - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - - // Run it. - $this->assertNull( beans_flush_compiler( 'beans', 'css' ) ); - - // Check that only the CSS file was removed. - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - } - - - /** - * Test beans_flush_compiler() should remove cached JS file. - */ - public function test_should_remove_cached_js_file() { - $this->overwrite_virtual_filesystem(); - - // Check that both files exist before we start. - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - - // Run it. - $this->assertNull( beans_flush_compiler( 'beans', 'js' ) ); - - // Check that only the JS file was removed. - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - } - - /** - * Test beans_flush_compiler() should remove all cached files. - */ - public function test_should_remove_all_cached_files() { - $this->overwrite_virtual_filesystem(); - - // Check that both files exist before we start. - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - - // Run it. - $this->assertNull( beans_flush_compiler( 'beans' ) ); - - // Check that the files and directory were removed. - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/beans' ) ); - $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/beans/' ) ); - } - - /** - * Overwrites the virtual filesystem for this test. - */ - private function overwrite_virtual_filesystem() { - $this->mock_filesystem = vfsStream::setup( - 'compiled', - 0755, - [ - 'beans' => [ - 'compiler' => [ - 'beans' => [ - '1234567-9876543.css' => $this->get_compiled_css(), - 'abcd3fg-hijklmn.js' => $this->get_compiled_js(), - ], - ], - ], - ] - ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php b/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php deleted file mode 100644 index 59aae7d0..00000000 --- a/tests/phpunit/integration/api/compiler/beansGetCompilerDir.php +++ /dev/null @@ -1,45 +0,0 @@ -assertSame( - vfsStream::url( 'compiled/beans/compiler/' ), - beans_get_compiler_dir() - ); - } - - /** - * Test beans_get_compiler_dir() should return the absolute path to the Beans' uploads admin compiler folder. - */ - public function test_should_return_absolute_path_to_compiler_admin_folder() { - $this->assertSame( - vfsStream::url( 'compiled/beans/admin-compiler/' ), - beans_get_compiler_dir( true ) - ); - } -} diff --git a/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php b/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php deleted file mode 100644 index 00249d0a..00000000 --- a/tests/phpunit/integration/api/compiler/beansGetCompilerUrl.php +++ /dev/null @@ -1,44 +0,0 @@ -assertSame( - site_url( 'compiled/beans/compiler/' ), - beans_get_compiler_url() - ); - } - - /** - * Test should return the URL to the Beans' admin compiler folder. - */ - public function test_should_return_url_to_compiler_admin_folder() { - $this->assertSame( - site_url( 'compiled/beans/admin-compiler/' ), - beans_get_compiler_url( true ) - ); - } -} diff --git a/tests/phpunit/integration/api/compiler/fixtures/jquery.test.js b/tests/phpunit/integration/api/compiler/fixtures/jquery.test.js deleted file mode 100644 index 73d60dc5..00000000 --- a/tests/phpunit/integration/api/compiler/fixtures/jquery.test.js +++ /dev/null @@ -1,29 +0,0 @@ -(function( $ ){ - 'use strict'; - - /** - * Initialize the script. - */ - var init = function() { - $( 'some-button' ).on( 'click', clickHandler ); - } - - /** - * Handle the button's click event. - * - * @param event - */ - var clickHandler = function( event ) { - event.preventDefault(); - - // do something cool here. - } - - /** - * Wait until the document is ready. - */ - $( document ).ready( function(){ - init(); - }); - -})( jQuery ); diff --git a/tests/phpunit/integration/api/compiler/fixtures/my-game-clock.js b/tests/phpunit/integration/api/compiler/fixtures/my-game-clock.js deleted file mode 100644 index ac082973..00000000 --- a/tests/phpunit/integration/api/compiler/fixtures/my-game-clock.js +++ /dev/null @@ -1,21 +0,0 @@ -class MyGameClock { - - /** - * Creates an instance of MyGameClock. - * - * @param maxTime Clock's timeout increment. - */ - constructor( maxTime ) { - this.maxTime = maxTime; - this.currentClock = 0; - } - - /** - * Get the remaining time on the clock. - * - * @returns {number} - */ - getRemainingTime() { - return this.maxTime - this.currentClock; - } -} \ No newline at end of file diff --git a/tests/phpunit/integration/api/compiler/fixtures/style.css b/tests/phpunit/integration/api/compiler/fixtures/style.css deleted file mode 100644 index a5aa904b..00000000 --- a/tests/phpunit/integration/api/compiler/fixtures/style.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - Stylesheet. - */ -body { - background-color: #fff; - color: #000; - font-size: 18px; -} - -a { - color: #cc0000; -} - -p { - margin-bottom: 30px; -} diff --git a/tests/phpunit/integration/api/compiler/fixtures/test.less b/tests/phpunit/integration/api/compiler/fixtures/test.less deleted file mode 100644 index fcda49a7..00000000 --- a/tests/phpunit/integration/api/compiler/fixtures/test.less +++ /dev/null @@ -1,7 +0,0 @@ -@test-font-size: 18px; - -body { - background-color: #fff; - color: @body-color; - font-size: @test-font-size; -} diff --git a/tests/phpunit/integration/api/compiler/fixtures/variables.less b/tests/phpunit/integration/api/compiler/fixtures/variables.less deleted file mode 100644 index 18615d17..00000000 --- a/tests/phpunit/integration/api/compiler/fixtures/variables.less +++ /dev/null @@ -1,8 +0,0 @@ -/** -These are the global variables. - */ -@body-color: #000; -@link-color: #039460; -@hover-color: #016F47; -@base-font: normal 18px / 22px "Helvetica Neue",Helvetica,Arial,sans-serif; -@base-font-size: 18px; /* this is an inline comment */ \ No newline at end of file diff --git a/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php deleted file mode 100644 index 818d815b..00000000 --- a/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php +++ /dev/null @@ -1,104 +0,0 @@ -set_up_virtual_filesystem(); - $this->compiled_dir = vfsStream::url( 'compiled' ); - - // Set the Uploads directory to our virtual filesystem. - add_filter( 'upload_dir', function( array $uploads_dir ) { - $uploads_dir['path'] = $this->compiled_dir . $uploads_dir['subdir']; - $uploads_dir['url'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['url'] ); - $uploads_dir['basedir'] = $this->compiled_dir; - $uploads_dir['baseurl'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['baseurl'] ); - - return $uploads_dir; - } ); - } - - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - Mockery::close(); - parent::tearDown(); - } - - /** - * Set up the virtual filesystem. - */ - protected function set_up_virtual_filesystem() { - $this->mock_filesystem = vfsStream::setup( - 'compiled', - 0755, - $this->get_virtual_structure() - ); - } - - /** - * Get the virtual filesystem's structure. - */ - protected function get_virtual_structure() { - return [ - 'beans' => [ - 'compiler' => [ - 'index.php' => '', - ], - 'admin-compiler' => [ - 'index.php' => '', - ], - ], - ]; - } - - /** - * Set Development Mode. - * - * @since 1.5.0 - * - * @param bool $is_enabled Optional. When true, turns on development mode. Default is false. - * - * @return void - */ - protected function set_dev_mode( $is_enabled = false ) { - update_option( 'beans_dev_mode', $is_enabled ); - } -} diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-options-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-options-test-case.php deleted file mode 100644 index bda86590..00000000 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-options-test-case.php +++ /dev/null @@ -1,48 +0,0 @@ -assertTrue( is_admin() ); - } -} diff --git a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php deleted file mode 100644 index c915c8e2..00000000 --- a/tests/phpunit/integration/api/compiler/includes/class-compiler-test-case.php +++ /dev/null @@ -1,327 +0,0 @@ - [], - 'less' => [], - 'js' => [], - ]; - - // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. - Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); - } - - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - wp_dequeue_script( 'test-jquery' ); - unset( $GLOBALS['wp_scripts']->registered['test-jquery'] ); - wp_dequeue_script( 'test-script' ); - unset( $GLOBALS['wp_scripts']->registered['test-script'] ); - wp_dequeue_script( 'test-js' ); - unset( $GLOBALS['wp_scripts']->registered['test-js'] ); - wp_dequeue_style( 'test-css' ); - unset( $GLOBALS['wp_styles']->registered['test-css'] ); - unset( $GLOBALS['wp_filesystem'] ); - parent::tearDown(); - } - - /** - * Set up the virtual filesystem. - */ - protected function set_up_virtual_filesystem() { - parent::set_up_virtual_filesystem(); - - // Set the fixture file dates back a week. - $fixtures_dir = $this->mock_filesystem->getChild( 'fixtures' ); - $file_modification_time = time() - ( 7 * 24 * 60 * 60 ); - foreach ( static::$fixture_filenames as $filename ) { - $fixtures_dir->getChild( $filename )->lastModified( $file_modification_time ); - } - } - - /** - * Get the virtual filesystem's structure. - */ - protected function get_virtual_structure() { - $structure = parent::get_virtual_structure(); - $structure['fixtures'] = $this->get_fixtures_content(); - - return $structure; - } - - /** - * Get the test fixture's content. - */ - private function get_fixtures_content() { - $fixtures = []; - - foreach ( static::$fixture_filenames as $filename ) { - $fixtures[ $filename ] = file_get_contents( static::$fixtures_dir . $filename ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid edge case. - } - - return $fixtures; - } - - /** - * Add the virtual directory to the filesystem. - * - * @since 1.5.0 - * - * @param string $dir_name Directory name. - * @param string $root_dir Optional. Root directory(ies) for the new directory. - * - * @return void - */ - protected function add_virtual_directory( $dir_name, $root_dir = 'compiled/beans/compiler' ) { - vfsStream::newDirectory( $dir_name )->at( $this->mock_filesystem->getChild( $root_dir ) ); - } - - /** - * Set the protected property "current_fragment". - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler The Compiler instance. - * @param mixed $fragment The given value to set. - * - * @return void - * @throws \ReflectionException Throws reflection error. - */ - protected function set_current_fragment( $compiler, $fragment ) { - $current_fragment = ( new \ReflectionClass( $compiler ) )->getProperty( 'current_fragment' ); - $current_fragment->setAccessible( true ); - $current_fragment->setValue( $compiler, $fragment ); - $current_fragment->setAccessible( false ); - } - - /** - * Get the filename. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the compiler. - * @param array $config The compiler's configuration. - * @param int $filemtime Optional. The fragment's filemtime. Default is null. - * - * @return string - */ - protected function get_filename( $compiler, $config, $filemtime = null ) { - - if ( is_null( $filemtime ) ) { - foreach ( $config['fragments'] as $index => $fragment ) { - $filemtimes[ $index ] = filemtime( $fragment ); - } - } else { - $filemtimes = [ $filemtime ]; - } - - return sprintf( - '%s-%s.%s', - $compiler->hash( $config ), - $compiler->hash( $filemtimes ), - 'style' === $config['type'] ? 'css' : 'js' - ); - } - - /** - * Set up the filesystem mocks for the fragments. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the Compiler. - * @param int $times_called Optional. Number of times the mock will be called. Default is 1. - * @param string $class Mock's class name. - * - * @return void - */ - protected function mock_filesystem_for_fragments( - $compiler, - $times_called = 1, - $class = 'WP_Filesystem_Direct_Mock' - ) { - - if ( ! defined( 'FS_CHMOD_FILE' ) ) { - define( 'FS_CHMOD_FILE', 0644 ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Valid constant. - } - - unset( $GLOBALS['wp_filesystem'] ); - - // Now set up the mock. - $mock = Mockery::mock( $class ); - - foreach ( $compiler->config['fragments'] as $fragment ) { - $mock->shouldReceive( 'get_contents' ) - ->times( $times_called ) - ->with( $fragment ) - ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents, WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents -- Valid in this edge case. - } - - $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case, as we are mocking the filesystem. - } - - /** - * Get the file's content. - * - * @since 1.5.0 - * - * @param string $filename Name of the file. - * @param string $id File's ID. - * - * @return string - */ - protected function get_cached_contents( $filename, $id ) { - return $this->mock_filesystem - ->getChild( 'beans/compiler/' . $id ) - ->getChild( $filename ) - ->getContent(); - } - - /** - * Get the compiled file's name. - * - * @param string $path The virtual filesystem's path. - * - * @return string - */ - protected function get_compiled_filename( $path ) { - $files = beans_scandir( $path ); - - if ( empty( $files ) ) { - return ''; - } - - return array_pop( $files ); - } - - /** - * Get the compiled jQuery. - * - * @since 1.5.0 - * - * @return string - */ - protected function get_compiled_jquery() { - $compiled_content = <<merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field( $field ); - $html = ob_get_clean(); - - $expected = << -
                -
                - - - Compile all WordPress styles -
                -
                -

                -EOB; - // Run the tests. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - $this->assertEquals( 1, did_action( 'beans_field_checkbox' ) ); - $this->assertEquals( 0, did_action( 'beans_field_group_label' ) ); - - // Clean up. - beans_remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); - } - - /** - * Test beans_field() should render the radio field. - */ - public function test_should_render_radio_field() { - // Set up the test. - require_once BEANS_THEME_DIR . '/lib/api/fields/types/radio.php'; - beans_add_smart_action( 'beans_field_radio', 'beans_field_radio' ); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_radio_test', - 'label' => 'Having fun?', - 'description' => 'Radio buttons', - 'type' => 'radio', - 'default' => 'no', - 'options' => [ - 'no' => 'No', - 'yes' => 'Yes', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field( $field ); - $html = ob_get_clean(); - - $expected = << -
                -
                -
                - Having fun? - - -
                -
                -
                -
                Radio buttons
                -
                -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - $this->assertEquals( 1, did_action( 'beans_field_radio' ) ); - $this->assertEquals( 0, did_action( 'beans_field_group_label' ) ); - - // Clean up. - beans_remove_action( 'beans_field_radio', 'beans_field_radio' ); - } - - /** - * Test beans_field() should render a group of fields. - */ - public function test_should_render_group_of_fields() { - // Set up the test. - require_once BEANS_THEME_DIR . '/lib/api/fields/types/activation.php'; - require_once BEANS_THEME_DIR . '/lib/api/fields/types/select.php'; - beans_add_smart_action( 'beans_field_activation', 'beans_field_activation' ); - beans_add_smart_action( 'beans_field_select', 'beans_field_select' ); - - // Prepare the group of fields. - $group = $this->merge_field_with_default( [ - 'id' => 'beans_group_test', - 'label' => 'Group of fields', - 'description' => 'This is a group of fields.', - 'type' => 'group', - 'context' => 'beans_group_tests', - 'fields' => [ - [ - 'id' => 'beans_group_activation_test', - 'label' => 'Activate Foo', - 'type' => 'activation', - 'default' => false, - ], - [ - 'id' => 'beans_group_select_test', - 'label' => 'Select Foo', - 'type' => 'select', - 'default' => 'aggressive', - 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - ], - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field( $group ); - $html = ob_get_clean(); - - $expected = << -
                -
                - Group of fields -
                - - - -
                -
                - - -
                -
                -
                -
                This is a group of fields.
                -
                -EOB; - // Run the tests. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - $this->assertEquals( 2, did_action( 'beans_field_group_label' ) ); - $this->assertEquals( 1, did_action( 'beans_field_activation' ) ); - $this->assertEquals( 1, did_action( 'beans_field_select' ) ); - - // Clean up. - beans_remove_action( 'beans_field_activation', 'beans_field_activation' ); - beans_remove_action( 'beans_field_select', 'beans_field_select' ); - } - - /** - * Test should render the single field. This is a full integration test for the Fields API. - */ - public function test_full_integration_should_render_single_field() { - $test_data = static::$test_data['single_fields']; - - // Register the fields. - beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ); - $fields = beans_get_fields( 'beans_tests', $test_data['section'] ); - - // Register the checkbox, label, and description callbacks (as they've been unregistered in previous tests). - add_action( 'beans_field_checkbox', 'beans_field_checkbox' ); - add_action( 'beans_field_group_label', 'beans_field_label' ); - add_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); - add_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field( $fields[1] ); - $html = ob_get_clean(); - - $expected = << -
                -
                - - - Enable the checkbox test -
                -
                -
                -EOB; - // Check the HTML. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - - // Clean up. - remove_action( 'beans_field_checkbox', 'beans_field_checkbox' ); - remove_action( 'beans_field_group_label', 'beans_field_label' ); - remove_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); - remove_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); - } - - /** - * Test should render a group of fields. This is a full integration test for the Fields API. - */ - public function test_full_integration_should_render_group_of_fields() { - $test_data = static::$test_data['group']; - - // Register the fields. - beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ); - $fields = beans_get_fields( 'beans_tests', $test_data['section'] ); - - // Register each field's callback (as it's been unregistered in previous tests). - foreach ( $test_data['fields'][0]['fields'] as $field ) { - add_action( 'beans_field_' . $field['type'], 'beans_field_' . $field['type'] ); - } - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field( $fields[0] ); - $html = ob_get_clean(); - - $expected = << -
                -
                - Group of fields -
                - - - -
                -
                - -
                -
                - - - Enable the checkbox test -
                -
                -
                -
                This is a group of fields.
                -
                -EOB; - // Check the HTML. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - - // Clean up. - foreach ( $test_data['fields'][0]['fields'] as $field ) { - remove_action( 'beans_field_' . $field['type'], 'beans_field_' . $field['type'] ); - } - } -} diff --git a/tests/phpunit/integration/api/fields/beansGetFields.php b/tests/phpunit/integration/api/fields/beansGetFields.php deleted file mode 100644 index 9b1ba4c7..00000000 --- a/tests/phpunit/integration/api/fields/beansGetFields.php +++ /dev/null @@ -1,44 +0,0 @@ - [ - $test_data['section'] => $test_data['fields'], - ], - ]; - - // Register the fields first. - $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); - $registered->setValue( new \_Beans_Fields(), $data_set ); - - $this->assertSame( $data_set['beans_tests'][ $test_data['section'] ], beans_get_fields( 'beans_tests', $test_data['section'] ) ); - } - } -} diff --git a/tests/phpunit/integration/api/fields/beansPreStandardizeFields.php b/tests/phpunit/integration/api/fields/beansPreStandardizeFields.php deleted file mode 100644 index 1f747974..00000000 --- a/tests/phpunit/integration/api/fields/beansPreStandardizeFields.php +++ /dev/null @@ -1,55 +0,0 @@ -assertArrayHasKey( $field['id'], $fields ); - $this->assertSame( $field, $fields[ $field['id'] ] ); - } - } - - /** - * Test _beans_pre_standardize_fields() should pre-standardize a group of fields. - */ - public function test_should_pre_standardize_group_of_fields() { - $actual = _beans_pre_standardize_fields( static::$test_data['group']['fields'] ); - - foreach ( static::$test_data['group']['fields'] as $group ) { - $this->assertArrayHasKey( $group['id'], $actual ); - - $actual_fields = $actual[ $group['id'] ]['fields']; - - // Check each of the grouped fields. - foreach ( $group['fields'] as $field ) { - $this->assertArrayHasKey( $field['id'], $actual_fields ); - $this->assertSame( $field, $actual_fields[ $field['id'] ] ); - } - } - } -} diff --git a/tests/phpunit/integration/api/fields/beansRegisterFields.php b/tests/phpunit/integration/api/fields/beansRegisterFields.php deleted file mode 100644 index 7cb1ada1..00000000 --- a/tests/phpunit/integration/api/fields/beansRegisterFields.php +++ /dev/null @@ -1,54 +0,0 @@ -assertFalse( beans_register_fields( [], '', '' ) ); - $this->assertFalse( beans_register_fields( [], 'post_meta', 'tm-beans' ) ); - } - - /** - * Test beans_register_fields() should register the fields. - */ - public function test_should_register_fields() { - $test_data = static::$test_data['single_fields']; - - $this->assertTrue( beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ) ); - - // Check what was registered. - $registered_property = $this->get_reflective_property( 'registered', '_Beans_Fields' ); - $registered = $registered_property->getValue( new _Beans_Fields() ); - - $this->assertArrayHasKey( 'beans_tests', $registered ); - $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); - - foreach ( $test_data['fields'] as $index => $field ) { - $expected = $this->merge_field_with_default( $field ); - $this->assertSame( $expected, $registered['beans_tests'][ $test_data['section'] ][ $index ] ); - } - } -} diff --git a/tests/phpunit/integration/api/fields/fixtures/test-fields.php b/tests/phpunit/integration/api/fields/fixtures/test-fields.php deleted file mode 100644 index 1b5d6533..00000000 --- a/tests/phpunit/integration/api/fields/fixtures/test-fields.php +++ /dev/null @@ -1,80 +0,0 @@ - [ - 'fields' => [ - [ - 'id' => 'beans_layout', - 'label' => 'Layout', - 'type' => 'radio', - 'default' => 'default_fallback', - 'options' => [ - 'default_fallback' => 'Use Default Layout', - 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', - 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', - 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', - ], - ], - [ - 'id' => 'beans_checkbox_test', - 'label' => false, - 'checkbox_label' => 'Enable the checkbox test', - 'type' => 'checkbox', - 'default' => false, - ], - [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => 'Testing the text field.', - ], - ], - 'context' => 'tests', - 'section' => 'tm-beans', - ], - - // Group of fields. - 'group' => [ - 'fields' => [ - [ - 'id' => 'beans_group_test', - 'label' => 'Group of fields', - 'description' => 'This is a group of fields.', - 'type' => 'group', - 'fields' => [ - [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ], - [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - ], - [ - 'id' => 'beans_checkbox_test', - 'label' => false, - 'checkbox_label' => 'Enable the checkbox test', - 'type' => 'checkbox', - 'default' => false, - ], - ], - ], - ], - 'context' => 'group_tests', - 'section' => 'tm-beans', - ], -]; diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php deleted file mode 100644 index da4c0285..00000000 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ /dev/null @@ -1,93 +0,0 @@ - false, - 'description' => false, - 'default' => false, - 'context' => 'beans_tests', - 'attributes' => [], - 'db_group' => false, - ], $field ); - $field['name'] = 'beans_fields[' . $field['id'] . ']'; - - if ( 'group' === $field['type'] ) { - - foreach ( $field['fields'] as $index => $_field ) { - $field['fields'][ $index ] = $this->merge_field_with_default( $_field, $set_value ); - } - } elseif ( $set_value ) { - $field['value'] = $field['default']; - } - - return $field; - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php deleted file mode 100644 index ca2052d1..00000000 --- a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php +++ /dev/null @@ -1,85 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_activation( $field ); - $html = ob_get_clean(); - - $expected = << - - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_activation() should render the activation field with attributes when given. - */ - public function test_should_render_activation_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_activation( $field ); - $html = ob_get_clean(); - - $expected = << - - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php deleted file mode 100644 index 10d86c97..00000000 --- a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php +++ /dev/null @@ -1,112 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_checkbox( $field ); - $html = ob_get_clean(); - - $expected = << - -Compile all WordPress styles -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_checkbox() should render the checkbox with the default label when none is given. - */ - public function test_should_render_checkbox_with_default_label_when_none_is_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'type' => 'checkbox', - 'default' => false, - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_checkbox( $field ); - $html = ob_get_clean(); - - $expected = << - -Enable -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_checkbox() should render the checkbox with attributes when given. - */ - public function test_should_render_checkbox_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_checkbox( $field ); - $html = ob_get_clean(); - - $expected = << - -Compile all WordPress styles -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php deleted file mode 100644 index eee8a65a..00000000 --- a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php +++ /dev/null @@ -1,100 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - ] ); - - $this->assertNull( beans_field_description( $field ) ); - - $field['description'] = ''; - $this->assertNull( beans_field_description( $field ) ); - } - - /** - * Test beans_field_description() should render the field's description. - */ - public function test_should_render_field_description() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'description' => 'Testing the text field.', - 'default' => '', - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_description( $field ); - $html = ob_get_clean(); - - $expected = <<Testing the text field.
                -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - - /** - * Test beans_field_description() should render the field's extended description. - */ - public function test_should_render_extended_description() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'description' => 'Testing the text field.This is the extended part of the description.', - 'default' => '', - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_description( $field ); - $html = ob_get_clean(); - - $expected = <<Testing the text field.
                - More... - -
                -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php deleted file mode 100644 index adbe4d34..00000000 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ /dev/null @@ -1,205 +0,0 @@ -post->create(); - $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, [ - 'post_mime_type' => 'image/jpeg', - 'post_type' => 'attachment', - ] ); - update_post_meta( $image_id, '_wp_attachment_image_alt', 'This is the alt value.', true ); - - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => $image_id, - ], false ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_image( $field ); - $html = ob_get_clean(); - - $expected = <<
                -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_radio() should render accessible images when accessibility parameters are given. - */ - public function test_should_render_accessible_images_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_layout', - 'label' => 'Layout', - 'description' => 'The layout settings.', - 'type' => 'radio', - 'default' => 'default_fallback', - 'options' => [ - 'default_fallback' => 'Use Default Layout', - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'alt' => 'Content Only Layout', - 'screen_reader_text' => 'Option for the Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/sp_c.png', - 'alt' => 'Sidebar Primary + Content Layout', - ], - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_radio( $field ); - $html = ob_get_clean(); - - $expected = << - Layout - - - - -
                -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php deleted file mode 100644 index 283096c1..00000000 --- a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php +++ /dev/null @@ -1,95 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_select( $field ); - $html = ob_get_clean(); - - $expected = << - - - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_select() should render the select field with attributes when given. - */ - public function test_should_render_select_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'standard', - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - 'attributes' => [ - 'style' => 'margin: -3px 0 0 -8px;', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_select( $field ); - $html = ob_get_clean(); - - $expected = << - - - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php deleted file mode 100644 index a816c6f2..00000000 --- a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php +++ /dev/null @@ -1,162 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 0, - 'max' => 100, - 'interval' => 1, - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_slider( $field ); - $html = ob_get_clean(); - - $expected = << - - -0 -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_slider() should render the slider field with unit when given. - */ - public function test_should_render_slider_field_with_unit_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 10, - 'max' => 100, - 'interval' => 5, - 'unit' => 'Number of beans', - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_slider( $field ); - $html = ob_get_clean(); - - $expected = << - - -0 -Number of beans -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_slider() should render the slider with the current value. - */ - public function test_should_render_slider_with_current_value() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 10, - 'max' => 100, - 'interval' => 5, - ] ); - $field['value'] = 15; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_slider( $field ); - $html = ob_get_clean(); - - $expected = << - - -15 -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_slider() should render the slider field with attributes when given. - */ - public function test_should_render_slider_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 1, - 'min' => 1, - 'max' => 20, - 'interval' => 1, - 'unit' => 'Number of beans', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_slider( $field ); - $html = ob_get_clean(); - - $expected = << - - -1 -Number of beans -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php deleted file mode 100644 index b093d7a3..00000000 --- a/tests/phpunit/integration/api/fields/types/beansFieldText.php +++ /dev/null @@ -1,83 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - ] ); - $field['value'] = 'Testing the text field.'; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_text( $field ); - $html = ob_get_clean(); - - $expected = << -EOB; - // Run the test. - $this->assertSame( $expected, $html ); - } - - /** - * Test beans_field_text() should render the text field with attributes when given. - */ - public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - $field['value'] = 'Testing the text field with attributes.'; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_text( $field ); - $html = ob_get_clean(); - - $expected = << -EOB; - // Run the test. - $this->assertSame( $expected, $html ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php deleted file mode 100644 index ea00fe18..00000000 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ /dev/null @@ -1,83 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - ] ); - $field['value'] = 'Testing the textarea field.'; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_textarea( $field ); - $html = ob_get_clean(); - - $expected = <<Testing the textarea field. -EOB; - // Run the test. - $this->assertSame( $expected, $html ); - } - - /** - * Test beans_field_textarea() should render the textarea field with attributes when given. - */ - public function test_should_render_textarea_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - $field['value'] = 'Testing the textarea field with attributes.'; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_textarea( $field ); - $html = ob_get_clean(); - - $expected = <<Testing the textarea field with attributes. -EOB; - // Run the test. - $this->assertSame( $expected, $html ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php b/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php deleted file mode 100644 index 204daaf2..00000000 --- a/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php +++ /dev/null @@ -1,74 +0,0 @@ -assertNull( _beans_get_image_alt( 0 ) ); - $this->assertNull( _beans_get_image_alt( - 1 ) ); - $this->assertNull( _beans_get_image_alt( null ) ); - $this->assertNull( _beans_get_image_alt( false ) ); - } - - /** - * Test _beans_get_image_alt() should return the default when the image does not have an "alt" defined. - */ - public function test_should_return_default_alt_when_image_alt_not_defined() { - $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, [ - 'post_mime_type' => 'image/png', - 'post_type' => 'attachment', - ] ); - - // Run the test. - $this->assertSame( 'Sorry, no description was given for this image.', _beans_get_image_alt( $image_id ) ); - } - - /** - * Test _beans_get_image_alt() should return the image's alt description. - */ - public function test_should_return_image_alt() { - $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, [ - 'post_mime_type' => 'image/jpeg', - 'post_type' => 'attachment', - ] ); - $alt = 'This is the alt value.'; - update_post_meta( $image_id, '_wp_attachment_image_alt', $alt, true ); - - // Run the test. - $this->assertSame( $alt, _beans_get_image_alt( $image_id ) ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php b/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php deleted file mode 100644 index 53ea86de..00000000 --- a/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php +++ /dev/null @@ -1,65 +0,0 @@ -assertNull( _beans_get_image_url( 0 ) ); - $this->assertNull( _beans_get_image_url( -1 ) ); - $this->assertNull( _beans_get_image_url( null ) ); - $this->assertNull( _beans_get_image_url( false ) ); - } - - /** - * Test _beans_get_image_url() should return null when the image does not exist. - */ - public function test_should_return_null_when_image_does_not_exist() { - $this->assertNull( _beans_get_image_url( 9999999 ) ); - } - - /** - * Test _beans_get_image_url() should return image's URL. - */ - public function test_should_return_image_url() { - $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, [ - 'post_mime_type' => 'image/jpeg', - 'post_type' => 'attachment', - ] ); - - // Run the test. - $this->assertSame( 'http://example.org/wp-content/uploads/image.jpeg', _beans_get_image_url( $image_id ) ); - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansIsRadioImage.php b/tests/phpunit/integration/api/fields/types/beansIsRadioImage.php deleted file mode 100644 index 8684337b..00000000 --- a/tests/phpunit/integration/api/fields/types/beansIsRadioImage.php +++ /dev/null @@ -1,90 +0,0 @@ - 'http://example.com/images/layouts/c.png', - 'c_sp' => 'http://example.com/images/layouts/c_sp.png', - 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ]; - - foreach ( $test_data as $src ) { - $this->assertTrue( _beans_is_radio_image( $src ) ); - } - } - - /** - * Test _beans_is_radio_image() should return false when a non-image source is given. - */ - public function test_should_return_false_when_non_image_src_given() { - $test_data = [ - __FILE__, - 'path/to/fields.js', - BEANS_THEME_DIR . 'style.css', - 'http://example.com/path/to/some.pdf', - ]; - - foreach ( $test_data as $src ) { - $this->assertFalse( _beans_is_radio_image( $src ) ); - } - } - - /** - * Test _beans_is_radio_image() should return true when an array is given, an array that configures the image. - */ - public function test_should_return_true_when_array_is_given() { - $test_data = [ - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'screen_reader_text' => 'Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'alt' => 'Content + Sidebar Primary Layout', - 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'alt' => 'Sidebar Primary + Content Layout', - ], - ]; - - foreach ( $test_data as $radio ) { - $this->assertTrue( _beans_is_radio_image( $radio ) ); - } - } -} diff --git a/tests/phpunit/integration/api/fields/types/beansStandardizeRadioImage.php b/tests/phpunit/integration/api/fields/types/beansStandardizeRadioImage.php deleted file mode 100644 index a5040ca6..00000000 --- a/tests/phpunit/integration/api/fields/types/beansStandardizeRadioImage.php +++ /dev/null @@ -1,136 +0,0 @@ - 'http://example.com/images/layouts/c.png', - 'c_sp' => 'http://example.com/images/layouts/c_sp.png', - 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ]; - - foreach ( $test_data as $value => $radio ) { - $expected = [ - 'src' => $radio, - 'alt' => "Option for {$value}", - 'screen_reader_text' => "Option for {$value}", - ]; - $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); - } - } - - /** - * Test _beans_standardize_radio_image() should standardize when the image's alt value is not given. - */ - public function test_should_standardize_when_alt_is_not_given() { - $test_data = [ - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'screen_reader_text' => 'Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'screen_reader_text' => 'Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'screen_reader_text' => 'Sidebar Primary + Content Layout', - ], - ]; - - foreach ( $test_data as $value => $radio ) { - $expected = [ - 'src' => $radio['src'], - 'alt' => $radio['screen_reader_text'], - 'screen_reader_text' => $radio['screen_reader_text'], - ]; - $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); - } - } - - /** - * Test _beans_standardize_radio_image() should standardize when the image's `screen_reader_text` is not given. - */ - public function test_should_standardize_when_screen_reader_text_is_not_given() { - $test_data = [ - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'alt' => 'Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'alt' => 'Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'alt' => 'Sidebar Primary + Content Layout', - ], - ]; - - foreach ( $test_data as $value => $radio ) { - $expected = $radio; - $expected['screen_reader_text'] = $radio['alt']; - $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); - } - } - - /** - * Test _beans_standardize_radio_image() should standardize when all of the image's parameters are given. - */ - public function test_should_standardize_when_all_parameters_given() { - $test_data = [ - 'c' => [ - 'src' => 'c.png', - 'alt' => 'Content Only Layout', - 'screen_reader_text' => 'Option to select the Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'c_sp.png', - 'alt' => 'Content + Sidebar Primary Layout', - 'screen_reader_text' => 'Option to select the Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'c_sp.png', - 'alt' => 'Sidebar Primary + Content Layout', - 'screen_reader_text' => 'Option to select the Sidebar Primary + Content Layout', - ], - ]; - - foreach ( $test_data as $value => $radio ) { - $this->assertSame( $radio, _beans_standardize_radio_image( $value, $radio ) ); - } - } -} diff --git a/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php b/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php deleted file mode 100644 index 54f3d70b..00000000 --- a/tests/phpunit/integration/api/filters/beansAddAnonymousFilter.php +++ /dev/null @@ -1,62 +0,0 @@ -assertSame( 'foo', $object->value_to_return ); - - // Clean up. - remove_action( 'do_foo', [ $object, 'callback' ], 20 ); - } - - /** - * Test _beans_add_anonymous_filter() should register callback to the given hook. - */ - public function test_should_register_callback_to_hook() { - $object = _beans_add_anonymous_filter( 'do_foo', false, 20 ); - - $this->assertTrue( has_filter( 'do_foo', [ $object, 'callback' ] ) !== false ); - - // Clean up. - remove_action( 'do_foo', [ $object, 'callback' ], 20 ); - } - - /** - * Test _beans_add_anonymous_filter() should call callback on the given hook. - */ - public function test_should_call_callback() { - foreach ( [ false, 'beans', 19, [ 'foo' ] ] as $value ) { - $object = _beans_add_anonymous_filter( 'beans_test_do_foo', $value, 20 ); - - $this->assertSame( $value, apply_filters( 'beans_test_do_foo', 'foo' ) ); - - // Clean up. - remove_action( 'beans_test_do_foo', [ $object, 'callback' ], 20 ); - } - } -} diff --git a/tests/phpunit/integration/api/filters/beansAddFilter.php b/tests/phpunit/integration/api/filters/beansAddFilter.php deleted file mode 100644 index c0fbca4e..00000000 --- a/tests/phpunit/integration/api/filters/beansAddFilter.php +++ /dev/null @@ -1,77 +0,0 @@ - $filter ) { - - if ( ! isset( $filter['callback'] ) ) { - continue; - } - - // Test that the filter has not yet been added. - $this->assertFalse( has_filter( $filter['hook'], $filter['callback'] ) ); - - // Let's add it. - $this->assertTrue( beans_add_filter( $filter['hook'], $filter['callback'], $filter['priority'], $filter['args'] ) ); - - // Check that the filter was registered. - $this->assertTrue( has_filter( $filter['hook'], $filter['callback'] ) !== false ); - - // Clean up. - remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); - } - } - - /** - * Test beans_add_filter() should add (register) the "anonymous" filter. - * - * Note: When the callback is not callable, Beans creates an anonymous filter, where the "callback" parameter in - * the filter is actually the "value" that will be returned when the filter fires. - */ - public function test_should_add_anonymous_filter() { - - foreach ( static::$test_filters as $beans_id => $filter ) { - - if ( ! isset( $filter['value_to_return'] ) ) { - continue; - } - - // Let's add it. - $object = beans_add_filter( $filter['hook'], $filter['value_to_return'], $filter['priority'], $filter['args'] ); - - // Check that the value stored in the anonymous callback matches our filter. - $this->assertSame( $filter['value_to_return'], $object->value_to_return ); - - // Check that the filter was registered. - $this->assertTrue( has_filter( $filter['hook'], [ $object, 'callback' ] ) !== false ); - - // Clean up. - remove_filter( $filter['hook'], [ $object, 'callback' ], $filter['priority'] ); - } - } -} diff --git a/tests/phpunit/integration/api/filters/beansApplyFilters.php b/tests/phpunit/integration/api/filters/beansApplyFilters.php deleted file mode 100644 index e1d112b0..00000000 --- a/tests/phpunit/integration/api/filters/beansApplyFilters.php +++ /dev/null @@ -1,98 +0,0 @@ -assertSame( 'foo', beans_apply_filters( $filter, 'foo' ) ); - } - } - - /** - * Test beans_apply_filters() should return value after calling one level of sub-hooks. - */ - public function test_should_return_value_after_calling_one_level_of_sub_hooks() { - add_filter( 'beans_test_query_args', 'beans_test_query_args_base' ); - add_filter( 'beans_test_query_args[_main]', 'beans_test_query_args_main' ); - - $this->assertSame( [ 'base', '_main' ], beans_apply_filters( 'beans_test_query_args[_main]', 'foo' ) ); - } - - /** - * Test beans_apply_filters() should return value after calling two levels of sub-hooks. - */ - public function test_should_return_value_after_calling_two_levels_of_sub_hooks() { - add_filter( 'beans_test_query_args', 'beans_test_query_args_base' ); - add_filter( 'beans_test_query_args[_main]', 'beans_test_query_args_main' ); - add_filter( 'beans_test_query_args[_second]', function( $args ) { - $args[] = '_second'; - return $args; - } ); - add_filter( 'beans_test_query_args[_main][_second]', function( $args ) { - $args[] = '[_main][_second]'; - return $args; - } ); - - $this->assertSame( - [ 'base', '_main', '_second', '[_main][_second]' ], - beans_apply_filters( 'beans_test_query_args[_main][_second]', 'foo' ) - ); - } - - /** - * Test beans_apply_filters() should return value after calling three levels of sub-hooks. - */ - public function test_should_return_value_after_calling_three_levels_of_sub_hooks() { - add_filter( 'beans_test_query_args', 'beans_test_query_args_base' ); - add_filter( 'beans_test_query_args[_main]', 'beans_test_query_args_main' ); - add_filter( 'beans_test_query_args[_second]', function( $args ) { - $args[] = '_second'; - return $args; - } ); - add_filter( 'beans_test_query_args[_main][_second]', function( $args ) { - $args[] = '[_main][_second]'; - return $args; - } ); - add_filter( 'beans_test_query_args[_third]', function( $args ) { - $args[] = '_third'; - return $args; - } ); - add_filter( 'beans_test_query_args[_main][_second][_third]', function( $args ) { - $args[] = '[_main][_second][_third]'; - return $args; - } ); - - $this->assertSame( - [ 'base', '_main', '_second', '[_main][_second]', '_third', '[_main][_second][_third]' ], - beans_apply_filters( 'beans_test_query_args[_main][_second][_third]', 'foo' ) - ); - } -} diff --git a/tests/phpunit/integration/api/filters/beansHasFilters.php b/tests/phpunit/integration/api/filters/beansHasFilters.php deleted file mode 100644 index 3dc1e98b..00000000 --- a/tests/phpunit/integration/api/filters/beansHasFilters.php +++ /dev/null @@ -1,57 +0,0 @@ -assertFalse( beans_has_filters( $filter['hook'], $filter['callback'] ) ); - } - } - - /** - * Test beans_has_filters() should return priority number when a callback is registered. - */ - public function test_should_return_priority_number_when_callback_registered() { - - foreach ( static::$test_filters as $filter ) { - - if ( ! isset( $filter['callback'] ) ) { - continue; - } - - beans_add_filter( $filter['hook'], $filter['callback'], $filter['priority'], $filter['args'] ); - - $this->assertSame( $filter['priority'], beans_has_filters( $filter['hook'], $filter['callback'] ) ); - - remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); - } - } -} diff --git a/tests/phpunit/integration/api/filters/fixtures/test-filters.php b/tests/phpunit/integration/api/filters/fixtures/test-filters.php deleted file mode 100644 index 701a7241..00000000 --- a/tests/phpunit/integration/api/filters/fixtures/test-filters.php +++ /dev/null @@ -1,41 +0,0 @@ - [ - 'hook' => 'beans_field_description_markup', - 'value_to_return' => 'p', - 'priority' => 10, - 'args' => 1, - ], - 'beans_widget_content_categories_output' => [ - 'hook' => 'beans_widget_content_categories_output', - 'callback' => 'beans_test_modify_widget_count', - 'priority' => 10, - 'args' => 1, - ], - 'beans_test_query_args' => [ - 'hook' => 'beans_test_query_args', - 'callback' => 'beans_test_query_args_base', - 'priority' => 20, - 'args' => 1, - ], - 'beans_test_query_args[_main]' => [ - 'hook' => 'beans_test_query_args[_main]', - 'callback' => 'beans_test_query_args_main', - 'priority' => 20, - 'args' => 1, - ], - 'the_content' => [ - 'hook' => 'the_content', - 'callback' => 'beans_test_the_content', - 'priority' => 20, - 'args' => 2, - ], -]; diff --git a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php deleted file mode 100644 index c8508603..00000000 --- a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php +++ /dev/null @@ -1,111 +0,0 @@ -mock_filter_callbacks(); - } - - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - - foreach ( static::$test_filters as $beans_id => $filter ) { - - if ( ! isset( $filter['callback'] ) ) { - continue; - } - - remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); - } - - parent::tearDown(); - } - - /** - * Check that the right parameters are registered in WordPress. - * - * @since 1.5.0 - * - * @param array $filter The filter that should be registered. - * @param bool $remove_filter When true, it removes the filter automatically to clean up this test. - * - * @return void - */ - protected function check_parameters_registered_in_wp( array $filter, $remove_filter = true ) { - global $wp_filter; - $registered_filter = $wp_filter[ $filter['hook'] ]->callbacks[ $filter['priority'] ]; - - $this->assertArrayHasKey( $filter['callback'], $registered_filter ); - $this->assertEquals( $filter['callback'], $registered_filter[ $filter['callback'] ]['function'] ); - $this->assertEquals( $filter['args'], $registered_filter[ $filter['callback'] ]['accepted_args'] ); - - // Then remove the filter. - if ( $remove_filter ) { - remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); - } - } - - /** - * Create a post, load it, and force the "template redirect" to fire. - */ - protected function go_to_post() { - $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); - $this->go_to( get_permalink( $post_id ) ); - do_action( 'template_redirect' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Valid use case as we need to fire this action as part of our tests. - } - - /** - * Define the mocks for the filter callbacks. - */ - protected function mock_filter_callbacks() { - Monkey\Functions\when( 'beans_test_the_content' )->alias( function ( $post_title, $post_id ) { - return $post_title . '_' . $post_id; - } ); - Monkey\Functions\when( 'beans_test_modify_widget_count' )->justReturn( 20 ); - Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( [ 'base' ] ); - Monkey\Functions\when( 'beans_test_query_args_main' )->alias( function ( $args ) { - $args[] = '_main'; - return $args; - } ); - } -} diff --git a/tests/phpunit/integration/api/html/beans-attribute/init.php b/tests/phpunit/integration/api/html/beans-attribute/init.php deleted file mode 100644 index c5f9a2b2..00000000 --- a/tests/phpunit/integration/api/html/beans-attribute/init.php +++ /dev/null @@ -1,47 +0,0 @@ -assertNull( $instance->init( 'does_not_exist' ) ); - $this->assertFalse( has_filter( 'foo_attributes', [ $instance, 'does_not_exist' ], 10 ) ); - } - - /** - * Test _Beans_Attribute::init() should register the callback when the method exists. - */ - public function test_should_register_the_callback_when_method_exists() { - $instance = new _Beans_Attribute( 'foo', 'data-test' ); - - $this->assertSame( $instance, $instance->init( 'add' ) ); - $this->assertSame( 10, has_filter( 'foo_attributes', [ $instance, 'add' ], 10 ) ); - - // Clean up. - remove_filter( 'foo_attributes', [ $instance, 'add' ] ); - } -} diff --git a/tests/phpunit/integration/api/html/beansAddAttribute.php b/tests/phpunit/integration/api/html/beansAddAttribute.php deleted file mode 100644 index fb86c649..00000000 --- a/tests/phpunit/integration/api/html/beansAddAttribute.php +++ /dev/null @@ -1,90 +0,0 @@ - $markup ) { - $instance = beans_add_attribute( $beans_id, 'data-test', 'test' ); - - // Check that it returns an instance of _Beans_Attribute. - $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); - - // Check that the object's "add" method is registered to the filter event for the given ID. - $this->assertSame( 10, has_filter( "{$beans_id}_attributes", [ $instance, 'add' ], 10 ) ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'add' ] ); - } - } - - /** - * Test the end result of beans_add_attribute() by firing the expected filter event for the given ID. Test should add the - * attribute when it does not exist in the given attributes. - */ - public function test_should_add_the_attribute_when_does_not_exist() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $instance = beans_add_attribute( $beans_id, 'data-test', 'foo' ); - - // Check that the attribute does not exist before we add it. - $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); - - // Fire the event to do the add. - $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Check that the attribute is added with the given value. - $expected = $markup['attributes']; - $expected['data-test'] = 'foo'; - $this->assertSame( $expected, $actual ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'add' ], 10 ); - } - } - - /** - * Test the end result of beans_add_attribute() by firing the expected filter event for the given ID. Test should add the - * value to an existing attribute's values. - */ - public function test_should_add_value_to_existing_attribute_values() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $instance = beans_add_attribute( $beans_id, $name, 'beans-test' ); - - // Fire the event to do the add. - $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - $expected = $markup['attributes']; - $expected[ $name ] .= ' beans-test'; - $this->assertSame( $expected, $actual ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'add' ], 10 ); - } - } -} diff --git a/tests/phpunit/integration/api/html/beansAddAttributes.php b/tests/phpunit/integration/api/html/beansAddAttributes.php deleted file mode 100644 index 7f3b30f0..00000000 --- a/tests/phpunit/integration/api/html/beansAddAttributes.php +++ /dev/null @@ -1,77 +0,0 @@ - $config ) { - $expected = $this->convert_attributes_into_html( $config['attributes'] ); - $this->assertSame( $expected, beans_add_attributes( $id, $config['attributes'] ) ); - } - } - - /** - * Test beans_add_attributes() should return the built attributes string when a query string of attributes is given. - */ - public function test_should_return_built_attributes_string_when_query_string_given() { - $this->assertSame( 'id="test"', beans_add_attributes( 'foo', 'id=test' ) ); - $this->assertSame( 'class="foo" data-foo="test"', beans_add_attributes( 'foo', 'class=foo&data-foo=test' ) ); - $this->assertSame( 'class="test" style="color:#fff;"', beans_add_attributes( 'beans-test', 'class=test&style=color:#fff;' ) ); - } - - /** - * Test beans_add_attributes() should return an empty string when no attributes are given. - */ - public function test_should_return_empty_string_when_no_attributes() { - $this->assertSame( '', beans_add_attributes( 'foo' ) ); - $this->assertSame( '', beans_add_attributes( 'foo', null ) ); - $this->assertSame( '', beans_add_attributes( 'foo', '' ) ); - $this->assertSame( '', beans_add_attributes( 'foo', false ) ); - } - - /** - * Test beans_add_attributes() should return filtered attributes when there is a registered callback. This test - * ensures the registration component works as expected. - */ - public function test_should_return_filtered_attributes_when_registered_callback() { - // Set up the test. - $attributes = [ 'class' => 'foo' ]; - Monkey\Functions\expect( 'foo_attributes_callback' ) - ->with( $attributes ) - ->once() - ->andReturnUsing( function ( $attributes ) { - return [ 'class' => 'changed-me' ]; - } ); - add_action( 'foo_attributes', 'foo_attributes_callback' ); - - // Run the test. - $this->assertSame( 'class="changed-me"', beans_add_attributes( 'foo', $attributes ) ); - - // Clean up. - remove_action( 'foo_attributes', 'foo_attributes_callback' ); - } -} diff --git a/tests/phpunit/integration/api/html/beansBuildSkipLinks.php b/tests/phpunit/integration/api/html/beansBuildSkipLinks.php deleted file mode 100644 index 792bea8d..00000000 --- a/tests/phpunit/integration/api/html/beansBuildSkipLinks.php +++ /dev/null @@ -1,247 +0,0 @@ -assertEquals( beans_get_layout(), 'c' ); - - $expected = << -
              • Skip to the content.
              • - -EOB; - ob_start(); - beans_build_skip_links(); - $actual = ob_get_clean(); - - $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } - - /** - * Test beans_build_skip_links() should output content and primary sidebar skip links. - */ - public function test_should_output_content_primary_sidebar_skip_links() { - Monkey\Functions\expect( 'beans_has_primary_sidebar' ) - ->once() - ->with( 'c_sp' ) - ->andReturn( true ); - Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) - ->once() - ->with( 'c_sp' ) - ->andReturn( false ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp'; - }); - - $this->assertEquals( beans_get_layout(), 'c_sp' ); - - $expected = << -
              • Skip to the content.
              • -
              • Skip to the primary sidebar.
              • - -EOB; - ob_start(); - beans_build_skip_links(); - $actual = ob_get_clean(); - - $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } - - /** - * Test beans_build_skip_links() should output content and secondary sidebar skip links. - */ - public function test_should_output_content_secondary_sidebar_skip_links() { - Monkey\Functions\expect( 'beans_has_primary_sidebar' ) - ->once() - ->with( 'c_ss' ) - ->andReturn( false ); - Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) - ->once() - ->with( 'c_ss' ) - ->andReturn( true ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_ss'; - }); - - $this->assertEquals( beans_get_layout(), 'c_ss' ); - - $expected = << -
              • Skip to the content.
              • -
              • Skip to the secondary sidebar.
              • - -EOB; - ob_start(); - beans_build_skip_links(); - $actual = ob_get_clean(); - - $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } - - - /** - * Test beans_build_skip_links() should output content and both sidebar skip links. - */ - public function test_should_output_content_both_sidebar_skip_links() { - Monkey\Functions\expect( 'beans_has_primary_sidebar' ) - ->once() - ->with( 'c_sp_ss' ) - ->andReturn( true ); - Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) - ->once() - ->with( 'c_sp_ss' ) - ->andReturn( true ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp_ss'; - }); - - $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); - - $expected = << -
              • Skip to the content.
              • -
              • Skip to the primary sidebar.
              • -
              • Skip to the secondary sidebar.
              • - -EOB; - ob_start(); - beans_build_skip_links(); - $actual = ob_get_clean(); - - $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } - - /** - * Test beans_build_skip_links() should output content and only the primary sidebar skip links when layout is 'c_sp_ss' but secondry sidebar is not active. - */ - public function test_should_output_content_only_primary_sidebar_skip_links_when_secondary_sidebar_not_active() { - Monkey\Functions\expect( 'beans_has_primary_sidebar' ) - ->once() - ->with( 'c_sp_ss' ) - ->andReturn( true ); - Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) - ->once() - ->with( 'c_sp_ss' ) - ->andReturn( false ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp_ss'; - }); - - $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); - - $expected = << -
              • Skip to the content.
              • -
              • Skip to the primary sidebar.
              • - -EOB; - ob_start(); - beans_build_skip_links(); - $actual = ob_get_clean(); - - $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } - - /** - * Test beans_build_skip_links() should output content and only the secondary sidebar skip links when layout is 'c_sp_ss' but primary sidebar is not active. - */ - public function test_should_output_content_only_secondary_sidebar_skip_links_when_primary_sidebar_not_active_() { - Monkey\Functions\expect( 'beans_has_primary_sidebar' ) - ->once() - ->with( 'c_sp_ss' ) - ->andReturn( false ); - Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) - ->once() - ->with( 'c_sp_ss' ) - ->andReturn( true ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp_ss'; - }); - - $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); - - $expected = << -
              • Skip to the content.
              • -
              • Skip to the secondary sidebar.
              • - -EOB; - ob_start(); - beans_build_skip_links(); - $actual = ob_get_clean(); - - $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } - - /** - * Test beans_build_skip_links() should output primary navigation, content and both sidebar skip links. - */ - public function test_should_output_primary_navigation_content_and_both_sidebar_skip_links() { - Monkey\Functions\expect( 'has_nav_menu' ) - ->once() - ->with( 'primary' ) - ->andReturn( true ); - Monkey\Functions\expect( 'beans_has_primary_sidebar' ) - ->once() - ->with( 'c_sp_ss' ) - ->andReturn( true ); - Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) - ->once() - ->with( 'c_sp_ss' ) - ->andReturn( true ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp_ss'; - }); - - $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); - - $expected = << -
              • Skip to the primary navigation.
              • -
              • Skip to the content.
              • -
              • Skip to the primary sidebar.
              • -
              • Skip to the secondary sidebar.
              • - -EOB; - ob_start(); - beans_build_skip_links(); - $actual = ob_get_clean(); - - $this->assertContains( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } -} diff --git a/tests/phpunit/integration/api/html/beansCloseMarkup.php b/tests/phpunit/integration/api/html/beansCloseMarkup.php deleted file mode 100644 index 60d5fcc3..00000000 --- a/tests/phpunit/integration/api/html/beansCloseMarkup.php +++ /dev/null @@ -1,152 +0,0 @@ -assertNull( beans_close_markup( 'beans_archive_title', null ) ); - } - - /** - * Test beans_close_markup() should fire "{$id}_append_markup" hooks and include the content in the returned HTML. - */ - public function test_should_fire_append_markup_hooks_and_include_content_in_returned_html() { - Monkey\Functions\expect( '__beans_render_title_append_markup' ) - ->once() - ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); - add_action( 'beans_archive_title_append_markup', '__beans_render_title_append_markup' ); - - // Run the tests. - $actual = beans_close_markup( 'beans_archive_title', 'h1' ); - $this->assertEquals( 1, did_action( 'beans_archive_title_append_markup' ) ); - $this->assertStringStartsWith( '', $actual ); - } - - /** - * Test beans_close_markup() should fire "{$id}_after_markup" hooks and include the content in the returned HTML. - */ - public function test_should_fire_after_markup_hooks_and_include_content_in_returned_html() { - Monkey\Functions\expect( '__beans_render_title_after_markup' ) - ->once() - ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); - add_action( 'beans_archive_title_after_markup', '__beans_render_title_after_markup' ); - - // Run the tests. - $actual = beans_close_markup( 'beans_archive_title', 'h1' ); - $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); - $this->assertStringEndsWith( '', $actual ); - } - - /** - * Test beans_close_markup() should return the closing tag only when a callback is not registered to either the - * "_append_markup" or "_after_markup" hook. - */ - public function test_should_return_closing_tag_when_callback_not_registered_to_either_hook() { - $actual = beans_close_markup( 'beans_archive_title', 'h1' ); - $this->assertSame( '', $actual ); - $this->assertEquals( 0, did_action( 'beans_archive_title_append_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); - } - - /** - * Test beans_close_markup() should return the append, tag, and after HTML when callbacks are registered - * to the "_append_markup" and "_after_markup" hooks. - */ - public function test_should_return_built_html_when_callback_registered_to_hooks() { - add_action( 'beans_archive_title_append_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_after_markup', function() { - echo ''; - } ); - - // Run the tests. - $actual = beans_close_markup( 'beans_archive_title', 'h1' ); - $expected = << -EOB; - - $this->assertSame( $expected, $actual ); - $this->assertEquals( 1, did_action( 'beans_archive_title_append_markup' ) ); - $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); - } - - /** - * Test beans_close_markup() should return an empty string when (1) the tag is an empty string and (2) a callback - * is not registered to either the "_append_markup" or "_after_markup" hook. - */ - public function test_should_return_empty_string_when_empty_tag_and_callback_not_registered_to_hooks() { - $this->assertSame( '', beans_close_markup( 'beans_archive_title', '' ) ); - } - - /** - * Test beans_close_markup() should return the hooked callbacks' output and not the closing tag when - * the tag is empty. - */ - public function test_should_return_hooked_callbacks_output_and_not_closing_tag_when_tag_is_empty() { - add_action( 'beans_archive_title_append_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_after_markup', function() { - echo ''; - } ); - - // Check with an empty string. - $actual = beans_close_markup( 'beans_archive_title', '' ); - $this->assertSame( '', $actual ); - - // Check with false. - $actual = beans_close_markup( 'beans_archive_title', false ); - $this->assertSame( '', $actual ); - - // Check the hooks. - $this->assertEquals( 2, did_action( 'beans_archive_title_append_markup' ) ); - $this->assertEquals( 2, did_action( 'beans_archive_title_after_markup' ) ); - } - - /** - * Test beans_close_markup() should escape the closing tag. - */ - public function test_should_escape_closing_tag() { - $expected = << -EOB; - // Check when given as the tag. - $this->assertSame( $expected, beans_close_markup( 'beans_post_title', '' ) ); - - // Check when tag is filtered. - add_filter( 'beans_post_title_markup', function() { - return ''; - }); - $this->assertSame( $expected, beans_close_markup( 'beans_post_title', 'h1' ) ); - } -} diff --git a/tests/phpunit/integration/api/html/beansCloseMarkupE.php b/tests/phpunit/integration/api/html/beansCloseMarkupE.php deleted file mode 100644 index 4469ea90..00000000 --- a/tests/phpunit/integration/api/html/beansCloseMarkupE.php +++ /dev/null @@ -1,72 +0,0 @@ -assertEquals( '', ob_get_clean() ); - } - - /** - * Test beans_close_markup_e() should echo the closing tag only when a callback is not registered to either the - * "_append_markup" or "_after_markup" hook. - */ - public function test_should_echo_closing_tag_when_callback_not_registered_to_either_hook() { - ob_start(); - beans_close_markup_e( 'beans_archive_title', 'h1' ); - $actual = ob_get_clean(); - - $this->assertSame( '', $actual ); - $this->assertEquals( 0, did_action( 'beans_archive_title_append_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); - } - - /** - * Test beans_close_markup_e() should echo the append, tag, and after HTML when callbacks are registered - * to the "_append_markup" and "_after_markup" hooks. - */ - public function test_should_echo_built_html_when_append_or_after_hooks() { - add_action( 'beans_archive_title_append_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_after_markup', function() { - echo ''; - } ); - - ob_start(); - beans_close_markup_e( 'beans_archive_title', 'h1' ); - $actual = ob_get_clean(); - $expected = << -EOB; - // Run the tests. - $this->assertSame( $expected, $actual ); - $this->assertEquals( 1, did_action( 'beans_archive_title_append_markup' ) ); - $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); - } -} diff --git a/tests/phpunit/integration/api/html/beansIsHtmlDevMode.php b/tests/phpunit/integration/api/html/beansIsHtmlDevMode.php deleted file mode 100644 index 19f3342a..00000000 --- a/tests/phpunit/integration/api/html/beansIsHtmlDevMode.php +++ /dev/null @@ -1,49 +0,0 @@ -assertFalse( defined( 'BEANS_HTML_DEV_MODE' ) ); - $this->assertFalse( _beans_is_html_dev_mode() ); - } - - /** - * Test _beans_is_html_dev_mode() should return the option's value. - */ - public function test_should_return_option_value() { - add_option( 'beans_dev_mode', 1 ); - $this->assertTrue( _beans_is_html_dev_mode() ); - - update_option( 'beans_dev_mode', 0 ); - $this->assertFalse( _beans_is_html_dev_mode() ); - - // Clean up. - delete_option( 'beans_dev_mode' ); - } -} diff --git a/tests/phpunit/integration/api/html/beansModifyMarkup.php b/tests/phpunit/integration/api/html/beansModifyMarkup.php deleted file mode 100644 index 885e529d..00000000 --- a/tests/phpunit/integration/api/html/beansModifyMarkup.php +++ /dev/null @@ -1,87 +0,0 @@ -assertInstanceOf( _Beans_Anonymous_Filters::class, beans_modify_markup( 'beans_archive_title', 'h2' ) ); - } - - /** - * Test beans_modify_markup() should register a callback to the "{$id}_markup" filter hook. - */ - public function test_should_register_callback_to_id_markup_filter() { - $anonymous_filter = beans_modify_markup( 'beans_archive_title', 'h2' ); - - $this->assertSame( 10, has_filter( 'beans_archive_title_markup', [ - $anonymous_filter, - 'callback', - ] ) ); - } - - /** - * Test beans_modify_markup() should modify the HTML markup tag. - */ - public function test_should_modify_html_markup_tag() { - beans_modify_markup( 'beans_archive_title', 'h2' ); - $expected = <<

                -EOB; - - // Let's test it out by running the markup for this ID. - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); - - // Check the opening markup. - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertSame( $expected, $actual ); - - // Check the closing markup. - $this->assertSame( '

                ', beans_close_markup( 'beans_archive_title', 'h1' ) ); - } - - /** - * Test beans_modify_markup() should modify the HTML markup self-closing tag. - */ - public function test_should_modify_html_markup_self_closing_tag() { - beans_modify_markup( 'beans_post_image_item', 'foo' ); - $expected = << -EOB; - $actual = beans_selfclose_markup( 'beans_post_image_item', 'img', [ - 'width' => 800, - 'height' => 500, - 'src' => 'http://example.com/image.png', - 'alt' => 'Some image', - 'itemprop' => 'image', - ] ); - $this->assertSame( $expected, $actual ); - } -} diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php deleted file mode 100644 index 04600d3e..00000000 --- a/tests/phpunit/integration/api/html/beansOpenMarkup.php +++ /dev/null @@ -1,236 +0,0 @@ -assertNull( beans_open_markup( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ) ); - } - - /** - * Test beans_open_markup() should fire "{$id}_before_markup" hooks and include the content in the returned HTML. - */ - public function test_should_fire_before_markup_hooks_and_include_content_in_returned_html() { - Monkey\Functions\expect( '__beans_render_title_before_markup' ) - ->once() - ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); - add_action( 'beans_archive_title_before_markup', '__beans_render_title_before_markup' ); - - // Run the tests. - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertEquals( 1, did_action( 'beans_archive_title_before_markup' ) ); - $this->assertStringStartsWith( '', $actual ); - } - - /** - * Test beans_open_markup() should fire "{$id}_prepend_markup" hooks and include the content in the returned HTML. - */ - public function test_should_fire_prepend_markup_hooks_and_include_content_in_returned_html() { - Monkey\Functions\expect( '__beans_render_title_prepend_markup' ) - ->once() - ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', '__beans_render_title_prepend_markup' ); - - // Run the tests. - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertEquals( 1, did_action( 'beans_archive_title_prepend_markup' ) ); - $this->assertStringEndsWith( '', $actual ); - } - - /** - * Test beans_open_markup() should fire _beans_render_action() for the "_after_markup" hooks when the global - * $_beans_is_selfclose_markup is set to true. - */ - public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { - Monkey\Functions\expect( '__beans_render_title_after_markup' ) - ->once() - ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); - add_action( 'beans_archive_title_after_markup', '__beans_render_title_after_markup' ); - - global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; - - // Run the tests. - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertEquals( 1, did_action( 'beans_archive_title_after_markup' ) ); - $this->assertStringEndsWith( '', $actual ); - - // Check that the global was unset. - $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); - } - - /** - * Test beans_open_markup() should return the built HTML element when before or prepend hooks are not registered. - */ - public function test_should_return_built_html_when_before_or_prepend_hooks_not_registered() { - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '

                ', $actual ); - $this->assertEquals( 0, did_action( 'beans_archive_title_before_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_archive_title_prepend_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); - } - - /** - * Test beans_open_markup() should return the built HTML element with the "data-markup-id" when in development mode. - */ - public function test_should_return_built_html_with_data_markup_id_when_in_dev_mode() { - add_option( 'beans_dev_mode', 1 ); - - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '

                ', $actual ); - } - - /** - * Test beans_open_markup() should return the built HTML when before and prepend hooks are registered. - */ - public function test_should_return_built_html_when_before_or_prepend_hooks() { - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); - - // Run the tests. - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $expected = <<

                -EOB; - - $this->assertSame( $expected, $actual ); - $this->assertEquals( 1, did_action( 'beans_archive_title_before_markup' ) ); - $this->assertEquals( 1, did_action( 'beans_archive_title_prepend_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); - } - - /** - * Test beans_open_markup() should return a built self-closing HTML element when the global - * $_beans_is_selfclose_markup is set to true. - */ - public function test_should_return_built_self_closing_html_when_selfclose_markup_is_true() { - $args = [ - 'width' => 800, - 'height' => 500, - 'src' => 'http://example.com/image.png', - 'alt' => 'Some image', - 'itemprop' => 'image', - ]; - - // Run it with development mode off. - global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; - - $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); - $expected = << -EOB; - $this->assertSame( $expected, $actual ); - - // Run it with development mode on. - add_option( 'beans_dev_mode', 1 ); - global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; - - $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); - $expected = << -EOB; - $this->assertSame( $expected, $actual ); - $this->assertEquals( 0, did_action( 'beans_post_image_item_before_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_post_image_item_prepend_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_post_image_item_after_markup' ) ); - } - - /** - * Test beans_open_markup() should return only the output from the hooked callbacks and not the HTML element when - * the tag is empty. - */ - public function test_should_return_only_hooked_callbacks_output_and_no_html_element_when_tag_is_empty() { - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); - - // Check with an empty string. - $actual = beans_open_markup( 'beans_archive_title', '', [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '', $actual ); - - // Check with false. - $actual = beans_open_markup( 'beans_archive_title', false, [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '', $actual ); - - // Check the hooks. - $this->assertEquals( 2, did_action( 'beans_archive_title_before_markup' ) ); - $this->assertEquals( 2, did_action( 'beans_archive_title_prepend_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); - } - - /** - * Test beans_open_markup() should escape the built HTML tag. - */ - public function test_should_escape_built_html_tag() { - $expected = << -EOB; - // Check when given as the tag. - $actual = beans_open_markup( 'beans_post_title', '', [ - 'class' => 'uk-article-title', - 'itemprop' => 'headline', - ] ); - $this->assertSame( $expected, $actual ); - - // Check when tag is filtered. - add_filter( 'beans_post_title_markup', function() { - return ''; - } ); - $actual = beans_open_markup( 'beans_post_title', 'h1', [ - 'class' => 'uk-article-title', - 'itemprop' => 'headline', - ] ); - $this->assertSame( $expected, $actual ); - - // Check the attributes too. - $expected = << -EOB; - $this->assertSame( $expected, beans_open_markup( 'beans_post_title_link', 'a', [ - 'href' => 'http://example.com/testing-ensure-safe?val=', - 'title' => 'Testing to ensure safe.', - 'rel' => 'bookmark', - ] ) ); - } -} diff --git a/tests/phpunit/integration/api/html/beansOpenMarkupE.php b/tests/phpunit/integration/api/html/beansOpenMarkupE.php deleted file mode 100644 index 11572b57..00000000 --- a/tests/phpunit/integration/api/html/beansOpenMarkupE.php +++ /dev/null @@ -1,86 +0,0 @@ - 'uk-article-title' ] ); - $this->assertEquals( '', ob_get_clean() ); - } - - /** - * Test beans_open_markup_e() should echo the HTML element only when neither the before nor prepend hooks are not - * registered. - */ - public function test_should_echo_html_element_when_hooks_not_registered() { - ob_start(); - beans_open_markup_e( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $actual = ob_get_clean(); - - $this->assertSame( '

                ', $actual ); - $this->assertEquals( 0, did_action( 'beans_archive_title_before_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_archive_title_prepend_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); - } - - /** - * Test beans_open_markup_e() should echo the HTML element with the "data-markup-id" when in development mode. - */ - public function test_should_echo_html_element_with_data_markup_id_when_in_dev_mode() { - add_option( 'beans_dev_mode', 1 ); - - ob_start(); - beans_open_markup_e( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '

                ', ob_get_clean() ); - } - - /** - * Test beans_open_markup_e() should echo the before, element, and prepend HTML when callbacks are registered to - * the "_before_markup" and "_prepend_markup" hooks. - */ - public function test_should_echo_before_element_prepend_html_when_before_or_prepend_hooks() { - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); - - ob_start(); - beans_open_markup_e( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $actual = ob_get_clean(); - - $expected = <<

                -EOB; - - // Run the tests. - $this->assertSame( $expected, $actual ); - $this->assertEquals( 1, did_action( 'beans_archive_title_before_markup' ) ); - $this->assertEquals( 1, did_action( 'beans_archive_title_prepend_markup' ) ); - $this->assertEquals( 0, did_action( 'beans_archive_title_after_markup' ) ); - } -} diff --git a/tests/phpunit/integration/api/html/beansOutput.php b/tests/phpunit/integration/api/html/beansOutput.php deleted file mode 100644 index 942c1d3c..00000000 --- a/tests/phpunit/integration/api/html/beansOutput.php +++ /dev/null @@ -1,97 +0,0 @@ -assertNull( beans_output( 'beans_post_meta_item_date', null ) ); - $this->assertNull( beans_output( 'beans_post_meta_item_author', '' ) ); - $this->assertNull( beans_output( 'beans_post_meta_item_comments', false ) ); - } - - /** - * Test beans_output() should return the filtered output after firing the "{$id}_output" filter hook. - */ - public function test_should_return_filtered_output_after_firing_output_filter_hook() { - add_option( 'beans_dev_mode', 0 ); - add_filter( 'beans_archive_title_text_output', 'return_fired_output' ); - Monkey\Functions\expect( 'return_fired_output' ) - ->with( 'Beans rocks!' ) - ->andReturn( 'WooHoo, I fired!' ); - - // Run the test. - $this->assertSame( 'WooHoo, I fired!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); - } - - /** - * Test beans_output() should return the output when not in HTML dev mode. - */ - public function test_should_return_output_when_not_in_html_dev_mode() { - add_option( 'beans_dev_mode', 0 ); - - $this->assertSame( 'Beans rocks!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); - } - - /** - * Test beans_output() should return the "comment wrapped" HTML when in HTML dev mode. - */ - public function test_should_return_comment_wrapped_html_when_in_html_dev_mode() { - add_option( 'beans_dev_mode', 1 ); - - $expected = <<Beans rocks! -EOB; - $this->assertSame( $expected, beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); - } - - /** - * Test beans_output() should pass the additional arguments when firing the filter hook. - */ - public function test_should_pass_additional_args_when_firing_filter_hook() { - add_filter( 'beans_breadcrumb_item_text_output', 'return_fired_output', 10, 3 ); - Monkey\Functions\expect( 'return_fired_output' ) - ->twice() - ->with( 'Beans rocks!', 47, 'Hello' ) - ->andReturnFirstArg(); - - // Check with HTML dev mode disabled. - add_option( 'beans_dev_mode', 0 ); - $this->assertSame( - 'Beans rocks!', - beans_output( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) - ); - - // Check with HTML dev mode enabled. - $expected = <<Beans rocks! -EOB; - update_option( 'beans_dev_mode', 1 ); - $this->assertSame( - $expected, - beans_output( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) - ); - } -} diff --git a/tests/phpunit/integration/api/html/beansOutputE.php b/tests/phpunit/integration/api/html/beansOutputE.php deleted file mode 100644 index 800832e4..00000000 --- a/tests/phpunit/integration/api/html/beansOutputE.php +++ /dev/null @@ -1,114 +0,0 @@ - null, - 'beans_post_meta_item_author' => '', - 'beans_post_meta_item_comments' => false, - ]; - - foreach ( $ids as $id => $output ) { - ob_start(); - beans_output_e( $id, $output ); - $this->assertEmpty( ob_get_clean() ); - } - } - - /** - * Test beans_output_e() should echo the filtered output. - */ - public function test_should_echo_the_filtered_output() { - add_option( 'beans_dev_mode', 0 ); - add_filter( 'beans_archive_title_text_output', 'return_fired_output' ); - Monkey\Functions\expect( 'return_fired_output' ) - ->with( 'Beans rocks!' ) - ->andReturn( 'WooHoo, I fired!' ); - - // Run the test. - ob_start(); - beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); - $this->assertSame( 'WooHoo, I fired!', ob_get_clean() ); - } - - /** - * Test beans_output_e() should echo the output when not in HTML dev mode. - */ - public function test_should_echo_output_when_not_in_html_dev_mode() { - add_option( 'beans_dev_mode', 0 ); - - ob_start(); - beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); - $this->assertSame( 'Beans rocks!', ob_get_clean() ); - } - - /** - * Test beans_output_e() should echo the "comment wrapped" HTML when in HTML dev mode. - */ - public function test_should_echo_comment_wrapped_html_when_in_html_dev_mode() { - add_option( 'beans_dev_mode', 1 ); - - ob_start(); - beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); - $actual = ob_get_clean(); - - $expected = <<Beans rocks! -EOB; - $this->assertSame( $expected, $actual ); - } - - /** - * Test beans_output_e() should pass the additional arguments. - */ - public function test_should_pass_additional_arguments() { - add_filter( 'beans_breadcrumb_item_text_output', 'return_fired_output', 10, 3 ); - Monkey\Functions\expect( 'return_fired_output' ) - ->twice() - ->with( 'Beans rocks!', 47, 'Hello' ) - ->andReturnUsing( function( $output, $arg1, $arg2 ) { - return $arg2; - } ); - - // Check with HTML dev mode disabled. - add_option( 'beans_dev_mode', 0 ); - ob_start(); - beans_output_e( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ); - $this->assertSame( 'Hello', ob_get_clean() ); - - // Check with HTML dev mode enabled. - update_option( 'beans_dev_mode', 1 ); - ob_start(); - beans_output_e( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ); - $actual = ob_get_clean(); - $expected = <<Hello -EOB; - $this->assertSame( $expected, $actual ); - } -} diff --git a/tests/phpunit/integration/api/html/beansRemoveAttribute.php b/tests/phpunit/integration/api/html/beansRemoveAttribute.php deleted file mode 100644 index 9fac5c6d..00000000 --- a/tests/phpunit/integration/api/html/beansRemoveAttribute.php +++ /dev/null @@ -1,147 +0,0 @@ - $markup ) { - $instance = beans_remove_attribute( $beans_id, 'data-test', 'test' ); - - // Check that it returns an instance of _Beans_Attribute. - $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); - - // Check that the object's "remove" method is registered to the filter event for the given ID. - $this->assertSame( 10, has_filter( "{$beans_id}_attributes", [ $instance, 'remove' ], 10 ) ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'remove' ] ); - } - } - - /** - * Test the end result of beans_remove_attribute() by firing the expected filter event for the given ID. Test - * should return the original attributes when the target attribute does not exist, meaning there's nothing to - * remove in the given attributes. - */ - public function test_should_return_original_attributes_when_target_attribute_does_not_exist() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $instance = beans_remove_attribute( $beans_id, 'data-test', 'test' ); - - // Check that the new attribute does not exist yet. - $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); - - // Fire the event to run the remove. - $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Run the full systems test by applying the filter. - $this->assertSame( $markup['attributes'], $actual ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'remove' ] ); - } - } - - /** - * Test the end result of beans_remove_attribute() by firing the expected filter event for the given ID. Test - * should remove the attribute when the given value is null. - */ - public function test_should_remove_attribute_when_value_is_null() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $instance = beans_remove_attribute( $beans_id, $name, null ); - - // Fire the event to run the remove. - $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Check that the attribute is removed. - $this->assertArrayNotHasKey( $name, $actual ); - - // Check that only that attribute is affected. - $expected = $markup['attributes']; - unset( $expected[ $name ] ); - $this->assertSame( $expected, $actual ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'remove' ], 10 ); - } - } - - /** - * Test the end result of beans_remove_attribute() by firing the expected filter event for the given ID. Test - * should remove the given value from the attribute. - */ - public function test_should_remove_the_given_value_from_attribute() { - $attributes = [ - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'https://schema.org/blogPost', - 'itemprop' => 'beans_post', - ]; - - $instance = beans_remove_attribute( 'beans_test', 'class', 'uk-panel-box' ); - - // Fire the event to run the remove. - $actual = apply_filters( 'beans_test_attributes', $attributes ); - - // Check that it removed only that attribute value. - $this->assertNotContains( 'uk-panel-box', $actual['class'] ); - $this->assertSame( 'uk-article category-beans', $actual['class'] ); - - // Check that only the class attribute is affected. - $expected = $attributes; - $expected['class'] = 'uk-article category-beans'; - $this->assertSame( $expected, $actual ); - - // Clean up. - remove_filter( 'beans_test_attributes', [ $instance, 'remove' ], 10 ); - } - - /** - * Test the end result of beans_remove_attribute() by firing the expected filter event for the given ID. Test - * should return an empty array when an empty array is given. Why? There is nothing to remove, as there are no - * attributes. - */ - public function test_should_return_empty_array_when_empty_array_given() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $value = current( $markup['attributes'] ); - $instance = beans_remove_attribute( $beans_id, $name, $value ); - - // Fire the event to run the remove. - $actual = apply_filters( "{$beans_id}_attributes", [] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Check that an empty array is returned. - $this->assertSame( [], $actual ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'remove' ], 10 ); - } - } -} diff --git a/tests/phpunit/integration/api/html/beansRemoveMarkup.php b/tests/phpunit/integration/api/html/beansRemoveMarkup.php deleted file mode 100644 index 7605ea25..00000000 --- a/tests/phpunit/integration/api/html/beansRemoveMarkup.php +++ /dev/null @@ -1,73 +0,0 @@ -assertInstanceOf( _Beans_Anonymous_Filters::class, beans_remove_markup( 'beans_archive_title' ) ); - } - - /** - * Test beans_remove_markup() should register a callback to the "{$id}_markup" filter hook. - */ - public function test_should_register_callback_to_id_markup_filter() { - $anonymous_filter = beans_remove_markup( 'beans_archive_title' ); - - $this->assertSame( 10, has_filter( 'beans_archive_title_markup', [ - $anonymous_filter, - 'callback', - ] ) ); - } - - /** - * Test beans_remove_markup() should remove the markup's element when $remove_actions is false (default behavior). - */ - public function test_should_remove_only_element_when_remove_actions_is_false() { - beans_remove_markup( 'beans_archive_title' ); - - // Let's test it out by running the markup for this ID. - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '', $actual ); - $this->assertSame( '', beans_close_markup( 'beans_archive_title', 'h1' ) ); - } - - /** - * Test beans_remove_markup() should remove the HTML markup when $remove_actions is true. - */ - public function test_should_remove_html_markup_when_remove_actions_is_true() { - beans_remove_markup( 'beans_archive_title' ); - - // Let's test it out by running the markup for this ID. - $this->assertSame( '', beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ) ); - $this->assertSame( '', beans_close_markup( 'beans_archive_title', 'h1' ) ); - } -} diff --git a/tests/phpunit/integration/api/html/beansRemoveOutput.php b/tests/phpunit/integration/api/html/beansRemoveOutput.php deleted file mode 100644 index 50f45169..00000000 --- a/tests/phpunit/integration/api/html/beansRemoveOutput.php +++ /dev/null @@ -1,63 +0,0 @@ -assertInstanceOf( _Beans_Anonymous_Filters::class, beans_remove_output( 'beans_post_meta_item_date' ) ); - } - - /** - * Test beans_remove_output() should register a callback to the "{$id}_output" filter hook. - */ - public function test_should_return_register_callback_to_id_output_filter() { - $anonymous_filter = beans_remove_output( 'beans_post_meta_item_date' ); - - $this->assertSame( 99999999, has_filter( 'beans_post_meta_item_date_output', [ - $anonymous_filter, - 'callback', - ] ) ); - } - - /** - * Test beans_remove_output() should remove the output. - */ - public function test_should_return_remove_output() { - // Check that everything works before we remove it. - $this->assertSame( 'Beans rocks!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); - - // Now remove the output. - beans_remove_output( 'beans_archive_title_text' ); - - // Check when not in developer mode. - add_option( 'beans_dev_mode', 0 ); - $this->assertNull( beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); - - // Check when in developer mode. - update_option( 'beans_dev_mode', 1 ); - $this->assertNull( beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); - } -} diff --git a/tests/phpunit/integration/api/html/beansReplaceAttribute.php b/tests/phpunit/integration/api/html/beansReplaceAttribute.php deleted file mode 100644 index 35e3c36a..00000000 --- a/tests/phpunit/integration/api/html/beansReplaceAttribute.php +++ /dev/null @@ -1,160 +0,0 @@ - $markup ) { - $instance = beans_replace_attribute( $beans_id, key( $markup['attributes'] ), current( $markup['attributes'] ), 'test' ); - - // Check that it returns an instance of _Beans_Attribute. - $this->assertInstanceOf( \_Beans_Attribute::class, $instance ); - - // Check that the object's "replace" method is registered to the filter event for the given ID. - $this->assertSame( 10, has_filter( "{$beans_id}_attributes", [ $instance, 'replace' ], 10 ) ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'replace' ] ); - } - } - - /** - * Test the end result of beans_replace_attribute() by firing the expected filter event for the given ID. Test should replace - * an existing attribute value. - */ - public function test_should_replace_existing_attribute_value() { - $attributes = [ - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'https://schema.org/blogPost', - 'itemprop' => 'beans_post', - ]; - - $instance = beans_replace_attribute( 'beans_post', 'class', 'uk-panel-box', 'beans-test' ); - - // Check that the attribute does not contain the new value. - $this->assertNotContains( 'beans-test', $attributes['class'] ); - - // Fire the event to run the replace. - $actual = apply_filters( 'beans_post_attributes', $attributes ); - - // Check that the attribute is added with the given value. - $this->assertContains( 'beans-test', $actual['class'] ); - $this->assertNotContains( 'uk-panel-box', $actual['class'] ); - - // Clean up. - remove_filter( 'beans_post_attributes', [ $instance, 'replace' ], 10 ); - } - - /** - * Test the end result of beans_replace_attribute() by firing the expected filter event for the given ID. Test should replace - * (overwrite) all attribute's values with the new value when the target value is empty (null, empty string, etc.). - */ - public function test_should_overwrite_attribute_values_when_target_value_is_empty() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $hook = "{$beans_id}_attributes"; - - // Check when both target value and new value are null. - $instance = beans_replace_attribute( $beans_id, $name, null ); - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - $this->assertNull( $actual[ $name ] ); - remove_filter( $hook, [ $instance, 'replace' ], 10 ); - - // Check when the target value is null. - $instance = beans_replace_attribute( $beans_id, $name, null, '' ); - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - $this->assertSame( '', $actual[ $name ] ); - remove_filter( $hook, [ $instance, 'replace' ], 10 ); - - // Check when the target value is an empty string. - $instance = beans_replace_attribute( $beans_id, $name, '', 'foo' ); - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - $this->assertSame( 'foo', $actual[ $name ] ); - remove_filter( $hook, [ $instance, 'replace' ], 10 ); - - // Check when the target value is false. - $instance = beans_replace_attribute( $beans_id, $name, false, 'foo' ); - $actual = apply_filters( $hook, $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - $this->assertSame( 'foo', $actual[ $name ] ); - remove_filter( $hook, [ $instance, 'replace' ], 10 ); - } - } - - /** - * Test the end result of beans_replace_attribute() by firing the expected filter event for the given ID. Test should add the - * attribute when it does not exists in the given attributes. - */ - public function test_should_add_attribute_when_it_does_not_exist() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $instance = beans_replace_attribute( $beans_id, 'data-test', 'foo', 'beans-test' ); - - // Check that the attribute does not exist. - $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); - - // Fire the event to run the replace. - $actual = apply_filters( "{$beans_id}_attributes", $markup['attributes'] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Check that the new attribute is added. - $this->assertArrayHasKey( 'data-test', $actual ); - $this->assertSame( 'beans-test', $actual['data-test'] ); - - // Check that only the data-test attribute is affected. - $expected = $markup['attributes']; - $expected['data-test'] = 'beans-test'; - $this->assertSame( $expected, $actual ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'replace' ], 10 ); - } - } - - /** - * Test the end result of beans_replace_attribute() by firing the expected filter event for the given ID. Test should add the - * attribute when an empty array is given. - */ - public function test_should_add_attribute_when_an_empty_array_given() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $value = current( $markup['attributes'] ); - $instance = beans_replace_attribute( $beans_id, $name, $value, 'beans-test' ); - - // Fire the event to run the replace. - $actual = apply_filters( "{$beans_id}_attributes", [] ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- The hook's name is in the value. - - // Check that it did add the attribute. - $this->assertArrayHasKey( $name, $actual ); - $this->assertSame( [ $name => 'beans-test' ], $actual ); - - // Clean up. - remove_filter( "{$beans_id}_attributes", [ $instance, 'replace' ], 10 ); - } - } -} diff --git a/tests/phpunit/integration/api/html/beansResetMarkup.php b/tests/phpunit/integration/api/html/beansResetMarkup.php deleted file mode 100644 index 2b4b4158..00000000 --- a/tests/phpunit/integration/api/html/beansResetMarkup.php +++ /dev/null @@ -1,84 +0,0 @@ -assertEquals( 20, has_filter( 'beans_archive_title_markup', [ $anonymous_filter, 'callback' ] ) ); - - // Reset it. - beans_reset_markup( 'beans_archive_title' ); - - // Check that it did reset. - $this->assertFalse( has_filter( 'beans_archive_title_markup' ) ); - - // Double check by building the markup. - $actual = beans_open_markup( 'beans_archive_title', 'h1' ); - $this->assertSame( '

                ', $actual ); - $this->assertSame( '

                ', beans_close_markup( 'beans_archive_title', 'h1' ) ); - } - - /** - * Test beans_reset_markup() should reset the HTML markup self-closing tag. - */ - public function test_should_reset_html_markup_self_closing_tag() { - // First, register to modify the tag. - $anonymous_filter = beans_modify_markup( 'beans_post_image_item', 'foo', 20 ); - $this->assertEquals( 20, has_filter( 'beans_post_image_item_markup', [ $anonymous_filter, 'callback' ] ) ); - - // Reset it. - beans_reset_markup( 'beans_post_image_item' ); - - // Check that it did reset. - $this->assertFalse( has_filter( 'beans_post_image_item_markup' ) ); - - // Double check by building the markup. - $actual = beans_selfclose_markup( 'beans_post_image_item', 'img' ); - $this->assertSame( '', $actual ); - } - - /** - * Test beans_reset_markup() should reset sub-hooks. - */ - public function test_should_reset_sub_hooks() { - // First, register to modify the tag. - $anonymous_filter = beans_modify_markup( 'beans_title[_foo]', 'p', 20 ); - $this->assertEquals( 20, has_filter( 'beans_title[_foo]_markup', [ $anonymous_filter, 'callback' ] ) ); - - // Reset it. - beans_reset_markup( 'beans_title[_foo]' ); - - // Check that it did reset. - $this->assertFalse( has_filter( 'beans_title[_foo]_markup' ) ); - - // Double check by building the markup. - $actual = beans_open_markup( 'beans_title[_foo]', 'h4' ); - $this->assertSame( '

                ', $actual ); - $this->assertSame( '

                ', beans_close_markup( 'beans_title[_foo]', 'h4' ) ); - } -} diff --git a/tests/phpunit/integration/api/html/beansSelfcloseMarkup.php b/tests/phpunit/integration/api/html/beansSelfcloseMarkup.php deleted file mode 100644 index bcd7bf2f..00000000 --- a/tests/phpunit/integration/api/html/beansSelfcloseMarkup.php +++ /dev/null @@ -1,70 +0,0 @@ -assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); - - beans_selfclose_markup( $attachment['id'], null, $attachment['attributes'], $attachment['attachment'] ); - - // Check after we run the function. - $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); - } - } - - /** - * Test beans_selfclose_markup() should return null when the tag is set to null. - */ - public function test_should_return_null_when_tag_set_to_null() { - - foreach ( static::$test_attachments as $attachment ) { - $this->assertNull( beans_selfclose_markup( $attachment['id'], null, $attachment['attributes'], $attachment['attachment'] ) ); - } - } - - /** - * Test beans_selfclose_markup() should return the built HTML self-closing element. - */ - public function test_should_return_built_html_self_closing_element() { - // Check the first attachment. - $attachment = current( static::$test_attachments ); - $expected = << -EOB; - $this->assertSame( $expected, beans_selfclose_markup( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ) ); - - // Check the next one. - $attachment = next( static::$test_attachments ); - $expected = << -EOB; - $this->assertSame( $expected, beans_selfclose_markup( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ) ); - } -} diff --git a/tests/phpunit/integration/api/html/beansSelfcloseMarkupE.php b/tests/phpunit/integration/api/html/beansSelfcloseMarkupE.php deleted file mode 100644 index 9ee93dfc..00000000 --- a/tests/phpunit/integration/api/html/beansSelfcloseMarkupE.php +++ /dev/null @@ -1,60 +0,0 @@ -assertSame( '', ob_get_clean() ); - } - } - - /** - * Test beans_selfclose_markup_e() should echo the built HTML self-closing element. - */ - public function test_should_echo_built_html_self_closing_element() { - // Check the first attachment. - $attachment = current( static::$test_attachments ); - $expected = << -EOB; - ob_start(); - beans_selfclose_markup_e( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ); - $this->assertSame( $expected, ob_get_clean() ); - - // Check the next one. - $attachment = next( static::$test_attachments ); - $expected = << -EOB; - ob_start(); - beans_selfclose_markup_e( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ); - $this->assertSame( $expected, ob_get_clean() ); - } -} diff --git a/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php b/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php deleted file mode 100644 index 3cd1b22d..00000000 --- a/tests/phpunit/integration/api/html/beansWrapInnerMarkup.php +++ /dev/null @@ -1,166 +0,0 @@ -callbacks[ $priority ] )['function'][0]; - } - - /** - * Test beans_wrap_inner_markup() should register beans_open_markup() to the given ID's '_prepend_markup' hook. - */ - public function test_should_register_beans_open_markup_to_given_id_prepend_markup_hook() { - $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); - - // Check that it did register a callback to the hook. - $this->assertTrue( has_action( 'foo_prepend_markup' ) ); - global $wp_filter; - $this->assertArrayHasKey( 'foo_prepend_markup', $wp_filter ); - $this->assertArrayHasKey( 1, $wp_filter['foo_prepend_markup'] ); - - // Check that the correct arguments were stored in the instance. - $anonymous_action = $this->get_instance_from_wp( 'foo_prepend_markup', 1 ); - $this->assertSame( - [ - 'beans_open_markup', - [ - 1 => 'new_foo', - 2 => 'div', - 3 => [ 'class' => 'test-wrap' ], - ], - ], - $anonymous_action->callback - ); - - // Clean up. - remove_action( 'foo_prepend_markup', [ $anonymous_action, 'callback' ], 1 ); - } - - /** - * Test beans_wrap_inner_markup() should register beans_close_markup() to the given ID's '_append_markup' hook. - */ - public function test_should_register_beans_close_markup_to_given_id_append_markup_hook() { - $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); - - // Check that it did register a callback to the hook. - $this->assertTrue( has_action( 'foo_append_markup' ) ); - global $wp_filter; - $this->assertArrayHasKey( 'foo_append_markup', $wp_filter ); - $this->assertArrayHasKey( 9999, $wp_filter['foo_append_markup'] ); - - // Check that the correct arguments were stored in the instance. - $anonymous_action = $this->get_instance_from_wp( 'foo_append_markup', 9999 ); - $this->assertSame( - [ - 'beans_close_markup', - [ - 1 => 'new_foo', - 2 => 'div', - ], - ], - $anonymous_action->callback - ); - - // Clean up. - remove_action( 'foo_append_markup', [ $anonymous_action, 'callback' ], 9999 ); - } - - /** - * Test beans_wrap_inner_markup() should not pass the given attributes to anonymous action. - */ - public function test_should_not_pass_attributes_for_append_markup_hook() { - beans_wrap_inner_markup( 'no_atts', '', 'div', [ 'class' => 'test-wrap' ] ); - - // Check that the attributes do not exist. - $anonymous_action = $this->get_instance_from_wp( 'no_atts_append_markup', 9999 ); - $this->assertNotContains( [ 'class' => 'test-wrap' ], $anonymous_action->callback[1] ); - - // Clean up. - remove_action( 'no_atts_append_markup', [ $anonymous_action, 'callback' ], 9999 ); - } - - /** - * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's - * '_prepend_markup' hook. - */ - public function test_should_pass_extra_arguments_for_prepend_markup_hook() { - beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', [ 'class' => 'test-wrap' ], 47, 'Beans Rocks!' ); - - // Check that the correct arguments were stored in the instance. - $anonymous_action = $this->get_instance_from_wp( 'extra_args_prepend_markup', 1 ); - $this->assertSame( - [ - 'beans_open_markup', - [ - 1 => 'new_extra_args', - 2 => 'div', - 3 => [ 'class' => 'test-wrap' ], - 4 => 47, - 5 => 'Beans Rocks!', - ], - ], - $anonymous_action->callback - ); - - // Clean up. - remove_action( 'extra_args_prepend_markup', [ $anonymous_action, 'callback' ], 1 ); - } - - /** - * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's - * '_append_markup' hook. - */ - public function test_should_pass_extra_arguments_for_append_markup_hook() { - beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', [ 'class' => 'test-wrap' ], 'Beans Rocks!', 'and so does WordPress!' ); - - // Check that the correct arguments were stored in the instance. - $anonymous_action = $this->get_instance_from_wp( 'extra_args_append_markup', 9999 ); - $this->assertSame( - [ - 'beans_close_markup', - [ - 1 => 'new_extra_args', - 2 => 'div', - 4 => 'Beans Rocks!', - 5 => 'and so does WordPress!', - ], - ], - $anonymous_action->callback - ); - - // Clean up. - remove_action( 'extra_args_append_markup', [ $anonymous_action, 'callback' ], 9999 ); - } -} diff --git a/tests/phpunit/integration/api/html/beansWrapMarkup.php b/tests/phpunit/integration/api/html/beansWrapMarkup.php deleted file mode 100644 index 0ab3dd9b..00000000 --- a/tests/phpunit/integration/api/html/beansWrapMarkup.php +++ /dev/null @@ -1,166 +0,0 @@ -callbacks[ $priority ] )['function'][0]; - } - - /** - * Test beans_wrap_markup() should register beans_open_markup() to the given ID's '_before_markup' hook. - */ - public function test_should_register_beans_open_markup_to_given_id_before_markup_hook() { - $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); - - // Check that it did register a callback to the hook. - $this->assertTrue( has_action( 'foo_before_markup' ) ); - global $wp_filter; - $this->assertArrayHasKey( 'foo_before_markup', $wp_filter ); - $this->assertArrayHasKey( 9999, $wp_filter['foo_before_markup'] ); - - // Check that the correct arguments were stored in the instance. - $anonymous_action = $this->get_instance_from_wp( 'foo_before_markup', 9999 ); - $this->assertSame( - [ - 'beans_open_markup', - [ - 1 => 'new_foo', - 2 => 'div', - 3 => [ 'class' => 'test-wrap' ], - ], - ], - $anonymous_action->callback - ); - - // Clean up. - remove_action( 'foo_before_markup', [ $anonymous_action, 'callback' ], 9999 ); - } - - /** - * Test beans_wrap_markup() should register beans_close_markup() to the given ID's '_after_markup' hook. - */ - public function test_should_register_beans_close_markup_to_given_id_after_markup_hook() { - $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); - - // Check that it did register a callback to the hook. - $this->assertTrue( has_action( 'foo_after_markup' ) ); - global $wp_filter; - $this->assertArrayHasKey( 'foo_after_markup', $wp_filter ); - $this->assertArrayHasKey( 1, $wp_filter['foo_after_markup'] ); - - // Check that the correct arguments were stored in the instance. - $anonymous_action = $this->get_instance_from_wp( 'foo_after_markup', 1 ); - $this->assertSame( - [ - 'beans_close_markup', - [ - 1 => 'new_foo', - 2 => 'div', - ], - ], - $anonymous_action->callback - ); - - // Clean up. - remove_action( 'foo_after_markup', [ $anonymous_action, 'callback' ], 1 ); - } - - /** - * Test beans_wrap_markup() should not pass the given attributes to anonymous action. - */ - public function test_should_not_pass_attributes_for_after_markup_hook() { - beans_wrap_markup( 'no_atts', '', 'div', [ 'class' => 'test-wrap' ] ); - - // Check that the attributes do not exist. - $anonymous_action = $this->get_instance_from_wp( 'no_atts_after_markup', 1 ); - $this->assertNotContains( [ 'class' => 'test-wrap' ], $anonymous_action->callback[1] ); - - // Clean up. - remove_action( 'no_atts_after_markup', [ $anonymous_action, 'callback' ], 1 ); - } - - /** - * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's - * '_before_markup' hook. - */ - public function test_should_pass_extra_arguments_for_before_markup_hook() { - beans_wrap_markup( 'extra_args', '', 'div', [ 'class' => 'test-wrap' ], 47, 'Beans Rocks!' ); - - // Check that the correct arguments were stored in the instance. - $anonymous_action = $this->get_instance_from_wp( 'extra_args_before_markup', 9999 ); - $this->assertSame( - [ - 'beans_open_markup', - [ - 1 => '', - 2 => 'div', - 3 => [ 'class' => 'test-wrap' ], - 4 => 47, - 5 => 'Beans Rocks!', - ], - ], - $anonymous_action->callback - ); - - // Clean up. - remove_action( 'extra_args_before_markup', [ $anonymous_action, 'callback' ], 9999 ); - } - - /** - * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's - * '_after_markup' hook. - */ - public function test_should_pass_extra_arguments_for_after_markup_hook() { - beans_wrap_markup( 'extra_args', '', 'div', [ 'class' => 'test-wrap' ], 'Beans Rocks!', 47 ); - - // Check that the correct arguments were stored in the instance. - $anonymous_action = $this->get_instance_from_wp( 'extra_args_after_markup', 1 ); - $this->assertSame( - [ - 'beans_close_markup', - [ - 1 => '', - 2 => 'div', - 4 => 'Beans Rocks!', - 5 => 47, - ], - ], - $anonymous_action->callback - ); - - // Clean up. - remove_action( 'extra_args_after_markup', [ $anonymous_action, 'callback' ], 1 ); - } -} diff --git a/tests/phpunit/integration/api/html/fixtures/test-attachment.php b/tests/phpunit/integration/api/html/fixtures/test-attachment.php deleted file mode 100644 index ab98f0a4..00000000 --- a/tests/phpunit/integration/api/html/fixtures/test-attachment.php +++ /dev/null @@ -1,50 +0,0 @@ - 'beans_post_image_small_item', - 'tag' => 'source', - 'attributes' => [ - 'media' => '(max-width: 200px)', - 'srcset' => 'https://example.com/small-image.png', - ], - 'attachment' => (object) [ - 'id' => 47, - 'src' => 'https://example.com/small-image.png', - 'width' => 200, - 'height' => 200, - 'alt' => 'Small image', - 'title' => 'This is a post title.', - 'caption' => 'This is the caption.', - 'description' => 'This is the description.', - ], - ], - [ - 'id' => 'beans_post_image_item', - 'tag' => 'img', - 'attributes' => [ - 'width' => 1200, - 'height' => 600, - 'src' => 'https://example.com/image.png', - 'alt' => 'A background image.', - 'itemprop' => 'image', - ], - 'attachment' => (object) [ - 'id' => 1047, - 'src' => 'https://example.com/image.png', - 'width' => 1200, - 'height' => 600, - 'alt' => 'A background image.', - 'title' => 'This is a post title.', - 'caption' => 'This is the caption.', - 'description' => 'This is the description.', - ], - ], -]; diff --git a/tests/phpunit/integration/api/html/fixtures/test-markup.php b/tests/phpunit/integration/api/html/fixtures/test-markup.php deleted file mode 100644 index 954725ba..00000000 --- a/tests/phpunit/integration/api/html/fixtures/test-markup.php +++ /dev/null @@ -1,64 +0,0 @@ - [ - 'id' => 'beans_post', - 'tag' => 'article', - 'attributes' => [ - 'id' => 47, - 'class' => 'uk-article uk-panel-box post-47 post type-post status-publish format-standard has-post-thumbnail hentry category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'https://schema.org/blogPost', - 'itemprop' => 'beans_post', - ], - ], - 'beans_post_header' => [ - 'id' => 'beans_post_header', - 'tag' => 'header', - ], - 'beans_post_body' => [ - 'id' => 'beans_post_body', - 'tag' => 'div', - 'attributes' => [ - 'itemprop' => 'articleBody', - ], - ], - 'beans_post_title' => [ - 'id' => 'beans_post_title', - 'tag' => 'h1', - 'attributes' => [ - 'class' => 'uk-article-title', - 'itemprop' => 'headline', - ], - ], - 'beans_post_meta' => [ - 'id' => 'beans_post_meta', - 'tag' => 'ul', - 'attributes' => [ - 'class' => 'uk-article-meta uk-subnav uk-subnav-line', - ], - ], - 'beans_post_meta_item[_date]' => [ - 'id' => 'beans_post_meta_item[_date]', - 'tag' => 'li', - ], - 'beans_post_meta_item[_author]' => [ - 'id' => 'beans_post_meta_item[_author]', - 'tag' => 'li', - ], - 'beans_post_image_link' => [ - 'id' => 'beans_post_image_link', - 'tag' => 'a', - 'attributes' => [ - 'href' => 'http://example.com/image.png', - 'title' => 'Some cool image', - ], - ], -]; diff --git a/tests/phpunit/integration/api/html/includes/class-html-test-case.php b/tests/phpunit/integration/api/html/includes/class-html-test-case.php deleted file mode 100644 index 78c0b88f..00000000 --- a/tests/phpunit/integration/api/html/includes/class-html-test-case.php +++ /dev/null @@ -1,85 +0,0 @@ - $value ) { - $html .= $attribute . '="' . $value . '" '; - } - - return rtrim( $html ); - } -} diff --git a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php deleted file mode 100644 index f9495d3c..00000000 --- a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php +++ /dev/null @@ -1,87 +0,0 @@ -get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $this->assertTrue( $created_edited_image->invoke( $editor ) ); - $this->assertFileExists( $edited_image_src ); - - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. - $this->assertEquals( 800, $width ); - $this->assertEquals( 420, $height ); - } - } - - /** - * Test _Beans_Image_Editor::create_edited_image() should return false when the image does not exist. - */ - public function test_should_return_false_when_no_image() { - $created_edited_image = $this->get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $src = 'path/does/not/exist/image.jpg'; - - $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ] ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertFalse( $created_edited_image->invoke( $editor ) ); - $this->assertFileNotExists( $edited_image_src ); - } -} diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php deleted file mode 100644 index 2848aa08..00000000 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ /dev/null @@ -1,339 +0,0 @@ -get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $image_info = $editor->run(); - $this->assertFileExists( $edited_image_src ); - $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info ); - - // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. - $this->assertEquals( 800, $width ); - $this->assertEquals( 420, $height ); - } - } - - /** - * Test _Beans_Image_Editor::run() should return original src when the image does not exist. - */ - public function test_should_return_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ] ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( $src, $editor->run() ); - } - - /** - * Test _Beans_Image_Editor::run() should return the URL when the edited image exists, meaning that it has already been edited and - * stored. - */ - public function test_should_return_url_when_edited_image_exists() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run it once to create the "edited image". - $editor->run(); - - // Run the tests. - $this->assertFileExists( $edited_image_src ); - $this->assertSame( beans_path_to_url( $edited_image_src ), $editor->run() ); - } - } - - /** - * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of its - * image info. - */ - public function test_should_edit_store_image_and_return_indexed_array() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $image_info = $editor->run(); - $this->assertFileExists( $edited_image_src ); - $this->assertSame( [ beans_path_to_url( $edited_image_src ), 800, 420 ], $image_info ); - - // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. - $this->assertEquals( 800, $width ); - $this->assertEquals( 420, $height ); - } - } - - /** - * Test _Beans_Image_Editor::run() should return an indexed array with the original src when the image does not exist. - */ - public function test_should_return_indexed_array_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], ARRAY_N ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( [ $src, null, null ], $editor->run() ); - } - - /** - * Test _Beans_Image_Editor::run() should return an indexed array when the edited image exists, meaning that it has already been - * edited and stored. - */ - public function test_should_return_index_array_when_edited_image_exists() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, ARRAY_N ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run it once to create the "edited image". - $editor->run(); - - // Run the tests. - $this->assertFileExists( $edited_image_src ); - $this->assertSame( [ beans_path_to_url( $edited_image_src ), 800, 420 ], $editor->run() ); - } - } - - /** - * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an - * object. - */ - public function test_should_edit_store_image_and_return_object() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 400, false ] ]; - - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, OBJECT ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $image_info = $editor->run(); - $this->assertFileExists( $edited_image_src ); - $this->assertInstanceOf( 'stdClass', $image_info ); - $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info->src ); - $this->assertSame( 400, $image_info->width ); - $this->assertSame( 210, $image_info->height ); - - // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. - $this->assertEquals( 400, $width ); - $this->assertEquals( 210, $height ); - } - } - - /** - * Test _Beans_Image_Editor::run() should return an object with the original src when the image does not exist. - */ - public function test_should_return_object_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], OBJECT ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $image_info = $editor->run(); - $this->assertInstanceOf( 'stdClass', $image_info ); - $this->assertSame( $src, $image_info->src ); - $this->assertNull( $image_info->width ); - $this->assertNull( $image_info->height ); - } - - /** - * Test _Beans_Image_Editor::run() should return an object when the edited image exists, meaning that it has already been - * edited and stored. - */ - public function test_should_return_object_when_edited_image_exists() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 400, false ] ]; - - // Run the tests. - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, OBJECT ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run it once to create the "edited image". - $editor->run(); - - // Run the tests. - $this->assertFileExists( $edited_image_src ); - $image_info = $editor->run(); - $this->assertInstanceOf( 'stdClass', $image_info ); - $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info->src ); - $this->assertSame( 400, $image_info->width ); - $this->assertSame( 210, $image_info->height ); - } - } - - /** - * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an - * associative array. - */ - public function test_should_edit_store_image_and_return_associative_array() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 600, false ] ]; - - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, ARRAY_A ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $image_info = $editor->run(); - $this->assertFileExists( $edited_image_src ); - $this->assertSame( - [ - 'src' => beans_path_to_url( $edited_image_src ), - 'width' => 600, - 'height' => 315, - ], - $image_info - ); - - // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. - $this->assertEquals( 600, $width ); - $this->assertEquals( 315, $height ); - } - } - - /** - * Test _Beans_Image_Editor::run() should return an array with the original src when the image does not exist. - */ - public function test_should_return_associative_array_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], ARRAY_A ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( - [ - 'src' => $src, - 'width' => null, - 'height' => null, - ], - $editor->run() - ); - } - - /** - * Test _Beans_Image_Editor::run() should return an associative array when the edited image exists, meaning that it has already - * been edited and stored. - */ - public function test_should_return_associatve_array_when_edited_image_exists() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 600, false ] ]; - - // Run the tests. - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args, ARRAY_A ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Run it once to create the "edited image". - $editor->run(); - - // Run the tests. - $this->assertFileExists( $edited_image_src ); - $this->assertSame( - [ - 'src' => beans_path_to_url( $edited_image_src ), - 'width' => 600, - 'height' => 315, - ], - $editor->run() - ); - } - } -} diff --git a/tests/phpunit/integration/api/image/beans-image-options/flush.php b/tests/phpunit/integration/api/image/beans-image-options/flush.php deleted file mode 100644 index 6338fa71..00000000 --- a/tests/phpunit/integration/api/image/beans-image-options/flush.php +++ /dev/null @@ -1,58 +0,0 @@ -directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); - - $this->assertNull( ( new _Beans_Image_Options() )->flush() ); - - // Check that it still exists and was not removed. - $this->directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); - } - - /** - * Test _Beans_Image_Options::flush() should remove the cached directory. - */ - public function test_should_remove_cached_dir() { - // Check that the cached directory exists before we start. - $this->directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); - - $this->go_to_settings_page(); - $_POST['beans_flush_edited_images'] = 1; - - // Return the virtual filesystem's path to avoid wp_normalize_path converting its prefix from vfs::// to vfs:/. - Monkey\Functions\when( 'wp_normalize_path' )->returnArg(); - - $this->assertNull( ( new _Beans_Image_Options() )->flush() ); - $this->assertDirectoryNotExists( vfsStream::url( 'uploads/beans/images/' ) ); - } -} diff --git a/tests/phpunit/integration/api/image/beans-image-options/register.php b/tests/phpunit/integration/api/image/beans-image-options/register.php deleted file mode 100644 index 89ddf3b6..00000000 --- a/tests/phpunit/integration/api/image/beans-image-options/register.php +++ /dev/null @@ -1,104 +0,0 @@ -fields = [ - [ - 'id' => 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - 'description' => 'Clear all edited images. New images will be created on page load.', - ], - ]; - - require_once BEANS_THEME_DIR . '/lib/api/options/functions.php'; - } - - /** - * Test _Beans_Image_Options::register() should register the options with column context when other metaboxes are - * registered. - */ - public function test_should_register_options_with_column_context_when_other_metaboxes_are_registered() { - $this->go_to_settings_page(); - - global $wp_meta_boxes; - $wp_meta_boxes = [ 'beans_settings' => [ 'foo' ] ]; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case to set up the test. - - $this->assertTrue( ( new _Beans_Image_Options() )->register() ); - - // Check that the right fields did get registered. - $registered_fields = beans_get_fields( 'option', 'images_options' ); - $this->assertCount( 1, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - ], current( $registered_fields ) ); - - // Check that the metabox did get registered. - global $wp_meta_boxes; - $this->assertArrayHasKey( 'images_options', $wp_meta_boxes['beans_settings']['column']['default'] ); - $this->assertEquals( 'Images options', $wp_meta_boxes['beans_settings']['column']['default']['images_options']['title'] ); - - // Clean up. - unset( $wp_meta_boxes['beans_settings'] ); - } - - /** - * Test _Beans_Image_Options::register() should register the options with normal context when no metaboxes are - * registered. - */ - public function test_should_register_options_with_normal_context_when_no_metaboxes_are_registered() { - $this->go_to_settings_page(); - - $this->assertTrue( ( new _Beans_Image_Options() )->register() ); - - // Check that the right fields did get registered. - $registered_fields = beans_get_fields( 'option', 'images_options' ); - $this->assertCount( 1, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - ], current( $registered_fields ) ); - - // Check that the metabox did get registered. - global $wp_meta_boxes; - $this->assertArrayHasKey( 'images_options', $wp_meta_boxes['beans_settings']['normal']['default'] ); - $this->assertEquals( 'Images options', $wp_meta_boxes['beans_settings']['normal']['default']['images_options']['title'] ); - - // Clean up. - unset( $wp_meta_boxes['beans_settings'] ); - } -} diff --git a/tests/phpunit/integration/api/image/beans-image-options/renderFlushButton.php b/tests/phpunit/integration/api/image/beans-image-options/renderFlushButton.php deleted file mode 100644 index d7bdbc26..00000000 --- a/tests/phpunit/integration/api/image/beans-image-options/renderFlushButton.php +++ /dev/null @@ -1,48 +0,0 @@ -render_flush_button( [ 'id' => 'foo' ] ); - $this->assertEmpty( ob_get_clean() ); - } - - /** - * Test _Beans_Image_Options::render_flush_button() should render when the field is for image options. - */ - public function test_should_render_when_field_is_image_options() { - ob_start(); - ( new _Beans_Image_Options() )->render_flush_button( [ 'id' => 'beans_edited_images_directories' ] ); - $actual = ob_get_clean(); - - $expected = << -EOB; - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } -} diff --git a/tests/phpunit/integration/api/image/beans-image-options/renderSuccessNotice.php b/tests/phpunit/integration/api/image/beans-image-options/renderSuccessNotice.php deleted file mode 100644 index f1a1c7f7..00000000 --- a/tests/phpunit/integration/api/image/beans-image-options/renderSuccessNotice.php +++ /dev/null @@ -1,59 +0,0 @@ -go_to_settings_page(); - $this->assertArrayNotHasKey( 'beans_flush_edited_images', $_POST ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- No need for nonce in this test. - - ob_start(); - ( new _Beans_Image_Options() )->render_success_notice(); - $this->assertEmpty( ob_get_clean() ); - } - - /** - * Test _Beans_Image_Options::render_success_notice() should render when flushing edited images cache. - */ - public function test_should_render_when_flushing_edited_images_cache() { - $this->go_to_settings_page(); - $_POST['beans_flush_edited_images'] = 1; - - ob_start(); - ( new _Beans_Image_Options() )->render_success_notice(); - $actual = ob_get_clean(); - - $expected = << -

                Images flushed successfully!

                - -EOB; - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - - // Clean up. - unset( $_POST['beans_flush_edited_images'] ); - } -} diff --git a/tests/phpunit/integration/api/image/beansEditImage.php b/tests/phpunit/integration/api/image/beansEditImage.php deleted file mode 100644 index a1170064..00000000 --- a/tests/phpunit/integration/api/image/beansEditImage.php +++ /dev/null @@ -1,98 +0,0 @@ -assertFileNotExists( $src ); - $this->assertSame( $src, beans_edit_image( $src, [ 'resize' => [ 800, false ] ] ) ); - } - - /** - * Test beans_edit_image() should return an indexed array with the original src when the image does not exist. - */ - public function test_should_return_indexed_array_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( - [ $src, null, null ], - beans_edit_image( $src, [ 'resize' => [ 800, false ] ], ARRAY_N ) - ); - } - - /** - * Test beans_edit_image() should return an object with the original src when the image does not exist. - */ - public function test_should_return_object_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - - // Run the tests. - $this->assertFileNotExists( $src ); - $image_info = beans_edit_image( $src, [ 'resize' => [ 800, false ] ], OBJECT ); - $this->assertInstanceOf( 'stdClass', $image_info ); - $this->assertSame( $src, $image_info->src ); - $this->assertNull( $image_info->width ); - $this->assertNull( $image_info->height ); - } - - /** - * Test beans_edit_image() should return an associative array with the original src when the image does not exist. - */ - public function test_should_return_associative_array_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( - [ - 'src' => $src, - 'width' => null, - 'height' => null, - ], - beans_edit_image( $src, [ 'resize' => [ 800, false ] ], ARRAY_A ) - ); - } -} diff --git a/tests/phpunit/integration/api/image/beansGetImagesDir.php b/tests/phpunit/integration/api/image/beansGetImagesDir.php deleted file mode 100644 index 45972465..00000000 --- a/tests/phpunit/integration/api/image/beansGetImagesDir.php +++ /dev/null @@ -1,49 +0,0 @@ -assertStringEndsWith( 'uploads/beans/images/', beans_get_images_dir() ); - } - - /** - * Test beans_get_images_dir() should return the filtered images' directory. - */ - public function test_should_return_filtered_images_dir() { - Monkey\Functions\expect( 'test_filter_beans_images_dir' ) - ->once() - ->with( vfsStream::url( 'uploads/beans/images/' ) ) - ->andReturn( 'foo' ); - - add_filter( 'beans_images_dir', 'test_filter_beans_images_dir' ); - - $this->assertSame( 'foo/', beans_get_images_dir() ); - - remove_filter( 'beans_images_dir', 'test_filter_beans_images_dir' ); - } -} diff --git a/tests/phpunit/integration/api/image/fixtures/image1.jpg b/tests/phpunit/integration/api/image/fixtures/image1.jpg deleted file mode 100644 index 598e9db3b4d55c59b616e655be84098ae0c59dd0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 31016 zcmeFYd0dm%x<8uMs87PcTLUi zAPiBEgd`A(7y?AV0f+(tLkIyvKtYBC0wQymZo1Dt=X}mT_w=6g*>`{L=l1#I9g_E5 z&$GVoTI(6t?%?kG13!ci2sdrb%y4+qYuCdAgG^E3VP-McZkhp2&zb@39b;}@Lt%pm z-v$N+hvFRc7C5bX--cdy&_jY@XJI$b2Ze-Qh>Hw@$GLf;;;<;2>w1omZ|!4jW5RBR z1re@&8xwW|hqsM!(EEGiw#w_@em2wl_V14nunu~E{f+ClS71MUdp1Hb(T=_$EIUPs$rc5?X#FXf$s z-ak4O9UW~N4KfXn3^oJW*w~nzH8(RiH&H%ef{(=!uEm((@cRGWf>RJ46&ZSy5E_pA z_O}+V1%^iv9Q5?elpM_d!Q!{e|L7a!-(~pY{09PmAn*qQe<1J&0)HUz|04wc(>e;m zDNUkirR}pT2b}pKB%BbA4++2dEy(mN!1~#{pmo#-1@ns zT`}M`;Pd~WJ<6*+Unq}zzS#T4Z?t#c-oMknef#%+xqtt@0|&nP>cD}o|0{jAXV0F! zU+g`wZ{LAK2M-)PbmXv-jvV>>L;pB^{cm^w^}YYN+m!&m06f^82OR#pEe5#$Tq)~k zyUzhCUw%&f;@3R@6~JdIpM9?K*=`%42k_Z%0`K|kxBmPa?LV;Z%e`MIW&Z55&j6q8 zRUZD6zWD6(J^R1hxA#xVfA;M8e9zv`_kVft@P6e3%0HCdQ`!H`m)`+ZkN(x;nx6Rq zHT83sBYxJm3XCM)f5iGT2yA`c3s3mlojMK8W2oR?a`MV3wJ!yeCoSN&p1ydcqHOc? z&-W?m%l&}A3-nu?Dtq^R^BqvxUc}G$AF1k@U#@*|^xWT`@IUHXfCD4(zr0ijmG!+J zUsU@u3cfoG_`{Y$tC{v}-d|0P_7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z1_*^q0Z#1t%Y}dU(2$a4#$NEXnR(eog=$s^V zd0MHXwIykWxgX`!#TK~sec>>@ybx8BfS)uLdfGnamVNov&l&g!A1TEzK2jY{TH<+s z6Y8~!EvaKDL3cv0^K;pn!|)IXzU{z}j?pgiuB>Bt-Uz2RuIp>{92FMIP^h05)|}1I z=sGi!QFqn$VgXuB2#v1cg#GEc(l)?8)>dh~1{PQ*I`!#VyawOb_okb=xxI8cZ;`fm zJyAqDJxxMEBTRep9~=JFqL_%r9s+6r9*< zPZVXo(fW2T%B!L{s#Fldz-hKc%U$fe=*<>7u32T2nl?>!Pjq=Z%FQj{93&z; zuv8pOFbK8At^A}1%gyB%$1)->Jn}=)ds~HtUn;lH4BxNaS+*N=GOs)*@HxZjN^I5Q zxSU(xuPm%Ch9$HS372IXq~vTiNYe7>J0JegfOkACn;9Jwv_PW&5KzczfmqncLG6GG z$LkVj3>SN{yW2dq^-+hu%grw>l77NV^|HM%-`2FX{Me ztL19vHR7cS3%c4M@UOh*y53@5rdh?JqZPVJry&8ILT#RZ9o7)uWY3nkwsH^pE?-1G zysCDgevkT{hi?(xf;9~boQFu7ddWSqku5{wyuTR7O49YD*(b{c#ioNuI>?Tn@Qm*r=f(Z{8+q&Nf!%p)y>^H;g39xUs>)4*6{%i0q%@hB1kUier_pUzon6cf%_u#d>`=Gyp+?}JuZv@%n?RWLL t$As+x{;odvkgPpI-__?H6SfEVyY+Jq$=W0I-Trou3EKnw|7ZOa{14D277PFY diff --git a/tests/phpunit/integration/api/image/includes/class-base-test-case.php b/tests/phpunit/integration/api/image/includes/class-base-test-case.php deleted file mode 100644 index f569686c..00000000 --- a/tests/phpunit/integration/api/image/includes/class-base-test-case.php +++ /dev/null @@ -1,100 +0,0 @@ -set_up_virtual_filesystem(); - - // Set the Uploads directory to our virtual filesystem. - add_filter( 'upload_dir', function( array $uploads_dir ) { - $virtual_dir = vfsStream::url( 'uploads' ); - $uploads_dir['path'] = $virtual_dir . $uploads_dir['subdir']; - $uploads_dir['basedir'] = $virtual_dir; - - return $uploads_dir; - } ); - } - - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - Mockery::close(); - parent::tearDown(); - } - - /** - * Set up the virtual filesystem. - */ - protected function set_up_virtual_filesystem() { - $this->mock_filesystem = vfsStream::setup( - 'uploads', - 0755, - $this->get_virtual_structure() - ); - $this->images_dir = vfsStream::url( 'uploads/beans/images' ); - } - - /** - * Get the virtual filesystem's structure. - */ - protected function get_virtual_structure() { - return [ - 'beans' => [ - 'images' => [ - 'index.php' => '', - ], - ], - ]; - } - - /** - * Set Development Mode. - * - * @since 1.5.0 - * - * @param bool $is_enabled Optional. When true, turns on development mode. Default is false. - * - * @return void - */ - protected function set_dev_mode( $is_enabled = false ) { - update_option( 'beans_dev_mode', $is_enabled ); - } -} diff --git a/tests/phpunit/integration/api/image/includes/class-image-test-case.php b/tests/phpunit/integration/api/image/includes/class-image-test-case.php deleted file mode 100644 index e68d56e6..00000000 --- a/tests/phpunit/integration/api/image/includes/class-image-test-case.php +++ /dev/null @@ -1,61 +0,0 @@ -returnArg(); - } - - /** - * Initialize the virtual "edited" image. - * - * @since 1.5.0 - * - * @param \ReflectionProperty $rebuilt_path Instance of the editor's "rebuilt path" property. - * @param _Beans_Image_Editor $editor Instance of the editor. - * @param string|null $path Optional. The image's "rebuilt path". - * - * @return string - */ - protected function init_virtual_image( $rebuilt_path, $editor, $path = null ) { - - if ( is_null( $path ) ) { - $path = $rebuilt_path->getValue( $editor ); - } - - $rebuilt_path->setValue( $editor, $path ); - return $rebuilt_path->getValue( $editor ); - } -} diff --git a/tests/phpunit/integration/api/image/includes/class-options-test-case.php b/tests/phpunit/integration/api/image/includes/class-options-test-case.php deleted file mode 100644 index f05f9f8c..00000000 --- a/tests/phpunit/integration/api/image/includes/class-options-test-case.php +++ /dev/null @@ -1,57 +0,0 @@ -assertTrue( is_admin() ); - } -} diff --git a/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php b/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php deleted file mode 100644 index 6f1b44b2..00000000 --- a/tests/phpunit/integration/api/layout/beansGetDefaultLayout.php +++ /dev/null @@ -1,52 +0,0 @@ -assertFalse( beans_has_widget_area( 'sidebar_primary' ) ); - $this->assertSame( 'c', beans_get_default_layout() ); - } - - /** - * Test beans_get_default_layout() should return "c_sp" when there is a primary sidebar. - */ - public function test_should_return_c_sp_when_has_primary_sidebar() { - $this->assertTrue( beans_has_widget_area( 'sidebar_primary' ) ); - $this->assertSame( 'c_sp', beans_get_default_layout() ); - } -} diff --git a/tests/phpunit/integration/api/layout/beansGetLayout.php b/tests/phpunit/integration/api/layout/beansGetLayout.php deleted file mode 100644 index b2c2445b..00000000 --- a/tests/phpunit/integration/api/layout/beansGetLayout.php +++ /dev/null @@ -1,177 +0,0 @@ -post->create(); - - // Run our tests for when the layout is set. - update_post_meta( $post_id, 'beans_layout', 'c_sp_ss' ); - $this->go_to( get_permalink( $post_id ) ); - $this->assertQueryTrue( 'is_singular', 'is_single' ); - $this->assertTrue( is_singular() ); - $this->assertSame( 'c_sp_ss', beans_get_layout() ); - - // Run our tests for when the layout is not set. - delete_post_meta( $post_id, 'beans_layout' ); - $this->go_to( get_permalink( $post_id ) ); - $this->assertSame( 'c_sp', beans_get_layout() ); - - // Run our tests for when the layout is set to fallback to the default. - update_post_meta( $post_id, 'beans_layout', 'default_fallback' ); - $this->go_to( get_permalink( $post_id ) ); - $this->assertSame( 'c_sp', beans_get_layout() ); - } - - /** - * Test beans_get_layout() should return the layout for the static posts page. - */ - public function test_should_return_layout_for_static_posts_page() { - // Configure the Posts Page for our static page. - $posts_page_id = self::factory()->post->create( [ - 'post_type' => 'page', - ] ); - update_option( 'show_on_front', 'page' ); - update_option( 'page_for_posts', $posts_page_id ); - - // Run our tests for when the layout is set. - update_post_meta( $posts_page_id, 'beans_layout', 'ss_c' ); - $this->go_to( get_permalink( $posts_page_id ) ); - $this->assertQueryTrue( 'is_home', 'is_posts_page' ); - $this->assertTrue( is_home() ); - $this->assertSame( 'ss_c', beans_get_layout() ); - - // Run our tests for when the layout is not set. - delete_post_meta( $posts_page_id, 'beans_layout' ); - $this->go_to( get_permalink( $posts_page_id ) ); - $this->assertSame( 'c_sp', beans_get_layout() ); - - // Run our tests for when the layout is set to fallback to the default. - update_post_meta( $posts_page_id, 'beans_layout', 'default_fallback' ); - $this->go_to( get_permalink( $posts_page_id ) ); - $this->assertSame( 'c_sp', beans_get_layout() ); - } - - /** - * Test beans_get_layout() should return the theme's default layout when a the static page is not configured for - * the Posts Page. - */ - public function test_should_return_default_layout_when_no_static_posts_page() { - // Run our tests without changing the default. - $this->go_to( get_permalink( '/' ) ); - $this->assertQueryTrue( 'is_home', 'is_front_page' ); - $this->assertTrue( is_home() ); - $this->assertSame( 'c_sp', beans_get_layout() ); - - // Run our tests when the theme's mod is set. - set_theme_mod( 'beans_layout', 'sp_ss_c' ); - $this->go_to( get_permalink( '/' ) ); - $this->assertSame( 'sp_ss_c', beans_get_layout() ); - } - - /** - * Test beans_get_layout() should return layout for a category. - */ - public function test_should_return_layout_for_category() { - $post_id = self::factory()->post->create(); - $category_id = self::factory()->category->create( [ 'slug' => 'test-cat' ] ); - wp_set_object_terms( $post_id, $category_id, 'category' ); - $meta_key = "beans_term_{$category_id}_beans_layout"; - - // Run our tests for when the layout is not set. - $this->go_to( "/?cat={$category_id}" ); - $this->assertQueryTrue( 'is_category', 'is_archive' ); - $this->assertTrue( is_category() ); - $this->assertSame( 'c_sp', beans_get_layout() ); - - // Run our tests for when the layout is set. - update_option( $meta_key, 'sp_c' ); - $this->go_to( "/?cat={$category_id}" ); - $this->assertSame( 'sp_c', beans_get_layout() ); - - // Run our tests for when the layout is set to fallback to the default. - update_option( $meta_key, 'default_fallback' ); - $this->go_to( "/?cat={$category_id}" ); - $this->assertSame( 'c_sp', beans_get_layout() ); - } - - /** - * Test beans_get_layout() should return layout for a tag. - */ - public function test_should_return_layout_for_tag() { - $post_id = self::factory()->post->create(); - $tag_id = self::factory()->tag->create( [ 'slug' => 'test-tag' ] ); - wp_set_object_terms( $post_id, $tag_id, 'post_tag' ); - $meta_key = "beans_term_{$tag_id}_beans_layout"; - - // Run our tests for when the layout is not set. - $this->go_to( '/?tag=test-tag' ); - $this->assertQueryTrue( 'is_tag', 'is_archive' ); - $this->assertTrue( is_tag() ); - $this->assertSame( 'c_sp', beans_get_layout() ); - - // Run our tests for when the layout is set. - update_option( $meta_key, 'sp_c' ); - $this->go_to( '/?tag=test-tag' ); - $this->assertSame( 'sp_c', beans_get_layout() ); - - // Run our tests for when the layout is set to fallback to the default. - update_option( $meta_key, 'default_fallback' ); - $this->go_to( '/?tag=test-tag' ); - $this->assertSame( 'c_sp', beans_get_layout() ); - } - - /** - * Test beans_get_layout() should return layout for a custom taxonomy. - */ - public function test_should_return_layout_for_custom_tax() { - register_taxonomy( 'test_tax', 'post', [ 'public' => true ] ); - $post_id = self::factory()->post->create(); - $term_id = self::factory()->term->create( [ - 'taxonomy' => 'test_tax', - 'slug' => 'custom-term', - ] ); - wp_set_object_terms( $post_id, $term_id, 'test_tax' ); - $meta_key = "beans_term_{$term_id}_beans_layout"; - - // Run our tests for when the layout is not set. - $this->go_to( '/?test_tax=custom-term' ); - $this->assertQueryTrue( 'is_tax', 'is_archive' ); - $this->assertTrue( is_tax() ); - $this->assertSame( 'c_sp', beans_get_layout() ); - - // Run our tests for when the layout is set. - update_option( $meta_key, 'sp_c' ); - $this->go_to( '/?test_tax=custom-term' ); - $this->assertSame( 'sp_c', beans_get_layout() ); - - // Run our tests for when the layout is set to fallback to the default. - update_option( $meta_key, 'default_fallback' ); - $this->go_to( '/?test_tax=custom-term' ); - $this->assertSame( 'c_sp', beans_get_layout() ); - - // Clean up. - _unregister_taxonomy( 'test_tax' ); - } -} diff --git a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php b/tests/phpunit/integration/api/layout/beansGetLayoutClass.php deleted file mode 100644 index f253ee08..00000000 --- a/tests/phpunit/integration/api/layout/beansGetLayoutClass.php +++ /dev/null @@ -1,382 +0,0 @@ -post_id = self::factory()->post->create(); - } - - /** - * Cleans up the test environment after each test. - */ - public function tearDown() { - - // Reset the Beans' sidebars. - beans_do_register_widget_areas(); - - parent::tearDown(); - } - - /** - * Run the tests for the given set of test parameters. - * - * @since 1.5.0 - * - * @param array $test_parameters Array of test parameters. - * @param string $layout_id The layout's ID for this test. - * - * @return void - */ - protected function run_the_tests( array $test_parameters, $layout_id ) { - // Go to the post's web page, i.e. to set up is_singular(). - update_post_meta( $this->post_id, 'beans_layout', $layout_id ); - $this->go_to( get_permalink( $this->post_id ) ); - $this->assertTrue( is_singular() ); - - foreach ( $test_parameters as $parameters ) { - - // Unregister the sidebar primary. - if ( ! $parameters['sidebar_primary'] ) { - unregister_sidebar( 'sidebar_primary' ); - } - - // Unregister the sidebar secondary. - if ( ! $parameters['sidebar_secondary'] ) { - unregister_sidebar( 'sidebar_secondary' ); - } - - foreach ( $parameters['expected'] as $id => $expected ) { - $this->assertSame( $expected, beans_get_layout_class( $id ) ); - } - - // Reset the sidebars. - beans_do_register_widget_areas(); - } - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "c". - */ - public function test_should_return_classes_when_layout_is_c() { - $test_parameters = [ - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ], - ]; - - $this->run_the_tests( $test_parameters, 'c' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "c_sp". - */ - public function test_should_return_classes_when_layout_is_c_sp() { - $test_parameters = [ - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-3-4', - 'sidebar_primary' => 'uk-width-medium-1-4', - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-3-4', - 'sidebar_primary' => 'uk-width-medium-1-4', - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ], - ]; - - $this->run_the_tests( $test_parameters, 'c_sp' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "sp_c". - */ - public function test_should_return_classes_when_layout_is_sp_c() { - $test_parameters = [ - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ], - ]; - - $this->run_the_tests( $test_parameters, 'sp_c' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "c_ss". - */ - public function test_should_return_classes_when_layout_is_c_ss() { - $test_parameters = [ - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-3-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => 'uk-width-medium-1-4', - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ], - ]; - - $this->run_the_tests( $test_parameters, 'c_ss' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "c_sp_ss". - */ - public function test_should_return_classes_when_layout_is_c_sp_ss() { - $test_parameters = [ - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-3-4', - 'sidebar_primary' => 'uk-width-medium-1-4', - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-2-4', - 'sidebar_primary' => 'uk-width-medium-1-4', - 'sidebar_secondary' => 'uk-width-medium-1-4', - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ], - ]; - - $this->run_the_tests( $test_parameters, 'c_sp_ss' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "ss_c". - */ - public function test_should_return_classes_when_layout_is_ss_c() { - $test_parameters = [ - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-3-4', - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ], - ]; - - $this->run_the_tests( $test_parameters, 'ss_c' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "sp_ss_c". - */ - public function test_should_return_classes_when_layout_is_sp_ss_c() { - $test_parameters = [ - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-2-4 uk-push-2-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', - 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-2-4', - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ], - ]; - - $this->run_the_tests( $test_parameters, 'sp_ss_c' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "sp_c_ss". - */ - public function test_should_return_classes_when_layout_is_sp_c_ss() { - $test_parameters = [ - [ - 'expected' => [ - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', - 'sidebar_secondary' => null, - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ], - [ - 'expected' => [ - 'content' => 'uk-width-medium-2-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', - 'sidebar_secondary' => 'uk-width-medium-1-4', - ], - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ], - ]; - - $this->run_the_tests( $test_parameters, 'sp_c_ss' ); - } -} diff --git a/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php b/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php deleted file mode 100644 index c09b8180..00000000 --- a/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php +++ /dev/null @@ -1,79 +0,0 @@ -assertEquals( beans_get_layout(), 'c' ); - - $this->assertFalse( beans_has_primary_sidebar( 'c' ) ); - } - - /** - * Test beans_has_primary_sidebar() should return false when the layout is content-secondary sidebar. - */ - public function test_should_return_false_when_content_sidebar_secondary_layout() { - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_ss'; - }); - - $this->assertEquals( beans_get_layout(), 'c_ss' ); - - $this->assertFalse( beans_has_primary_sidebar( 'c_ss' ) ); - } - - /** - * Test beans_has_primary_sidebar() should return false when the layout is content-primary sidebar without an active widget. - */ - public function test_should_return_false_when_content_primary_sidebar_layout_without_active_widget() { - Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp'; - }); - - $this->assertEquals( beans_get_layout(), 'c_sp' ); - - $this->assertFalse( beans_has_primary_sidebar( 'c_sp' ) ); - } - - /** - * Test beans_has_primary_sidebar() should return true when the layout is content-primary sidebar with an active widget. - */ - public function test_should_return_true_when_content_primary_sidebar_layout_with_active_widget() { - Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp'; - }); - - $this->assertEquals( beans_get_layout(), 'c_sp' ); - - $this->assertTrue( beans_has_primary_sidebar( 'c_sp' ) ); - } -} diff --git a/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php b/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php deleted file mode 100644 index 53573b55..00000000 --- a/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php +++ /dev/null @@ -1,78 +0,0 @@ -assertEquals( beans_get_layout(), 'c' ); - - $this->assertFalse( beans_has_secondary_sidebar( 'c' ) ); - } - - /** - * Test beans_has_secondary_sidebar() should return false when the layout is content-primary sidebar. - */ - public function test_should_return_false_when_content_primary_sidebar_layout() { - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp'; - }); - - $this->assertEquals( beans_get_layout(), 'c_sp' ); - - $this->assertFalse( beans_has_secondary_sidebar( 'c_sp' ) ); - } - - /** - * Test beans_has_secondary_sidebar() should return false when the layout is content-secondary sidebar without an active widget. - */ - public function test_should_return_false_when_content_secondary_sidebar_layout_without_active_widget() { - Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_ss'; - }); - - $this->assertEquals( beans_get_layout(), 'c_ss' ); - - $this->assertFalse( beans_has_secondary_sidebar( 'c_ss' ) ); - } - - /** - * Test beans_has_secondary_sidebar() should return true when the layout is content-secondary sidebar with an active widget. - */ - public function test_should_return_true_when_content_secondary_sidebar_layout_with_active_widget() { - Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); - - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_ss'; - }); - - $this->assertEquals( beans_get_layout(), 'c_ss' ); - - $this->assertTrue( beans_has_secondary_sidebar( 'c_ss' ) ); - } -} diff --git a/tests/phpunit/integration/api/options/beans-options/processActions.php b/tests/phpunit/integration/api/options/beans-options/processActions.php deleted file mode 100644 index 23a12c6c..00000000 --- a/tests/phpunit/integration/api/options/beans-options/processActions.php +++ /dev/null @@ -1,200 +0,0 @@ -assertArrayNotHasKey( 'beans_save_options', $_POST ); - $this->assertArrayNotHasKey( 'beans_reset_options', $_POST ); - $this->assertNull( $instance->process_actions() ); - $this->assertFalse( has_action( 'admin_notices', [ $instance, 'render_save_notice' ] ) ); - $this->assertFalse( has_action( 'admin_notices', [ $instance, 'render_reset_notice' ] ) ); - } - - /** - * Test _Beans_Options::process_actions() should not save options when the nonce fails. - */ - public function test_should_not_save_options_when_nonce_fails() { - $_POST['beans_save_options'] = 1; - $test_data = [ - 'beans_compile_all_styles' => 1, - 'beans_compile_all_scripts' => 1, - 'beans_dev_mode' => 1, - ]; - $_POST['beans_fields'] = $test_data; - $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); - $instance = new _Beans_Options(); - - // Check with no nonce. - $instance->process_actions(); - $this->assertFalse( $success_property->getValue( $instance ) ); - - foreach ( $test_data as $option ) { - // Check that the value was not saved. - $this->assertNull( get_option( $option, null ) ); - } - - // Check with an invalid nonce. - $_POST['beans_options_nonce'] = 'invalid-nonce'; - - $instance->process_actions(); - $this->assertFalse( $success_property->getValue( $instance ) ); - - foreach ( $test_data as $option ) { - // Check that the value was not saved. - $this->assertNull( get_option( $option, null ) ); - } - } - - /** - * Test _Beans_Options::process_actions() should save the field values when a save action is passed. - */ - public function test_should_save_field_values_when_save_action() { - // Set up the test. - $nonce = wp_create_nonce( 'beans_options_nonce' ); - $_POST['beans_options_nonce'] = $nonce; - $_POST['beans_save_options'] = 1; - $test_data = [ - 'beans_compile_all_styles' => 1, - 'beans_compile_all_scripts' => 1, - 'beans_dev_mode' => 1, - ]; - $_POST['beans_fields'] = $test_data; - - $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); - $instance = new _Beans_Options(); - $instance->process_actions(); - - // Check that the success property was set. - $this->assertTrue( $success_property->getValue( $instance ) ); - - // Check the save. - $this->assertArrayHasKey( 'beans_save_options', $_POST ); - $this->assertEquals( 10, has_action( 'admin_notices', [ $instance, 'render_save_notice' ] ) ); - - // Check the reset. - $this->assertArrayNotHasKey( 'beans_reset_options', $_POST ); - $this->assertFalse( has_action( 'admin_notices', [ $instance, 'render_reset_notice' ] ) ); - - foreach ( $test_data as $option => $value ) { - // Check that the value was saved. - $this->assertEquals( $value, get_option( $option ) ); - - // Clean up. - delete_option( $option ); - } - } - - /** - * Test _Beans_Options::process_actions() should not reset options when the nonce fails. - */ - public function test_should_not_reset_options_when_nonce_fails() { - $_POST['beans_reset_options'] = 1; - $test_data = [ - 'beans_compile_all_styles' => 1, - 'beans_compile_all_scripts' => 1, - 'beans_dev_mode' => 1, - ]; - - // Add the options. - foreach ( $test_data as $option => $value ) { - add_option( $option, $value ); - } - - $_POST['beans_fields'] = $test_data; - $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); - $instance = new _Beans_Options(); - - // Check with no nonce. - $instance->process_actions(); - $this->assertFalse( $success_property->getValue( $instance ) ); - - foreach ( $test_data as $option => $value ) { - // Check that the value was not reset. - $this->assertEquals( $value, get_option( $option ) ); - } - - // Check with an invalid nonce. - $_POST['beans_options_nonce'] = 'invalid-nonce'; - - $instance->process_actions(); - $this->assertFalse( $success_property->getValue( $instance ) ); - - foreach ( $test_data as $option => $value ) { - // Check that the value was not reset. - $this->assertEquals( $value, get_option( $option ) ); - - // Clean up. - delete_option( $option ); - } - } - - /** - * Test _Beans_Options::process_actions() should delete the options when it's a reset action. - */ - public function test_should_delete_options_when_reset_action() { - // Set up the test. - $nonce = wp_create_nonce( 'beans_options_nonce' ); - $_POST['beans_options_nonce'] = $nonce; - $_POST['beans_reset_options'] = 1; - $test_data = [ - 'beans_compile_all_styles' => 1, - 'beans_compile_all_scripts' => 1, - 'beans_dev_mode' => 1, - ]; - $_POST['beans_fields'] = $test_data; - - // Add the options. - foreach ( $test_data as $option => $value ) { - add_option( $option, $value ); - } - - $success_property = $this->get_reflective_property( 'success', '_Beans_Options' ); - $instance = new _Beans_Options(); - $instance->process_actions(); - - // Check that the success property was set. - $this->assertTrue( $success_property->getValue( $instance ) ); - - // Check the reset. - $this->assertArrayHasKey( 'beans_options_nonce', $_POST ); - $this->assertEquals( 10, has_action( 'admin_notices', [ $instance, 'render_reset_notice' ] ) ); - - // Check the save. - $this->assertArrayNotHasKey( 'beans_save_options', $_POST ); - $this->assertFalse( has_action( 'admin_notices', [ $instance, 'render_save_notice' ] ) ); - - // Check that the option was deleted. - foreach ( $test_data as $option ) { - $this->assertNull( get_option( $option, null ) ); - } - } -} diff --git a/tests/phpunit/integration/api/options/beans-options/register.php b/tests/phpunit/integration/api/options/beans-options/register.php deleted file mode 100644 index c4750de1..00000000 --- a/tests/phpunit/integration/api/options/beans-options/register.php +++ /dev/null @@ -1,72 +0,0 @@ -register( $options['section'], $options['args'] ); - - // Check that the callback is registered to the hook. - $this->assertEquals( 10, has_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ) ); - - // Clean up. - remove_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ); - } - } - - /** - * Test _Beans_Options::register() should register the metabox with WordPress. - */ - public function test_should_register_metabox_with_wp() { - $instance = new _Beans_Options(); - $this->go_to_settings_page(); - - foreach ( static::$test_data as $option ) { - // Register the option. - $instance->register( $option['section'], $option['args'] ); - - // Check that the metabox is registered with WordPress. - global $wp_meta_boxes; - $this->assertArrayHasKey( 'themesphppagebeans_settings', $wp_meta_boxes ); - $this->assertArrayHasKey( $option['args']['context'], $wp_meta_boxes['themesphppagebeans_settings'] ); - $this->assertArrayHasKey( 'default', $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ] ); - $this->assertArrayHasKey( $option['section'], $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'] ); - $this->assertSame( [ - 'id' => $option['section'], - 'title' => $option['args']['title'], - 'callback' => [ $instance, 'render_metabox' ], - 'args' => null, - ], $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); - - // Clean up. - remove_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ); - } - } -} diff --git a/tests/phpunit/integration/api/options/beans-options/renderMetabox.php b/tests/phpunit/integration/api/options/beans-options/renderMetabox.php deleted file mode 100644 index 6bd41c49..00000000 --- a/tests/phpunit/integration/api/options/beans-options/renderMetabox.php +++ /dev/null @@ -1,77 +0,0 @@ -register( $option['section'], $option['args'] ); - - // Run the test. - $this->assertNull( $instance->render_metabox() ); - } - } - - /** - * Test _Beans_Options::render_metabox() should render the registered fields. - */ - public function test_should_render_registered_fields() { - $instance = new _Beans_Options(); - - // Register the field and option. - $option = end( static::$test_data ); - beans_register_fields( $option['fields'], 'option', $option['section'] ); - beans_add_smart_action( 'beans_field_wrap_prepend_markup', 'beans_field_label' ); - beans_add_smart_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); - beans_add_smart_action( 'beans_field_checkbox', 'beans_field_checkbox' ); - $instance->register( $option['section'], $option['args'] ); - - // Run the method and grab the HTML out of the buffer. - ob_start(); - $instance->render_metabox(); - $html = ob_get_clean(); - - // Run the tests. - $this->assertFileExists( BEANS_THEME_DIR . '/lib/api/fields/types/checkbox.php' ); - $expected = << -

                -
                - - - Enable development mode -
                -
                -
                This option should be enabled while your website is in development.
                - -EOB; - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/integration/api/options/beans-options/renderPage.php b/tests/phpunit/integration/api/options/beans-options/renderPage.php deleted file mode 100644 index dba86a35..00000000 --- a/tests/phpunit/integration/api/options/beans-options/renderPage.php +++ /dev/null @@ -1,164 +0,0 @@ -assertNull( ( new _Beans_Options() )->render_page( 'beans_settings' ) ); - } - - /** - * Test _Beans_Options::render_page() should render the form when "normal" context is configured. - */ - public function test_should_render_form_when_context_normal() { - $instance = new _Beans_Options(); - $this->go_to_settings_page(); - - // Register the first option. - $option = current( static::$test_data ); - $instance->register( $option['section'], $option['args'] ); - - // Run the method and grab the HTML out of the buffer. - ob_start(); - ( new _Beans_Options() )->render_page( 'themesphppagebeans_settings' ); - $html = ob_get_clean(); - $html = $this->prepare_html( $html ); - - // Run the tests. Exclude checking for the nonce fields. - $expected = << -EOB; - $this->assertContains( $this->format_the_html( $expected ), $html ); - - $expected = << -
                -
                - -

                Compiler options

                -
                -
                -
                - -

                - - -

                - -EOB; - $this->assertContains( $this->format_the_html( $expected ), $html ); - } - - /** - * Test _Beans_Options::render_page() should render the form when "column" context is configured. - */ - public function test_should_render_form_when_column_context() { - $instance = new _Beans_Options(); - $this->go_to_settings_page(); - - // Register the options. - foreach ( static::$test_data as $option ) { - $instance->register( $option['section'], $option['args'] ); - } - - global $wp_meta_boxes; - $this->assertArrayHasKey( 'themesphppagebeans_settings', $wp_meta_boxes ); - - // Run the method and grab the HTML out of the buffer. - ob_start(); - ( new _Beans_Options() )->render_page( 'themesphppagebeans_settings' ); - $html = ob_get_clean(); - $html = $this->prepare_html( $html ); - - // Run the tests. - $expected = << -EOB; - $this->assertContains( $this->format_the_html( $expected ), $html ); - - $expected = << -
                -
                - -

                Compiler options

                -
                -
                -
                -
                -
                - -

                Images options

                -
                -
                -
                - -

                Mode options

                -
                -
                -
                - -

                - - -

                - -EOB; - $this->assertContains( $this->format_the_html( $expected ), $html ); - } - - /** - * Prepares the HTML by: - * 1. formatting it - * 2. Converting each instance of class='hndle' to class="hndle" - * - * @param string $html The given HTML to prepare. - * - * @return string - */ - protected function prepare_html( $html ) { - $html = $this->format_the_html( $html ); - - if ( strpos( $html, "class='hndle'>" ) === false ) { - return $html; - } - - return str_replace( "class='hndle'>", 'class="hndle">', $html ); - } -} diff --git a/tests/phpunit/integration/api/options/fixtures/test-options.php b/tests/phpunit/integration/api/options/fixtures/test-options.php deleted file mode 100644 index 0549be3a..00000000 --- a/tests/phpunit/integration/api/options/fixtures/test-options.php +++ /dev/null @@ -1,91 +0,0 @@ - [ - [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - 'description' => 'Clear CSS and Javascript cached files. New cached versions will be compiled on page load.', - ], - [ - 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - 'description' => 'Compile and cache all the CSS files that have been enqueued to the WordPress head.', - ], - [ - 'id' => 'beans_compile_all_scripts_group', - 'label' => 'Compile all WordPress scripts', - 'type' => 'group', - 'fields' => [ - [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ], - [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - ], - ], - 'description' => 'Compile and cache all the Javascript files that have been enqueued to the WordPress head.JavaSript is outputted in the footer if the level is set to Aggressive and might conflict with some third party plugins which are not following WordPress standards.', - ], - ], - 'menu_slug' => 'beans_settings', - 'section' => 'compiler_options', - 'args' => [ - 'title' => 'Compiler options', - 'context' => 'normal', - ], - ], - // Images Options. - [ - 'fields' => [ - [ - 'id' => 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - 'description' => 'Clear all edited images. New images will be created on page load.', - ], - ], - 'menu_slug' => 'beans_settings', - 'section' => 'images_options', - 'args' => [ - 'title' => 'Images options', - 'context' => 'column', - ], - ], - // Mode Options. - [ - 'fields' => [ - [ - 'id' => 'beans_dev_mode', - 'checkbox_label' => 'Enable development mode', - 'type' => 'checkbox', - 'description' => 'This option should be enabled while your website is in development.', - ], - ], - 'menu_slug' => 'beans_settings', - 'section' => 'mode_options', - 'args' => [ - 'title' => 'Mode options', - 'context' => 'column', - ], - ], -]; diff --git a/tests/phpunit/integration/api/options/includes/class-options-test-case.php b/tests/phpunit/integration/api/options/includes/class-options-test-case.php deleted file mode 100644 index 6597f242..00000000 --- a/tests/phpunit/integration/api/options/includes/class-options-test-case.php +++ /dev/null @@ -1,70 +0,0 @@ -clean_up_global_scope(); - - global $wp_meta_boxes; - $wp_meta_boxes = []; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. - - parent::tearDown(); - } - - /** - * Go to the Settings Page. - */ - protected function go_to_settings_page() { - set_current_screen( 'themes.php?page=beans_settings' ); - - $this->assertTrue( is_admin() ); - } -} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php deleted file mode 100644 index c3bdd841..00000000 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/construct.php +++ /dev/null @@ -1,47 +0,0 @@ - 'Post Options' ] ); - - $this->assertEquals( 10, has_action( 'edit_form_top', [ $post_meta, 'render_nonce' ] ) ); - $this->assertEquals( 10, has_action( 'save_post', [ $post_meta, 'save' ] ) ); - $this->assertEquals( 10, has_filter( 'attachment_fields_to_save', [ $post_meta, 'save_attachment' ] ) ); - $this->assertEquals( 10, has_action( 'add_meta_boxes', [ $post_meta, 'register_metabox' ] ) ); - - // Subsequent instantiation sets 'add_meta_boxes' hook only. - $post_meta_2 = new _Beans_Post_Meta( 'tm-beans-custom-post-meta', [ 'title' => 'Custom Options' ] ); - - $this->assertFalse( has_action( 'edit_form_top', [ $post_meta_2, 'render_nonce' ] ) ); - $this->assertFalse( has_action( 'save_post', [ $post_meta_2, 'save' ] ) ); - $this->assertFalse( has_filter( 'attachment_fields_to_save', [ $post_meta_2, 'save_attachment' ] ) ); - $this->assertEquals( 10, has_action( 'add_meta_boxes', [ $post_meta_2, 'register_metabox' ] ) ); - } -} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php deleted file mode 100644 index 9fb3850a..00000000 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/okToSave.php +++ /dev/null @@ -1,87 +0,0 @@ - 'Post Options' ] ); - $post_id = $this->factory()->post->create(); - - $this->assertFalse( $post_meta->ok_to_save( $post_id, [ [ 'id' => 'beans_test_slider' ] ] ) ); - } - - /** - * Test _Beans_Post_Meta::ok_to_save() should return false when `edit_post` user permissions are not met. - */ - public function test_ok_to_save_should_return_false_when_user_permissions_not_met() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - $post_id = $this->factory()->post->create(); - - // Run without permission to save. - $user_id = $this->factory()->user->create( [ 'role' => 'subscriber' ] ); - wp_set_current_user( $user_id ); - - // Set a nonce to return. - $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); - - $this->assertFalse( $post_meta->ok_to_save( $post_id, [ [ 'id' => 'beans_test_slider' ] ] ) ); - } - - /** - * Test _Beans_Post_Meta::ok_to_save() should return false when post meta has no fields. - */ - public function test_ok_to_save_should_return_false_when_no_fields() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - $post_id = $this->factory()->post->create(); - - // Run with permission to save. - $user_id = $this->factory()->user->create( [ 'role' => 'administrator' ] ); - wp_set_current_user( $user_id ); - - // Set a nonce to return. - $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); - - $this->assertFalse( $post_meta->ok_to_save( $post_id, [] ) ); - } - - /** - * Test _Beans_Post_Meta::ok_to_save() should return true when all conditions for saving are met. - */ - public function test_ok_to_save_should_return_true_when_all_conditions_met() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - $post_id = $this->factory()->post->create(); - - // Run with permission to save. - $user_id = $this->factory()->user->create( [ 'role' => 'administrator' ] ); - wp_set_current_user( $user_id ); - - // Set a nonce to return. - $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); - - $this->assertTrue( $post_meta->ok_to_save( $post_id, [ [ 'id' => 'beans_test_slider' ] ] ) ); - } -} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php deleted file mode 100644 index aa88ddf9..00000000 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/registerMetabox.php +++ /dev/null @@ -1,38 +0,0 @@ - 'Post Options' ] ); - $post_meta->register_metabox( 'post' ); - - $this->assertArrayHasKey( 'tm-beans', $wp_meta_boxes['post']['normal']['high'] ); - } -} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php deleted file mode 100644 index 8fa28f03..00000000 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderMetaboxContent.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Post Options' ] ); - - beans_register_fields( $test_data['fields'], 'post_meta', $test_data['section'] ); - - $post_id = $this->factory()->post->create(); - - ob_start(); - $post_meta->render_metabox_content( $post_id ); - $output = ob_get_clean(); - - $this->assertContains( 'bs-radio', $output ); - $this->assertContains( 'bs-checkbox', $output ); - $this->assertContains( 'bs-text', $output ); - } -} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php deleted file mode 100644 index 841ead48..00000000 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/renderNonce.php +++ /dev/null @@ -1,41 +0,0 @@ - 'Post Options' ] ); - - $expected_html_output = ''; - - ob_start(); - $post_meta->render_nonce(); - $actual_output = ob_get_clean(); - - $this->assertStringMatchesFormat( $expected_html_output, $actual_output ); - } -} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php deleted file mode 100644 index 09793104..00000000 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/save.php +++ /dev/null @@ -1,55 +0,0 @@ - 'Post Options' ] ); - $post_id = $this->factory()->post->create(); - - $this->assertEquals( $post_id, $post_meta->save( $post_id ) ); - } - - /** - * Test _Beans_Post_Meta::save() should run update_post_meta() and return null when ok_to_save() is true. - */ - public function test_should_run_update_post_meta_and_return_null_when_ok_to_save() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - $post_id = $this->factory()->post->create(); - - // Run with permission to save. - $user_id = $this->factory()->user->create( [ 'role' => 'administrator' ] ); - wp_set_current_user( $user_id ); - - // Give beans_post() a field to find and set a nonce to return. - $_POST['beans_fields'] = [ 'beans_post_test_field' => 'beans_post_test_field_value' ]; - $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); - - $this->assertnull( $post_meta->save( $post_id ) ); - $this->assertEquals( 'beans_post_test_field_value', get_post_meta( $post_id, 'beans_post_test_field', true ) ); - } -} diff --git a/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php b/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php deleted file mode 100644 index bdf9ce08..00000000 --- a/tests/phpunit/integration/api/post-meta/beans-post-meta/saveAttachment.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Post Options' ] ); - $attachment_id = $this->factory()->attachment->create(); - $attachment_data = get_post( $attachment_id, ARRAY_A ); - - // Run with permission to save. - $user_id = $this->factory()->user->create( [ 'role' => 'administrator' ] ); - wp_set_current_user( $user_id ); - - // Give beans_post() a field to find and set a nonce to return. - $_POST['beans_fields'] = [ 'beans_post_test_field' => 'beans_post_test_field_value' ]; - $_POST['beans_post_meta_nonce'] = wp_create_nonce( 'beans_post_meta_nonce' ); - - $this->assertSame( $attachment_data, $post_meta->save_attachment( $attachment_data ) ); - $this->assertEquals( 'beans_post_test_field_value', get_post_meta( $attachment_id, 'beans_post_test_field', true ) ); - } -} diff --git a/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php b/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php deleted file mode 100644 index 6b72eebc..00000000 --- a/tests/phpunit/integration/api/post-meta/beansGetPostMeta.php +++ /dev/null @@ -1,75 +0,0 @@ -assertFalse( beans_get_post_meta( 'beans_layout' ) ); - $this->assertSame( 'default_fallback', beans_get_post_meta( 'beans_layout', 'default_fallback' ) ); - } - - /** - * Test beans_get_post_meta() should return the default when the post meta does not exist. - */ - public function test_should_return_default_when_post_meta_does_not_exist() { - $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); - update_post_meta( $post_id, 'foo', 'foo' ); - - $this->assertFalse( beans_get_post_meta( 'beans_layout', false, $post_id ) ); - $this->assertSame( '', beans_get_post_meta( 'beans_layout', '', $post_id ) ); - $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c', $post_id ) ); - } - - /** - * Test beans_get_post_meta() should get the post ID when none is provided. - */ - public function test_should_get_post_id_when_none_is_provided() { - $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); - $_GET['post'] = $post_id; - $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); - unset( $_GET['post'] ); - - $this->go_to( get_permalink( $post_id ) ); - $this->assertSame( 'c_sp', beans_get_post_meta( 'beans_layout', 'c_sp' ) ); - } - - /** - * Test beans_get_post_meta() should return the post's meta value when all conditions are met. - */ - public function test_should_return_post_meta_value() { - $post_id = self::factory()->post->create( [ 'post_title' => 'Hello Beans' ] ); - update_post_meta( $post_id, 'beans_layout', 'c_sp' ); - $this->assertSame( 'c_sp', beans_get_post_meta( 'beans_layout', false, $post_id ) ); - - $_GET['post'] = $post_id; - update_post_meta( $post_id, 'beans_layout', 'default_fallback' ); - $this->assertSame( 'default_fallback', beans_get_post_meta( 'beans_layout', 'c' ) ); - unset( $_GET['post'] ); - - update_post_meta( $post_id, 'beans_layout', 'sp_c' ); - $this->go_to( get_permalink( $post_id ) ); - $this->assertSame( 'sp_c', beans_get_post_meta( 'beans_layout' ) ); - } -} diff --git a/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php b/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php deleted file mode 100644 index 63c29dce..00000000 --- a/tests/phpunit/integration/api/post-meta/beansIsPostMetaConditions.php +++ /dev/null @@ -1,166 +0,0 @@ -assertTrue( _beans_is_post_meta_conditions( true ) ); - } - - /** - * Test _beans_is_post_meta_conditions() should return true when it's a new post and $conditions include 'post'. - */ - public function test_should_return_true_when_new_post_and_conditions_include_post() { - set_current_screen( 'post' ); - $_SERVER['REQUEST_URI'] = 'post-new.php'; - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'post' ] ) ); - - // Clean up server globals. - $_SERVER['REQUEST_URI'] = ''; - } - - /** - * Test _beans_is_post_meta_conditions() should return false when it's a new post and $conditions don't include 'post'. - */ - public function test_should_return_false_when_new_post_and_conditions_do_not_include_post() { - set_current_screen( 'post' ); - $_SERVER['REQUEST_URI'] = 'post-new.php'; - - $this->assertFalse( _beans_is_post_meta_conditions( [ 'page' ] ) ); - - // Clean up server globals. - $_SERVER['REQUEST_URI'] = ''; - } - - /** - * Test _beans_is_post_meta_conditions() should return false when post_ID can't be found. - */ - public function test_should_return_false_when_post_id_not_found() { - set_current_screen( 'edit' ); - - $this->assertFalse( _beans_is_post_meta_conditions( [ 'post' ] ) ); - } - - /** - * Test _beans_is_post_meta_conditions() should return true when $conditions match post type. - */ - public function test_should_return_true_when_conditions_match_post_type() { - $post_id = $this->factory()->post->create( [ 'post_type' => 'cpt' ] ); - set_current_screen( 'cpt' ); - - // Setup for when post_ID is in GET. - $_GET['post'] = $post_id; - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'cpt' ] ) ); - - // Clear Global GET. - $_GET['post'] = null; - - // Setup for when post_ID is in POST. - $_POST['post_ID'] = $post_id; - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'cpt' ] ) ); - - // Clear Global POST. - $_POST['post_ID'] = null; - } - - /** - * Test _beans_is_post_meta_conditions() should return true when conditions match post_ID. - */ - public function test_should_return_true_when_conditions_match_post_id() { - $post_id = $this->factory()->post->create(); - set_current_screen( 'edit' ); - - // Setup for when post_ID is in GET. - $_GET['post'] = $post_id; - - $this->assertTrue( _beans_is_post_meta_conditions( [ $post_id ] ) ); - - // Clear Global GET. - $_GET['post'] = null; - - // Setup for when post_ID is in POST. - $_POST['post_ID'] = $post_id; - - $this->assertTrue( _beans_is_post_meta_conditions( [ $post_id ] ) ); - - // Clear Global POST. - $_POST['post_ID'] = null; - } - - /** - * Test _beans_is_post_meta_conditions() should return true when conditions match a page template name. - */ - public function test_should_return_true_when_conditions_match_page_template_name() { - $page_id = $this->factory()->post->create( [ 'post_type' => 'page' ] ); - set_current_screen( 'edit' ); - add_post_meta( $page_id, '_wp_page_template', 'page-template-name' ); - - // Setup for when post_ID is in GET. - $_GET['post'] = $page_id; - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'page-template-name' ] ) ); - - // Clear Global GET. - $_GET['post'] = null; - - // Setup for when post_ID is in POST. - $_POST['post_ID'] = $page_id; - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'page-template-name' ] ) ); - - // Clear Global POST. - $_POST['post_ID'] = null; - } - - /** - * Test _beans_is_post_meta_conditions() should return false when no conditions match. - */ - public function test_should_return_false_when_no_conditions_match() { - - $page_id = $this->factory()->post->create( [ 'post_type' => 'page' ] ); - set_current_screen( 'edit' ); - add_post_meta( $page_id, '_wp_page_template', 'page-template-name' ); - - // Setup for when post_ID is in GET. - $_GET['post'] = $page_id; - - $this->assertFalse( _beans_is_post_meta_conditions( [ 'some-other-conditions' ] ) ); - - // Clear Global GET. - $_GET['post'] = null; - - // Setup for when post_ID is in POST. - $_POST['post_ID'] = $page_id; - - $this->assertFalse( _beans_is_post_meta_conditions( [ 'some-other-conditions' ] ) ); - - // Clear Global POST. - $_POST['post_ID'] = null; - } -} diff --git a/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php b/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php deleted file mode 100644 index 7ca4607e..00000000 --- a/tests/phpunit/integration/api/post-meta/beansPostMetaPageTemplateReload.php +++ /dev/null @@ -1,71 +0,0 @@ -assertSame( '', $output ); - } - - /** - * Test _beans_post_meta_page_template_reload() should do nothing when post meta is not assigned to a page templates. - */ - public function test_should_do_nothing_when_post_meta_not_assigned_to_page_templates() { - global $_beans_post_meta_conditions, $pagenow; - - $_beans_post_meta_conditions = []; - $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. - - ob_start(); - _beans_post_meta_page_template_reload(); - $output = ob_get_clean(); - - $this->assertSame( '', $output ); - } - - /** - * Test _beans_post_meta_page_template_reload() should output script HTML when post meta is assigned to page templates. - */ - public function test_should_output_script_html_when_post_meta_assigned_to_page_templates() { - global $_beans_post_meta_conditions, $pagenow; - - $_beans_post_meta_conditions = [ 'page-template-name.php' ]; - $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. - - ob_start(); - _beans_post_meta_page_template_reload(); - $output = ob_get_clean(); - - $this->assertContains( ' -EOB; - - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $inline_script ) ); - } - - /** - * Get the mocked assets. - * - * @since 1.5.0 - * - * @param array $queue Array of assets to build. - * @param bool $with_extras When true, adds the extras for localization. Default is false. - * - * @return \Mockery\MockInterface - */ - protected function get_mock_assets( array $queue, $with_extras = false ) { - $wp_scripts_mock = Mockery::mock( 'WP_Scripts' ); - $wp_scripts_mock->queue = $queue; - $registered = [ - 'jquery' => $this->get_deps_mock( [ - 'handle' => 'jquery', - 'src' => false, - 'deps' => [ 'jquery-core', 'jquery-migrate' ], - 'ver' => '1.12.4', - ] ), - 'jquery-core' => $this->get_deps_mock( [ - 'handle' => 'jquery-core', - 'src' => '/wp-includes/js/jquery/jquery.js', - 'ver' => '1.12.4', - ] ), - 'jquery-migrate' => $this->get_deps_mock( [ - 'handle' => 'jquery-migrate', - 'src' => '/wp-includes/js/jquery/jquery-migrate.js', - 'ver' => '1.4.1', - ] ), - ]; - - if ( in_array( 'debug-bar', $queue, true ) ) { - $registered['debug-bar'] = $this->get_deps_mock( [ - 'handle' => 'debug-bar', - 'src' => '/wp-content/plugins/debug-bar/js/debug-bar.dev.js', - 'deps' => [ 'jquery' ], - 'ver' => '20170515', - 'extra' => $with_extras ? [ 'data' => 'var testParams = "hello-beans";' ] : [], - ] ); - } - - if ( in_array( 'uikit', $queue, true ) ) { - $registered['uikit'] = $this->get_deps_mock( [ - 'handle' => 'uikit', - 'src' => 'wp-content/uploads/beans/compiler/uikit/3b2a958-921f3e0.js', - 'deps' => [ 'jquery' ], - ] ); - } - - $wp_scripts_mock->registered = $registered; - - global $wp_scripts; - $wp_scripts = $wp_scripts_mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case to load mocks for tests. - - return $wp_scripts_mock; - } -} diff --git a/tests/phpunit/unit/api/compiler/beansAddCompilerOptionsToSettings.php b/tests/phpunit/unit/api/compiler/beansAddCompilerOptionsToSettings.php deleted file mode 100644 index cc471664..00000000 --- a/tests/phpunit/unit/api/compiler/beansAddCompilerOptionsToSettings.php +++ /dev/null @@ -1,32 +0,0 @@ -assertInstanceOf( _Beans_Compiler_Options::class, beans_add_compiler_options_to_settings() ); - } -} diff --git a/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php b/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php deleted file mode 100644 index d97d12fe..00000000 --- a/tests/phpunit/unit/api/compiler/beansCompileCssFragments.php +++ /dev/null @@ -1,33 +0,0 @@ -assertFalse( beans_compile_css_fragments( 'foo', '' ) ); - $this->assertFalse( beans_compile_css_fragments( 'foo', [] ) ); - $this->assertFalse( beans_compile_css_fragments( 'foo', [], [ 'arg' => '' ] ) ); - } -} diff --git a/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php b/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php deleted file mode 100644 index 837332ff..00000000 --- a/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php +++ /dev/null @@ -1,36 +0,0 @@ -assertFalse( beans_compile_js_fragments( 'foo', '' ) ); - $this->assertFalse( beans_compile_js_fragments( 'foo', [] ) ); - $this->assertFalse( beans_compile_js_fragments( 'foo', [], [ - 'dependencies' => [], - 'in_footer' => true, - ] ) ); - } -} diff --git a/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php b/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php deleted file mode 100644 index 62d5fce5..00000000 --- a/tests/phpunit/unit/api/compiler/beansCompileLessFragments.php +++ /dev/null @@ -1,33 +0,0 @@ -assertFalse( beans_compile_less_fragments( 'foo', '' ) ); - $this->assertFalse( beans_compile_less_fragments( 'foo', [] ) ); - $this->assertFalse( beans_compile_less_fragments( 'foo', [], [ 'arg' => '' ] ) ); - } -} diff --git a/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php b/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php deleted file mode 100644 index ab1a8f1e..00000000 --- a/tests/phpunit/unit/api/compiler/beansCompilerAddFragment.php +++ /dev/null @@ -1,92 +0,0 @@ -assertFalse( beans_compiler_add_fragment( 'foo', '', 'less' ) ); - $this->assertFalse( beans_compiler_add_fragment( 'foo', [], 'css' ) ); - $this->assertFalse( beans_compiler_add_fragment( 'foo', [], 'js' ) ); - } - - /** - * Test beans_compiler_add_fragment() should not add fragments when the format is not valid. - */ - public function test_should_not_add_fragments_when_format_is_not_valid() { - global $_beans_compiler_added_fragments; - - $this->assertNull( beans_compiler_add_fragment( 'test-css', vfsStream::url( 'compiled/fixtures/style.css' ), 'style' ) ); - $this->assertArrayNotHasKey( 'style', $_beans_compiler_added_fragments ); - - $this->assertNull( beans_compiler_add_fragment( 'test-js', vfsStream::url( 'compiled/fixtures/jquery.test.js' ), 'script' ) ); - $this->assertArrayNotHasKey( 'script', $_beans_compiler_added_fragments ); - } - - /** - * Test beans_compiler_add_fragment() should add fragments when the format is valid. - */ - public function test_should_add_fragments_when_format_is_valid() { - global $_beans_compiler_added_fragments; - - $fragment = vfsStream::url( 'compiled/fixtures/style.css' ); - $this->assertNull( beans_compiler_add_fragment( 'test-css', $fragment, 'css' ) ); - $this->assertArrayHasKey( 'test-css', $_beans_compiler_added_fragments['css'] ); - $this->assertSame( [ $fragment ], $_beans_compiler_added_fragments['css']['test-css'] ); - - $fragments = [ - vfsStream::url( 'compiled/fixtures/test.less' ), - vfsStream::url( 'compiled/fixtures/variables.less' ), - ]; - $this->assertNull( beans_compiler_add_fragment( 'test-less', $fragments, 'less' ) ); - $this->assertArrayHasKey( 'test-less', $_beans_compiler_added_fragments['less'] ); - $this->assertSame( $fragments, $_beans_compiler_added_fragments['less']['test-less'] ); - - $fragments = [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ]; - $this->assertNull( beans_compiler_add_fragment( 'test-js', $fragments, 'js' ) ); - $this->assertArrayHasKey( 'test-js', $_beans_compiler_added_fragments['js'] ); - $this->assertSame( $fragments, $_beans_compiler_added_fragments['js']['test-js'] ); - } - - /** - * Test beans_compiler_add_fragment() should add fragment(s) to existing ID. - */ - public function test_should_add_fragment_to_existing_id() { - global $_beans_compiler_added_fragments; - - $_beans_compiler_added_fragments['less']['test-css'] = [ 'theme/base.less' ]; - - $fragments = [ - vfsStream::url( 'compiled/fixtures/test.less' ), - vfsStream::url( 'compiled/fixtures/variables.less' ), - ]; - $this->assertNull( beans_compiler_add_fragment( 'test-less', $fragments, 'less' ) ); - $this->assertContains( $fragments[0], $_beans_compiler_added_fragments['less']['test-less'] ); - $this->assertContains( $fragments[1], $_beans_compiler_added_fragments['less']['test-less'] ); - } -} diff --git a/tests/phpunit/unit/api/compiler/beansFlushCompiler.php b/tests/phpunit/unit/api/compiler/beansFlushCompiler.php deleted file mode 100644 index 7ffcdfbb..00000000 --- a/tests/phpunit/unit/api/compiler/beansFlushCompiler.php +++ /dev/null @@ -1,165 +0,0 @@ -twice() - ->with( false ) - ->andReturn( $compiler_dir ); - Monkey\Functions\expect( 'beans_remove_dir' )->never(); - - $this->assertNull( beans_flush_compiler( 'beans' ) ); - } - - /** - * Test beans_flush_compiler() should remove cached CSS file. - */ - public function test_should_remove_cached_css_file() { - $this->overwrite_virtual_filesystem(); - - $compiler_dir = vfsStream::url( 'compiled/beans/compiler/' ); - Monkey\Functions\expect( 'beans_get_compiler_dir' ) - ->once() - ->with( false ) - ->andReturn( $compiler_dir ); - Monkey\Functions\expect( 'beans_remove_dir' )->never(); - - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - $this->assertNull( beans_flush_compiler( 'beans', 'css' ) ); - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - } - - /** - * Test beans_flush_compiler() should remove cached JS file. - */ - public function test_should_remove_cached_js_file() { - $this->overwrite_virtual_filesystem(); - - $compiler_dir = vfsStream::url( 'compiled/beans/compiler/' ); - Monkey\Functions\expect( 'beans_get_compiler_dir' ) - ->once() - ->with( false ) - ->andReturn( $compiler_dir ); - Monkey\Functions\expect( 'beans_remove_dir' )->never(); - - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - $this->assertNull( beans_flush_compiler( 'beans', 'js' ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - } - - /** - * Test beans_flush_compiler() should remove all cached files. - */ - public function test_should_remove_all_cached_files() { - $this->overwrite_virtual_filesystem(); - - $compiler_dir = vfsStream::url( 'compiled/beans/compiler/' ); - Monkey\Functions\expect( 'beans_get_compiler_dir' ) - ->once() - ->with( false ) - ->andReturn( $compiler_dir ); - Monkey\Functions\expect( 'beans_remove_dir' ) - ->once() - ->with( trailingslashit( $compiler_dir ) . 'beans' ) - ->andReturnUsing( function( $dir_path ) { - $items = scandir( $dir_path ); - unset( $items[0], $items[1] ); - - $dir_path = trailingslashit( $dir_path ); - - foreach ( $items as $needle => $item ) { - unlink( $dir_path . $item ); - } - - return rmdir( $dir_path ); - } ); - - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - $this->assertNull( beans_flush_compiler( 'beans' ) ); - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); - $this->assertFileNotExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); - $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/beans' ) ); - $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/beans/' ) ); - } - - /** - * Overwrites the virtual filesystem for this test. - */ - private function overwrite_virtual_filesystem() { - $this->mock_filesystem = vfsStream::setup( - 'compiled', - 0755, - [ - 'beans' => [ - 'compiler' => [ - 'beans' => [ - '1234567-9876543.css' => $this->get_compiled_css(), - 'abcd3fg-hijklmn.js' => $this->get_compiled_js(), - ], - ], - ], - ] - ); - } - - /** - * Get the compiled JavaScript. - * - * @since 1.5.0 - * - * @return string - */ - protected function get_compiled_js() { - return <<assertSame( - vfsStream::url( 'compiled/beans/compiler/' ), - beans_get_compiler_dir() - ); - } - - /** - * Test beans_get_compiler_dir() should return the absolute path to the Beans' uploads admin compiler folder. - */ - public function test_should_return_absolute_path_to_compiler_admin_folder() { - $this->assertSame( - vfsStream::url( 'compiled/beans/admin-compiler/' ), - beans_get_compiler_dir( true ) - ); - } -} diff --git a/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php b/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php deleted file mode 100644 index 717fbbdd..00000000 --- a/tests/phpunit/unit/api/compiler/beansGetCompilerUrl.php +++ /dev/null @@ -1,44 +0,0 @@ -assertSame( - $this->compiled_url . 'beans/compiler/', - beans_get_compiler_url() - ); - } - - /** - * Test should return the URL to the Beans' admin compiler folder. - */ - public function test_should_return_url_to_compiler_admin_folder() { - $this->assertSame( - $this->compiled_url . 'beans/admin-compiler/', - beans_get_compiler_url( true ) - ); - } -} diff --git a/tests/phpunit/unit/api/compiler/fixtures/jquery.test.js b/tests/phpunit/unit/api/compiler/fixtures/jquery.test.js deleted file mode 100644 index 73d60dc5..00000000 --- a/tests/phpunit/unit/api/compiler/fixtures/jquery.test.js +++ /dev/null @@ -1,29 +0,0 @@ -(function( $ ){ - 'use strict'; - - /** - * Initialize the script. - */ - var init = function() { - $( 'some-button' ).on( 'click', clickHandler ); - } - - /** - * Handle the button's click event. - * - * @param event - */ - var clickHandler = function( event ) { - event.preventDefault(); - - // do something cool here. - } - - /** - * Wait until the document is ready. - */ - $( document ).ready( function(){ - init(); - }); - -})( jQuery ); diff --git a/tests/phpunit/unit/api/compiler/fixtures/my-game-clock.js b/tests/phpunit/unit/api/compiler/fixtures/my-game-clock.js deleted file mode 100644 index ac082973..00000000 --- a/tests/phpunit/unit/api/compiler/fixtures/my-game-clock.js +++ /dev/null @@ -1,21 +0,0 @@ -class MyGameClock { - - /** - * Creates an instance of MyGameClock. - * - * @param maxTime Clock's timeout increment. - */ - constructor( maxTime ) { - this.maxTime = maxTime; - this.currentClock = 0; - } - - /** - * Get the remaining time on the clock. - * - * @returns {number} - */ - getRemainingTime() { - return this.maxTime - this.currentClock; - } -} \ No newline at end of file diff --git a/tests/phpunit/unit/api/compiler/fixtures/style.css b/tests/phpunit/unit/api/compiler/fixtures/style.css deleted file mode 100644 index a5aa904b..00000000 --- a/tests/phpunit/unit/api/compiler/fixtures/style.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - Stylesheet. - */ -body { - background-color: #fff; - color: #000; - font-size: 18px; -} - -a { - color: #cc0000; -} - -p { - margin-bottom: 30px; -} diff --git a/tests/phpunit/unit/api/compiler/fixtures/test.less b/tests/phpunit/unit/api/compiler/fixtures/test.less deleted file mode 100644 index fcda49a7..00000000 --- a/tests/phpunit/unit/api/compiler/fixtures/test.less +++ /dev/null @@ -1,7 +0,0 @@ -@test-font-size: 18px; - -body { - background-color: #fff; - color: @body-color; - font-size: @test-font-size; -} diff --git a/tests/phpunit/unit/api/compiler/fixtures/variables.less b/tests/phpunit/unit/api/compiler/fixtures/variables.less deleted file mode 100644 index 18615d17..00000000 --- a/tests/phpunit/unit/api/compiler/fixtures/variables.less +++ /dev/null @@ -1,8 +0,0 @@ -/** -These are the global variables. - */ -@body-color: #000; -@link-color: #039460; -@hover-color: #016F47; -@base-font: normal 18px / 22px "Helvetica Neue",Helvetica,Arial,sans-serif; -@base-font-size: 18px; /* this is an inline comment */ \ No newline at end of file diff --git a/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php deleted file mode 100644 index ff32f3de..00000000 --- a/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php +++ /dev/null @@ -1,101 +0,0 @@ -set_up_virtual_filesystem(); - $this->compiled_dir = vfsStream::url( 'compiled' ); - $this->compiled_url = 'http:://beans.test/compiled/'; - - $this->load_original_functions( [ - 'api/utilities/functions.php', - 'api/compiler/functions.php', - ] ); - - $this->setup_common_wp_stubs(); - } - - /** - * Set up the virtual filesystem. - */ - protected function set_up_virtual_filesystem() { - $this->mock_filesystem = vfsStream::setup( - 'compiled', - 0755, - $this->get_virtual_structure() - ); - } - - /** - * Get the virtual filesystem's structure. - */ - protected function get_virtual_structure() { - return [ - 'beans' => [ - 'compiler' => [ - 'index.php' => '', - ], - 'admin-compiler' => [ - 'index.php' => '', - ], - ], - ]; - } - - /** - * Add the virtual directory to the filesystem. - * - * @since 1.5.0 - * - * @param string $dir_name Directory name. - * @param string $root_dir Optional. Root directory(ies) for the new directory. - * - * @return void - */ - protected function add_virtual_directory( $dir_name, $root_dir = 'compiled/beans/compiler' ) { - vfsStream::newDirectory( $dir_name )->at( $this->mock_filesystem->getChild( $root_dir ) ); - } -} diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php deleted file mode 100644 index 4e19c981..00000000 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php +++ /dev/null @@ -1,34 +0,0 @@ -load_original_functions( [ - 'api/compiler/class-beans-compiler-options.php', - 'api/options/functions.php', - ] ); - - $this->setup_common_wp_stubs(); - } -} diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php deleted file mode 100644 index 411ade7a..00000000 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ /dev/null @@ -1,333 +0,0 @@ -set_up_function_mocks(); - - $this->load_original_functions( [ - 'api/compiler/class-beans-compiler.php', - ] ); - } - - /** - * Set up the virtual filesystem. - */ - protected function set_up_virtual_filesystem() { - parent::set_up_virtual_filesystem(); - - // Set the fixture file dates back a week. - $fixtures_dir = $this->mock_filesystem->getChild( 'fixtures' ); - $file_modification_time = time() - ( 7 * 24 * 60 * 60 ); - foreach ( static::$fixture_filenames as $filename ) { - $fixtures_dir->getChild( $filename )->lastModified( $file_modification_time ); - } - } - - /** - * Get the virtual filesystem's structure. - */ - protected function get_virtual_structure() { - $structure = parent::get_virtual_structure(); - $structure['fixtures'] = $this->get_fixtures_content(); - - return $structure; - } - - /** - * Get the test fixture's content. - */ - private function get_fixtures_content() { - $fixtures = []; - - foreach ( static::$fixture_filenames as $filename ) { - $fixtures[ $filename ] = file_get_contents( static::$fixtures_dir . $filename ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid edge case. - } - - return $fixtures; - } - - /** - * Set up function mocks. - */ - protected function set_up_function_mocks() { - Functions\when( 'wp_upload_dir' )->justReturn( [ - 'path' => '', - 'url' => '', - 'subdir' => '', - 'basedir' => $this->compiled_dir, - 'baseurl' => $this->compiled_url, - 'error' => false, - ] ); - Functions\when( 'is_admin' )->justReturn( $this->is_admin ); - Functions\when( 'site_url' )->justReturn( 'http:://beans.local' ); - } - - /** - * Add the virtual directory to the filesystem. - * - * @since 1.5.0 - * - * @param string $dir_name Directory name. - * @param string $root_dir Optional. Root directory(ies) for the new directory. - * - * @return void - */ - protected function add_virtual_directory( $dir_name, $root_dir = 'compiled/beans/compiler' ) { - vfsStream::newDirectory( $dir_name )->at( $this->mock_filesystem->getChild( $root_dir ) ); - } - - /** - * Create a file in the virtual directory system. - * - * @since 1.0.0 - * - * @param string $folder_name Name of the folder to create, which is the configuration's ID. - * @param string $filename File's name. - * @param string $content The content to store in the file. - * - * @return string - */ - protected function create_virtual_file( $folder_name, $filename, $content ) { - $this->add_virtual_directory( $folder_name ); - vfsStream::newFile( $filename ) - ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $folder_name ) ) - ->setContent( $content ); - - $cached_file = vfsStream::url( 'compiled/beans/compiler/' . $folder_name . '/' . $filename ); - - // vfs has a little quirk: We need to check the file to finish storing it in the system. This helps us to modify it later. - file_exists( $cached_file ); - - return $cached_file; - } - - /** - * Create the compiler. - * - * @since 1.0.0 - * - * @param array $config Compiler's configuration parameters. - * - * @return _Beans_Compiler - */ - protected function create_compiler( array $config = [] ) { - Monkey\Functions\when( 'beans_get_compiler_dir' )->justReturn( vfsStream::url( 'compiled/beans/compiler/' ) ); - Monkey\Functions\when( 'beans_get_compiler_url' )->justReturn( $this->compiled_url . 'beans/compiler/' ); - - return new _Beans_Compiler( $config ); - } - - /** - * Set the protected property "current_fragment". - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler The Compiler instance. - * @param mixed $fragment The given value to set. - * - * @return \ReflectionProperty|string - * @throws \ReflectionException Throws an exception if property does not exist. - */ - protected function set_current_fragment( $compiler, $fragment ) { - return $this->set_reflective_property( $fragment, 'current_fragment', $compiler ); - } - - /** - * Get the filename. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the compiler. - * @param array $config The compiler's configuration. - * @param int $filemtime Optional. The fragment's filemtime. Default is null. - * - * @return string - */ - protected function get_filename( $compiler, $config, $filemtime = null ) { - - if ( is_null( $filemtime ) ) { - foreach ( $config['fragments'] as $index => $fragment ) { - $filemtimes[ $index ] = filemtime( $fragment ); - } - } else { - $filemtimes = [ $filemtime ]; - } - - return sprintf( - '%s-%s.%s', - $compiler->hash( $config ), - $compiler->hash( $filemtimes ), - 'style' === $config['type'] ? 'css' : 'js' - ); - } - - /** - * Set up the filesystem mocks for the fragments. - * - * @since 1.5.0 - * - * @param _Beans_Compiler $compiler Instance of the Compiler. - * @param int $times_called Optional. Number of times the mock will be called. Default is 1. - * - * @return void - */ - protected function mock_filesystem_for_fragments( $compiler, $times_called = 1 ) { - $mock = Mockery::mock( 'WP_Filesystem_Direct' ); - - foreach ( $compiler->config['fragments'] as $fragment ) { - $mock->shouldReceive( 'get_contents' ) - ->times( $times_called ) - ->with( $fragment ) - ->andReturn( file_get_contents( $fragment ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Valid in this edge case. - } - - $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case as we are mocking the filesystem. - } - - /** - * Get the compiled jQuery. - * - * @since 1.5.0 - * - * @return string - */ - protected function get_compiled_jquery() { - $compiled_content = <<load_original_functions( [ - 'api/compiler/class-beans-page-compiler.php', - 'api/options/functions.php', - ] ); - } - - /** - * Get the deps mock. - * - * @since 1.5.0 - * - * @param array $config Configuration parameters to set the properties. - * - * @return Mockery\MockInterface - */ - protected function get_deps_mock( array $config ) { - $mock = Mockery::mock( '_WP_Dependency' ); - $mock->handle = $config['handle']; - $mock->src = $config['src']; - $mock->deps = isset( $config['deps'] ) ? $config['deps'] : []; - $mock->ver = isset( $config['ver'] ) ? $config['ver'] : false; - $mock->args = isset( $config['args'] ) ? $config['args'] : 'all'; - $mock->extra = isset( $config['extra'] ) ? $config['extra'] : []; - - return $mock; - } -} diff --git a/tests/phpunit/unit/api/fields/beansGetFields.php b/tests/phpunit/unit/api/fields/beansGetFields.php deleted file mode 100644 index ba174825..00000000 --- a/tests/phpunit/unit/api/fields/beansGetFields.php +++ /dev/null @@ -1,44 +0,0 @@ - [ - $test_data['section'] => $test_data['fields'], - ], - ]; - - // Register the fields first. - $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); - $registered->setValue( new \_Beans_Fields(), $data_set ); - - $this->assertSame( $data_set['beans_tests'][ $test_data['section'] ], beans_get_fields( 'beans_tests', $test_data['section'] ) ); - } - } -} diff --git a/tests/phpunit/unit/api/fields/beansPreStandardizeFields.php b/tests/phpunit/unit/api/fields/beansPreStandardizeFields.php deleted file mode 100644 index fa2d7891..00000000 --- a/tests/phpunit/unit/api/fields/beansPreStandardizeFields.php +++ /dev/null @@ -1,55 +0,0 @@ -assertArrayHasKey( $field['id'], $fields ); - $this->assertSame( $field, $fields[ $field['id'] ] ); - } - } - - /** - * Test _beans_pre_standardize_fields() should pre-standardize a group of fields. - */ - public function test_should_pre_standardize_group_of_fields() { - $actual = _beans_pre_standardize_fields( static::$test_data['group']['fields'] ); - - foreach ( static::$test_data['group']['fields'] as $group ) { - $this->assertArrayHasKey( $group['id'], $actual ); - - $actual_fields = $actual[ $group['id'] ]['fields']; - - // Check each of the grouped fields. - foreach ( $group['fields'] as $field ) { - $this->assertArrayHasKey( $field['id'], $actual_fields ); - $this->assertSame( $field, $actual_fields[ $field['id'] ] ); - } - } - } -} diff --git a/tests/phpunit/unit/api/fields/beansRegisterFields.php b/tests/phpunit/unit/api/fields/beansRegisterFields.php deleted file mode 100644 index dca0c7c9..00000000 --- a/tests/phpunit/unit/api/fields/beansRegisterFields.php +++ /dev/null @@ -1,56 +0,0 @@ -assertFalse( beans_register_fields( [], '', '' ) ); - $this->assertFalse( beans_register_fields( [], 'post_meta', 'tm-beans' ) ); - } - - /** - * Test beans_register_fields() should register the single fields. - */ - public function test_should_register_single_fields() { - $test_data = static::$test_data['single_fields']; - - $this->assertTrue( beans_register_fields( $test_data['fields'], 'beans_tests', $test_data['section'] ) ); - - // Check what was registered. - $registered_property = $this->get_reflective_property( 'registered', '_Beans_Fields' ); - $registered = $registered_property->getValue( new _Beans_Fields() ); - - $this->assertArrayHasKey( 'beans_tests', $registered ); - $this->assertArrayHasKey( $test_data['section'], $registered['beans_tests'] ); - - foreach ( $test_data['fields'] as $index => $field ) { - $this->assertSame( - $this->merge_field_with_default( $field ), - $registered['beans_tests'][ $test_data['section'] ][ $index ] - ); - } - } -} diff --git a/tests/phpunit/unit/api/fields/fixtures/test-fields.php b/tests/phpunit/unit/api/fields/fixtures/test-fields.php deleted file mode 100644 index 82ab361a..00000000 --- a/tests/phpunit/unit/api/fields/fixtures/test-fields.php +++ /dev/null @@ -1,80 +0,0 @@ - [ - 'fields' => [ - [ - 'id' => 'beans_layout', - 'label' => 'Layout', - 'type' => 'radio', - 'default' => 'default_fallback', - 'options' => [ - 'default_fallback' => 'Use Default Layout', - 'c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c.png', - 'c_sp' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/c_sp.png', - 'sp_c' => BEANS_THEME_DIR . 'lib/admin/assets/images/layouts/sp_c.png', - ], - ], - [ - 'id' => 'beans_checkbox_test', - 'label' => false, - 'checkbox_label' => 'Enable the checkbox test', - 'type' => 'checkbox', - 'default' => false, - ], - [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => 'Testing the text field.', - ], - ], - 'context' => 'tests', - 'section' => 'tm-beans', - ], - - // Group of fields. - 'group' => [ - 'fields' => [ - [ - 'id' => 'beans_group_test', - 'label' => 'Group of fields', - 'description' => 'This is a group of fields.', - 'type' => 'group', - 'fields' => [ - [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ], - [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - ], - [ - 'id' => 'beans_checkbox_test', - 'label' => false, - 'checkbox_label' => 'Enable the checkbox test', - 'type' => 'checkbox', - 'default' => false, - ], - ], - ], - ], - 'context' => 'group_tests', - 'section' => 'tm-beans', - ], -]; diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php deleted file mode 100644 index 28859a6f..00000000 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ /dev/null @@ -1,130 +0,0 @@ -load_original_functions( [ - 'api/actions/functions.php', - 'api/fields/functions.php', - 'api/fields/class-beans-fields.php', - 'api/utilities/functions.php', - ] ); - - $this->setup_function_mocks(); - $this->setup_common_wp_stubs(); - } - - /** - * Merge the given field with the default structure. - * - * @since 1.5.0 - * - * @param array $field The given field to merge. - * @param bool $set_value Optional. When true, sets the "value" to the "default". - * - * @return array - */ - protected function merge_field_with_default( array $field, $set_value = true ) { - $merged_field = array_merge( [ - 'label' => false, - 'description' => false, - 'default' => false, - 'context' => 'beans_tests', - 'attributes' => [], - 'db_group' => false, - ], $field ); - $merged_field['name'] = 'beans_fields[' . $field['id'] . ']'; - - if ( $set_value ) { - $merged_field['value'] = $field['default']; - } - - return $merged_field; - } - - /** - * Set up function mocks. - */ - protected function setup_function_mocks() { - Monkey\Functions\when( 'checked' )->alias( function( $actual, $value ) { - - if ( $actual === $value ) { - echo " checked='checked'"; - } - } ); - - Monkey\Functions\when( 'selected' )->alias( function( $actual, $value ) { - - if ( $actual === $value ) { - echo " selected='selected'"; - } - } ); - - Monkey\Functions\when( '_n' )->alias( function( $single, $plural, $number ) { - return $number > 1 ? $plural : $single; - } ); - - Monkey\Functions\when( 'beans_get' )->alias( function( $needle, $haystack = false, $default = null ) { - $haystack = (array) $haystack; - - return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : $default; - } ); - - Monkey\Functions\when( 'beans_esc_attributes' )->alias( function( $attributes ) { - $string = ''; - - foreach ( (array) $attributes as $attribute => $value ) { - - if ( null === $value ) { - continue; - } - - $string .= $attribute . '="' . $value . '" '; - } - - return trim( $string ); - } ); - - Monkey\Functions\when( 'beans_add_smart_action' )->justReturn(); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php deleted file mode 100644 index 579b5d84..00000000 --- a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php +++ /dev/null @@ -1,85 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_activation( $field ); - $html = ob_get_clean(); - - $expected = << - - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_activation() should render the activation field with attributes when given. - */ - public function test_should_render_activation_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_activation( $field ); - $html = ob_get_clean(); - - $expected = << - - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php deleted file mode 100644 index 136aa915..00000000 --- a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php +++ /dev/null @@ -1,112 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_checkbox( $field ); - $html = ob_get_clean(); - - $expected = << - -Compile all WordPress styles -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_checkbox() should render the checkbox with the default label when none is given. - */ - public function test_should_render_checkbox_with_default_label_when_none_is_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'type' => 'checkbox', - 'default' => false, - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_checkbox( $field ); - $html = ob_get_clean(); - - $expected = << - -Enable -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_checkbox() should render the checkbox with attributes when given. - */ - public function test_should_render_checkbox_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_checkbox( $field ); - $html = ob_get_clean(); - - $expected = << - -Compile all WordPress styles -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php deleted file mode 100644 index 6204aec0..00000000 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ /dev/null @@ -1,203 +0,0 @@ -with( 1, 'thumbnail' ) - ->once() - ->andReturn( 'image.png' ); - Monkey\Functions\expect( 'get_post_meta' ) - ->once() - ->andReturn( 'This is the image alt value.' ); - - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => 1, // attachment ID. - ], false ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_image( $field ); - $html = ob_get_clean(); - - $expected = <<

                -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_radio() should render accessible images when accessibility parameters are given. - */ - public function test_should_render_accessible_images_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_layout', - 'label' => 'Layout', - 'description' => 'The layout settings.', - 'type' => 'radio', - 'default' => 'default_fallback', - 'options' => [ - 'default_fallback' => 'Use Default Layout', - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'alt' => 'Content Only Layout', - 'screen_reader_text' => 'Option for the Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/sp_c.png', - 'alt' => 'Sidebar Primary + Content Layout', - ], - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_radio( $field ); - $html = ob_get_clean(); - - $expected = << - Layout - - - - -
                -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php deleted file mode 100644 index a7d50c18..00000000 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ /dev/null @@ -1,95 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_select( $field ); - $html = ob_get_clean(); - - $expected = << - - - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_select() should render the select field with attributes when given. - */ - public function test_should_render_select_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'standard', - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - 'attributes' => [ - 'style' => 'margin: -3px 0 0 -8px;', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_select( $field ); - $html = ob_get_clean(); - - $expected = << - - - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php deleted file mode 100644 index 9fcf4acb..00000000 --- a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php +++ /dev/null @@ -1,162 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 0, - 'max' => 100, - 'interval' => 1, - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_slider( $field ); - $html = ob_get_clean(); - - $expected = << - - -0 -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_slider() should render the slider field with unit when given. - */ - public function test_should_render_slider_field_with_unit_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 10, - 'max' => 100, - 'interval' => 5, - 'unit' => 'Number of beans', - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_slider( $field ); - $html = ob_get_clean(); - - $expected = << - - -0 -Number of beans -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_slider() should render the slider with the current value. - */ - public function test_should_render_slider_with_current_value() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 10, - 'max' => 100, - 'interval' => 5, - ] ); - $field['value'] = 15; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_slider( $field ); - $html = ob_get_clean(); - - $expected = << - - -15 -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test beans_field_slider() should render the slider field with attributes when given. - */ - public function test_should_render_slider_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 1, - 'min' => 1, - 'max' => 20, - 'interval' => 1, - 'unit' => 'Number of beans', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_slider( $field ); - $html = ob_get_clean(); - - $expected = << - - -1 -Number of beans -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php deleted file mode 100644 index 95860f44..00000000 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ /dev/null @@ -1,83 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - ] ); - $field['value'] = 'Testing the text field.'; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_text( $field ); - $html = ob_get_clean(); - - $expected = << -EOB; - // Run the test. - $this->assertSame( $expected, $html ); - } - - /** - * Test beans_field_text() should render the text field with attributes when given. - */ - public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - $field['value'] = 'Testing the text field with attributes.'; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_text( $field ); - $html = ob_get_clean(); - - $expected = << -EOB; - // Run the test. - $this->assertSame( $expected, $html ); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php deleted file mode 100644 index db7c0fd0..00000000 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ /dev/null @@ -1,83 +0,0 @@ -merge_field_with_default( [ - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - ] ); - $field['value'] = 'Testing the textarea field.'; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_textarea( $field ); - $html = ob_get_clean(); - - $expected = <<Testing the textarea field. -EOB; - // Run the test. - $this->assertSame( $expected, $html ); - } - - /** - * Test beans_field_textarea() should render the textarea field with attributes when given. - */ - public function test_should_render_textarea_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); - $field['value'] = 'Testing the textarea field with attributes.'; - - // Run the function and grab the HTML out of the buffer. - ob_start(); - beans_field_textarea( $field ); - $html = ob_get_clean(); - - $expected = <<Testing the textarea field with attributes. -EOB; - // Run the test. - $this->assertSame( $expected, $html ); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansGetImageAlt.php b/tests/phpunit/unit/api/fields/types/beansGetImageAlt.php deleted file mode 100644 index 3014a147..00000000 --- a/tests/phpunit/unit/api/fields/types/beansGetImageAlt.php +++ /dev/null @@ -1,71 +0,0 @@ -assertNull( _beans_get_image_alt( 0 ) ); - $this->assertNull( _beans_get_image_alt( - 1 ) ); - $this->assertNull( _beans_get_image_alt( null ) ); - $this->assertNull( _beans_get_image_alt( false ) ); - } - - /** - * Test _beans_get_image_alt() should return the default when the image does not have an "alt" defined. - */ - public function test_should_return_default_alt_when_image_alt_not_defined() { - Monkey\Functions\expect( 'get_post_meta' ) - ->with( 1, '_wp_attachment_image_alt', true ) - ->once() - ->andReturnNull(); - - // Run the test. - $this->assertSame( 'Sorry, no description was given for this image.', _beans_get_image_alt( 1 ) ); - } - - /** - * Test _beans_get_image_alt() should return the image's alt description. - */ - public function test_should_return_image_alt() { - Monkey\Functions\expect( 'get_post_meta' ) - ->with( 1, '_wp_attachment_image_alt', true ) - ->once() - ->andReturn( 'This is the alt value.' ); - - // Run the test. - $this->assertSame( 'This is the alt value.', _beans_get_image_alt( 1 ) ); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansGetImageUrl.php b/tests/phpunit/unit/api/fields/types/beansGetImageUrl.php deleted file mode 100644 index fa9b7dca..00000000 --- a/tests/phpunit/unit/api/fields/types/beansGetImageUrl.php +++ /dev/null @@ -1,76 +0,0 @@ -assertNull( _beans_get_image_url( 0 ) ); - $this->assertNull( _beans_get_image_url( - 1 ) ); - $this->assertNull( _beans_get_image_url( null ) ); - $this->assertNull( _beans_get_image_url( false ) ); - } - - /** - * Test _beans_get_image_url() should return null when the image does not exist. - */ - public function test_should_return_null_when_image_does_not_exist() { - Monkey\Functions\expect( 'wp_get_attachment_image_src' ) - ->with( 9999999, 'thumbnail' ) - ->once() - ->andReturnNull(); - - $this->assertNull( _beans_get_image_url( 9999999 ) ); - } - - /** - * Test _beans_get_image_url() should return image's URL. - */ - public function test_should_return_image_url() { - Monkey\Functions\expect( 'wp_get_attachment_image_src' ) - ->with( 1, 'thumbnail' ) - ->once() - ->andReturn( - [ - 'http://example.org/wp-content/uploads/image.jpeg', - 300, - 300, - ] - ); - - // Run the test. - $this->assertSame( 'http://example.org/wp-content/uploads/image.jpeg', _beans_get_image_url( 1 ) ); - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansIsRadioImage.php b/tests/phpunit/unit/api/fields/types/beansIsRadioImage.php deleted file mode 100644 index 2e0621bb..00000000 --- a/tests/phpunit/unit/api/fields/types/beansIsRadioImage.php +++ /dev/null @@ -1,90 +0,0 @@ - 'http://example.com/images/layouts/c.png', - 'c_sp' => 'http://example.com/images/layouts/c_sp.png', - 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ]; - - foreach ( $test_data as $src ) { - $this->assertTrue( _beans_is_radio_image( $src ) ); - } - } - - /** - * Test _beans_is_radio_image() should false when a non-image source is given. - */ - public function test_should_return_false_when_non_image_src_given() { - $test_data = [ - __FILE__, - 'path/to/fields.js', - BEANS_THEME_DIR . 'style.css', - 'http://example.com/path/to/some.pdf', - ]; - - foreach ( $test_data as $src ) { - $this->assertFalse( _beans_is_radio_image( $src ) ); - } - } - - /** - * Test _beans_is_radio_image() should return true when an array is given, an array that configures the image. - */ - public function test_should_return_true_when_array_is_given() { - $test_data = [ - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'screen_reader_text' => 'Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'alt' => 'Content + Sidebar Primary Layout', - 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'alt' => 'Sidebar Primary + Content Layout', - ], - ]; - - foreach ( $test_data as $radio ) { - $this->assertTrue( _beans_is_radio_image( $radio ) ); - } - } -} diff --git a/tests/phpunit/unit/api/fields/types/beansStandardizeRadioImage.php b/tests/phpunit/unit/api/fields/types/beansStandardizeRadioImage.php deleted file mode 100644 index a8b23427..00000000 --- a/tests/phpunit/unit/api/fields/types/beansStandardizeRadioImage.php +++ /dev/null @@ -1,136 +0,0 @@ - 'http://example.com/images/layouts/c.png', - 'c_sp' => 'http://example.com/images/layouts/c_sp.png', - 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ]; - - foreach ( $test_data as $value => $radio ) { - $expected = [ - 'src' => $radio, - 'alt' => "Option for {$value}", - 'screen_reader_text' => "Option for {$value}", - ]; - $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); - } - } - - /** - * Test _beans_standardize_radio_image() should standardize when the image's alt value is not given. - */ - public function test_should_standardize_when_alt_is_not_given() { - $test_data = [ - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'screen_reader_text' => 'Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'screen_reader_text' => 'Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'screen_reader_text' => 'Sidebar Primary + Content Layout', - ], - ]; - - foreach ( $test_data as $value => $radio ) { - $expected = [ - 'src' => $radio['src'], - 'alt' => $radio['screen_reader_text'], - 'screen_reader_text' => $radio['screen_reader_text'], - ]; - $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); - } - } - - /** - * Test _beans_standardize_radio_image() should standardize when the image's `screen_reader_text` is not given. - */ - public function test_should_standardize_when_screen_reader_text_is_not_given() { - $test_data = [ - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'alt' => 'Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'alt' => 'Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'alt' => 'Sidebar Primary + Content Layout', - ], - ]; - - foreach ( $test_data as $value => $radio ) { - $expected = $radio; - $expected['screen_reader_text'] = $radio['alt']; - $this->assertSame( $expected, _beans_standardize_radio_image( $value, $radio ) ); - } - } - - /** - * Test _beans_standardize_radio_image() should standardize when all of the image's parameters are given. - */ - public function test_should_standardize_when_all_parameters_given() { - $test_data = [ - 'c' => [ - 'src' => 'c.png', - 'alt' => 'Content Only Layout', - 'screen_reader_text' => 'Option to select the Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'c_sp.png', - 'alt' => 'Content + Sidebar Primary Layout', - 'screen_reader_text' => 'Option to select the Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'c_sp.png', - 'alt' => 'Sidebar Primary + Content Layout', - 'screen_reader_text' => 'Option to select the Sidebar Primary + Content Layout', - ], - ]; - - foreach ( $test_data as $value => $radio ) { - $this->assertSame( $radio, _beans_standardize_radio_image( $value, $radio ) ); - } - } -} diff --git a/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php b/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php deleted file mode 100644 index 1ab56794..00000000 --- a/tests/phpunit/unit/api/filters/beans-anonymous-filters/_construct.php +++ /dev/null @@ -1,56 +0,0 @@ -assertSame( 'foo', $object->value_to_return ); - - // Clean up. - remove_action( 'do_foo', [ $object, 'callback' ], 20 ); - } - - /** - * Test __construct() should register callback to the given hook. - */ - public function test_should_register_callback_to_hook() { - $object = new _Beans_Anonymous_Filters( 'do_foo', false, 20 ); - - $this->assertTrue( has_filter( 'do_foo', [ $object, 'callback' ] ) !== false ); - - // Clean up. - remove_action( 'do_foo', [ $object, 'callback' ], 20 ); - } -} diff --git a/tests/phpunit/unit/api/filters/beansAddFilter.php b/tests/phpunit/unit/api/filters/beansAddFilter.php deleted file mode 100644 index 64c7c465..00000000 --- a/tests/phpunit/unit/api/filters/beansAddFilter.php +++ /dev/null @@ -1,74 +0,0 @@ - $filter ) { - - if ( ! isset( $filter['callback'] ) ) { - continue; - } - - // Test that the filter has not yet been added. - $this->assertFalse( has_filter( $filter['hook'], $filter['callback'] ) ); - - // Let's add it. - $this->assertTrue( beans_add_filter( $filter['hook'], $filter['callback'], $filter['priority'], $filter['args'] ) ); - - // Check that the filter was registered. - $this->assertTrue( has_filter( $filter['hook'], $filter['callback'] ) !== false ); - } - } - - /** - * Test beans_add_filter() should add (register) the "anonymous" filter. - * - * Note: When the callback is not callable, Beans creates an anonymous filter, where the "callback" parameter in - * the filter is actually the "value" that will be returned when the filter fires. - */ - public function test_should_add_anonymous_filter() { - - foreach ( static::$test_filters as $beans_id => $filter ) { - - if ( ! isset( $filter['value_to_return'] ) ) { - continue; - } - - // Let's add it. - $object = beans_add_filter( $filter['hook'], $filter['value_to_return'], $filter['priority'], $filter['args'] ); - - // Check that the value stored in the anonymous callback matches our filter. - $this->assertSame( $filter['value_to_return'], $object->value_to_return ); - - // Check that the filter was registered. - $this->assertTrue( has_filter( $filter['hook'], [ $object, 'callback' ] ) !== false ); - - // Clean up. - remove_filter( $filter['hook'], [ $object, 'callback' ], $filter['priority'] ); - } - } -} diff --git a/tests/phpunit/unit/api/filters/beansApplyFilters.php b/tests/phpunit/unit/api/filters/beansApplyFilters.php deleted file mode 100644 index 913fd6a3..00000000 --- a/tests/phpunit/unit/api/filters/beansApplyFilters.php +++ /dev/null @@ -1,148 +0,0 @@ -assertSame( 'foo', beans_apply_filters( $filter, 'foo' ) ); - } - } - - /** - * Test beans_apply_filters() should return value after calling one level of sub-hooks. - */ - public function test_should_return_value_after_calling_one_level_of_sub_hooks() { - $filters = [ - 'beans_loop_query_args[_main]' => [ - 'beans_loop_query_args', - 'beans_loop_query_args[_main]', - ], - 'beans_loop_query_args[_foo]' => [ - 'beans_loop_query_args', - 'beans_loop_query_args[_foo]', - ], - 'beans_widgets_area_args[_sidebar_primary]' => [ - 'beans_widgets_area_args', - 'beans_widgets_area_args[_sidebar_primary]', - ], - 'beans_widgets_area_args[_offcanvas_menu]' => [ - 'beans_widgets_area_args', - 'beans_widgets_area_args[_offcanvas_menu]', - ], - ]; - - foreach ( $filters as $filter => $events ) { - - // Set up the WordPress simulator for each of the filter events that will fire. - foreach ( $events as $index => $event_name ) { - Monkey\Filters\expectApplied( $events[ $index ] ) - ->once() - ->with( 0 === $index ? 'foo' : $events[ $index - 1 ] ) - ->andReturn( $events[ $index ] ); - } - - $this->assertSame( end( $events ), beans_apply_filters( $filter, 'foo' ) ); - } - } - - /** - * Test beans_apply_filters() should return value after calling two levels of sub-hooks. - */ - public function test_should_return_value_after_calling_two_levels_of_sub_hooks() { - $filters = [ - 'beans_loop_query_args[_first][_second]' => [ - 'beans_loop_query_args', - 'beans_loop_query_args[_first]', - 'beans_loop_query_args[_second]', - 'beans_loop_query_args[_first][_second]', - ], - 'beans_widgets_area_args[_first][_second]' => [ - 'beans_widgets_area_args', - 'beans_widgets_area_args[_first]', - 'beans_widgets_area_args[_second]', - 'beans_widgets_area_args[_first][_second]', - ], - ]; - - foreach ( $filters as $filter => $events ) { - - // Set up the WordPress simulator for each of the filter events that will fire. - foreach ( $events as $index => $event_name ) { - Monkey\Filters\expectApplied( $events[ $index ] ) - ->once() - ->with( 0 === $index ? 'bar' : $events[ $index - 1 ] ) - ->andReturn( $events[ $index ] ); - } - - $this->assertSame( end( $events ), beans_apply_filters( $filter, 'bar' ) ); - } - } - - /** - * Test beans_apply_filters() should return value after calling three levels of sub-hooks. - */ - public function test_should_return_value_after_calling_three_levels_of_sub_hooks() { - $filters = [ - 'beans_loop_query_args[_first][_second][_third]' => [ - 'beans_loop_query_args', - 'beans_loop_query_args[_first]', - 'beans_loop_query_args[_second]', - 'beans_loop_query_args[_first][_second]', - 'beans_loop_query_args[_third]', - 'beans_loop_query_args[_first][_second][_third]', - ], - 'beans_widgets_area_args[_first][_second][_third]' => [ - 'beans_widgets_area_args', - 'beans_widgets_area_args[_first]', - 'beans_widgets_area_args[_second]', - 'beans_widgets_area_args[_first][_second]', - 'beans_widgets_area_args[_third]', - 'beans_widgets_area_args[_first][_second][_third]', - ], - ]; - - foreach ( $filters as $filter => $events ) { - - // Set up the WordPress simulator for each of the filter events that will fire. - foreach ( $events as $index => $event_name ) { - Monkey\Filters\expectApplied( $events[ $index ] ) - ->once() - ->with( 0 === $index ? 'beans' : $events[ $index - 1 ] ) - ->andReturn( $events[ $index ] ); - } - - $this->assertSame( end( $events ), beans_apply_filters( $filter, 'beans' ) ); - } - } -} diff --git a/tests/phpunit/unit/api/filters/beansHasFilters.php b/tests/phpunit/unit/api/filters/beansHasFilters.php deleted file mode 100644 index 4d519e06..00000000 --- a/tests/phpunit/unit/api/filters/beansHasFilters.php +++ /dev/null @@ -1,57 +0,0 @@ -assertFalse( beans_has_filters( $filter['hook'], $filter['callback'] ) ); - } - } - - /** - * Test beans_has_filters() should return priority number when a callback is registered. - */ - public function test_should_return_priority_number_when_callback_registered() { - - foreach ( static::$test_filters as $filter ) { - - if ( ! isset( $filter['callback'] ) ) { - continue; - } - - beans_add_filter( $filter['hook'], $filter['callback'] ); - - $this->assertTrue( beans_has_filters( $filter['hook'], $filter['callback'] ) ); - - remove_filter( $filter['hook'], $filter['callback'] ); - } - } -} diff --git a/tests/phpunit/unit/api/filters/fixtures/test-filters.php b/tests/phpunit/unit/api/filters/fixtures/test-filters.php deleted file mode 100644 index 81c19b31..00000000 --- a/tests/phpunit/unit/api/filters/fixtures/test-filters.php +++ /dev/null @@ -1,41 +0,0 @@ - [ - 'hook' => 'beans_field_description_markup', - 'value_to_return' => 'p', - 'priority' => 10, - 'args' => 1, - ], - 'beans_widget_content_categories_output' => [ - 'hook' => 'beans_widget_content_categories_output', - 'callback' => 'beans_test_modify_widget_count', - 'priority' => 10, - 'args' => 1, - ], - 'beans_test_query_args[_main]' => [ - 'hook' => 'beans_test_query_args[_main]', - 'callback' => 'beans_test_query_args_base', - 'priority' => 20, - 'args' => 1, - ], - 'beans_test_query_args[_main]' => [ - 'hook' => 'beans_test_query_args[_main]', - 'callback' => 'beans_test_query_args_main', - 'priority' => 20, - 'args' => 1, - ], - 'the_content' => [ - 'hook' => 'the_content', - 'callback' => 'beans_test_the_content', - 'priority' => 20, - 'args' => 2, - ], -]; diff --git a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php deleted file mode 100644 index f7350b2d..00000000 --- a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php +++ /dev/null @@ -1,82 +0,0 @@ -mock_filter_callbacks(); - - $this->load_original_functions( [ - 'api/filters/functions.php', - ] ); - } - - /** - * Reset the test fixture. - */ - protected function tearDown() { - - foreach ( static::$test_filters as $beans_id => $filter ) { - - if ( ! isset( $filter['callback'] ) ) { - continue; - } - - remove_filter( $filter['hook'], $filter['callback'], $filter['priority'] ); - } - - parent::tearDown(); - } - - /** - * Define the mocks for the filter callbacks. - */ - protected function mock_filter_callbacks() { - Monkey\Functions\when( 'beans_test_the_content' )->alias( function ( $post_title, $post_id ) { - return $post_title . '_' . $post_id; - } ); - Monkey\Functions\when( 'beans_test_modify_widget_count' )->justReturn( 20 ); - Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( [ 'base' ] ); - Monkey\Functions\when( 'beans_test_query_args_main' )->alias( function ( $args ) { - $args[] = '_main'; - return $args; - } ); - } -} diff --git a/tests/phpunit/unit/api/html/beans-attribute/add.php b/tests/phpunit/unit/api/html/beans-attribute/add.php deleted file mode 100644 index 163705b6..00000000 --- a/tests/phpunit/unit/api/html/beans-attribute/add.php +++ /dev/null @@ -1,75 +0,0 @@ - $markup ) { - // Check that the attribute does not exist before we add it. - $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); - - $actual = ( new _Beans_Attribute( $beans_id, 'data-test', 'foo' ) )->add( $markup['attributes'] ); - - // Check that the attribute is added with the given value. - $expected = $markup['attributes']; - $expected['data-test'] = 'foo'; - $this->assertSame( $expected, $actual ); - } - } - - /** - * Test _Beans_Attribute::add() should add the attribute when an empty array is given. - */ - public function test_should_add_the_attribute_when_empty_array_given() { - - foreach ( array_keys( static::$test_attributes ) as $beans_id ) { - $actual = ( new _Beans_Attribute( $beans_id, 'data-test', 'foo' ) )->add( [] ); - - $this->assertSame( [ 'data-test' => 'foo' ], $actual ); - } - } - - /** - * Test _Beans_Attribute::add() should add the value to an existing attribute's values. - */ - public function test_should_add_value_to_existing_attribute_values() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - - // This test seems silly as we just grabbed the key above. But it's here to make a point that the attribute exists. - $this->assertArrayHasKey( $name, $markup['attributes'] ); - - $actual = ( new _Beans_Attribute( $beans_id, $name, 'beans-test' ) )->add( $markup['attributes'] ); - - // Check that the given value is appended to the end of the existing attribute. - $expected = $markup['attributes']; - $expected[ $name ] .= ' beans-test'; - $this->assertSame( $expected, $actual ); - } - } -} diff --git a/tests/phpunit/unit/api/html/beans-attribute/init.php b/tests/phpunit/unit/api/html/beans-attribute/init.php deleted file mode 100644 index bfaa5f98..00000000 --- a/tests/phpunit/unit/api/html/beans-attribute/init.php +++ /dev/null @@ -1,47 +0,0 @@ -assertNull( $instance->init( 'does_not_exist' ) ); - } - - /** - * Test _Beans_Attribute::init() should register the callback when the method exists. - */ - public function test_should_register_the_callback_when_method_exists() { - $instance = new _Beans_Attribute( 'foo', 'data-test' ); - - Monkey\Functions\expect( 'beans_add_filter' ) - ->with( 'foo_attributes', [ $instance, 'add' ] ) - ->once(); - - $this->assertSame( $instance, $instance->init( 'add' ) ); - } -} diff --git a/tests/phpunit/unit/api/html/beans-attribute/remove.php b/tests/phpunit/unit/api/html/beans-attribute/remove.php deleted file mode 100644 index 939679da..00000000 --- a/tests/phpunit/unit/api/html/beans-attribute/remove.php +++ /dev/null @@ -1,108 +0,0 @@ - $markup ) { - // Check that the attribute does not exist before we run the test. - $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); - - // Run the remove. - $actual = ( new _Beans_Attribute( $beans_id, 'data-test', 'test' ) )->remove( $markup['attributes'] ); - - // Check that the original attributes are returned. - $this->assertSame( $markup['attributes'], $actual ); - } - } - - /** - * Test _Beans_Attribute::remove() should remove the attribute when the given value is null. - */ - public function test_should_remove_attribute_when_value_is_null() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - - // Run the remove. - $actual = ( new _Beans_Attribute( 'beans_test_post', $name ) )->remove( $markup['attributes'] ); - - // Check that the attribute is removed. - $this->assertArrayNotHasKey( $name, $actual ); - - // Check that only that attribute is affected. - $expected = $markup['attributes']; - unset( $expected[ $name ] ); - $this->assertSame( $expected, $actual ); - } - } - - /** - * Test _Beans_Attribute::remove() should remove the given value from the attribute. - */ - public function test_should_remove_the_given_value_from_attribute() { - $attributes = [ - 'id' => 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'https://schema.org/blogPost', - 'itemprop' => 'beans_post', - ]; - - // Run the remove. - $actual = ( new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box' ) )->remove( $attributes ); - - // Check that it removed only that attribute value. - $this->assertNotContains( 'uk-panel-box', $actual['class'] ); - $this->assertSame( 'uk-article category-beans', $actual['class'] ); - - // Check that only the class attribute is affected. - $expected = $attributes; - $expected['class'] = 'uk-article category-beans'; - $this->assertSame( $expected, $actual ); - } - - /** - * Test _Beans_Attribute::remove() should return an empty array when an empty array is given. Why? There is nothing to remove, as there are - * no attributes. - */ - public function test_should_return_empty_array_when_empty_array_given() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $value = current( $markup['attributes'] ); - - // Run the remove. - $actual = ( new _Beans_Attribute( $beans_id, $name, $value ) )->remove( [] ); - - // Check that an empty array is returned. - $this->assertSame( [], $actual ); - } - } -} diff --git a/tests/phpunit/unit/api/html/beans-attribute/replace.php b/tests/phpunit/unit/api/html/beans-attribute/replace.php deleted file mode 100644 index cb1f1186..00000000 --- a/tests/phpunit/unit/api/html/beans-attribute/replace.php +++ /dev/null @@ -1,120 +0,0 @@ - 47, - 'class' => 'uk-article uk-panel-box category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'https://schema.org/blogPost', - 'itemprop' => 'beans_post', - ]; - - $instance = new _Beans_Attribute( 'beans_post', 'class', 'uk-panel-box', 'beans-test' ); - - // Check that the attribute does not contain the new value. - $this->assertNotContains( 'beans-test', $attributes['class'] ); - - // Run the replace. - $actual = $instance->replace( $attributes ); - - // Check that the attribute is added with the given value. - $this->assertContains( 'beans-test', $actual['class'] ); - $this->assertNotContains( 'uk-panel-box', $actual['class'] ); - } - - /** - * Test _Beans_Attribute::replace() should replace (overwrite) all attribute's values with the new value when the target value is - * empty (null, empty string, etc.). - */ - public function test_should_overwrite_attribute_values_with_new_value() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - - // Check when both value and new value are null. - $actual = ( new _Beans_Attribute( 'beans_post', $name ) )->replace( $markup['attributes'] ); - $this->assertNull( $actual[ $name ] ); - - // Check when the value is null. - $actual = ( new _Beans_Attribute( 'beans_post', $name, null, '' ) )->replace( $markup['attributes'] ); - $this->assertSame( '', $actual[ $name ] ); - - // Check when the value is an empty string. - $actual = ( new _Beans_Attribute( 'beans_post', $name, '', 'foo' ) )->replace( $markup['attributes'] ); - $this->assertSame( 'foo', $actual[ $name ] ); - - // Check when the target value is false. - $actual = ( new _Beans_Attribute( 'beans_post', $name, false, 'foo' ) )->replace( $markup['attributes'] ); - $this->assertSame( 'foo', $actual[ $name ] ); - } - } - - /** - * Test _Beans_Attribute::replace() should add the attribute when it does not exists in the given attributes. - */ - public function test_should_add_attribute_when_it_does_not_exist() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - - $instance = new _Beans_Attribute( $beans_id, 'data-test', 'foo', 'beans-test' ); - - // Check that the attribute does not exist. - $this->assertArrayNotHasKey( 'data-test', $markup['attributes'] ); - - // Run the replace. - $actual = $instance->replace( $markup['attributes'] ); - - // Check that the new attribute is added. - $this->assertArrayHasKey( 'data-test', $actual ); - $this->assertSame( 'beans-test', $actual['data-test'] ); - - // Check that only the data-test attribute is affected. - $expected = $markup['attributes']; - $expected['data-test'] = 'beans-test'; - $this->assertSame( $expected, $actual ); - } - } - - /** - * Test _Beans_Attribute::replace() should add the attribute when an empty array is given. - */ - public function test_should_add_attribute_when_an_empty_array_given() { - - foreach ( static::$test_attributes as $beans_id => $markup ) { - $name = key( $markup['attributes'] ); - $value = current( $markup['attributes'] ); - $actual = ( new _Beans_Attribute( $beans_id, $name, $value, 'beans-test' ) )->replace( [] ); - - // Check that it did add the attribute. - $this->assertArrayHasKey( $name, $actual ); - $this->assertSame( [ $name => 'beans-test' ], $actual ); - } - } -} diff --git a/tests/phpunit/unit/api/html/beansAddAttributes.php b/tests/phpunit/unit/api/html/beansAddAttributes.php deleted file mode 100644 index 4a22ae4f..00000000 --- a/tests/phpunit/unit/api/html/beansAddAttributes.php +++ /dev/null @@ -1,93 +0,0 @@ -alias( function( $args ) { - - if ( is_array( $args ) ) { - return $args; - } - - if ( is_object( $args ) ) { - return get_object_vars( $args ); - } - - if ( is_string( $args ) ) { - parse_str( $args, $result ); - - return $result; - } - } ); - } - - /** - * Test beans_add_attributes() should return the built attributes string. - */ - public function test_should_return_built_attributes_string() { - - foreach ( static::$test_attributes as $id => $config ) { - Monkey\Functions\expect( 'beans_apply_filters' ) - ->with( $id . '_attributes', $config['attributes'] ) - ->once() - ->andReturn( $config['attributes'] ); - - $expected = $this->convert_attributes_into_html( $config['attributes'] ); - $this->assertSame( $expected, beans_add_attributes( $id, $config['attributes'] ) ); - } - } - - /** - * Test beans_add_attributes() should return an empty string when no attributes are given. - */ - public function test_should_return_empty_string_when_no_attributes() { - Monkey\Functions\expect( 'beans_apply_filters' ) - ->with( 'foo_attributes', [] ) - ->times( 4 ) - ->andReturn( [] ); - - $this->assertSame( '', beans_add_attributes( 'foo' ) ); - $this->assertSame( '', beans_add_attributes( 'foo', null ) ); - $this->assertSame( '', beans_add_attributes( 'foo', '' ) ); - $this->assertSame( '', beans_add_attributes( 'foo', false ) ); - } - - /** - * Test beans_add_attributes() should pass additional arguments when given. - */ - public function test_should_pass_additional_arguments_when_given() { - $attributes = [ 'class' => 'foo' ]; - Monkey\Functions\expect( 'beans_apply_filters' ) - ->with( 'foo_attributes', $attributes, 14, 'hi' ) - ->once() - ->andReturn( $attributes ); - - $this->assertSame( 'class="foo"', beans_add_attributes( 'foo', $attributes, 14, 'hi' ) ); - } -} diff --git a/tests/phpunit/unit/api/html/beansBuildSkipLinks.php b/tests/phpunit/unit/api/html/beansBuildSkipLinks.php deleted file mode 100644 index cf8e1a42..00000000 --- a/tests/phpunit/unit/api/html/beansBuildSkipLinks.php +++ /dev/null @@ -1,69 +0,0 @@ -once()->andReturn( 'c_sp' ); - Monkey\Functions\expect( 'has_nav_menu' ) - ->once() - ->with( 'primary' ) - ->andReturn( 'true' ); - Monkey\Functions\expect( 'beans_has_primary_sidebar' ) - ->once() - ->with( 'c_sp' ) - ->andReturn( true ); - Monkey\Functions\expect( 'beans_has_secondary_sidebar' ) - ->once() - ->with( 'c_sp' ) - ->andReturn( false ); - Monkey\Functions\expect( 'beans_output_skip_links' ) - ->once() - ->andReturn(); - - $this->assertNull( beans_build_skip_links() ); - } - - /** - * Test beans_build_skip_links() should not call beans_has_primary_sidebar() or beans_has_secondary_sidebar() when the layout is full-width. - */ - public function test_should_not_call_beans_has_primary_sidebar_or_beans_has_secondary_sidebara_when_fullwith_layout() { - Monkey\Functions\expect( 'beans_get_layout' )->once()->andReturn( 'c' ); - Monkey\Functions\expect( 'has_nav_menu' ) - ->once() - ->with( 'primary' ) - ->andReturn( 'true' ); - Monkey\Functions\expect( 'beans_has_primary_sidebar' )->never(); - Monkey\Functions\expect( 'beans_has_secondary_sidebar' )->never(); - - Monkey\Functions\expect( 'beans_output_skip_links' ) - ->once() - ->andReturn(); - - $this->assertNull( beans_build_skip_links() ); - } - -} diff --git a/tests/phpunit/unit/api/html/beansCloseMarkup.php b/tests/phpunit/unit/api/html/beansCloseMarkup.php deleted file mode 100644 index 22dc98c1..00000000 --- a/tests/phpunit/unit/api/html/beansCloseMarkup.php +++ /dev/null @@ -1,135 +0,0 @@ -once() - ->with( 'beans_archive_title_markup', null ) - ->andReturnNull(); - - $this->assertNull( beans_close_markup( 'beans_archive_title', null ) ); - } - - /** - * Test beans_close_markup() should fire "{$id}_append_markup" hooks and include the content in the returned HTML. - */ - public function test_should_fire_append_markup_hooks_and_include_content_in_returned_html() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\expect( '_beans_render_action' ) - ->once() - ->with( 'beans_archive_title_append_markup' ) - ->andReturn( '' ); - - $actual = beans_close_markup( 'beans_archive_title', 'h1' ); - $this->assertStringStartsWith( '', $actual ); - } - - /** - * Test beans_close_markup() should fire "{$id}_after_markup" hooks and include the content in the returned HTML. - */ - public function test_should_fire_after_markup_hooks_and_include_content_in_returned_html() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\expect( '_beans_render_action' ) - ->once() - ->with( 'beans_archive_title_after_markup' ) - ->andReturn( '' ); - - $actual = beans_close_markup( 'beans_archive_title', 'h1' ); - $this->assertStringEndsWith( '', $actual ); - } - - /** - * Test beans_close_markup() should return the closing tag only when a callback is not registered to either the - * "_append_markup" or "_after_markup" hook. - */ - public function test_should_return_closing_tag_when_callback_not_registered_to_either_hook() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); - - $this->assertSame( '', beans_close_markup( 'beans_archive_title', 'h1' ) ); - } - - /** - * Test beans_close_markup() should return the append, tag, and after HTML when callbacks are registered - * to the "_append_markup" and "_after_markup" hooks. - */ - public function test_should_return_built_html_when_callback_registered_to_hooks() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\expect( '_beans_render_action' ) - ->once() - ->with( 'beans_archive_title_append_markup' ) - ->ordered() - ->andReturn( '' ) - ->andAlsoExpectIt() - ->once() - ->with( 'beans_archive_title_after_markup' ) - ->ordered() - ->andReturn( '' ); - - $actual = beans_close_markup( 'beans_archive_title', 'h1' ); - $expected = << -EOB; - $this->assertSame( $expected, $actual ); - } - - /** - * Test beans_close_markup() should return an empty string when (1) the tag is an empty string and (2) a callback - * is not registered to either the "_append_markup" or "_after_markup" hook. - */ - public function test_should_return_empty_string_when_empty_tag_and_callback_not_registered_to_hooks() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); - - $this->assertSame( '', beans_close_markup( 'beans_archive_title', '' ) ); - } - - /** - * Test beans_close_markup() should return the hooked callbacks' output and not the closing tag when - * the tag is empty. - */ - public function test_should_return_hooked_callbacks_output_and_not_closing_tag_when_tag_is_empty() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\expect( '_beans_render_action' ) - ->twice() - ->with( 'beans_archive_title_append_markup' ) - ->andReturn( '' ) - ->andAlsoExpectIt() - ->twice() - ->with( 'beans_archive_title_after_markup' ) - ->andReturn( '' ); - - // Check with an empty string. - $actual = beans_close_markup( 'beans_archive_title', '' ); - $this->assertSame( '', $actual ); - - // Check with false. - $actual = beans_close_markup( 'beans_archive_title', false ); - $this->assertSame( '', $actual ); - } -} diff --git a/tests/phpunit/unit/api/html/beansCloseMarkupE.php b/tests/phpunit/unit/api/html/beansCloseMarkupE.php deleted file mode 100644 index efa06cc9..00000000 --- a/tests/phpunit/unit/api/html/beansCloseMarkupE.php +++ /dev/null @@ -1,80 +0,0 @@ -once() - ->with( 'beans_archive_title_markup', null ) - ->andReturnNull(); - - ob_start(); - beans_close_markup_e( 'beans_archive_title', null ); - $this->assertEquals( '', ob_get_clean() ); - } - - /** - * Test beans_close_markup_e() should echo the closing tag only when a callback is not registered to either the - * "_append_markup" or "_after_markup" hook. - */ - public function test_should_echo_closing_tag_when_callback_not_registered_to_either_hook() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); - - ob_start(); - beans_close_markup_e( 'beans_archive_title', 'h1' ); - $this->assertSame( '', ob_get_clean() ); - } - - /** - * Test beans_close_markup_e() should echo the append, tag, and after HTML when callbacks are registered - * to the "_append_markup" and "_after_markup" hooks. - */ - public function test_should_echo_built_html_when_append_and_after_hooks() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\expect( '_beans_render_action' ) - ->once() - ->with( 'beans_archive_title_append_markup' ) - ->ordered() - ->andReturn( '' ) - ->andAlsoExpectIt() - ->once() - ->with( 'beans_archive_title_after_markup' ) - ->ordered() - ->andReturn( '' ); - - ob_start(); - beans_close_markup_e( 'beans_archive_title', 'h1' ); - $actual = ob_get_clean(); - - $expected = << -EOB; - // Run test. - $this->assertSame( $expected, $actual ); - } -} diff --git a/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php b/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php deleted file mode 100644 index 3114d4af..00000000 --- a/tests/phpunit/unit/api/html/beansIsHtmlDevMode.php +++ /dev/null @@ -1,68 +0,0 @@ -assertFalse( defined( 'BEANS_HTML_DEV_MODE' ) ); - - Monkey\Functions\expect( 'get_option' ) - ->with( 'beans_dev_mode', false ) - ->once() - ->andReturn( false ); - - $this->assertFalse( _beans_is_html_dev_mode() ); - } - - /** - * Test _beans_is_html_dev_mode() should return the option's value. - */ - public function test_should_return_option_value() { - Monkey\Functions\expect( 'get_option' ) - ->with( 'beans_dev_mode', false ) - ->once() - ->andReturn( 0 ); - - $this->assertFalse( _beans_is_html_dev_mode() ); - - Monkey\Functions\expect( 'get_option' ) - ->with( 'beans_dev_mode', false ) - ->once() - ->andReturn( 1 ); - - $this->assertTrue( _beans_is_html_dev_mode() ); - } - - /** - * Test _beans_is_html_dev_mode() should return the constant's value. - */ - public function test_should_return_constant_value() { - Monkey\Functions\expect( 'get_option' )->never(); - - define( 'BEANS_HTML_DEV_MODE', 0 ); - $this->assertFalse( _beans_is_html_dev_mode() ); - } -} diff --git a/tests/phpunit/unit/api/html/beansModifyMarkup.php b/tests/phpunit/unit/api/html/beansModifyMarkup.php deleted file mode 100644 index fdaeebc5..00000000 --- a/tests/phpunit/unit/api/html/beansModifyMarkup.php +++ /dev/null @@ -1,59 +0,0 @@ -alias( function( $hook, $value ) { - return new Anonymous_Filter_Stub( $hook, $value, 10 ); - } ); - - $this->assertInstanceOf( Anonymous_Filter_Stub::class, beans_modify_markup( 'beans_archive_title', 'h2' ) ); - } - - /** - * Test beans_modify_markup() should call beans_add_filter() to register the callback for the modification process. - */ - public function test_should_call_beans_add_filter_to_register_callback() { - Monkey\Functions\expect( 'beans_add_filter' ) - ->once() - ->with( 'beans_archive_title_markup', 'h2', 10, 1 ); - beans_modify_markup( 'beans_archive_title', 'h2' ); - - // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. - $this->assertTrue( true ); - } -} diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php deleted file mode 100644 index 2fad6d00..00000000 --- a/tests/phpunit/unit/api/html/beansOpenMarkup.php +++ /dev/null @@ -1,212 +0,0 @@ -once() - ->with( 'beans_archive_title_markup', null ) - ->andReturnNull(); - - $this->assertNull( beans_open_markup( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ) ); - } - - /** - * Test beans_open_markup() should fire "{$id}_before_markup" hooks and include the content in the returned HTML. - */ - public function test_should_fire_before_markup_hooks_and_include_content_in_returned_html() { - Monkey\Functions\when( 'beans_add_attributes' )->justReturn( 'class="uk-article-title"' ); - Monkey\Functions\when( '_beans_is_html_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( '_beans_render_action' ) - ->once() - ->with( 'beans_archive_title_before_markup' ) - ->andReturn( '' ); - - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertStringStartsWith( '', $actual ); - } - - /** - * Test beans_open_markup() should fire "{$id}_prepend_markup" hooks and include the content in the returned HTML. - */ - public function test_should_fire_prepend_markup_hooks_and_include_content_in_returned_html() { - Monkey\Functions\when( 'beans_add_attributes' )->justReturn( 'class="uk-article-title"' ); - Monkey\Functions\when( '_beans_is_html_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( '_beans_render_action' ) - ->once() - ->with( 'beans_archive_title_prepend_markup' ) - ->andReturn( '' ); - - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertStringEndsWith( '', $actual ); - } - - /** - * Test beans_open_markup() should fire _beans_render_action() for the "_after_markup" hooks when the global - * $_beans_is_selfclose_markup is set to true. - */ - public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { - Monkey\Functions\when( 'beans_add_attributes' )->justReturn( 'class="uk-article-title"' ); - Monkey\Functions\when( '_beans_is_html_dev_mode' )->justReturn( false ); - Monkey\Functions\expect( '_beans_render_action' ) - ->once() - ->with( 'beans_archive_title_after_markup' ) - ->andReturn( 'Worked!' ); - - global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; - - $this->assertContains( 'Worked!', beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ) ); - - // Check that the global was unset. - $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); - } - - /** - * Test beans_open_markup() should return the built HTML element when before or prepend hooks are not registered. - */ - public function test_should_return_built_html_when_before_or_prepend_hooks_not_registered() { - Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); - Monkey\Functions\expect( 'beans_add_attributes' ) - ->once() - ->with( 'beans_archive_title', [ 'class' => 'uk-article-title' ] ) - ->andReturn( 'class="uk-article-title"' ); - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); - - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '

                ', $actual ); - } - - /** - * Test beans_open_markup() should return the built HTML element with the "data-markup-id" when in development mode. - */ - public function test_should_return_built_html_with_data_markup_id_when_in_dev_mode() { - Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); - Monkey\Functions\expect( 'beans_add_attributes' ) - ->once() - ->with( 'beans_archive_title', [ 'class' => 'uk-article-title' ] ) - ->andReturn( 'class="uk-article-title"' ); - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( true ); - - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '

                ', $actual ); - } - - /** - * Test beans_open_markup() should return the built HTML when before or prepend hooks are registered. - */ - public function test_should_return_built_html_when_before_or_prepend_hooks() { - Monkey\Functions\expect( 'beans_add_attributes' ) - ->once() - ->with( 'beans_archive_title', [ 'class' => 'uk-article-title' ] ) - ->andReturn( 'class="uk-article-title"' ); - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); - Monkey\Functions\expect( '_beans_render_action' ) - ->once() - ->with( 'beans_archive_title_before_markup' ) - ->andReturn( '' ) - ->andAlsoExpectIt() - ->once() - ->with( 'beans_archive_title_prepend_markup' ) - ->andReturn( '' ); - - $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); - $expected = <<

                -EOB; - $this->assertSame( $expected, $actual ); - } - - /** - * Test beans_open_markup() should return a built self-closing HTML element when the global - * $_beans_is_selfclose_markup is set to true. - */ - public function test_should_return_built_self_closing_html_when_selfclose_markup_is_true() { - $args = [ - 'width' => 800, - 'height' => 500, - 'src' => 'http://example.com/image.png', - 'alt' => 'Some image', - 'itemprop' => 'image', - ]; - - Monkey\Functions\when( '_beans_render_action' )->justReturn( '' ); - Monkey\Functions\expect( 'beans_add_attributes' ) - ->twice() - ->with( 'beans_post_image_item', $args, 'http://example.com/image.png' ) - ->andReturnUsing( function( $id, $attributes ) { - return $this->convert_attributes_into_html( $attributes ); - } ); - - // Run it with development mode off. - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); - global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; - - $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); - $expected = << -EOB; - $this->assertSame( $expected, $actual ); - - // Run it with development mode on. - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( true ); - global $_beans_is_selfclose_markup; - $_beans_is_selfclose_markup = true; - - $actual = beans_open_markup( 'beans_post_image_item', 'img', $args, 'http://example.com/image.png' ); - $expected = << -EOB; - $this->assertSame( $expected, $actual ); - } - - /** - * Test beans_open_markup() should return only the output from the hooked callbacks and not the HTML element when - * the tag is empty. - */ - public function test_should_return_only_hooked_callbacks_output_and_no_html_element_when_tag_is_empty() { - Monkey\Functions\expect( 'beans_add_attributes' )->never(); - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->never(); - Monkey\Functions\expect( '_beans_render_action' ) - ->twice() - ->with( 'beans_archive_title_before_markup' ) - ->andReturn( '' ) - ->andAlsoExpectIt() - ->twice() - ->with( 'beans_archive_title_prepend_markup' ) - ->andReturn( '' ); - - // Check with an empty string. - $actual = beans_open_markup( 'beans_archive_title', '', [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '', $actual ); - - // Check with false. - $actual = beans_open_markup( 'beans_archive_title', false, [ 'class' => 'uk-article-title' ] ); - $this->assertSame( '', $actual ); - } -} diff --git a/tests/phpunit/unit/api/html/beansOpenMarkupE.php b/tests/phpunit/unit/api/html/beansOpenMarkupE.php deleted file mode 100644 index cceedfa3..00000000 --- a/tests/phpunit/unit/api/html/beansOpenMarkupE.php +++ /dev/null @@ -1,54 +0,0 @@ -once() - ->with( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ) - ->andReturn( null ); - - ob_start(); - beans_open_markup_e( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ); - $this->assertEquals( '', ob_get_clean() ); - } - - /** - * Test beans_open_markup_e() should echo the HTML element only when before or prepend hooks are not registered. - */ - public function test_should_echo_html_element_when_hooks_not_registered() { - Monkey\Functions\expect( 'beans_open_markup' ) - ->once() - ->with( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ) - ->andReturn( '

                ' ); - - // Run the tests. - ob_start(); - beans_open_markup_e( 'beans_archive_title', null, [ 'class' => 'uk-article-title' ] ); - $this->assertEquals( '

                ', ob_get_clean() ); - } -} diff --git a/tests/phpunit/unit/api/html/beansOutput.php b/tests/phpunit/unit/api/html/beansOutput.php deleted file mode 100644 index 62c28ebe..00000000 --- a/tests/phpunit/unit/api/html/beansOutput.php +++ /dev/null @@ -1,118 +0,0 @@ -times( 3 )->andReturnUsing( function( $hook, $output ) { - return $output; - } ); - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->never(); - - $this->assertNull( beans_output( 'beans_post_meta_item_date', null ) ); - $this->assertNull( beans_output( 'beans_post_meta_item_author', '' ) ); - $this->assertNull( beans_output( 'beans_post_meta_item_comments', false ) ); - } - - /** - * Test beans_output() should return the filtered output after firing the "{$id}_output" filter hook. - */ - public function test_should_return_filtered_output_after_firing_output_filter_hook() { - // Check the applied filter. - Monkey\Filters\expectApplied( 'beans_archive_title_text_output' ) - ->once() - ->with( 'Beans rocks!' ) - ->andReturn( 'WooHoo, I fired!' ); - - // Setup beans_apply_filters() mock to fire apply_filters(). - Monkey\Functions\expect( 'beans_apply_filters' ) - ->once() - ->with( 'beans_archive_title_text_output', 'Beans rocks!' ) - ->andReturnUsing( function( $hook, $output ) { - return apply_filters( $hook, $output ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Prefix is in the value represented by the variable. - } ); - - // Check with HTML dev mode disabled. - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); - - // Run the tests. - $this->assertSame( 'WooHoo, I fired!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); - $this->assertSame( 1, Monkey\Filters\applied( 'beans_archive_title_text_output' ) ); - } - - /** - * Test beans_output() should return the output when not in HTML dev mode. - */ - public function test_should_return_output_when_not_in_html_dev_mode() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); - - $this->assertSame( 'Beans rocks!', beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); - } - - /** - * Test beans_output() should return the "comment wrapped" HTML when in HTML dev mode. - */ - public function test_should_return_comment_wrapped_html_when_in_html_dev_mode() { - Monkey\Functions\when( 'beans_apply_filters' )->returnArg( 2 ); - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( true ); - - $expected = <<Beans rocks! -EOB; - $this->assertSame( $expected, beans_output( 'beans_archive_title_text', 'Beans rocks!' ) ); - } - - /** - * Test beans_output() should pass the additional arguments when firing the filter hook. - */ - public function test_should_pass_additional_args_when_firing_filter_hook() { - // Check that beans_apply_filters() is called as expected. - Monkey\Functions\expect( 'beans_apply_filters' ) - ->twice() - ->with( 'beans_breadcrumb_item_text_output', 'Beans rocks!', 47, 'Hello' ) - ->andReturnUsing( function( $hook, $output ) { - return $output; - } ); - - // Check with HTML dev mode disabled. - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); - $this->assertSame( - 'Beans rocks!', - beans_output( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) - ); - - // Check with HTML dev mode enabled. - $expected = <<Beans rocks! -EOB; - Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( true ); - $this->assertSame( - $expected, - beans_output( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) - ); - } -} diff --git a/tests/phpunit/unit/api/html/beansOutputE.php b/tests/phpunit/unit/api/html/beansOutputE.php deleted file mode 100644 index 230bf1e1..00000000 --- a/tests/phpunit/unit/api/html/beansOutputE.php +++ /dev/null @@ -1,114 +0,0 @@ -times( 3 )->andReturnUsing( function( $id, $output ) { - return $output; - } ); - - $ids = [ - 'beans_post_meta_item_date' => null, - 'beans_post_meta_item_author' => '', - 'beans_post_meta_item_comments' => false, - ]; - - foreach ( $ids as $id => $output ) { - ob_start(); - beans_output_e( $id, $output ); - $this->assertEmpty( ob_get_clean() ); - } - } - - /** - * Test beans_output_e() should echo the filtered output. - */ - public function test_should_echo_the_filtered_output() { - Monkey\Functions\expect( 'beans_output' ) - ->once() - ->with( 'beans_archive_title_text', 'Beans rocks!' ) - ->andReturn( 'WooHoo, I fired!' ); - - // Run the tests. - ob_start(); - beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); - $this->assertSame( 'WooHoo, I fired!', ob_get_clean() ); - } - - /** - * Test beans_output_e() should echo the output when not in HTML dev mode. - */ - public function test_should_echo_output_when_not_in_html_dev_mode() { - Monkey\Functions\expect( 'beans_output' ) - ->once() - ->with( 'beans_archive_title_text', 'Beans rocks!' ) - ->andReturnUsing( function( $id, $output ) { - return $output; - } ); - - ob_start(); - beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); - $this->assertSame( 'Beans rocks!', ob_get_clean() ); - } - - /** - * Test beans_output_e() should echo the "comment wrapped" HTML when in HTML dev mode. - */ - public function test_should_echo_comment_wrapped_html_when_in_html_dev_mode() { - Monkey\Functions\expect( 'beans_output' ) - ->once() - ->with( 'beans_archive_title_text', 'Beans rocks!' ) - ->andReturnUsing( function( $id, $output ) { - return "" . $output . ""; - } ); - - ob_start(); - beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); - $actual = ob_get_clean(); - - $expected = <<Beans rocks! -EOB; - $this->assertSame( $expected, $actual ); - } - - /** - * Test beans_output_e() should pass the additional arguments when firing the filter hook. - */ - public function test_should_pass_additional_args() { - Monkey\Functions\expect( 'beans_output' ) - ->once() - ->with( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) - ->andReturnUsing( function( $id, $output, $arg1, $arg2 ) { - return $arg2; - } ); - - ob_start(); - beans_output_e( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ); - $this->assertSame( 'Hello', ob_get_clean() ); - } -} diff --git a/tests/phpunit/unit/api/html/beansRemoveMarkup.php b/tests/phpunit/unit/api/html/beansRemoveMarkup.php deleted file mode 100644 index 93b48ac3..00000000 --- a/tests/phpunit/unit/api/html/beansRemoveMarkup.php +++ /dev/null @@ -1,64 +0,0 @@ -alias( function( $hook, $value ) { - return new Anonymous_Filter_Stub( $hook, $value, 10 ); - } ); - - $this->assertInstanceOf( Anonymous_Filter_Stub::class, beans_remove_markup( 'beans_archive_title' ) ); - } - - /** - * Test beans_remove_markup() should call beans_add_filter() to register the callback for the remove process. - */ - public function test_should_call_beans_add_filter_to_register_callback() { - Monkey\Functions\expect( 'beans_add_filter' ) - ->once() - ->with( 'beans_archive_title_markup', false ); - beans_remove_markup( 'beans_archive_title' ); - - Monkey\Functions\expect( 'beans_add_filter' ) - ->once() - ->with( 'beans_archive_title_markup', null ); - beans_remove_markup( 'beans_archive_title', true ); - - // Tests are focused above on ensuring beans_add_filter() is called with the right arguments. - $this->assertTrue( true ); - } -} diff --git a/tests/phpunit/unit/api/html/beansRemoveOutput.php b/tests/phpunit/unit/api/html/beansRemoveOutput.php deleted file mode 100644 index df03be4e..00000000 --- a/tests/phpunit/unit/api/html/beansRemoveOutput.php +++ /dev/null @@ -1,69 +0,0 @@ -alias( function( $hook, $value, $priority ) { - return new Anonymous_Filter_Stub( $hook, $value, $priority ); - } ); - - $this->assertInstanceOf( Anonymous_Filter_Stub::class, beans_remove_output( 'beans_post_meta_item_date' ) ); - } - - /** - * Test beans_remove_output() should call beans_add_filter() to register the callback for the remove process. - */ - public function test_should_call_beans_add_filter_to_register_callback() { - $ids = [ - 'beans_post_meta_item_date', - 'beans_post_meta_item_author', - 'beans_post_meta_item_comments', - ]; - - foreach ( $ids as $id ) { - Monkey\Functions\expect( 'beans_add_filter' ) - ->once() - ->with( "{$id}_output", false, 99999999 ) - ->andReturn( false ); - - beans_remove_output( $id ); - } - - // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. - $this->assertTrue( true ); - } -} diff --git a/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php b/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php deleted file mode 100644 index fea702a0..00000000 --- a/tests/phpunit/unit/api/html/beansSelfcloseMarkup.php +++ /dev/null @@ -1,60 +0,0 @@ -justReturn(); - - foreach ( static::$test_attachments as $attachment ) { - // Check before we start. - $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); - - beans_selfclose_markup( $attachment['id'], null, $attachment['attributes'], $attachment['attachment'] ); - - // Check after we run the function. - $this->assertArrayNotHasKey( '_beans_is_selfclose_markup', $GLOBALS ); - } - } - - /** - * Test beans_selfclose_markup() should invoke beans_open_markup(). - */ - public function test_should_invoke_beans_open_markup() { - - foreach ( static::$test_attachments as $attachment ) { - Monkey\Functions\expect( 'beans_open_markup' ) - ->once() - ->with( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ) - ->andReturnNull(); - - beans_selfclose_markup( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ); - } - - // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. - $this->assertTrue( true ); - } -} diff --git a/tests/phpunit/unit/api/html/beansSelfcloseMarkupE.php b/tests/phpunit/unit/api/html/beansSelfcloseMarkupE.php deleted file mode 100644 index a1b1a165..00000000 --- a/tests/phpunit/unit/api/html/beansSelfcloseMarkupE.php +++ /dev/null @@ -1,45 +0,0 @@ -once() - ->with( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ) - ->andReturnNull(); - - ob_start(); - beans_selfclose_markup_e( $attachment['id'], $attachment['tag'], $attachment['attributes'], $attachment['attachment'] ); - ob_get_clean(); - } - - // Placeholder for PHPUnit, as it requires an assertion. The real test is the "expect" above. - $this->assertTrue( true ); - } -} diff --git a/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php b/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php deleted file mode 100644 index c6d30169..00000000 --- a/tests/phpunit/unit/api/html/beansWrapInnerMarkup.php +++ /dev/null @@ -1,180 +0,0 @@ -assertFalse( beans_wrap_inner_markup( 'foo', 'new_foo', null ) ); - $this->assertFalse( beans_wrap_inner_markup( 'bar', 'new_bar', '' ) ); - $this->assertFalse( beans_wrap_inner_markup( 'baz', 'new_baz', false, [ 'class' => 'test-wrap' ] ) ); - } - - /** - * Test beans_wrap_inner_markup() should register beans_open_markup() to the given ID's '_prepend_markup' hook. - */ - public function test_should_register_beans_open_markup_to_given_id_prepend_markup_hook() { - // Set up the tests. - $args = [ - 'beans_open_markup', - [ - 1 => 'new_foo', - 2 => 'div', - 3 => [ 'class' => 'test-wrap' ], - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_prepend_markup', $args, 1 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'foo_prepend_markup', $args, 1 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); - $this->assertTrue( has_action( 'foo_prepend_markup', [ $anonymous_action_mock, 'callback' ] ) ); - - // Clean up. - remove_action( 'foo_prepend_markup', [ $anonymous_action_mock, 'callback' ], 1 ); - } - - /** - * Test beans_wrap_inner_markup() should register beans_close_markup() to the given ID's '_append_markup' hook. - */ - public function test_should_register_beans_close_markup_to_given_id_append_markup_hook() { - // Set up the tests. - $args = [ - 'beans_close_markup', - [ - 1 => 'new_foo', - 2 => 'div', - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_append_markup', $args, 9999 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'foo_append_markup', $args, 9999 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); - $this->assertTrue( has_action( 'foo_append_markup', [ $anonymous_action_mock, 'callback' ] ) ); - - // Clean up. - remove_action( 'foo_append_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); - } - - /** - * Test beans_wrap_inner_markup() should not pass the given attributes to anonymous action. - */ - public function test_should_not_pass_attributes_for_append_markup_hook() { - // Set up the tests. - $args = [ - 'beans_close_markup', - [ - 1 => 'new_no_atts', - 2 => 'div', - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'no_atts_append_markup', $args, 9999 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'no_atts_append_markup', $args, 9999 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'no_atts', 'new_no_atts', 'div', [ 'class' => 'test-wrap' ] ) ); - $this->assertSame( $args, $anonymous_action_mock->callback ); - - // Clean up. - remove_action( 'no_atts_append_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); - } - - /** - * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's '_prepend_markup' hook. - */ - public function test_should_pass_extra_arguments_for_prepend_markup_hook() { - // Set up the tests. - $args = [ - 'beans_open_markup', - [ - 1 => 'new_extra_args', - 2 => 'div', - 3 => [ 'class' => 'test-wrap' ], - 4 => 47, - 5 => 'Beans Rocks!', - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_prepend_markup', $args, 1 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'extra_args_prepend_markup', $args, 1 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', [ 'class' => 'test-wrap' ], 47, 'Beans Rocks!' ) ); - $this->assertSame( $args, $anonymous_action_mock->callback ); - - // Clean up. - remove_action( 'extra_args_prepend_markup', [ $anonymous_action_mock, 'callback' ], 1 ); - } - - /** - * Test beans_wrap_inner_markup() should pass the extra arguments to the anonymous action for the given ID's '_append_markup' hook. - */ - public function test_should_pass_extra_arguments_for_append_markup_hook() { - // Set up the tests. - $args = [ - 'beans_close_markup', - [ - 1 => 'new_extra_args', - 2 => 'div', - 4 => 'Beans Rocks!', - 5 => 47, - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_append_markup', $args, 9999 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'extra_args_append_markup', $args, 9999 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_inner_markup( 'extra_args', 'new_extra_args', 'div', [ 'class' => 'test-wrap' ], 'Beans Rocks!', 47 ) ); - $this->assertSame( $args, $anonymous_action_mock->callback ); - - // Clean up. - remove_action( 'extra_args_append_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); - } -} diff --git a/tests/phpunit/unit/api/html/beansWrapMarkup.php b/tests/phpunit/unit/api/html/beansWrapMarkup.php deleted file mode 100644 index 65b59634..00000000 --- a/tests/phpunit/unit/api/html/beansWrapMarkup.php +++ /dev/null @@ -1,180 +0,0 @@ -assertFalse( beans_wrap_markup( 'foo', '', null ) ); - $this->assertFalse( beans_wrap_markup( 'foo', '', '' ) ); - $this->assertFalse( beans_wrap_markup( 'foo', '', false, [ 'class' => 'test-wrap' ] ) ); - } - - /** - * Test beans_wrap_markup() should register beans_open_markup() to the given ID's '_before_markup' hook. - */ - public function test_should_register_beans_open_markup_to_given_id_before_markup_hook() { - // Set up the tests. - $args = [ - 'beans_open_markup', - [ - 1 => 'new_foo', - 2 => 'div', - 3 => [ 'class' => 'test-wrap' ], - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_before_markup', $args, 9999 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'foo_before_markup', $args, 9999 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); - $this->assertTrue( has_action( 'foo_before_markup', [ $anonymous_action_mock, 'callback' ] ) ); - - // Clean up. - remove_action( 'foo_before_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); - } - - /** - * Test beans_wrap_markup() should register beans_close_markup() to the given ID's '_after_markup' hook. - */ - public function test_should_register_beans_close_markup_to_given_id_after_markup_hook() { - // Set up the tests. - $args = [ - 'beans_close_markup', - [ - 1 => 'new_foo', - 2 => 'div', - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'foo_after_markup', $args, 1 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'foo_after_markup', $args, 1 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_markup( 'foo', 'new_foo', 'div', [ 'class' => 'test-wrap' ] ) ); - $this->assertTrue( has_action( 'foo_after_markup', [ $anonymous_action_mock, 'callback' ] ) ); - - // Clean up. - remove_action( 'foo_after_markup', [ $anonymous_action_mock, 'callback' ], 1 ); - } - - /** - * Test beans_wrap_markup() should not pass the given attributes to anonymous action. - */ - public function test_should_not_pass_attributes_for_after_markup_hook() { - // Set up the tests. - $args = [ - 'beans_close_markup', - [ - 1 => '', - 2 => 'div', - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'no_atts_after_markup', $args, 1 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'no_atts_after_markup', $args, 1 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_markup( 'no_atts', '', 'div', [ 'class' => 'test-wrap' ] ) ); - $this->assertSame( $args, $anonymous_action_mock->callback ); - - // Clean up. - remove_action( 'no_atts_after_markup', [ $anonymous_action_mock, 'callback' ], 1 ); - } - - /** - * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's '_before_markup' hook. - */ - public function test_should_pass_extra_arguments_for_before_markup_hook() { - // Set up the tests. - $args = [ - 'beans_open_markup', - [ - 1 => '', - 2 => 'div', - 3 => [ 'class' => 'test-wrap' ], - 4 => 47, - 5 => 'Beans Rocks!', - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_before_markup', $args, 9999 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'extra_args_before_markup', $args, 9999 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_markup( 'extra_args', '', 'div', [ 'class' => 'test-wrap' ], 47, 'Beans Rocks!' ) ); - $this->assertSame( $args, $anonymous_action_mock->callback ); - - // Clean up. - remove_action( 'extra_args_before_markup', [ $anonymous_action_mock, 'callback' ], 9999 ); - } - - /** - * Test beans_wrap_markup() should pass the extra arguments to the anonymous action for the given ID's '_after_markup' hook. - */ - public function test_should_pass_extra_arguments_for_after_markup_hook() { - // Set up the tests. - $args = [ - 'beans_close_markup', - [ - 1 => '', - 2 => 'div', - 4 => 'Beans Rocks!', - 5 => 47, - ], - ]; - $anonymous_action_mock = new Anonymous_Action_Stub( 'extra_args_after_markup', $args, 1 ); - Monkey\Functions\expect( '_beans_add_anonymous_action' ) - ->once() - ->with( 'extra_args_after_markup', $args, 1 ) - ->andReturn( $anonymous_action_mock ); - - // Run the tests. - $this->assertTrue( beans_wrap_markup( 'extra_args', '', 'div', [ 'class' => 'test-wrap' ], 'Beans Rocks!', 47 ) ); - $this->assertSame( $args, $anonymous_action_mock->callback ); - - // Clean up. - remove_action( 'extra_args_after_markup', [ $anonymous_action_mock, 'callback' ], 1 ); - } -} diff --git a/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php b/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php deleted file mode 100644 index 3349ffb4..00000000 --- a/tests/phpunit/unit/api/html/fixtures/class-anonymous-action-stub.php +++ /dev/null @@ -1,45 +0,0 @@ -callback = $callback; - - add_action( $hook, [ $this, 'callback' ], $priority ); - } - - /** - * Mocked callback. - */ - public function callback() { - // do nothing. - } -} diff --git a/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php b/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php deleted file mode 100644 index 03b5e77c..00000000 --- a/tests/phpunit/unit/api/html/fixtures/class-anonymous-filter-stub.php +++ /dev/null @@ -1,45 +0,0 @@ -value_to_return = $value_to_return; - - add_filter( $hook, [ $this, 'callback' ], $priority ); - } - - /** - * Mocked callback. - */ - public function callback() { - return $this->value_to_return; - } -} diff --git a/tests/phpunit/unit/api/html/fixtures/test-attachment.php b/tests/phpunit/unit/api/html/fixtures/test-attachment.php deleted file mode 100644 index 967b2fbc..00000000 --- a/tests/phpunit/unit/api/html/fixtures/test-attachment.php +++ /dev/null @@ -1,50 +0,0 @@ - 'beans_post_image_small_item', - 'tag' => 'source', - 'attributes' => [ - 'media' => '(max-width: 200px)', - 'srcset' => 'https://example.com/small-image.png', - ], - 'attachment' => (object) [ - 'id' => 47, - 'src' => 'https://example.com/small-image.png', - 'width' => 200, - 'height' => 200, - 'alt' => 'Small image', - 'title' => 'This is a post title.', - 'caption' => 'This is the caption.', - 'description' => 'This is the description.', - ], - ], - [ - 'id' => 'beans_post_image_item', - 'tag' => 'img', - 'attributes' => [ - 'width' => 1200, - 'height' => 600, - 'src' => 'https://example.com/image.png', - 'alt' => 'A background image.', - 'itemprop' => 'image', - ], - 'attachment' => (object) [ - 'id' => 1047, - 'src' => 'https://example.com/image.png', - 'width' => 1200, - 'height' => 600, - 'alt' => 'A background image.', - 'title' => 'This is a post title.', - 'caption' => 'This is the caption.', - 'description' => 'This is the description.', - ], - ], -]; diff --git a/tests/phpunit/unit/api/html/fixtures/test-markup.php b/tests/phpunit/unit/api/html/fixtures/test-markup.php deleted file mode 100644 index ebd2d582..00000000 --- a/tests/phpunit/unit/api/html/fixtures/test-markup.php +++ /dev/null @@ -1,64 +0,0 @@ - [ - 'id' => 'beans_post', - 'tag' => 'article', - 'attributes' => [ - 'id' => 47, - 'class' => 'uk-article uk-panel-box post-47 post type-post status-publish format-standard has-post-thumbnail hentry category-beans', - 'itemscope' => 'itemscope', - 'itemtype' => 'https://schema.org/blogPost', - 'itemprop' => 'beans_post', - ], - ], - 'beans_post_header' => [ - 'id' => 'beans_post_header', - 'tag' => 'header', - ], - 'beans_post_body' => [ - 'id' => 'beans_post_body', - 'tag' => 'div', - 'attributes' => [ - 'itemprop' => 'articleBody', - ], - ], - 'beans_post_title' => [ - 'id' => 'beans_post_title', - 'tag' => 'h1', - 'attributes' => [ - 'class' => 'uk-article-title', - 'itemprop' => 'headline', - ], - ], - 'beans_post_meta' => [ - 'id' => 'beans_post_meta', - 'tag' => 'ul', - 'attributes' => [ - 'class' => 'uk-article-meta uk-subnav uk-subnav-line', - ], - ], - 'beans_post_meta_item[_date]' => [ - 'id' => 'beans_post_meta_item[_date]', - 'tag' => 'li', - ], - 'beans_post_meta_item[_author]' => [ - 'id' => 'beans_post_meta_item[_author]', - 'tag' => 'li', - ], - 'beans_post_image_link' => [ - 'id' => 'beans_post_image_link', - 'tag' => 'a', - 'attributes' => [ - 'href' => 'http://example.com/image.png', - 'title' => 'Some cool image', - ], - ], -]; diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php deleted file mode 100644 index 05b70c4b..00000000 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ /dev/null @@ -1,106 +0,0 @@ -setup_function_mocks(); - $this->setup_common_wp_stubs(); - - $this->load_original_functions( [ - 'api/html/class-beans-attribute.php', - 'api/html/functions.php', - 'api/html/accessibility.php', - 'api/filters/functions.php', - 'api/layout/functions.php', - 'api/widget/functions.php', - ] ); - - // Reset the test fixtures. - reset( static::$test_markup ); - reset( static::$test_attributes ); - reset( static::$test_attachments ); - } - - /** - * Setup dependency function mocks. - */ - protected function setup_function_mocks() { - Monkey\Functions\when( 'beans_esc_attributes' )->alias( [ $this, 'convert_attributes_into_html' ] ); - Monkey\Functions\when( 'beans_add_smart_action' )->justReturn(); - } - - /** - * Convert an array of attributes into a combined HTML string. - * - * @since 1.5.0 - * - * @param array $attributes The given attributes to combine. - * - * @return string - */ - public function convert_attributes_into_html( array $attributes ) { - $html = ''; - - foreach ( $attributes as $attribute => $value ) { - $html .= $attribute . '="' . $value . '" '; - } - - return rtrim( $html ); - } -} diff --git a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php deleted file mode 100644 index 3bc90539..00000000 --- a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php +++ /dev/null @@ -1,101 +0,0 @@ -get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $image_sources = [ - static::$fixtures_dir . '/image1.jpg', - static::$fixtures_dir . '/image2.jpg', - ]; - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $image_sources as $src ) { - $editor = new _Beans_Image_Editor( $src, $args ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Simulate the WordPress' Editor. - $wp_editor = Mockery::mock( 'WP_Image_Editor' ); - $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); - $wp_editor->shouldReceive( 'save' ) - ->once() - ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $src ) { - imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); - } ); - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); - Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $this->assertTrue( $create_edited_image->invoke( $editor ) ); - $this->assertFileExists( $edited_image_src ); - } - } - - /** - * Test _Beans_Image_Editor::create_edited_image() should return false when the image does not exist. - */ - public function test_should_return_false_when_no_image() { - $create_edited_image = $this->get_reflective_method( 'create_edited_image', '_Beans_Image_Editor' ); - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $src = 'path/does/not/exist/image.jpg'; - $args = [ 'resize' => [ 800, false ] ]; - - $editor = new _Beans_Image_Editor( $src, $args ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Simulate the WordPress' Editor. - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); - Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertFalse( $create_edited_image->invoke( $editor ) ); - $this->assertFileNotExists( $edited_image_src ); - } -} diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php deleted file mode 100644 index 8b55617b..00000000 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ /dev/null @@ -1,355 +0,0 @@ -get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $this->images as $actual_path ) { - $editor = new _Beans_Image_Editor( $actual_path, $args ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Simulate the WordPress' Editor. - $wp_editor = Mockery::mock( 'WP_Image_Editor' ); - $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); - $wp_editor->shouldReceive( 'save' ) - ->once() - ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { - imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); - } ); - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); - Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $image_info = $editor->run(); - $this->assertFileExists( $edited_image_src ); - $this->assertSame( $edited_image_src, $image_info ); - } - } - - /** - * Test _Beans_Image_Editor::run() should return original src when the image does not exist. - */ - public function test_should_return_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ] ); - - // Set up the mocks. - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); - Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); - Monkey\Functions\expect( 'beans_path_to_url' )->never(); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( $src, $editor->run() ); - } - - /** - * Test _Beans_Image_Editor::run() should return the URL when the edited image exists, meaning that it has already been edited and - * stored. - */ - public function test_should_return_url_when_edited_image_exists() { - $this->load_images_into_vfs(); - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $this->images as $virtual_path => $actual_path ) { - $editor = new _Beans_Image_Editor( $actual_path, $args ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $virtual_path ); - - // Check that the WordPress Editor does not get called. - Monkey\Functions\expect( 'wp_get_image_editor' )->never(); - Monkey\Functions\expect( 'is_wp_error' )->never(); - - // Run the tests. - $this->assertFileExists( $edited_image_src ); - $this->assertSame( $edited_image_src, $editor->run() ); - } - } - - /** - * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return an indexed array of - * its image info. - */ - public function test_should_edit_store_image_and_return_indexed_array() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $this->images as $virtual_path => $actual_path ) { - $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_N ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Simulate the WordPress' Editor. - $wp_editor = Mockery::mock( 'WP_Image_Editor' ); - $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); - $wp_editor->shouldReceive( 'save' ) - ->once() - ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { - imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); - } ); - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); - Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $image_info = $editor->run(); - $this->assertFileExists( $edited_image_src ); - $this->assertSame( [ $edited_image_src, 1200, 630 ], $image_info ); - } - } - - /** - * Test _Beans_Image_Editor::run() should return an indexed array with the original src when the image does not exist. - */ - public function test_should_return_indexed_array_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], ARRAY_N ); - - // Set up the mocks. - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); - Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); - Monkey\Functions\expect( 'beans_path_to_url' )->never(); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( [ $src, null, null ], $editor->run() ); - } - - /** - * Test _Beans_Image_Editor::run() should return return an indexed array when the edited image exists, meaning that it has already been - * edited and stored. - */ - public function test_should_return_index_array_when_edited_image_exists() { - $this->load_images_into_vfs(); - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = [ 'resize' => [ 800, false ] ]; - - foreach ( $this->images as $virtual_path => $actual_path ) { - $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_N ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $virtual_path ); - - // Check that the WordPress Editor does not get called. - Monkey\Functions\expect( 'wp_get_image_editor' )->never(); - Monkey\Functions\expect( 'is_wp_error' )->never(); - - // Run the tests. - $this->assertFileExists( $edited_image_src ); - $this->assertSame( [ $edited_image_src, 1200, 630 ], $editor->run() ); - } - } - - /** - * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an - * object. - */ - public function test_should_edit_store_image_and_return_object() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = [ 'resize' => [ 400, false ] ]; - - foreach ( $this->images as $actual_path ) { - $editor = new _Beans_Image_Editor( $actual_path, $args, OBJECT ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Simulate the WordPress' Editor. - $wp_editor = Mockery::mock( 'WP_Image_Editor' ); - $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); - $wp_editor->shouldReceive( 'save' ) - ->once() - ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { - imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); - } ); - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); - Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $image_info = $editor->run(); - $this->assertInstanceOf( 'stdClass', $image_info ); - $this->assertSame( $edited_image_src, $image_info->src ); - $this->assertSame( 1200, $image_info->width ); - $this->assertSame( 630, $image_info->height ); - $this->assertFileExists( $edited_image_src ); - } - } - - /** - * Test _Beans_Image_Editor::run() should return an object with the original src when the image does not exist. - */ - public function test_should_return_object_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], OBJECT ); - - // Set up the mocks. - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); - Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); - Monkey\Functions\expect( 'beans_path_to_url' )->never(); - - // Run the tests. - $this->assertFileNotExists( $src ); - $image_info = $editor->run(); - $this->assertInstanceOf( 'stdClass', $image_info ); - $this->assertSame( $src, $image_info->src ); - $this->assertNull( $image_info->width ); - $this->assertNull( $image_info->height ); - } - - /** - * Test _Beans_Image_Editor::run() should return an object when the edited image exists, meaning that it has already been - * edited and stored. - */ - public function test_should_return_object_when_edited_image_exists() { - $this->load_images_into_vfs(); - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = [ 'resize' => [ 400, false ] ]; - - foreach ( $this->images as $virtual_path => $actual_path ) { - $editor = new _Beans_Image_Editor( $actual_path, $args, OBJECT ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $virtual_path ); - - // Check that the WordPress Editor does not get called. - Monkey\Functions\expect( 'wp_get_image_editor' )->never(); - Monkey\Functions\expect( 'is_wp_error' )->never(); - - // Run the tests. - $this->assertFileExists( $edited_image_src ); - $actual = $editor->run(); - $this->assertInstanceOf( 'stdClass', $actual ); - $this->assertSame( $edited_image_src, $actual->src ); - $this->assertSame( 1200, $actual->width ); - $this->assertSame( 630, $actual->height ); - } - } - - /** - * Test _Beans_Image_Editor::run() should edit the existing image, store it in the "rebuilt path", and then return its image info as an - * associative array. - */ - public function test_should_edit_store_image_and_return_associative_array() { - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = [ 'resize' => [ 600, false ] ]; - - foreach ( $this->images as $actual_path ) { - $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_A ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor ); - - // Simulate the WordPress' Editor. - $wp_editor = Mockery::mock( 'WP_Image_Editor' ); - $wp_editor->shouldReceive( 'resize' )->once()->with( $args['resize'][0], $args['resize'][1] ); - $wp_editor->shouldReceive( 'save' ) - ->once() - ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { - imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); - } ); - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); - Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); - - // Run the tests. - $this->assertFileNotExists( $edited_image_src ); - $image_info = $editor->run(); - $this->assertFileExists( $edited_image_src ); - $this->assertSame( - [ - 'src' => $edited_image_src, - 'width' => 1200, - 'height' => 630, - ], - $image_info - ); - } - } - - /** - * Test _Beans_Image_Editor::run() should return an associative array with the original src when the image does not exist. - */ - public function test_should_return_associative_array_with_original_src_when_no_image() { - $src = 'path/does/not/exist/image.jpg'; - $editor = new _Beans_Image_Editor( $src, [ 'resize' => [ 800, false ] ], ARRAY_A ); - - // Set up the mocks. - Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once(); - Monkey\Functions\expect( 'is_wp_error' )->once()->andReturn( true ); - Monkey\Functions\expect( 'beans_path_to_url' )->never(); - - // Run the tests. - $this->assertFileNotExists( $src ); - $this->assertSame( - [ - 'src' => $src, - 'width' => null, - 'height' => null, - ], - $editor->run() - ); - } - - /** - * Test _Beans_Image_Editor::run() should return an associative array when the edited image exists, meaning that it has already - * been edited and stored. - */ - public function test_should_return_associative_array_when_edited_image_exists() { - $this->load_images_into_vfs(); - $rebuilt_path = $this->get_reflective_property( 'rebuilt_path', '_Beans_Image_Editor' ); - $args = [ 'resize' => [ 600, false ] ]; - - foreach ( $this->images as $virtual_path => $actual_path ) { - $editor = new _Beans_Image_Editor( $actual_path, $args, ARRAY_A ); - $edited_image_src = $this->init_virtual_image( $rebuilt_path, $editor, $virtual_path ); - - // Check that the WordPress Editor does not get called. - Monkey\Functions\expect( 'wp_get_image_editor' )->never(); - Monkey\Functions\expect( 'is_wp_error' )->never(); - - // Run the tests. - $this->assertFileExists( $edited_image_src ); - $this->assertSame( - [ - 'src' => $edited_image_src, - 'width' => 1200, - 'height' => 630, - ], - $editor->run() - ); - } - } -} diff --git a/tests/phpunit/unit/api/image/beans-image-options/flush.php b/tests/phpunit/unit/api/image/beans-image-options/flush.php deleted file mode 100644 index 029897dd..00000000 --- a/tests/phpunit/unit/api/image/beans-image-options/flush.php +++ /dev/null @@ -1,74 +0,0 @@ -directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); - - Monkey\Functions\expect( 'beans_post' ) - ->once() - ->with( 'beans_flush_edited_images' ) - ->andReturnNull(); - Monkey\Functions\expect( 'beans_get_images_dir' )->never(); - Monkey\Functions\expect( 'beans_remove_dir' )->never(); - - $this->assertNull( ( new _Beans_Image_Options() )->flush() ); - - // Check that it still exists and was not removed. - $this->directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); - } - - /** - * Test _Beans_Image_Options::flush() should remove the cached directory. - */ - public function test_should_remove_cached_dir() { - // Check that the cached directory exists before we start. - $this->directoryExists( vfsStream::url( 'uploads/beans/images/' ) ); - - Monkey\Functions\expect( 'beans_post' ) - ->once() - ->with( 'beans_flush_edited_images' ) - ->andReturnFirstArg(); - Monkey\Functions\expect( 'beans_get_images_dir' ) - ->once() - ->andReturn( vfsStream::url( 'uploads/beans/images/' ) ); - Monkey\Functions\expect( 'beans_remove_dir' ) - ->once() - ->with( vfsStream::url( 'uploads/beans/images/' ) ) - ->andReturnUsing( function() { - // Keep it simple. Remove by redefining. - vfsStream::setup( 'uploads', 0755, [ 'beans' => [] ] ); - } ); - - $this->assertNull( ( new _Beans_Image_Options() )->flush() ); - $this->assertDirectoryNotExists( vfsStream::url( 'uploads/beans/images/' ) ); - } -} diff --git a/tests/phpunit/unit/api/image/beans-image-options/register.php b/tests/phpunit/unit/api/image/beans-image-options/register.php deleted file mode 100644 index 8eb857e0..00000000 --- a/tests/phpunit/unit/api/image/beans-image-options/register.php +++ /dev/null @@ -1,94 +0,0 @@ -fields = require BEANS_THEME_DIR . '/lib/api/image/config/fields.php'; - } - - /** - * Test _Beans_Image_Options::register() should register the options with column context when other metaboxes are - * registered. - */ - public function test_should_register_options_with_column_context_when_other_metaboxes_are_registered() { - global $wp_meta_boxes; - Monkey\Functions\expect( 'beans_get' ) - ->once() - ->with( 'beans_settings', $wp_meta_boxes ) - ->andReturn( [ 'foo' ] ); - Monkey\Functions\expect( 'beans_register_options' ) - ->once() - ->with( - $this->fields, - 'beans_settings', - 'images_options', - [ - 'title' => 'Images options', - 'context' => 'column', - ] - ) - ->andReturn( true ); - - $this->assertTrue( ( new _Beans_Image_Options() )->register() ); - } - - /** - * Test _Beans_Image_Options::register() should register the options with normal context when no metaboxes are - * registered. - */ - public function test_should_register_options_with_normal_context_when_no_metaboxes_are_registered() { - global $wp_meta_boxes; - Monkey\Functions\expect( 'beans_get' ) - ->once() - ->with( 'beans_settings', $wp_meta_boxes ) - ->andReturn( [] ); - Monkey\Functions\expect( 'beans_register_options' ) - ->once() - ->with( - $this->fields, - 'beans_settings', - 'images_options', - [ - 'title' => 'Images options', - 'context' => 'normal', - ] - ) - ->andReturn( true ); - - $this->assertTrue( ( new _Beans_Image_Options() )->register() ); - } -} diff --git a/tests/phpunit/unit/api/image/beans-image-options/renderFlushButton.php b/tests/phpunit/unit/api/image/beans-image-options/renderFlushButton.php deleted file mode 100644 index 77da2ad9..00000000 --- a/tests/phpunit/unit/api/image/beans-image-options/renderFlushButton.php +++ /dev/null @@ -1,51 +0,0 @@ -never(); - - ob_start(); - ( new _Beans_Image_Options() )->render_flush_button( [ 'id' => 'foo' ] ); - $this->assertEmpty( ob_get_clean() ); - } - - /** - * Test _Beans_Image_Options::render_flush_button() should render when the field is for image options. - */ - public function test_should_render_when_field_is_image_options() { - ob_start(); - ( new _Beans_Image_Options() )->render_flush_button( [ 'id' => 'beans_edited_images_directories' ] ); - $actual = ob_get_clean(); - - $expected = << -EOB; - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } -} diff --git a/tests/phpunit/unit/api/image/beans-image-options/renderSuccessNotice.php b/tests/phpunit/unit/api/image/beans-image-options/renderSuccessNotice.php deleted file mode 100644 index 0068428e..00000000 --- a/tests/phpunit/unit/api/image/beans-image-options/renderSuccessNotice.php +++ /dev/null @@ -1,61 +0,0 @@ -once() - ->with( 'beans_flush_edited_images' ) - ->andReturn( false ); - Monkey\Functions\expect( 'esc_html_e' )->never(); - - ob_start(); - ( new _Beans_Image_Options() )->render_success_notice(); - $this->assertEmpty( ob_get_clean() ); - } - - /** - * Test _Beans_Image_Options::render_success_notice() should render when flushing edited images cache. - */ - public function test_should_render_when_flushing_edited_images_cache() { - Monkey\Functions\expect( 'beans_post' ) - ->once() - ->with( 'beans_flush_edited_images' ) - ->andReturn( true ); - ob_start(); - ( new _Beans_Image_Options() )->render_success_notice(); - $actual = ob_get_clean(); - - $expected = << -

                Images flushed successfully!

                - -EOB; - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $actual ) ); - } -} diff --git a/tests/phpunit/unit/api/image/beansGetImagesDir.php b/tests/phpunit/unit/api/image/beansGetImagesDir.php deleted file mode 100644 index cae7d9dc..00000000 --- a/tests/phpunit/unit/api/image/beansGetImagesDir.php +++ /dev/null @@ -1,45 +0,0 @@ -assertStringEndsWith( '/uploads/beans/images/', beans_get_images_dir() ); - } - - /** - * Test beans_get_images_dir() should return the filtered images' directory. - */ - public function test_should_return_filtered_images_dir() { - Monkey\Filters\expectApplied( 'beans_images_dir' ) - ->once() - ->with( vfsStream::url( 'uploads/beans/images/' ) ) - ->andReturn( 'foo' ); - - $this->assertSame( 'foo/', beans_get_images_dir() ); - } -} diff --git a/tests/phpunit/unit/api/image/fixtures/image1.jpg b/tests/phpunit/unit/api/image/fixtures/image1.jpg deleted file mode 100644 index 598e9db3b4d55c59b616e655be84098ae0c59dd0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 31016 zcmeFYd0dm%x<8uMs87PcTLUi zAPiBEgd`A(7y?AV0f+(tLkIyvKtYBC0wQymZo1Dt=X}mT_w=6g*>`{L=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{PQ*I`!#VyawOb_okb=xxI8cZ;`fm zJyAqDJxxMEBTRep9~=JFqL_%r9s+6r9*< zPZVXo(fW2T%B!L{s#Fldz-hKc%U$fe=*<>7u32T2nl?>!Pjq=Z%FQj{93&z; zuv8pOFbK8At^A}1%gyB%$1)->Jn}=)ds~HtUn;lH4BxNaS+*N=GOs)*@HxZjN^I5Q zxSU(xuPm%Ch9$HS372IXq~vTiNYe7>J0JegfOkACn;9Jwv_PW&5KzczfmqncLG6GG z$LkVj3>SN{yW2dq^-+hu%grw>l77NV^|HM%-`2FX{Me ztL19vHR7cS3%c4M@UOh*y53@5rdh?JqZPVJry&8ILT#RZ9o7)uWY3nkwsH^pE?-1G zysCDgevkT{hi?(xf;9~boQFu7ddWSqku5{wyuTR7O49YD*(b{c#ioNuI>?Tn@Qm*r=f(Z{8+q&Nf!%p)y>^H;g39xUs>)4*6{%i0q%@hB1kUier_pUzon6cf%_u#d>`=Gyp+?}JuZv@%n?RWLL t$As+x{;odvkgPpI-__?H6SfEVyY+Jq$=W0I-Trou3EKnw|7ZOa{14D277PFY diff --git a/tests/phpunit/unit/api/image/includes/class-base-test-case.php b/tests/phpunit/unit/api/image/includes/class-base-test-case.php deleted file mode 100644 index aa367885..00000000 --- a/tests/phpunit/unit/api/image/includes/class-base-test-case.php +++ /dev/null @@ -1,84 +0,0 @@ -set_up_virtual_filesystem(); - - $this->load_original_functions( [ - 'api/utilities/functions.php', - 'api/image/functions.php', - ] ); - - $this->setup_common_wp_stubs(); - } - - /** - * Set up the virtual filesystem. - */ - protected function set_up_virtual_filesystem() { - $this->mock_filesystem = vfsStream::setup( - 'uploads', - 0755, - $this->get_virtual_structure() - ); - $this->images_dir = vfsStream::url( 'uploads/beans/images' ); - $this->images_url = 'http://example.com/uploads/beans/images/'; - } - - /** - * Get the virtual filesystem's structure. - */ - protected function get_virtual_structure() { - return [ - 'beans' => [ - 'images' => [ - 'index.php' => '', - ], - ], - ]; - } -} diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php deleted file mode 100644 index 294a2a5a..00000000 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ /dev/null @@ -1,139 +0,0 @@ -setup_function_mocks(); - - $this->load_original_functions( [ - 'api/image/class-beans-image-editor.php', - ] ); - - $this->images = [ - $this->images_dir . '/image1.jpg' => static::$fixtures_dir . '/image1.jpg', - $this->images_dir . '/image2.jpg' => static::$fixtures_dir . '/image2.jpg', - ]; - } - - /** - * Load the images into the virtual filesystem. - */ - protected function load_images_into_vfs() { - - foreach ( $this->images as $virtual_path => $actual_path ) { - imagejpeg( imagecreatefromjpeg( $actual_path ), $virtual_path ); - } - } - - /** - * Initialize the virtual "edited" image. - * - * @since 1.5.0 - * - * @param \ReflectionProperty $rebuilt_path Instance of the editor's "rebuilt path" property. - * @param _Beans_Image_Editor $editor Instance of the editor. - * @param string|null $path Optional. The image's "rebuilt path". - * - * @return string - */ - protected function init_virtual_image( $rebuilt_path, $editor, $path = null ) { - - if ( is_null( $path ) ) { - $path = $rebuilt_path->getValue( $editor ); - } - - $rebuilt_path->setValue( $editor, $path ); - - return $rebuilt_path->getValue( $editor ); - } - - /** - * Set up the mocks. - * - * @since 1.5.0 - * - * @return void - */ - protected function setup_function_mocks() { - Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); - Monkey\Functions\when( 'beans_path_to_url' )->returnArg(); - - Monkey\Functions\expect( 'wp_upload_dir' )->andReturn( [ - 'path' => '', - 'url' => '', - 'subdir' => '', - 'basedir' => vfsStream::url( 'uploads' ), - 'baseurl' => $this->images_url, - 'error' => false, - ] ); - } -} diff --git a/tests/phpunit/unit/api/image/includes/class-options-test-case.php b/tests/phpunit/unit/api/image/includes/class-options-test-case.php deleted file mode 100644 index 6cfe3b5b..00000000 --- a/tests/phpunit/unit/api/image/includes/class-options-test-case.php +++ /dev/null @@ -1,32 +0,0 @@ -load_original_functions( [ - 'api/image/class-beans-image-options.php', - 'api/options/functions.php', - ] ); - } -} diff --git a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php deleted file mode 100644 index 4d43aefc..00000000 --- a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php +++ /dev/null @@ -1,67 +0,0 @@ -load_original_functions( [ - 'api/layout/functions.php', - 'api/widget/functions.php', - ] ); - } - - /** - * Test beans_get_default_layout() should return "c" when there is no primary sidebar. - */ - public function test_should_return_c_when_no_primary_sidebar() { - Monkey\Functions\expect( 'beans_has_widget_area' ) - ->once() - ->with( 'sidebar_primary' ) - ->andReturn( false ); - Monkey\Filters\expectApplied( 'beans_default_layout' ) - ->once() - ->with( 'c' ) - ->andReturn( 'c' ); - - $this->assertSame( 'c', beans_get_default_layout() ); - } - - /** - * Test beans_get_default_layout() should return "c_sp" when there is a primary sidebar. - */ - public function test_should_return_c_sp_when_has_primary_sidebar() { - Monkey\Functions\expect( 'beans_has_widget_area' ) - ->once() - ->with( 'sidebar_primary' ) - ->andReturn( true ); - Monkey\Filters\expectApplied( 'beans_default_layout' ) - ->once() - ->with( 'c_sp' ) - ->andReturn( 'c_sp' ); - - $this->assertSame( 'c_sp', beans_get_default_layout() ); - } -} diff --git a/tests/phpunit/unit/api/layout/beansGetLayout.php b/tests/phpunit/unit/api/layout/beansGetLayout.php deleted file mode 100644 index ea94e30d..00000000 --- a/tests/phpunit/unit/api/layout/beansGetLayout.php +++ /dev/null @@ -1,196 +0,0 @@ -load_original_functions( [ - 'api/layout/functions.php', - 'api/post-meta/functions.php', - 'api/term-meta/functions.php', - ] ); - } - - /** - * Test beans_get_layout() should return the layout for a single post or page. - */ - public function test_should_return_layout_for_singular() { - Monkey\Functions\expect( 'is_singular' ) - ->times( 3 ) - ->andReturn( true ); - - foreach ( [ 'c', 'c_sp', 'sp_c_ss' ] as $layout ) { - - Monkey\Functions\expect( 'beans_get_post_meta' ) - ->once() - ->with( 'beans_layout' ) - ->andReturn( $layout ); - - Monkey\Filters\expectApplied( 'beans_layout' ) - ->once() - ->with( $layout ) - ->andReturn( $layout ); - - $this->assertSame( $layout, beans_get_layout() ); - } - } - - /** - * Test beans_get_layout() should return the layout for the static posts page. - */ - public function test_should_return_layout_for_static_posts_page() { - Monkey\Functions\expect( 'is_singular' ) - ->times( 3 ) - ->andReturn( false ); - - Monkey\Functions\expect( 'is_home' ) - ->times( 3 ) - ->andReturn( true ); - - Monkey\Functions\expect( 'get_option' ) - ->times( 3 ) - ->with( 'page_for_posts' ) - ->andReturn( 1 ); - - foreach ( [ 'c', 'c_sp', 'sp_c_ss' ] as $layout ) { - - Monkey\Functions\expect( 'beans_get_post_meta' ) - ->once() - ->with( 'beans_layout', false, 1 ) - ->andReturn( $layout ); - - Monkey\Filters\expectApplied( 'beans_layout' ) - ->once() - ->with( $layout ) - ->andReturn( $layout ); - - $this->assertSame( $layout, beans_get_layout() ); - } - } - - /** - * Test beans_get_layout() should return layout for category, tag, or taxonomy archive web page. - */ - public function test_should_return_layout_for_cat_tag_tax() { - Monkey\Functions\expect( 'is_singular' ) - ->times( 3 ) - ->andReturn( false ); - Monkey\Functions\expect( 'is_home' ) - ->times( 3 ) - ->andReturn( false ); - - Monkey\Functions\expect( 'is_category' ) - ->times( 3 ) - ->andReturn( true ); - - foreach ( [ 'c', 'c_sp', 'sp_c_ss' ] as $layout ) { - - Monkey\Functions\expect( 'beans_get_term_meta' ) - ->once() - ->with( 'beans_layout' ) - ->andReturn( $layout ); - - Monkey\Filters\expectApplied( 'beans_layout' ) - ->once() - ->with( $layout ) - ->andReturn( $layout ); - - $this->assertSame( $layout, beans_get_layout() ); - } - } - - /** - * Test beans_get_layout() should return default layout when layout is not set. - */ - public function test_should_return_default_layout_when_layout_is_not_set() { - Monkey\Functions\when( 'is_singular' )->justReturn( false ); - Monkey\Functions\when( 'is_home' )->justReturn( false ); - Monkey\Functions\when( 'is_category' )->justReturn( false ); - Monkey\Functions\when( 'is_tag' )->justReturn( false ); - Monkey\Functions\when( 'is_tax' )->justReturn( false ); - Monkey\Functions\when( 'beans_has_widget_area' )->justReturn( true ); - - Monkey\Functions\expect( 'get_theme_mod' ) - ->once() - ->with( 'beans_layout', 'c_sp' ) - ->andReturn( 'c_sp' ); - - Monkey\Filters\expectApplied( 'beans_layout' ) - ->once() - ->with( 'c_sp' ) - ->andReturn( 'c_sp' ); - - $this->assertSame( 'c_sp', beans_get_layout() ); - } - - /** - * Test beans_get_layout() should return default layout when layout is `false`. - */ - public function test_should_return_default_layout_when_layout_is_false() { - Monkey\Functions\when( 'is_singular' )->justReturn( true ); - Monkey\Functions\expect( 'beans_get_post_meta' ) - ->once() - ->with( 'beans_layout' ) - ->andReturn( false ); - Monkey\Functions\when( 'beans_has_widget_area' )->justReturn( true ); - - Monkey\Functions\expect( 'get_theme_mod' ) - ->once() - ->with( 'beans_layout', 'c_sp' ) - ->andReturn( 'c_sp' ); - - Monkey\Filters\expectApplied( 'beans_layout' ) - ->once() - ->with( 'c_sp' ) - ->andReturn( 'c_sp' ); - - $this->assertSame( 'c_sp', beans_get_layout() ); - } - - /** - * Test beans_get_layout() should return default layout when layout is set to "default_fallback". - */ - public function test_should_return_default_layout_when_layout_is_default_fallback() { - Monkey\Functions\when( 'is_singular' )->justReturn( true ); - Monkey\Functions\expect( 'beans_get_post_meta' ) - ->once() - ->with( 'beans_layout' ) - ->andReturn( 'default_fallback' ); - Monkey\Functions\when( 'beans_has_widget_area' )->justReturn( true ); - - Monkey\Functions\expect( 'get_theme_mod' ) - ->once() - ->with( 'beans_layout', 'c_sp' ) - ->andReturn( 'c_sp' ); - - Monkey\Filters\expectApplied( 'beans_layout' ) - ->once() - ->with( 'c_sp' ) - ->andReturn( 'c_sp' ); - - $this->assertSame( 'c_sp', beans_get_layout() ); - } -} diff --git a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php deleted file mode 100644 index 41f48172..00000000 --- a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php +++ /dev/null @@ -1,377 +0,0 @@ -load_original_functions( array( - 'api/layout/functions.php', - 'api/utilities/functions.php', - 'api/post-meta/functions.php', - ) ); - - Monkey\Functions\when( 'beans_get' )->alias( function ( $needle, $haystack ) { - - if ( isset( $haystack[ $needle ] ) ) { - return $haystack[ $needle ]; - } - } ); - } - - /** - * Run the tests for the given set of test parameters. - * - * @since 1.5.0 - * - * @param array $test_parameters Array of test parameters. - * @param string $layout_id The layout's ID for this test. - * - * @return void - */ - protected function run_the_tests( array $test_parameters, $layout_id ) { - Monkey\Functions\when( 'is_singular' )->justReturn( true ); - Monkey\Functions\when( 'beans_get_post_meta' )->justReturn( $layout_id ); - - foreach ( $test_parameters as $parameters ) { - foreach ( $parameters['expected'] as $id => $expected ) { - Monkey\Functions\expect( 'beans_has_widget_area' ) - ->with( 'sidebar_primary' ) - ->once() - ->andReturn( $parameters['sidebar_primary'] ); - - if ( true === $parameters['sidebar_primary'] ) { - Monkey\Functions\expect( 'beans_has_widget_area' ) - ->with( 'sidebar_secondary' ) - ->once() - ->andReturn( $parameters['sidebar_secondary'] ); - } - - Monkey\Filters\expectApplied( 'beans_layout_class_' . $id ) - ->with( $expected ) - ->once() - ->andReturn( $expected ); - - $this->assertSame( $expected, beans_get_layout_class( $id ) ); - } - } - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "c". - */ - public function test_should_return_classes_when_layout_is_c() { - $test_parameters = array( - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ), - ); - - $this->run_the_tests( $test_parameters, 'c' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "c_sp". - */ - public function test_should_return_classes_when_layout_is_c_sp() { - $test_parameters = array( - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-3-4', - 'sidebar_primary' => 'uk-width-medium-1-4', - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-3-4', - 'sidebar_primary' => 'uk-width-medium-1-4', - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ), - ); - - $this->run_the_tests( $test_parameters, 'c_sp' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "sp_c". - */ - public function test_should_return_classes_when_layout_is_sp_c() { - $test_parameters = array( - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ), - ); - - $this->run_the_tests( $test_parameters, 'sp_c' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "c_ss". - */ - public function test_should_return_classes_when_layout_is_c_ss() { - $test_parameters = array( - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-3-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => 'uk-width-medium-1-4', - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ), - ); - - $this->run_the_tests( $test_parameters, 'c_ss' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "c_sp_ss". - */ - public function test_should_return_classes_when_layout_is_c_sp_ss() { - $test_parameters = array( - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-3-4', - 'sidebar_primary' => 'uk-width-medium-1-4', - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-2-4', - 'sidebar_primary' => 'uk-width-medium-1-4', - 'sidebar_secondary' => 'uk-width-medium-1-4', - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ), - ); - - $this->run_the_tests( $test_parameters, 'c_sp_ss' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "ss_c". - */ - public function test_should_return_classes_when_layout_is_ss_c() { - $test_parameters = array( - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-3-4', - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ), - ); - - $this->run_the_tests( $test_parameters, 'ss_c' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "sp_ss_c". - */ - public function test_should_return_classes_when_layout_is_sp_ss_c() { - $test_parameters = array( - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-2-4 uk-push-2-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', - 'sidebar_secondary' => 'uk-width-medium-1-4 uk-pull-2-4', - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ), - ); - - $this->run_the_tests( $test_parameters, 'sp_ss_c' ); - } - - /** - * Test beans_get_default_layout() should return classes when the layout is "sp_c_ss". - */ - public function test_should_return_classes_when_layout_is_sp_c_ss() { - $test_parameters = array( - array( - 'expected' => array( - 'content' => 'uk-width-medium-4-4', - 'sidebar_primary' => null, - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => false, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-3-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-3-4', - 'sidebar_secondary' => null, - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => false, - ), - array( - 'expected' => array( - 'content' => 'uk-width-medium-2-4 uk-push-1-4', - 'sidebar_primary' => 'uk-width-medium-1-4 uk-pull-2-4', - 'sidebar_secondary' => 'uk-width-medium-1-4', - ), - 'sidebar_primary' => true, - 'sidebar_secondary' => true, - ), - ); - - $this->run_the_tests( $test_parameters, 'sp_c_ss' ); - } -} diff --git a/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php b/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php deleted file mode 100644 index 881d18b5..00000000 --- a/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php +++ /dev/null @@ -1,66 +0,0 @@ -load_original_functions( array( - 'api/layout/functions.php', - ) ); - } - - /** - * Test beans_has_primary_sidebar() should return false when the layout is full-width. - */ - public function test_should_return_false_when_full_width_layout() { - $this->assertFalse( beans_has_primary_sidebar( 'c' ) ); - } - - /** - * Test beans_has_primary_sidebar() should return false when the layout is content-secondary sidebar. - */ - public function test_should_return_false_when_content_secondary_sidebar_layout() { - $this->assertFalse( beans_has_primary_sidebar( 'c_ss' ) ); - } - - /** - * Test beans_has_primary_sidebar() should return false when the layout is content-primary sidebar without an active widget. - */ - public function test_should_return_false_when_content_primary_sidebar_layout_without_active_widget() { - Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); - - $this->assertFalse( beans_has_primary_sidebar( 'c_sp' ) ); - } - - /** - * Test beans_has_primary_sidebar() should return true when the layout is content-primary sidebar with an active widget. - */ - public function test_should_return_true_when_content_primary_sidebar_layout_with_active_widget() { - Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); - - $this->assertTrue( beans_has_primary_sidebar( 'c_sp' ) ); - } -} diff --git a/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php b/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php deleted file mode 100644 index 63d33d0d..00000000 --- a/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php +++ /dev/null @@ -1,66 +0,0 @@ -load_original_functions( [ - 'api/layout/functions.php', - ] ); - } - - /** - * Test beans_has_secondary_sidebar() should return false when the layout is full-width. - */ - public function test_should_return_false_when_full_width_layout() { - $this->assertFalse( beans_has_secondary_sidebar( 'c' ) ); - } - - /** - * Test beans_has_secondary_sidebar() should return false when the layout is content-secondary sidebar. - */ - public function test_should_return_false_when_content_secondary_sidebar_layout() { - $this->assertFalse( beans_has_secondary_sidebar( 'c_sp' ) ); - } - - /** - * Test beans_has_secondary_sidebar() should return false when the layout is content-secondary sidebar without an active widget. - */ - public function test_should_return_false_when_content_secondary_sidebar_layout_without_active_widget() { - Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); - - $this->assertFalse( beans_has_secondary_sidebar( 'c_ss' ) ); - } - - /** - * Test beans_has_secondary_sidebar() should return true when the layout is content-secondary sidebar with an active widget. - */ - public function test_should_return_true_when_content_secondary_sidebar_layout_with_active_widget() { - Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); - - $this->assertTrue( beans_has_secondary_sidebar( 'c_ss' ) ); - } -} diff --git a/tests/phpunit/unit/api/options/beans-options/register.php b/tests/phpunit/unit/api/options/beans-options/register.php deleted file mode 100644 index e044ee1c..00000000 --- a/tests/phpunit/unit/api/options/beans-options/register.php +++ /dev/null @@ -1,87 +0,0 @@ -get_reflective_property( 'args', '_Beans_Options' ); - - $instance = new _Beans_Options(); - $instance->register( 'foo', [] ); - $this->assertSame( [ - 'title' => 'Undefined', - 'context' => 'normal', - ], $property->getValue( $instance ) ); - - $instance = new _Beans_Options(); - $instance->register( 'beans_test', [ 'title' => 'Beans Tests' ] ); - $this->assertSame( [ - 'title' => 'Beans Tests', - 'context' => 'normal', - ], $property->getValue( $instance ) ); - } - - /** - * Test _Beans_Options::register() should register the callback to the 'admin_enqueue_scripts' hook. - */ - public function test_should_register_callback_to_admin_enqueue_scripts_hook() { - $instance = new _Beans_Options(); - $instance->register( 'beans_test', [ 'title' => 'Beans Tests' ] ); - - $this->assertEquals( 10, has_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ) ); - } - - /** - * Test _Beans_Options::register() should register the metabox with WordPress. - */ - public function test_should_register_metabox_with_wp() { - $instance = new _Beans_Options(); - - foreach ( static::$test_data as $option ) { - Monkey\Functions\expect( 'beans_get' )->with( 'page' )->once()->andReturn( 'beans_settings' ); - - // Register the option. - $instance->register( $option['section'], $option['args'] ); - - // Check that the metabox is registered with WordPress. - global $wp_meta_boxes; - $this->assertArrayHasKey( 'beans_settings', $wp_meta_boxes ); - $this->assertArrayHasKey( $option['args']['context'], $wp_meta_boxes['beans_settings'] ); - $this->assertArrayHasKey( 'default', $wp_meta_boxes['beans_settings'][ $option['args']['context'] ] ); - $this->assertArrayHasKey( $option['section'], $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'] ); - $this->assertSame( [ - 'id' => $option['section'], - 'title' => $option['args']['title'], - 'callback' => [ $instance, 'render_metabox' ], - 'args' => null, - ], $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); - - // Clean up. - remove_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ); - } - } -} diff --git a/tests/phpunit/unit/api/options/beans-options/renderMetabox.php b/tests/phpunit/unit/api/options/beans-options/renderMetabox.php deleted file mode 100644 index 2632ce9a..00000000 --- a/tests/phpunit/unit/api/options/beans-options/renderMetabox.php +++ /dev/null @@ -1,64 +0,0 @@ -with( 'page' )->once()->andReturn( 'beans_settings' ); - Monkey\Functions\expect( 'beans_get_fields' )->with( 'option', $option['section'] )->once()->andReturn( false ); - - // Register the option. - $instance->register( $option['section'], $option['args'] ); - - // Run the test. - $this->assertNull( $instance->render_metabox() ); - } - } - - /** - * Test _Beans_Options::render_metabox() should render the registered fields. For this test, we'll not render but rather check that - * each function is called as expected. - */ - public function test_should_render_registered_fields() { - $instance = new _Beans_Options(); - - foreach ( static::$test_data as $option ) { - Monkey\Functions\expect( 'beans_get' )->with( 'page' )->once()->andReturn( 'beans_settings' ); - Monkey\Functions\expect( 'beans_get_fields' )->with( 'option', $option['section'] )->once()->andReturn( $option['fields'] ); - - // Register the option. - $instance->register( $option['section'], $option['args'] ); - - // Run the tests. - Monkey\Functions\expect( 'beans_field' )->times( count( $option['fields'] ) )->andReturn( null ); - $this->assertNull( $instance->render_metabox() ); - } - } -} diff --git a/tests/phpunit/unit/api/options/beans-options/renderPage.php b/tests/phpunit/unit/api/options/beans-options/renderPage.php deleted file mode 100644 index 1acdc1de..00000000 --- a/tests/phpunit/unit/api/options/beans-options/renderPage.php +++ /dev/null @@ -1,120 +0,0 @@ -with( 'beans_tests', [] )->once()->andReturn( null ); - - $this->assertNull( ( new _Beans_Options() )->render_page( 'beans_tests' ) ); - } - - /** - * Test _Beans_Options::render_page() should render the form when "normal" context is configured. - */ - public function test_should_render_form_when_context_normal() { - Monkey\Functions\expect( 'beans_get' ) - ->with( 'beans_tests', [] ) - ->once() - ->andReturn( [ 'column' => '' ] ) - ->andAlsoExpectIt() - ->with( 'column', [ 'column' => '' ], [] ) - ->once() - ->andReturn( [] ) - ->andAlsoExpectIt() - ->with( 'page' ) - ->once() - ->andReturn( 'beans-test' ); - Monkey\Functions\expect( 'do_meta_boxes' )->with( 'beans_tests', 'normal', null )->once()->andReturnNull(); - Monkey\Functions\expect( 'wp_nonce_field' )->twice()->andReturnNull(); - Monkey\Functions\expect( 'wp_create_nonce' )->once()->andReturn( 'foo' ); - - // Run the method and grab the HTML out of the buffer. - ob_start(); - ( new _Beans_Options() )->render_page( 'beans_tests' ); - $html = ob_get_clean(); - - $expected = << - -

                -

                - - -

                - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test _Beans_Options::render_page() should render the form when "column" context is configured. - */ - public function test_should_render_form_when_column_context() { - Monkey\Functions\expect( 'beans_get' ) - ->with( 'beans_tests', [] ) - ->once() - ->andReturn( [ 'column' => true ] ) - ->andAlsoExpectIt() - ->with( 'column', [ 'column' => true ], [] ) - ->once() - ->andReturn( true ) - ->andAlsoExpectIt() - ->with( 'page' ) - ->once() - ->andReturn( 'beans-test' ); - Monkey\Functions\expect( 'do_meta_boxes' ) - ->with( 'beans_tests', 'normal', null ) - ->once() - ->andReturnNull() - ->andAlsoExpectIt() - ->with( 'beans_tests', 'column', null ) - ->once() - ->andReturnNull(); - Monkey\Functions\expect( 'wp_nonce_field' )->twice()->andReturnNull(); - Monkey\Functions\expect( 'wp_create_nonce' )->once()->andReturn( 'foo' ); - - // Run the method and grab the HTML out of the buffer. - ob_start(); - ( new _Beans_Options() )->render_page( 'beans_tests' ); - $html = ob_get_clean(); - - $expected = << - -
                -

                - - -

                - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php b/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php deleted file mode 100644 index 8f8be9a2..00000000 --- a/tests/phpunit/unit/api/options/beans-options/renderRenderNotice.php +++ /dev/null @@ -1,66 +0,0 @@ -render_reset_notice(); - $html = ob_get_clean(); - - $expected = << -

                Settings could not be reset, please try again.

                - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test _Beans_Options::render_reset_notice() should render the updated message when the "success" property is set. - */ - public function test_should_render_updated_message_when_success_is_set() { - $property = $this->get_reflective_property( 'success', '_Beans_Options' ); - $instance = new _Beans_Options(); - $property->setValue( $instance, true ); - - // Run the method and grab the HTML out of the buffer. - ob_start(); - $instance->render_reset_notice(); - $html = ob_get_clean(); - - $expected = << -

                Settings reset successfully!

                - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php b/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php deleted file mode 100644 index 35a9471b..00000000 --- a/tests/phpunit/unit/api/options/beans-options/renderSaveNotice.php +++ /dev/null @@ -1,66 +0,0 @@ -render_save_notice(); - $html = ob_get_clean(); - - $expected = << -

                Settings could not be saved, please try again.

                - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } - - /** - * Test _Beans_Options::render_save_notice() should render the updated message when the "success" property is set. - */ - public function test_should_render_updated_message_when_success_is_set() { - $property = $this->get_reflective_property( 'success', '_Beans_Options' ); - $instance = new _Beans_Options(); - $property->setValue( $instance, true ); - - // Run the method and grab the HTML out of the buffer. - ob_start(); - $instance->render_save_notice(); - $html = ob_get_clean(); - - $expected = << -

                Settings saved successfully!

                - -EOB; - // Run the test. - $this->assertSame( $this->format_the_html( $expected ), $this->format_the_html( $html ) ); - } -} diff --git a/tests/phpunit/unit/api/options/fixtures/test-options.php b/tests/phpunit/unit/api/options/fixtures/test-options.php deleted file mode 100644 index 92f57f7b..00000000 --- a/tests/phpunit/unit/api/options/fixtures/test-options.php +++ /dev/null @@ -1,91 +0,0 @@ - [ - [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - 'description' => 'Clear CSS and Javascript cached files. New cached versions will be compiled on page load.', - ], - [ - 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - 'description' => 'Compile and cache all the CSS files that have been enqueued to the WordPress head.', - ], - [ - 'id' => 'beans_compile_all_scripts_group', - 'label' => 'Compile all WordPress scripts', - 'type' => 'group', - 'fields' => [ - [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ], - [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - ], - ], - 'description' => 'Compile and cache all the Javascript files that have been enqueued to the WordPress head.JavaSript is outputted in the footer if the level is set to Aggressive and might conflict with some third party plugins which are not following WordPress standards.', - ], - ], - 'menu_slug' => 'beans_settings', - 'section' => 'compiler_options', - 'args' => [ - 'title' => 'Compiler options', - 'context' => 'normal', - ], - ], - // Images Options. - [ - 'fields' => [ - [ - 'id' => 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - 'description' => 'Clear all edited images. New images will be created on page load.', - ], - ], - 'menu_slug' => 'beans_settings', - 'section' => 'images_options', - 'args' => [ - 'title' => 'Images options', - 'context' => 'column', - ], - ], - // Mode Options. - [ - 'fields' => [ - [ - 'id' => 'beans_dev_mode', - 'checkbox_label' => 'Enable development mode', - 'type' => 'checkbox', - 'description' => 'This option should be enabled while your website is in development.', - ], - ], - 'menu_slug' => 'beans_settings', - 'section' => 'mode_options', - 'args' => [ - 'title' => 'Mode options', - 'context' => 'column', - ], - ], -]; diff --git a/tests/phpunit/unit/api/options/includes/class-options-test-case.php b/tests/phpunit/unit/api/options/includes/class-options-test-case.php deleted file mode 100644 index a4f5c00c..00000000 --- a/tests/phpunit/unit/api/options/includes/class-options-test-case.php +++ /dev/null @@ -1,93 +0,0 @@ -load_original_functions( [ - 'api/utilities/functions.php', - 'api/options/class-beans-options.php', - 'api/options/functions.php', - 'api/fields/functions.php', - ] ); - - $this->setup_function_mocks(); - $this->setup_common_wp_stubs(); - } - - /** - * Cleans up the test environment after each test. - */ - protected function tearDown() { - global $wp_meta_boxes; - $wp_meta_boxes = []; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. - - parent::tearDown(); - } - - /** - * Setup dependency function mocks. - */ - protected function setup_function_mocks() { - Monkey\Functions\when( 'add_meta_box' )->alias( function( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { - global $wp_meta_boxes; - - if ( empty( $screen ) ) { - $screen = 'beans'; - } - - // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Mocking global here for tests. - $wp_meta_boxes = [ - $screen => [ - $context => [ - $priority => [ - $id => [ - 'id' => $id, - 'title' => $title, - 'callback' => $callback, - 'args' => $callback_args, - ], - ], - ], - ], - ]; - } ); - } -} diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/okToSave.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/okToSave.php deleted file mode 100644 index 06b01115..00000000 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/okToSave.php +++ /dev/null @@ -1,72 +0,0 @@ - 'Post Options' ] ); - - Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( false ); - $this->assertFalse( $post_meta->ok_to_save( 456, [ [ 'id' => 'beans_test_slider' ] ] ) ); - } - - /** - * Test _Beans_Post_Meta::ok_to_save() should return false when `edit post` user permissions are not met. - */ - public function test_ok_to_save_should_return_false_when_user_permissions_not_met() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - - Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); - Monkey\Functions\expect( 'current_user_can' ) - ->once() - ->with( 'edit_post', 456 ) - ->andReturn( false ); - $this->assertFalse( $post_meta->ok_to_save( 456, [ [ 'id' => 'beans_test_slider' ] ] ) ); - } - - /** - * Test _Beans_Post_Meta::ok_to_save() should return false when post meta has no fields. - */ - public function test_ok_to_save_should_return_false_when_no_fields() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - - Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); - Monkey\Functions\expect( 'current_user_can' )->once()->andReturn( true ); - $this->assertFalse( $post_meta->ok_to_save( 456, [] ) ); - } - - /** - * Test _Beans_Post_Meta::ok_to_save() should return true when all conditions for saving are met. - */ - public function test_ok_to_save_should_return_true_when_all_conditions_met() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - - Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); - Monkey\Functions\expect( 'current_user_can' )->once()->andReturn( true ); - $this->assertTrue( $post_meta->ok_to_save( 456, [ [ 'id' => 'beans_test_slider' ] ] ) ); - } -} diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/registerMetabox.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/registerMetabox.php deleted file mode 100644 index 23db927c..00000000 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/registerMetabox.php +++ /dev/null @@ -1,57 +0,0 @@ - 'Post Options' ] ); - - $wp_meta_boxes['post']['normal']['high']['1'] = [ - 'id' => 1, - 'title' => 'Post Options', - 'callback' => [ $this, 'render_metabox_content' ], - 'callback_args' => null, - ]; - - Monkey\Functions\expect( 'add_meta_box' ) - ->once() - ->with( 'tm-beans', 'Post Options', [ $post_meta, 'render_metabox_content' ], 'post', 'normal', 'high' ) - ->andReturn( $wp_meta_boxes['post']['normal']['high']['1'] ); - - $post_meta->register_metabox( 'post' ); - - $this->assertEquals( - $wp_meta_boxes['post']['normal']['high'][1], - [ - 'id' => 1, - 'title' => 'Post Options', - 'callback' => [ $this, 'render_metabox_content' ], - 'callback_args' => null, - ] - ); - } -} diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php deleted file mode 100644 index 7ef2c41b..00000000 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php +++ /dev/null @@ -1,56 +0,0 @@ - 'beans_layout', - 'label' => 'Layout', - 'type' => 'radio', - 'context' => 'tm-beams', - 'default' => 'default_fallback', - 'options' => 'options html from layout options callback', - ]; - - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - - Monkey\Functions\expect( 'beans_get_fields' ) - ->once() - ->with( 'post_meta', 'tm-beans' ) - ->andReturn( [ $field ] ); - Monkey\Functions\expect( 'beans_field' )->once()->with( $field )->andReturnUsing( function () { - echo 'beans_field_html'; - } ); - - ob_start(); - $post_meta->render_metabox_content( 74 ); - $output = ob_get_clean(); - - $this->assertEquals( 'beans_field_html', $output ); - } -} diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderNonce.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/renderNonce.php deleted file mode 100644 index 9116c855..00000000 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderNonce.php +++ /dev/null @@ -1,41 +0,0 @@ -once()->with( 'beans_post_meta_nonce' )->andReturn( '123456' ); - $expected_html_output = ''; - - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - ob_start(); - $post_meta->render_nonce(); - $actual_output = ob_get_clean(); - - $this->assertContains( $expected_html_output, $actual_output ); - } -} diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php deleted file mode 100644 index 48954ea7..00000000 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/save.php +++ /dev/null @@ -1,65 +0,0 @@ - 'Post Options' ] ); - - Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( true ); - $this->assertFalse( $post_meta->save( 256 ) ); - } - - /** - * Test _Beans_Post_Meta::save() should return the post_ID when ok_to_save() is false. - */ - public function test_should_return_post_id_when_ok_to_save_false() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - - Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( false ); - Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( false ); - $this->assertEquals( 256, $post_meta->save( 256 ) ); - } - - /** - * Test _Beans_Post_Meta::save() should run update_post_meta() and return null when ok_to_save() is true. - */ - public function test_should_run_update_post_meta_and_return_null_when_ok_to_save() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - $fields = [ 'beans_post_test_field' => 'beans_test_post_field_value' ]; - - Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( false ); - Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); - Monkey\Functions\expect( 'current_user_can' )->once()->andReturn( true ); - Monkey\Functions\expect( 'beans_post' )->andReturn( $fields ); - Monkey\Functions\expect( 'update_post_meta' ) - ->once() - ->with( 256, 'beans_post_test_field', 'beans_test_post_field_value' ) - ->andReturn( true ); - $this->assertnull( $post_meta->save( 256 ) ); - } -} diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php deleted file mode 100644 index 0bb0793c..00000000 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/saveAttachment.php +++ /dev/null @@ -1,57 +0,0 @@ - 'Post Options' ] ); - $attachment = [ 'ID' => 543 ]; - - Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( true ); - Monkey\Functions\expect( 'update_post_meta' )->never(); - $this->assertEquals( $attachment, $post_meta->save_attachment( $attachment ) ); - } - - /** - * Test _Beans_Post_Meta::save_attachment() should run update_post_meta() and return attachment when ok_to_save() is true. - */ - public function test_should_run_update_post_meta_and_return_attachment_when_ok_to_save() { - $post_meta = new _Beans_Post_Meta( 'tm-beans', [ 'title' => 'Post Options' ] ); - $attachment = [ 'ID' => 543 ]; - $fields = [ 'beans_post_test_field' => 'beans_test_post_field_value' ]; - - Monkey\Functions\expect( '_beans_doing_autosave' )->once()->andReturn( false ); - Monkey\Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true ); - Monkey\Functions\expect( 'current_user_can' )->once()->andReturn( true ); - Monkey\Functions\expect( 'beans_post' )->andReturn( $fields ); - Monkey\Functions\expect( 'update_post_meta' ) - ->once() - ->with( 543, 'beans_post_test_field', 'beans_test_post_field_value' ) - ->andReturn( true ); - $this->assertEquals( $attachment, $post_meta->save_attachment( $attachment ) ); - } -} diff --git a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php b/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php deleted file mode 100644 index d4e1a0a7..00000000 --- a/tests/phpunit/unit/api/post-meta/beansGetPostMeta.php +++ /dev/null @@ -1,121 +0,0 @@ -twice()->andReturn( false ); - Monkey\Functions\expect( 'beans_get' )->twice()->andReturn( null ); - Monkey\Functions\expect( 'get_post_meta' )->never(); - - $this->assertFalse( beans_get_post_meta( 'beans_layout' ) ); - $this->assertSame( 'default_fallback', beans_get_post_meta( 'beans_layout', 'default_fallback' ) ); - } - - /** - * Test beans_get_post_meta() should return the default when the post meta does not exist. - */ - public function test_should_return_default_when_post_meta_does_not_exist() { - Monkey\Functions\expect( 'get_post_meta' ) - ->with( 1 ) - ->times( 3 ) - ->andReturn( [] ); - - $this->assertFalse( beans_get_post_meta( 'beans_layout', false, 1 ) ); - $this->assertSame( '', beans_get_post_meta( 'beans_layout', '', 1 ) ); - $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c', 1 ) ); - } - - /** - * Test beans_get_post_meta() should get the post ID when none is provided. - */ - public function test_should_get_post_id_when_none_is_provided() { - Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 47 ); - Monkey\Functions\expect( 'get_post_meta' ) - ->with( 47 ) - ->once() - ->andReturn( [] ); - $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); - - Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 0 ); - Monkey\Functions\expect( 'beans_get' ) - ->once() - ->with( 'post' ) - ->andReturn( 18 ); - Monkey\Functions\expect( 'get_post_meta' ) - ->with( '18' ) - ->once() - ->andReturn( [] ); - $this->assertSame( 'c', beans_get_post_meta( 'beans_layout', 'c' ) ); - } - - /** - * Test beans_get_post_meta() should return the post's meta value. - */ - public function test_should_return_post_meta_value() { - Monkey\Functions\expect( 'get_post_meta' ) - ->with( 521 ) - ->once() - ->ordered() - ->andReturn( [ 'beans_layout' => 'c_sp' ] ) - ->andAlsoExpectIt() - ->with( 521, 'beans_layout', true ) - ->once() - ->ordered() - ->andReturn( 'c_sp' ); - $this->assertSame( 'c_sp', beans_get_post_meta( 'beans_layout', false, 521 ) ); - - Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 47 ); - Monkey\Functions\expect( 'get_post_meta' ) - ->with( 47 ) - ->once() - ->ordered() - ->andReturn( [ 'beans_layout' => 'sp_c' ] ) - ->andAlsoExpectIt() - ->with( 47, 'beans_layout', true ) - ->once() - ->ordered() - ->andReturn( 'sp_c' ); - $this->assertSame( 'sp_c', beans_get_post_meta( 'beans_layout' ) ); - - Monkey\Functions\expect( 'get_the_ID' )->once()->andReturn( 0 ); - Monkey\Functions\expect( 'beans_get' ) - ->once() - ->with( 'post' ) - ->andReturn( 18 ); - Monkey\Functions\expect( 'get_post_meta' ) - ->with( '18' ) - ->once() - ->ordered() - ->andReturn( [ 'beans_layout' => 'default_fallback' ] ) - ->andAlsoExpectIt() - ->with( '18', 'beans_layout', true ) - ->once() - ->ordered() - ->andReturn( 'default_fallback' ); - $this->assertSame( 'default_fallback', beans_get_post_meta( 'beans_layout', 'c' ) ); - } -} diff --git a/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php b/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php deleted file mode 100644 index ecc05bfb..00000000 --- a/tests/phpunit/unit/api/post-meta/beansIsPostMetaConditions.php +++ /dev/null @@ -1,169 +0,0 @@ -assertTrue( _beans_is_post_meta_conditions( true ) ); - } - - /** - * Test _beans_is_post_meta_conditions() should return true when it's a new post and $conditions include 'post'. - */ - public function test_shold_return_true_when_new_post_and_conditions_include_post() { - $_SERVER['REQUEST_URI'] = 'post-new.php'; - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post_type' )->andReturn( 'post' ); - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'post' ] ) ); - - // Clean up server globals. - $_SERVER['REQUEST_URI'] = ''; - } - - /** - * Test _beans_is_post_meta_conditions() should return false when it's a new post and $conditions don't include 'post'. - */ - public function test_should_return_false_when_new_post_and_conditions_do_not_include_post() { - $_SERVER['REQUEST_URI'] = 'post-new.php'; - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post_type' )->andReturn( 'page' ); - - $this->assertFalse( _beans_is_post_meta_conditions( [ 'post' ] ) ); - - // Clean up server globals. - $_SERVER['REQUEST_URI'] = ''; - } - - /** - * Test _beans_is_post_meta_conditions() should return false when post_id can't be found. - */ - public function test_should_return_false_when_post_id_not_found() { - - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); - Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); - - $this->assertFalse( _beans_is_post_meta_conditions( [ 'post' ] ) ); - } - - /** - * Test _beans_is_post_meta_conditions() should return true when $conditions match post type. - */ - public function test_should_return_true_when_conditions_match_post_type() { - - // Setup for when post_ID is in GET. - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 25 ); - Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); - Monkey\Functions\expect( 'get_post_type' )->once()->with( 25 )->andReturn( 'cpt' ); - Monkey\Functions\expect( 'get_post_meta' )->once()->andReturn( false ); - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'cpt' ] ) ); - - // Setup for when post_ID is in POST. - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); - Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( 25 ); - Monkey\Functions\expect( 'get_post_type' )->once()->with( 25 )->andReturn( 'cpt' ); - Monkey\Functions\expect( 'get_post_meta' )->once()->andReturn( false ); - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'cpt' ] ) ); - } - - /** - * Test _beans_is_post_meta_conditions() should return true when conditions match post_ID. - */ - public function test_should_return_true_when_conditions_match_post_id() { - - // Setup for when post_ID is in GET. - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 1 ); - Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); - Monkey\Functions\expect( 'get_post_type' )->once()->with( 1 )->andReturn( 'cpt' ); - Monkey\Functions\expect( 'get_post_meta' )->once()->andReturn( false ); - - $this->assertTrue( _beans_is_post_meta_conditions( [ 1 ] ) ); - - // Setup for when post_ID is in POST. - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); - Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( 2 ); - Monkey\Functions\expect( 'get_post_type' )->once()->with( 2 )->andReturn( 'cpt' ); - Monkey\Functions\expect( 'get_post_meta' )->once()->andReturn( false ); - - $this->assertTrue( _beans_is_post_meta_conditions( [ 2 ] ) ); - } - - /** - * Test _beans_is_post_meta_conditions() should return true when conditions match a page template name. - */ - public function test_should_return_true_when_conditions_match_page_template_name() { - - // Setup for when post_ID is in GET. - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 345 ); - Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); - Monkey\Functions\expect( 'get_post_type' )->once()->with( 345 )->andReturn( 'page' ); - Monkey\Functions\expect( 'get_post_meta' ) - ->once() - ->with( '345', '_wp_page_template', true ) - ->andReturn( 'page-template-name' ); - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'page-template-name' ] ) ); - - // Setup for when post_ID is in POST. - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); - Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( 543 ); - Monkey\Functions\expect( 'get_post_type' )->once()->with( 543 )->andReturn( 'page' ); - Monkey\Functions\expect( 'get_post_meta' ) - ->once() - ->with( '543', '_wp_page_template', true ) - ->andReturn( 'page-template-name' ); - - $this->assertTrue( _beans_is_post_meta_conditions( [ 'page-template-name' ] ) ); - } - - /** - * Test _beans_is_post_meta_conditions() should return false when no conditions match. - */ - public function test_should_return_false_when_no_conditions_match() { - - // Setup for when post_ID is in GET. - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( 345 ); - Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( false ); - Monkey\Functions\expect( 'get_post_type' )->once()->with( 345 )->andReturn( 'page' ); - Monkey\Functions\expect( 'get_post_meta' ) - ->once() - ->with( '345', '_wp_page_template', true ) - ->andReturn( 'page-template-name' ); - - $this->assertFalse( _beans_is_post_meta_conditions( [ 'some-other-conditions' ] ) ); - - // Setup for when post_ID is in POST. - Monkey\Functions\expect( 'beans_get' )->once()->with( 'post' )->andReturn( false ); - Monkey\Functions\expect( 'beans_post' )->once()->with( 'post_ID' )->andReturn( 543 ); - Monkey\Functions\expect( 'get_post_type' )->once()->with( 543 )->andReturn( 'page' ); - Monkey\Functions\expect( 'get_post_meta' ) - ->once() - ->with( '543', '_wp_page_template', true ) - ->andReturn( 'page-template-name' ); - - $this->assertFalse( _beans_is_post_meta_conditions( [ 'some-other-conditions' ] ) ); - } -} diff --git a/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php b/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php deleted file mode 100644 index e0f5ccf4..00000000 --- a/tests/phpunit/unit/api/post-meta/beansPostMetaPageTemplateReload.php +++ /dev/null @@ -1,71 +0,0 @@ -assertSame( '', $output ); - } - - /** - * Test _beans_post_meta_page_template_reload() should do nothing when post meta is not assigned to a page templates. - */ - public function test_should_do_nothing_when_post_meta_not_assigned_to_page_templates() { - global $_beans_post_meta_conditions, $pagenow; - - $_beans_post_meta_conditions = []; - $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. - - ob_start(); - _beans_post_meta_page_template_reload(); - $output = ob_get_clean(); - - $this->assertSame( '', $output ); - } - - /** - * Test _beans_post_meta_page_template_reload should output script HTML when post meta is assigned to page templates. - */ - public function test_should_output_script_html_when_post_meta_assigned_to_page_templates() { - global $_beans_post_meta_conditions, $pagenow; - - $_beans_post_meta_conditions = [ 'page-template-name.php' ]; - $pagenow = 'post.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Resetting global here for tests. - - ob_start(); - _beans_post_meta_page_template_reload(); - $output = ob_get_clean(); - - $this->assertContains( '